diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-14 10:21:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-14 10:21:05 +0100 |
| commit | b50bb65c2a2e1814099f16f56a6e787eda1da09a (patch) | |
| tree | 4ddbb2df075c13aab1fd12de0e0018835324e19a | |
| parent | 75e8d65ccde2f4c238770db19adaf9c50a4c559c (diff) | |
| parent | f3ecd64c617585e79956a3bba265e22ff1cad1e4 (diff) | |
| download | rust-b50bb65c2a2e1814099f16f56a6e787eda1da09a.tar.gz rust-b50bb65c2a2e1814099f16f56a6e787eda1da09a.zip | |
Rollup merge of #91875 - b-naber:mir-transform-norm-erase-reg, r=Aaron1011
Use try_normalize_erasing_regions in RevealAllVisitor Fixes https://github.com/rust-lang/rust/issues/91745 Thanks to ``@Aaron1011`` for [pointing out the problem](https://github.com/rust-lang/rust/issues/91745#issuecomment-991996008). r? ``@Aaron1011``
| -rw-r--r-- | compiler/rustc_mir_transform/src/reveal_all.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/mir/issue-91745.rs | 21 |
2 files changed, 25 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/reveal_all.rs b/compiler/rustc_mir_transform/src/reveal_all.rs index a717dd3e0cd..ee661793a44 100644 --- a/compiler/rustc_mir_transform/src/reveal_all.rs +++ b/compiler/rustc_mir_transform/src/reveal_all.rs @@ -36,6 +36,9 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> { #[inline] fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _: TyContext) { - *ty = self.tcx.normalize_erasing_regions(self.param_env, ty); + // We have to use `try_normalize_erasing_regions` here, since it's + // possible that we visit impossible-to-satisfy where clauses here, + // see #91745 + *ty = self.tcx.try_normalize_erasing_regions(self.param_env, *ty).unwrap_or(ty); } } diff --git a/src/test/ui/mir/issue-91745.rs b/src/test/ui/mir/issue-91745.rs new file mode 100644 index 00000000000..ca3d66b1c8e --- /dev/null +++ b/src/test/ui/mir/issue-91745.rs @@ -0,0 +1,21 @@ +// check-pass + +pub trait Foo { + type Bar; +} + +pub trait Broken { + type Assoc; + fn broken(&self) where Self::Assoc: Foo; +} + +impl<T> Broken for T { + type Assoc = (); + fn broken(&self) where Self::Assoc: Foo { + let _x: <Self::Assoc as Foo>::Bar; + } +} + +fn main() { + let _m: &dyn Broken<Assoc=()> = &(); +} |
