Closed
Description
generates invalid code after rust-lang/rust#89970
the generated code:
fn open< 'a>(& 'a mut self,path: & 'a[u8],flags:usize) -> Self::__real_async_trait_impl_TypeFor_open< 'a> ;
type __real_async_trait_impl_TypeFor_open< 'a> : ::core::future::Future<Output = Result<usize,Errno> > + 'a;
18 | #[real_async_trait]
| ^^^^^^^^^^^^^^^^^^^
...
21 | async fn open<'a>(&'a mut self, path: &'a [u8], flags: usize) -> Result<usize, Errno>;
| - help: add the required where clauses: `where Self: 'a`
the expected code:
fn open<'a>(&'a mut self, path: &'a [u8], flags: usize, ) -> Self::__real_async_trait_impl_TypeFor_opsen<'a>;
type __real_async_trait_impl_TypeFor_opsen<'a>: ::core::future::Future<Output = Result<usize, Errno>> + 'a where Self: 'a;
i'm not sure if this is solving the issue completely but it was ok in my case.
diff --git a/src/lib.rs b/src/lib.rs
index 1366b81..cc2ba22 100644
--- a/src/lib.rs
+++ b/src/lib.rs
use syn::{
AngleBracketedGenericArguments, AttrStyle, Attribute, Binding, Block, Expr, ExprAsync, FnArg,
GenericArgument, GenericParam, Generics, Ident, ImplItem, ImplItemType, ItemImpl, ItemTrait,
@@ -311,7 +315,30 @@ fn handle_item_impl(mut item: ItemImpl) -> TokenStream {
generics: Generics {
lt_token: Some(Token!(<)(Span::call_site())),
gt_token: Some(Token!(>)(Span::call_site())),
- where_clause: None,
+ where_clause: Some(WhereClause {
+ where_token: Where::default(),
+ predicates: function_lifetimes
+ .iter()
+ .cloned()
+ .map(|lifetimedef| {
+ WherePredicate::Type(PredicateType {
+ colon_token: Token!(:)(Span::call_site()),
+ lifetimes: None,
+ bounded_ty: Type::Path(TypePath {
+ qself: None,
+ path: Path {
+ leading_colon: None,
+ segments: Punctuated::from_iter([PathSegment {
+ ident: Ident::new("Self", Span::call_site()),
+ arguments: PathArguments::None,
+ }]),
+ },
+ }),
+ bounds: Punctuated::from_iter([TypeParamBound::Lifetime(lifetimedef.lifetime)]),
+ })
+ })
+ .collect(),
+ }),
params: function_lifetimes
.iter()
.cloned()
@@ -590,7 +617,30 @@ fn handle_item_trait(mut item: ItemTrait) -> TokenStream {
generics: Generics {
lt_token: Some(Token!(<)(Span::call_site())),
gt_token: Some(Token!(>)(Span::call_site())),
- where_clause: None,
+ where_clause: Some(WhereClause {
+ where_token: Where::default(),
+ predicates: function_lifetimes
+ .iter()
+ .cloned()
+ .map(|lifetimedef| {
+ WherePredicate::Type(PredicateType {
+ colon_token: Token!(:)(Span::call_site()),
+ lifetimes: None,
+ bounded_ty: Type::Path(TypePath {
+ qself: None,
+ path: Path {
+ leading_colon: None,
+ segments: Punctuated::from_iter([PathSegment {
+ ident: Ident::new("Self", Span::call_site()),
+ arguments: PathArguments::None,
+ }]),
+ },
+ }),
+ bounds: Punctuated::from_iter([TypeParamBound::Lifetime(lifetimedef.lifetime)]),
+ })
+ })
+ .collect(),
+ }),
params: function_lifetimes
.iter()
.cloned()
Metadata
Metadata
Assignees
Labels
No labels