diff --git a/src/bound.rs b/src/bound.rs index f0a79c4..50182f6 100644 --- a/src/bound.rs +++ b/src/bound.rs @@ -1,4 +1,5 @@ -use proc_macro2::{Ident, Span}; +use proc_macro2::{Ident, Span, TokenStream}; +use quote::quote_spanned; use syn::punctuated::Punctuated; use syn::{Token, TypeParamBound}; @@ -34,8 +35,9 @@ impl InferredBound { } } - pub fn spanned_ident(&self, span: Span) -> Ident { - Ident::new(self.as_str(), span) + pub fn spanned_path(&self, span: Span) -> TokenStream { + let ident = Ident::new(self.as_str(), span); + quote_spanned!(span=> ::core::marker::#ident) } } diff --git a/src/expand.rs b/src/expand.rs index ce99c6f..4cc4243 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -257,8 +257,8 @@ fn transform_sig( where_clause.predicates.push(if assume_bound || is_local { parse_quote_spanned!(default_span=> Self: 'async_trait) } else { - let bound = bound.spanned_ident(default_span); - parse_quote_spanned!(default_span=> Self: ::core::marker::#bound + 'async_trait) + let bound = bound.spanned_path(default_span); + parse_quote_spanned!(default_span=> Self: #bound + 'async_trait) }); }