| 1 | use craterust-analyzer cargo const_format_proc_macros 0.2.34 crate/::spannedrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/::Spansrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#; |
| 2 | |
| 3 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::{ |
| 4 | Delimiterrust-analyzer cargo proc-macro2 1.0.107 Delimiter#, Grouprust-analyzer cargo proc-macro2 1.0.107 Group#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, Literalrust-analyzer cargo proc-macro2 1.0.107 Literal#, Punctrust-analyzer cargo proc-macro2 1.0.107 Punct#, Spacingrust-analyzer cargo proc-macro2 1.0.107 Spacing#, Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream# as TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#, |
| 5 | TokenTreerust-analyzer cargo proc-macro2 1.0.107 TokenTree# as TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#, |
| 6 | }; |
| 7 | |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#; |
| 9 | |
| 10 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 11 | pub struct Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error# { |
| 12 | messagesrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#messages.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<CompileErrorrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#>, |
| 13 | } |
| 14 | |
| 15 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 16 | enum CompileErrorrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError# { |
| 17 | Basicrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic# { |
| 18 | start_spanrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#start_span.: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, |
| 19 | end_spanrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#end_span.: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, |
| 20 | msgrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#msg.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 21 | }, |
| 22 | #[cfg(feature = "derive")] |
| 23 | Synrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Syn#(TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#), |
| 24 | } |
| 25 | |
| 26 | impl Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error# { |
| 27 | pub fn newrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]new().<T: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#>(span: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, msg: T) -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error] { |
| 28 | Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error# { |
| 29 | messagesrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#messages.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![CompileErrorrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#::Basicrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic# { |
| 30 | start_spanrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#start_span.: span, |
| 31 | end_spanrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#end_span.: span, |
| 32 | msgrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#msg.: msg.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 33 | }], |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | pub fn spannedrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]spanned().<T: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#>(spans: Spansrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#, msg: T) -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error] { |
| 38 | Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error# { |
| 39 | messagesrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#messages.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![CompileErrorrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#::Basicrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic# { |
| 40 | start_spanrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#start_span.: spans.startrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#start., |
| 41 | end_spanrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#end_span.: spans.endrust-analyzer cargo const_format_proc_macros 0.2.34 spanned/Spans#end., |
| 42 | msgrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#msg.: msg.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 43 | }], |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | pub fn to_compile_errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]to_compile_error().(&self) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream# { |
| 48 | macro_rules! tokenstreamrust-analyzer cargo const_format_proc_macros 0.2.34 error/tokenstream!{ |
| 49 | ($($tt:expr),* $(,)*) => ({ |
| 50 | let list: Vec<TokenTree2> = vec![ |
| 51 | $($tt.into(),)* |
| 52 | ]; |
| 53 | list.into_iter().collect::<TokenStream2>() |
| 54 | }) |
| 55 | } |
| 56 | |
| 57 | self.messagesrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#messages. |
| 58 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 59 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|em| match em { |
| 60 | CompileErrorrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#::Basicrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic# { |
| 61 | start_spanrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#start_span., |
| 62 | end_spanrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#end_span., |
| 63 | msgrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Basic#msg., |
| 64 | } => { |
| 65 | let ts = tokenstreamrust-analyzer cargo const_format_proc_macros 0.2.34 error/tokenstream!![ |
| 66 | Identrust-analyzer cargo proc-macro2 1.0.107 Ident#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]new().("compile_error", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().start_span), |
| 67 | { |
| 68 | let mut this = Punctrust-analyzer cargo proc-macro2 1.0.107 Punct#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Punct]new().('!', Spacingrust-analyzer cargo proc-macro2 1.0.107 Spacing#::Alonerust-analyzer cargo proc-macro2 1.0.107 Spacing#Alone#); |
| 69 | this.set_spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Punct]set_span().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().start_span); |
| 70 | this |
| 71 | }, |
| 72 | { |
| 73 | let mut group = Grouprust-analyzer cargo proc-macro2 1.0.107 Group#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]new().( |
| 74 | Delimiterrust-analyzer cargo proc-macro2 1.0.107 Delimiter#::Parenthesisrust-analyzer cargo proc-macro2 1.0.107 Delimiter#Parenthesis#, |
| 75 | tokenstreamrust-analyzer cargo const_format_proc_macros 0.2.34 error/tokenstream!![{ |
| 76 | let mut lit = Literalrust-analyzer cargo proc-macro2 1.0.107 Literal#::stringrust-analyzer cargo proc-macro2 1.0.107 impl#[Literal]string().(msg); |
| 77 | lit.set_spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Literal]set_span().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().end_span); |
| 78 | TokenTree2rust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Literalrust-analyzer cargo proc-macro2 1.0.107 TokenTree#Literal#(lit) |
| 79 | }], |
| 80 | ); |
| 81 | group.set_spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]set_span().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().end_span); |
| 82 | group |
| 83 | }, |
| 84 | ]; |
| 85 | |
| 86 | // Still have no idea why the compile_error has to be wrapped in parentheses |
| 87 | // so that the spans point at the stuff between start_span and end_span. |
| 88 | let mut this = Grouprust-analyzer cargo proc-macro2 1.0.107 Group#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]new().(Delimiterrust-analyzer cargo proc-macro2 1.0.107 Delimiter#::Parenthesisrust-analyzer cargo proc-macro2 1.0.107 Delimiter#Parenthesis#, ts); |
| 89 | this.set_spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]set_span().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().end_span); |
| 90 | tokenstreamrust-analyzer cargo const_format_proc_macros 0.2.34 error/tokenstream!![this] |
| 91 | } |
| 92 | #[cfg(feature = "derive")] |
| 93 | CompileErrorrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#::Synrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Syn#(x) => x.clonerust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][Clone]clone().(), |
| 94 | }) |
| 95 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 96 | } |
| 97 | |
| 98 | pub fn combinerust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error]combine().(&mut self, another: Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#) { |
| 99 | self.messagesrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#messages..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(another.messagesrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#messages.) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | #[cfg(feature = "derive")] |
| 104 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<synrust-analyzer cargo syn 1.0.109 crate/::Errorrust-analyzer cargo syn 1.0.109 error/Error#> for Errorrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error# { |
| 105 | fn fromrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error][`From<syn::Error>`]from().(err: synrust-analyzer cargo syn 1.0.109 crate/::Errorrust-analyzer cargo syn 1.0.109 error/Error#) -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error][`From<syn::Error>`] { |
| 106 | Selfrust-analyzer cargo const_format_proc_macros 0.2.34 error/impl#[Error][`From<syn::Error>`] { |
| 107 | messagesrust-analyzer cargo const_format_proc_macros 0.2.34 error/Error#messages.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![CompileErrorrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#::Synrust-analyzer cargo const_format_proc_macros 0.2.34 error/CompileError#Syn#(err.to_compile_errorrust-analyzer cargo syn 1.0.109 error/impl#[Error]to_compile_error().())], |
| 108 | } |
| 109 | } |
| 110 | } |