forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#105005 - estebank:where-clause-lts, r=compi…
…ler-errors On E0195 point at where clause lifetime bounds Fix rust-lang#104733
- Loading branch information
Showing
5 changed files
with
120 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
trait Trait<T> { | ||
fn foo<'a, K>(self, _: T, _: K) where T: 'a, K: 'a; | ||
} | ||
|
||
impl Trait<()> for () { | ||
fn foo<'a, K>(self, _: (), _: K) where { //~ ERROR E0195 | ||
todo!(); | ||
} | ||
} | ||
|
||
struct State; | ||
|
||
trait Foo<T> { | ||
fn foo<'a>(&self, state: &'a State) -> &'a T | ||
where | ||
T: 'a; | ||
} | ||
|
||
impl<F, T> Foo<T> for F | ||
where | ||
F: Fn(&State) -> &T, | ||
{ | ||
fn foo<'a>(&self, state: &'a State) -> &'a T { //~ ERROR E0195 | ||
self(state) | ||
} | ||
} | ||
|
||
trait Bar { | ||
fn foo<'a>(&'a self) {} | ||
} | ||
|
||
impl Bar for () { | ||
fn foo<'a: 'a>(&'a self) {} //~ ERROR E0195 | ||
} | ||
|
||
fn main() { | ||
().foo((), ()); | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/ui/trait-bounds/impl-missing-where-clause-lifetimes-from-trait.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration | ||
--> $DIR/impl-missing-where-clause-lifetimes-from-trait.rs:6:11 | ||
| | ||
LL | fn foo<'a, K>(self, _: T, _: K) where T: 'a, K: 'a; | ||
| ------- -- -- this bound might be missing in the impl | ||
| | | | ||
| | this bound might be missing in the impl | ||
| lifetimes in impl do not match this method in trait | ||
... | ||
LL | fn foo<'a, K>(self, _: (), _: K) where { | ||
| ^^^^^^^ lifetimes do not match method in trait | ||
|
||
error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration | ||
--> $DIR/impl-missing-where-clause-lifetimes-from-trait.rs:23:11 | ||
| | ||
LL | fn foo<'a>(&self, state: &'a State) -> &'a T | ||
| ---- lifetimes in impl do not match this method in trait | ||
LL | where | ||
LL | T: 'a; | ||
| -- this bound might be missing in the impl | ||
... | ||
LL | fn foo<'a>(&self, state: &'a State) -> &'a T { | ||
| ^^^^ lifetimes do not match method in trait | ||
|
||
error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration | ||
--> $DIR/impl-missing-where-clause-lifetimes-from-trait.rs:33:11 | ||
| | ||
LL | fn foo<'a>(&'a self) {} | ||
| ---- lifetimes in impl do not match this method in trait | ||
... | ||
LL | fn foo<'a: 'a>(&'a self) {} | ||
| ^^^^^^^^ lifetimes do not match method in trait | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0195`. |