File tree Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -80,13 +80,6 @@ pub fn expand(input: &mut Item, is_local: bool) {
80
80
}
81
81
}
82
82
Item :: Impl ( input) => {
83
- let mut lifetimes = CollectLifetimes :: new ( "'impl" ) ;
84
- lifetimes. visit_type_mut ( & mut * input. self_ty ) ;
85
- lifetimes. visit_path_mut ( & mut input. trait_ . as_mut ( ) . unwrap ( ) . 1 ) ;
86
- let params = & input. generics . params ;
87
- let elided = lifetimes. elided ;
88
- input. generics . params = parse_quote ! ( #( #elided, ) * #params) ;
89
-
90
83
let mut associated_type_impl_traits = Set :: new ( ) ;
91
84
for inner in & input. items {
92
85
if let ImplItem :: Type ( assoc) = inner {
@@ -167,7 +160,7 @@ fn transform_sig(
167
160
ReturnType :: Type ( arrow, ret) => ( * arrow, quote ! ( #ret) ) ,
168
161
} ;
169
162
170
- let mut lifetimes = CollectLifetimes :: new ( "'life" ) ;
163
+ let mut lifetimes = CollectLifetimes :: new ( ) ;
171
164
for arg in sig. inputs . iter_mut ( ) {
172
165
match arg {
173
166
FnArg :: Receiver ( arg) => lifetimes. visit_receiver_mut ( arg) ,
Original file line number Diff line number Diff line change @@ -9,15 +9,13 @@ use syn::{
9
9
pub struct CollectLifetimes {
10
10
pub elided : Vec < Lifetime > ,
11
11
pub explicit : Vec < Lifetime > ,
12
- pub name : & ' static str ,
13
12
}
14
13
15
14
impl CollectLifetimes {
16
- pub fn new ( name : & ' static str ) -> Self {
15
+ pub fn new ( ) -> Self {
17
16
CollectLifetimes {
18
17
elided : Vec :: new ( ) ,
19
18
explicit : Vec :: new ( ) ,
20
- name,
21
19
}
22
20
}
23
21
@@ -37,7 +35,7 @@ impl CollectLifetimes {
37
35
}
38
36
39
37
fn next_lifetime ( & mut self , span : Span ) -> Lifetime {
40
- let name = format ! ( "{}{}" , self . name , self . elided. len( ) ) ;
38
+ let name = format ! ( "'life{}" , self . elided. len( ) ) ;
41
39
let life = Lifetime :: new ( & name, span) ;
42
40
self . elided . push ( life. clone ( ) ) ;
43
41
life
Original file line number Diff line number Diff line change @@ -1585,3 +1585,22 @@ pub mod issue236 {
1585
1585
}
1586
1586
}
1587
1587
}
1588
+
1589
+ // https://github.com/dtolnay/async-trait/issues/238
1590
+ pub mod issue238 {
1591
+ #![ deny( single_use_lifetimes) ]
1592
+
1593
+ use async_trait:: async_trait;
1594
+
1595
+ #[ async_trait]
1596
+ pub trait Trait {
1597
+ async fn f ( ) ;
1598
+ }
1599
+
1600
+ pub struct Struct ;
1601
+
1602
+ #[ async_trait]
1603
+ impl Trait for & Struct {
1604
+ async fn f ( ) { }
1605
+ }
1606
+ }
You can’t perform that action at this time.
0 commit comments