Ensure we error in case of non-higher-kinded lifetimes
This commit is contained in:
parent
7a1ccf9a03
commit
bae04fb3de
4 changed files with 49 additions and 2 deletions
23
src/test/ui/impl-trait/issues/issue-88236-2.rs
Normal file
23
src/test/ui/impl-trait/issues/issue-88236-2.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// this used to cause stack overflows
|
||||
|
||||
trait Hrtb<'a> {
|
||||
type Assoc;
|
||||
}
|
||||
|
||||
impl<'a> Hrtb<'a> for () {
|
||||
type Assoc = ();
|
||||
}
|
||||
|
||||
impl<'a> Hrtb<'a> for &'a () {
|
||||
type Assoc = ();
|
||||
}
|
||||
|
||||
fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {}
|
||||
fn make_weird_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {
|
||||
&() //~ ERROR implementation of `Hrtb` is not general enough
|
||||
}
|
||||
fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {
|
||||
x //~ ERROR implementation of `Hrtb` is not general enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
20
src/test/ui/impl-trait/issues/issue-88236-2.stderr
Normal file
20
src/test/ui/impl-trait/issues/issue-88236-2.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error: implementation of `Hrtb` is not general enough
|
||||
--> $DIR/issue-88236-2.rs:17:5
|
||||
|
|
||||
LL | &()
|
||||
| ^^^ implementation of `Hrtb` is not general enough
|
||||
|
|
||||
= note: `Hrtb<'0>` would have to be implemented for the type `&()`, for any lifetime `'0`...
|
||||
= note: ...but `Hrtb<'1>` is actually implemented for the type `&'1 ()`, for some specific lifetime `'1`
|
||||
|
||||
error: implementation of `Hrtb` is not general enough
|
||||
--> $DIR/issue-88236-2.rs:20:5
|
||||
|
|
||||
LL | x
|
||||
| ^ implementation of `Hrtb` is not general enough
|
||||
|
|
||||
= note: `&()` must implement `Hrtb<'0>`, for any lifetime `'0`...
|
||||
= note: ...but `Hrtb<'_>` is actually implemented for the type `&()`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -10,6 +10,10 @@ impl<'a> Hrtb<'a> for () {
|
|||
type Assoc = ();
|
||||
}
|
||||
|
||||
impl<'a> Hrtb<'a> for &'a () {
|
||||
type Assoc = ();
|
||||
}
|
||||
|
||||
fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {}
|
||||
|
||||
fn main() {}
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ fn main() {
|
|||
type BlahFut<'a> = impl Future<Output = ()> + Send + 'a;
|
||||
fn blah<'a>(_value: &'a u8) -> BlahFut<'a> {
|
||||
async {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue