-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #121679 - lcnr:opaque-wf-check-2, r=oli-obk
stricter hidden type wf-check [based on #115008] Original work by `@aliemjay` in #115008. A huge thanks to them for originally figuring out this approach ❤️ Fixes #114728 Fixes #114572 Instead of adding the `WellFormed` obligations when relating opaque types, we now always emit such an obligation when defining the hidden type. This causes nested opaque types which aren't wf to error, see the comment below for the described impact. I believe this change to be desirable as it significantly reduces complexity by removing special-cases. It also caused an issue with RPITIT: in defaulted trait methods, we add a `Projection(synthetic_assoc, rpit_of_trait_method)` clause to the `param_env`. This clause is not added to the `ParamEnv` of the nested coroutines. This caused a normalization failure in `fn check_coroutine_obligations` with the new solver. I fixed that by using the env of the typeck root instead. r? `@oli-obk`
- Loading branch information
Showing
21 changed files
with
315 additions
and
138 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
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.