-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Actually use placeholder regions for trait method late bound regions in collect_return_position_impl_trait_in_trait_tys
#133428
Open
compiler-errors
wants to merge
2
commits into
rust-lang:master
Choose a base branch
from
compiler-errors:rpitit-unsound
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−41
Open
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 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
30 changes: 30 additions & 0 deletions
30
tests/ui/impl-trait/in-trait/do-not-imply-from-trait-impl.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,30 @@ | ||
// Make sure that we don't accidentally collect an RPITIT hidden type that does not | ||
// hold for all instantiations of the trait signature. | ||
|
||
trait MkStatic { | ||
fn mk_static(self) -> &'static str; | ||
} | ||
|
||
impl MkStatic for &'static str { | ||
fn mk_static(self) -> &'static str { self } | ||
} | ||
|
||
trait Foo { | ||
fn foo<'a: 'static, 'late>(&'late self) -> impl MkStatic; | ||
} | ||
|
||
impl Foo for str { | ||
fn foo<'a: 'static>(&'a self) -> impl MkStatic + 'static { | ||
//~^ ERROR method not compatible with trait | ||
self | ||
} | ||
} | ||
|
||
fn call_foo<T: Foo + ?Sized>(t: &T) -> &'static str { | ||
t.foo().mk_static() | ||
} | ||
|
||
fn main() { | ||
let s = call_foo(String::from("hello, world").as_str()); | ||
println!("> {s}"); | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/ui/impl-trait/in-trait/do-not-imply-from-trait-impl.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,22 @@ | ||
error[E0308]: method not compatible with trait | ||
--> $DIR/do-not-imply-from-trait-impl.rs:17:38 | ||
| | ||
LL | fn foo<'a: 'static>(&'a self) -> impl MkStatic + 'static { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ||
| | ||
= note: expected signature `fn(&'late _) -> _` | ||
found signature `fn(&'a _) -> _` | ||
note: the lifetime `'late` as defined here... | ||
--> $DIR/do-not-imply-from-trait-impl.rs:13:25 | ||
| | ||
LL | fn foo<'a: 'static, 'late>(&'late self) -> impl MkStatic; | ||
| ^^^^^ | ||
note: ...does not necessarily outlive the lifetime `'a` as defined here | ||
--> $DIR/do-not-imply-from-trait-impl.rs:17:12 | ||
| | ||
LL | fn foo<'a: 'static>(&'a self) -> impl MkStatic + 'static { | ||
| ^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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 |
---|---|---|
|
@@ -11,12 +11,12 @@ note: type in trait | |
| | ||
LL | fn early<'early, T>(x: &'early T) -> impl Sized; | ||
| ^^^^^^^^^ | ||
= note: expected signature `fn(&T)` | ||
found signature `fn(&'late ())` | ||
= note: expected signature `fn(&'early T)` | ||
found signature `fn(&())` | ||
help: change the parameter type to match the trait | ||
| | ||
LL | fn early<'late, T>(_: &T) {} | ||
| ~~ | ||
LL | fn early<'late, T>(_: &'early T) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may think, wow this diagnostic sucks, since it's mentioning a lifetime that isn't even in the signature. Well, it does suck, but it doesn't suck any more than the error you would get from the code if it had no RPITITs. So I don't think it needs fixing here. |
||
| ~~~~~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
|
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
15 changes: 8 additions & 7 deletions
15
tests/ui/impl-trait/in-trait/signature-mismatch.failure.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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
error[E0623]: lifetime mismatch | ||
error[E0477]: the type `impl Future<Output = Vec<u8>>` does not fulfill the required lifetime | ||
--> $DIR/signature-mismatch.rs:77:10 | ||
| | ||
LL | &'a self, | ||
| -------- this parameter and the return type are declared with different lifetimes... | ||
... | ||
LL | ) -> impl Future<Output = Vec<u8>> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| ...but data from `buff` is returned here | ||
| | ||
note: type must outlive the lifetime `'a` as defined here as required by this binding | ||
--> $DIR/signature-mismatch.rs:73:32 | ||
| | ||
LL | fn async_fn_reduce_outlive<'a, 'b, T>( | ||
| ^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0623`. | ||
For more information about this error, try `rustc --explain E0477`. |
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
7 changes: 4 additions & 3 deletions
7
tests/ui/impl-trait/precise-capturing/rpitit-impl-captures-too-much.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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this.
In fact, it has the potential to cause ICEs since us not remapping bivariant lifetimes on opaques may lead us to leaking infer vars into query responses. This does not happen in practice though.