-
Notifications
You must be signed in to change notification settings - Fork 13k
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
stricter hidden type wf-check [based on #115008] #121679
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
93bc7a4
wf-check RPITs
lcnr 71d82c2
when defining opaques, require the hidden type to be well-formed
lcnr 6591c80
use typeck root when checking closure oblig
lcnr 300cffa
yeet now unnecessary special-case
lcnr af0d508
update comments
lcnr 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
error: unconstrained opaque type | ||
--> $DIR/issue-86800.rs:31:34 | ||
--> $DIR/issue-86800.rs:25:34 | ||
| | ||
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
error: internal compiler error[E0792]: expected generic lifetime parameter, found `'_` | ||
--> $DIR/issue-86800.rs:39:5 | ||
= note: `TransactionFuture` must be used in combination with a concrete type within the same module | ||
|
||
error[E0792]: expected generic lifetime parameter, found `'_` | ||
--> $DIR/issue-86800.rs:34:5 | ||
| | ||
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>; | ||
| --- this generic parameter must be used with a generic lifetime parameter | ||
... | ||
LL | f | ||
| ^ | ||
|
||
error: the compiler unexpectedly panicked. this is a bug. | ||
error[E0792]: expected generic lifetime parameter, found `'_` | ||
--> $DIR/issue-86800.rs:42:5 | ||
| | ||
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>; | ||
| --- this generic parameter must be used with a generic lifetime parameter | ||
... | ||
LL | / { | ||
LL | | | ||
LL | | let mut conn = Connection {}; | ||
LL | | let mut transaction = TestTransaction { conn: &mut conn }; | ||
LL | | f(&mut transaction).await | ||
LL | | } | ||
| |_____^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
query stack during panic: | ||
#0 [mir_borrowck] borrow-checking `execute_transaction_fut` | ||
#1 [type_of_opaque] computing type of opaque `execute_transaction_fut::{opaque#0}` | ||
end of query stack | ||
For more information about this error, try `rustc --explain E0792`. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//! Regression test for #114728. | ||
|
||
trait Extend<'a, 'b> { | ||
fn extend(self, _: &'a str) -> &'b str; | ||
} | ||
|
||
impl<'a, 'b> Extend<'a, 'b> for Option<&'b &'a ()> { | ||
fn extend(self, s: &'a str) -> &'b str { | ||
s | ||
} | ||
} | ||
|
||
fn boom<'a, 'b>() -> impl Extend<'a, 'b> { | ||
None::<&'_ &'_ ()> //~ ERROR lifetime may not live long enough | ||
} | ||
|
||
fn main() { | ||
let y = boom().extend(&String::from("temporary")); | ||
println!("{}", y); | ||
} |
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,14 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/wf-check-hidden-type.rs:14:5 | ||
| | ||
LL | fn boom<'a, 'b>() -> impl Extend<'a, 'b> { | ||
| -- -- lifetime `'b` defined here | ||
| | | ||
| lifetime `'a` defined here | ||
LL | None::<&'_ &'_ ()> | ||
| ^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` | ||
| | ||
= help: consider adding the following bound: `'a: 'b` | ||
|
||
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
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
Oops, something went wrong.
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.
I removed this, cc #106038 (comment) @aliemjay
I do not think this special-case is worth it and it's fairly fragile, as we cannot check that nested opaque types are well formed while in the defining scope. While I am still positive that the previous behavior was sound, having to allow types which aren't well-formed adds complexity which I don't think is worth it here.