-
Notifications
You must be signed in to change notification settings - Fork 13.4k
On E0195 point at where clause lifetime bounds #105005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.