Normalize all projections in mir validation again
This commit is contained in:
parent
1c5bfb1770
commit
4cfaf9a931
2 changed files with 35 additions and 1 deletions
|
@ -169,8 +169,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
// Equal types, all is good.
|
// Equal types, all is good.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// Normalization reveals opaque types, but we may be validating MIR while computing
|
||||||
|
// said opaque types, causing cycles.
|
||||||
|
if (src, dest).has_opaque_types() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// Normalize projections and things like that.
|
// Normalize projections and things like that.
|
||||||
let param_env = self.param_env;
|
let param_env = self.param_env.with_reveal_all_normalized(self.tcx);
|
||||||
let src = self.tcx.normalize_erasing_regions(param_env, src);
|
let src = self.tcx.normalize_erasing_regions(param_env, src);
|
||||||
let dest = self.tcx.normalize_erasing_regions(param_env, dest);
|
let dest = self.tcx.normalize_erasing_regions(param_env, dest);
|
||||||
|
|
||||||
|
|
29
src/test/ui/impl-trait/projection.rs
Normal file
29
src/test/ui/impl-trait/projection.rs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// build-pass
|
||||||
|
// needs to be build-pass, because it is a regression test for a mir validation failure
|
||||||
|
// that only happens during codegen.
|
||||||
|
|
||||||
|
struct D;
|
||||||
|
|
||||||
|
trait Tr {
|
||||||
|
type It;
|
||||||
|
fn foo(self) -> Option<Self::It>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Tr for &'a D {
|
||||||
|
type It = ();
|
||||||
|
fn foo(self) -> Option<()> { None }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run<F>(f: F)
|
||||||
|
where for<'a> &'a D: Tr,
|
||||||
|
F: Fn(<&D as Tr>::It),
|
||||||
|
{
|
||||||
|
let d = &D;
|
||||||
|
while let Some(i) = d.foo() {
|
||||||
|
f(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
run(|_| {});
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue