forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#125501 - compiler-errors:opaque-opaque-anon…
…-ct, r=BoxyUwU Resolve anon const's parent predicates to direct parent instead of opaque's parent When an anon const is inside of an opaque, rust-lang#99801 added a hack to resolve the anon const's parent predicates *not* to the opaque's predicates, but to the opaque's *parent's* predicates. This is insufficient when considering nested opaques. This means that the `predicates_of` an anon const might reference duplicated lifetimes (installed by `compute_bidirectional_outlives_predicates`) when computing known outlives in MIR borrowck, leading to these ICEs: Fixes rust-lang#121574 Fixes rust-lang#118403 ~~Instead, we should be using the `OpaqueTypeOrigin` to acquire the owner item (fn/type alias/etc) of the opaque, whose predicates we're fine to mention.~~ ~~I think it's a bit sketchy that we're doing this at all, tbh; I think it *should* be fine for the anon const to inherit the predicates of the opaque it's located inside. However, that would also mean that we need to make sure the `generics_of` that anon const line up in the same way.~~ ~~None of this is important to solve right now; I just want to fix these ICEs so we can land rust-lang#125468, which accidentally fixes these issues in a different and unrelated way.~~ edit: We don't need this special case anyways because we install the right parent item in `generics_of` anyways: https://github.com/rust-lang/rust/blob/213ad10c8f0fc275648552366275dc4e07f97462/compiler/rustc_hir_analysis/src/collect/generics_of.rs#L150 r? `@BoxyUwU`
- Loading branch information
Showing
6 changed files
with
71 additions
and
97 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
tests/ui/const-generics/generic_const_exprs/double-opaque-parent-predicates.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,13 @@ | ||
//@ check-pass | ||
|
||
#![feature(generic_const_exprs)] | ||
//~^ WARN the feature `generic_const_exprs` is incomplete and may not be safe to use | ||
|
||
pub fn y<'a, U: 'a>() -> impl IntoIterator<Item = impl IntoIterator<Item = [u8; { 1 + 2 }]> + 'a> { | ||
[[[1, 2, 3]]] | ||
} | ||
// Make sure that the `predicates_of` for `{ 1 + 2 }` don't mention the duplicated lifetimes of | ||
// the *outer* iterator. Whether they should mention the duplicated lifetimes of the *inner* | ||
// iterator are another question, but not really something we need to answer immediately. | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui/const-generics/generic_const_exprs/double-opaque-parent-predicates.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,11 @@ | ||
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/double-opaque-parent-predicates.rs:3:12 | ||
| | ||
LL | #![feature(generic_const_exprs)] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|