Skip to content

Commit 1696043

Browse files
authored
Rollup merge of rust-lang#130989 - compiler-errors:unsize-opaque, r=estebank
Don't check unsize goal in MIR validation when opaques remain Similarly to `mir_assign_valid_types`, let's just skip when there are opaques. Fixes rust-lang#130921.
2 parents 4cc494b + 4af6137 commit 1696043

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

compiler/rustc_mir_transform/src/validate.rs

+11
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,17 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
595595
&self,
596596
pred: impl Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>,
597597
) -> bool {
598+
let pred: ty::Predicate<'tcx> = pred.upcast(self.tcx);
599+
600+
// We sometimes have to use `defining_opaque_types` for predicates
601+
// to succeed here and figuring out how exactly that should work
602+
// is annoying. It is harmless enough to just not validate anything
603+
// in that case. We still check this after analysis as all opaque
604+
// types have been revealed at this point.
605+
if pred.has_opaque_types() {
606+
return true;
607+
}
608+
598609
let infcx = self.tcx.infer_ctxt().build();
599610
let ocx = ObligationCtxt::new(&infcx);
600611
ocx.register_obligation(Obligation::new(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ check-pass
2+
//@ compile-flags: -Zvalidate-mir
3+
4+
fn hello() -> &'static [impl Sized; 0] {
5+
if false {
6+
let x = hello();
7+
let _: &[i32] = x;
8+
}
9+
&[]
10+
}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)