forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#120277 - compiler-errors:normalize-before-validating, r=oli-obk Normalize field types before checking validity I forgot to normalize field types when checking ADT-like aggregates in the MIR validator. This normalization is needed due to a crude check for opaque types in `mir_assign_valid_types` which prevents opaque type cycles -- if we pass in an unnormalized type, we may not detect that the destination type is an opaque, and therefore will call `type_of(opaque)` later on, which causes a cycle error -> ICE. Fixes rust-lang#120253
- Loading branch information
Showing
2 changed files
with
45 additions
and
9 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
31 changes: 31 additions & 0 deletions
31
tests/ui/type-alias-impl-trait/struct-assignment-validity.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,31 @@ | ||
// compile-flags: -Zvalidate-mir | ||
// check-pass | ||
|
||
// Check that we don't cause cycle errors when validating pre-`Reveal::All` MIR | ||
// that assigns opaques through normalized projections. | ||
|
||
#![feature(impl_trait_in_assoc_type)] | ||
|
||
struct Bar; | ||
|
||
trait Trait { | ||
type Assoc; | ||
fn foo() -> Foo; | ||
} | ||
|
||
impl Trait for Bar { | ||
type Assoc = impl std::fmt::Debug; | ||
fn foo() -> Foo | ||
where | ||
Self::Assoc:, | ||
{ | ||
let x: <Bar as Trait>::Assoc = (); | ||
Foo { field: () } | ||
} | ||
} | ||
|
||
struct Foo { | ||
field: <Bar as Trait>::Assoc, | ||
} | ||
|
||
fn main() {} |