Skip to content
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

Use try_normalize_erasing_regions in RevealAllVisitor #91875

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/rustc_mir_transform/src/reveal_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining that the MIR we are visiting might have impossible-to-satiafy where clauses?

}
}
21 changes: 21 additions & 0 deletions src/test/ui/mir/issue-91745.rs
Original file line number Diff line number Diff line change
@@ -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=()> = &();
}