-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Incorrect lifetime bound check in async + impl_trait_in_assoc_type #114572
Comments
This is |
searched nightlies: from nightly-2023-02-01 to nightly-2023-04-01 bisected with cargo-bisect-rustc v0.6.5Host triple: aarch64-unknown-linux-gnu cargo bisect-rustc --start=2023-02-01 --end=2023-04-01 --prompt This regressed in #104833. Strange, but perhaps a case that #105300 didn't end up fixing? cc @aliemjay |
Minimized: #![feature(type_alias_impl_trait)]
struct Static<T: 'static>(T);
type Output<'a> = impl Sized + 'a;
fn relate<'a>(msg: Static<&'static u8>) -> Output<'a> {
msg
} The hidden type is inferred to be |
stricter hidden type wf-check [based on rust-lang#115008] Original work by `@aliemjay` in rust-lang#115008. A huge thanks to them for originally figuring out this approach ❤️ Fixes rust-lang#114728 Fixes rust-lang#114572 Instead of adding the `WellFormed` obligations when relating opaque types, I add 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`
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 rust-lang/rust#114728 Fixes rust-lang/rust#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`
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 rust-lang/rust#114728 Fixes rust-lang/rust#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`
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 rust-lang/rust#114728 Fixes rust-lang/rust#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`
I tried this code:
I expected to see this happen: The code correctly compiles
Instead, this happened: The code fails to compile with lifetime bound check errors.
More information that might be helpful
I did a bisect and found that the above code compiles in
nightly-2023-03-14
but fails innightly-2023-03-15
, possibly due to #108909 but I didn't dig deep to find the root cause.Also, by changing the implementation of the
to_string
function ofFooPrinter
by wrapping the async block with a smart pointer (see below), the code successfully compilesLet me know if more info is needed, or actually my codes fails to compile by design.
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: