File tree Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Original file line number Diff line number Diff line change
1
+ // this used to cause stack overflows
2
+
3
+ trait Hrtb < ' a > {
4
+ type Assoc ;
5
+ }
6
+
7
+ impl < ' a > Hrtb < ' a > for ( ) {
8
+ type Assoc = ( ) ;
9
+ }
10
+
11
+ impl < ' a > Hrtb < ' a > for & ' a ( ) {
12
+ type Assoc = ( ) ;
13
+ }
14
+
15
+ fn make_impl ( ) -> impl for < ' a > Hrtb < ' a , Assoc = impl Send + ' a > { }
16
+ fn make_weird_impl < ' b > ( x : & ' b ( ) ) -> impl for < ' a > Hrtb < ' a , Assoc = impl Send + ' a > {
17
+ & ( ) //~ ERROR implementation of `Hrtb` is not general enough
18
+ }
19
+ fn make_bad_impl < ' b > ( x : & ' b ( ) ) -> impl for < ' a > Hrtb < ' a , Assoc = impl Send + ' a > {
20
+ x //~ ERROR implementation of `Hrtb` is not general enough
21
+ }
22
+
23
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: implementation of `Hrtb` is not general enough
2
+ --> $DIR/issue-88236-2.rs:17:5
3
+ |
4
+ LL | &()
5
+ | ^^^ implementation of `Hrtb` is not general enough
6
+ |
7
+ = note: `Hrtb<'0>` would have to be implemented for the type `&()`, for any lifetime `'0`...
8
+ = note: ...but `Hrtb<'1>` is actually implemented for the type `&'1 ()`, for some specific lifetime `'1`
9
+
10
+ error: implementation of `Hrtb` is not general enough
11
+ --> $DIR/issue-88236-2.rs:20:5
12
+ |
13
+ LL | x
14
+ | ^ implementation of `Hrtb` is not general enough
15
+ |
16
+ = note: `&()` must implement `Hrtb<'0>`, for any lifetime `'0`...
17
+ = note: ...but `Hrtb<'_>` is actually implemented for the type `&()`
18
+
19
+ error: aborting due to 2 previous errors
20
+
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ impl<'a> Hrtb<'a> for () {
10
10
type Assoc = ( ) ;
11
11
}
12
12
13
+ impl < ' a > Hrtb < ' a > for & ' a ( ) {
14
+ type Assoc = ( ) ;
15
+ }
16
+
13
17
fn make_impl ( ) -> impl for < ' a > Hrtb < ' a , Assoc = impl Send + ' a > { }
14
18
15
- fn main ( ) { }
19
+ fn main ( ) { }
Original file line number Diff line number Diff line change @@ -16,4 +16,4 @@ fn main() {
16
16
type BlahFut < ' a > = impl Future < Output = ( ) > + Send + ' a ;
17
17
fn blah < ' a > ( _value : & ' a u8 ) -> BlahFut < ' a > {
18
18
async { }
19
- }
19
+ }
You can’t perform that action at this time.
0 commit comments