thiserror_impl/
lib.rs

1//! # Notice: This is a modified version of [`thiserror`](https://crates.io/crates/thiserror) with `no_std` support.
2
3#![allow(
4    clippy::blocks_in_conditions,
5    clippy::cast_lossless,
6    clippy::cast_possible_truncation,
7    clippy::manual_find,
8    clippy::manual_let_else,
9    clippy::manual_map,
10    clippy::map_unwrap_or,
11    clippy::module_name_repetitions,
12    clippy::needless_pass_by_value,
13    clippy::range_plus_one,
14    clippy::single_match_else,
15    clippy::struct_field_names,
16    clippy::too_many_lines,
17    clippy::wrong_self_convention
18)]
19
20extern crate proc_macro;
21
22mod ast;
23mod attr;
24mod expand;
25mod fmt;
26mod generics;
27mod prop;
28mod span;
29mod valid;
30
31use proc_macro::TokenStream;
32use syn::{parse_macro_input, DeriveInput};
33
34#[cfg(feature = "std")]
35fn use_std() -> bool {
36    true
37}
38
39#[cfg(not(feature = "std"))]
40fn use_std() -> bool {
41    false
42}
43
44#[proc_macro_derive(Error, attributes(backtrace, error, from, source))]
45pub fn derive_error(input: TokenStream) -> TokenStream {
46    let input = parse_macro_input!(input as DeriveInput);
47    expand::derive(&input).into()
48}