Rollup merge of #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 #130921.
This commit is contained in:
commit
b6a085a16e
3 changed files with 23 additions and 10 deletions
|
@ -595,6 +595,17 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
&self,
|
&self,
|
||||||
pred: impl Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>,
|
pred: impl Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
let pred: ty::Predicate<'tcx> = pred.upcast(self.tcx);
|
||||||
|
|
||||||
|
// We sometimes have to use `defining_opaque_types` for predicates
|
||||||
|
// to succeed here and figuring out how exactly that should work
|
||||||
|
// is annoying. It is harmless enough to just not validate anything
|
||||||
|
// in that case. We still check this after analysis as all opaque
|
||||||
|
// types have been revealed at this point.
|
||||||
|
if pred.has_opaque_types() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
let infcx = self.tcx.infer_ctxt().build();
|
let infcx = self.tcx.infer_ctxt().build();
|
||||||
let ocx = ObligationCtxt::new(&infcx);
|
let ocx = ObligationCtxt::new(&infcx);
|
||||||
ocx.register_obligation(Obligation::new(
|
ocx.register_obligation(Obligation::new(
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
//@ known-bug: #130921
|
|
||||||
//@ compile-flags: -Zvalidate-mir -Copt-level=0 --crate-type lib
|
|
||||||
|
|
||||||
pub fn hello() -> [impl Sized; 2] {
|
|
||||||
if false {
|
|
||||||
let x = hello();
|
|
||||||
let _: &[i32] = &x;
|
|
||||||
}
|
|
||||||
todo!()
|
|
||||||
}
|
|
12
tests/ui/impl-trait/unsize-cast-validation-rpit.rs
Normal file
12
tests/ui/impl-trait/unsize-cast-validation-rpit.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
//@ check-pass
|
||||||
|
//@ compile-flags: -Zvalidate-mir
|
||||||
|
|
||||||
|
fn hello() -> &'static [impl Sized; 0] {
|
||||||
|
if false {
|
||||||
|
let x = hello();
|
||||||
|
let _: &[i32] = x;
|
||||||
|
}
|
||||||
|
&[]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Reference in a new issue