diff --git a/src/error_macros.rs b/src/error_macros.rs index ecc7d73..00669ce 100644 --- a/src/error_macros.rs +++ b/src/error_macros.rs @@ -22,8 +22,8 @@ macro_rules! handle_syn_result { Ok(value) => value, Err(e) => { let mut ts = quote! { - impl #$generics_intro syn::parse::Parse for #$ident #$generics_args #$where_clause { - fn parse(input: syn::parse::ParseStream) -> syn::Result { + impl #$generics_intro ::syn::parse::Parse for #$ident #$generics_args #$where_clause { + fn parse(input: ::syn::parse::ParseStream) -> ::syn::Result { unimplemented!("failed to derive `Parse`") } } diff --git a/src/fields.rs b/src/fields.rs index 9886569..a362518 100644 --- a/src/fields.rs +++ b/src/fields.rs @@ -312,7 +312,7 @@ fn handle_field_attrs(field_name: &Ident, ty_span: Span, attrs: FieldAttrs) -> P let macro_name = tree_kind.macro_name(); let tree_name = tree_name(field_name); - parse_expr = quote_spanned! { span=> syn::#macro_name!(#tree_name in #input_source) }; + parse_expr = quote_spanned! { span=> ::syn::#macro_name!(#tree_name in #input_source) }; } } diff --git a/src/lib.rs b/src/lib.rs index 8d2c35d..1bddc9b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -387,8 +387,8 @@ pub(crate) fn derive_parse_internal(input: DeriveInput) -> TokenStream { let parse_input = parse_input(); quote!( - impl #generics_intro syn::parse::Parse for #ident #generics_args #where_clause { - fn parse(#parse_input: syn::parse::ParseStream) -> syn::Result { + impl #generics_intro ::syn::parse::Parse for #ident #generics_args #where_clause { + fn parse(#parse_input: ::syn::parse::ParseStream) -> ::syn::Result { #parse_impl } } @@ -417,12 +417,12 @@ fn require_impl_parse_if_type(param: &syn::GenericParam) -> Result let parse_bound = if colon_token.is_some() { quote_spanned! { ident.span()=> - + syn::parse::Parse + + ::syn::parse::Parse } } else { quote_spanned! { ident.span()=> - : syn::parse::Parse + : ::syn::parse::Parse } }; diff --git a/src/tests.rs b/src/tests.rs index b932a13..9c5d55c 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -34,8 +34,8 @@ test_all! { bar: Bar, baz: Baz, }", - "impl syn::parse::Parse for Foo { - fn parse(__parse_input: syn::parse::ParseStream) -> syn::Result { + "impl ::syn::parse::Parse for Foo { + fn parse(__parse_input: ::syn::parse::ParseStream) -> ::syn::Result { let bar = __parse_input.parse()?; let baz = __parse_input.parse()?; @@ -54,10 +54,10 @@ test_all! { baz: Baz, quacker: Q, }", - "impl syn::parse::Parse for Foo + "impl ::syn::parse::Parse for Foo where ::Qux: Quack, { - fn parse(__parse_input: syn::parse::ParseStream) -> syn::Result { + fn parse(__parse_input: ::syn::parse::ParseStream) -> ::syn::Result { let bar = __parse_input.parse()?; let baz = __parse_input.parse()?; let quacker = __parse_input.parse()?; @@ -78,12 +78,12 @@ test_all! { #[inside(paren)] baz: Baz, }", - "impl syn::parse::Parse for Foo { - fn parse(__parse_input: syn::parse::ParseStream) -> syn::Result { + "impl ::syn::parse::Parse for Foo { + fn parse(__parse_input: ::syn::parse::ParseStream) -> ::syn::Result { let bar = __parse_input.parse()?; let __paren_backing_token_stream; - let paren = syn::parenthesized!(__paren_backing_token_stream in __parse_input); + let paren = ::syn::parenthesized!(__paren_backing_token_stream in __parse_input); let baz = __paren_backing_token_stream.parse()?; Ok(Foo { @@ -105,15 +105,15 @@ test_all! { #[inside(snd)] baz: Baz, }", - "impl syn::parse::Parse for Foo { - fn parse(__parse_input: syn::parse::ParseStream) -> syn::Result { + "impl ::syn::parse::Parse for Foo { + fn parse(__parse_input: ::syn::parse::ParseStream) -> ::syn::Result { let bar = __parse_input.parse()?; let __fst_backing_token_stream; - let fst = syn::bracketed!(__fst_backing_token_stream in __parse_input); + let fst = ::syn::bracketed!(__fst_backing_token_stream in __parse_input); let __snd_backing_token_stream; - let snd = syn::braced!(__snd_backing_token_stream in __fst_backing_token_stream); + let snd = ::syn::braced!(__snd_backing_token_stream in __fst_backing_token_stream); let baz = __snd_backing_token_stream.parse()?; @@ -132,8 +132,8 @@ test_all! { #[peek_with(|p| !p.is_empty())] baz: Baz, }", - "impl syn::parse::Parse for Foo { - fn parse(__parse_input: syn::parse::ParseStream) -> syn::Result { + "impl ::syn::parse::Parse for Foo { + fn parse(__parse_input: ::syn::parse::ParseStream) -> ::syn::Result { let bar = __parse_input.parse()?; let baz = match (|p| !p.is_empty())(__parse_input) {