diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-07-27 16:05:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-27 16:05:15 +0200 |
| commit | 218e88e5d8f6503fade7bc7f669c3d7dd5f5de07 (patch) | |
| tree | 515c4d76cc6d8c9b85b403cfeb32c9742cb04709 | |
| parent | 0bebfa39cc250c3341e574776ac3999ad21c925c (diff) | |
| parent | 99a9a63ca6086338a3208b26b224f894d5a29d58 (diff) | |
| download | rust-218e88e5d8f6503fade7bc7f669c3d7dd5f5de07.tar.gz rust-218e88e5d8f6503fade7bc7f669c3d7dd5f5de07.zip | |
Rollup merge of #114123 - oli-obk:tait_wtf, r=WaffleLapkin
Turns out opaque types can have hidden types registered during mir validation See the newly added test's documentation for an explanation. fixes #114121
| -rw-r--r-- | compiler/rustc_const_eval/src/util/compare_types.rs | 15 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/broken_mir.rs | 16 |
2 files changed, 25 insertions, 6 deletions
diff --git a/compiler/rustc_const_eval/src/util/compare_types.rs b/compiler/rustc_const_eval/src/util/compare_types.rs index 88d4f5e715c..83376c8e992 100644 --- a/compiler/rustc_const_eval/src/util/compare_types.rs +++ b/compiler/rustc_const_eval/src/util/compare_types.rs @@ -57,12 +57,15 @@ pub fn is_subtype<'tcx>( // we would get unification errors because we're unable to look into opaque types, // even if they're constrained in our current function. for (key, ty) in infcx.take_opaque_types() { - span_bug!( - ty.hidden_type.span, - "{}, {}", - tcx.type_of(key.def_id).instantiate(tcx, key.args), - ty.hidden_type.ty - ); + let hidden_ty = tcx.type_of(key.def_id).instantiate(tcx, key.args); + if hidden_ty != ty.hidden_type.ty { + span_bug!( + ty.hidden_type.span, + "{}, {}", + tcx.type_of(key.def_id).instantiate(tcx, key.args), + ty.hidden_type.ty + ); + } } errors.is_empty() } diff --git a/tests/ui/type-alias-impl-trait/broken_mir.rs b/tests/ui/type-alias-impl-trait/broken_mir.rs new file mode 100644 index 00000000000..b68e798fb7c --- /dev/null +++ b/tests/ui/type-alias-impl-trait/broken_mir.rs @@ -0,0 +1,16 @@ +//! ICE: https://github.com/rust-lang/rust/issues/114121 +//! This test checks that MIR validation never constrains +//! new hidden types that *differ* from the actual hidden types. +//! This test used to ICE because oli-obk assumed mir validation +//! was only ever run after opaque types were revealed in MIR. + +// compile-flags: -Zvalidate-mir +// check-pass + +fn main() { + let _ = Some(()).into_iter().flat_map(|_| Some(()).into_iter().flat_map(func)); +} + +fn func(_: ()) -> impl Iterator<Item = ()> { + Some(()).into_iter().flat_map(|_| vec![]) +} |
