fix some ICEs
This commit is contained in:
parent
8f7e492305
commit
b6e79dbbf5
2 changed files with 17 additions and 1 deletions
|
@ -223,7 +223,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn monomorphize(&self, ty: Ty<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
let substituted = ty.subst(self.tcx, substs);
|
||||
// miri doesn't care about lifetimes, and will choke on some crazy ones
|
||||
// let's simply get rid of them
|
||||
let without_lifetimes = self.tcx.erase_regions(&ty);
|
||||
let substituted = without_lifetimes.subst(self.tcx, substs);
|
||||
self.tcx.normalize_associated_type(&substituted)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,21 @@ struct A<'a> {
|
|||
y: &'a i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
struct B<'a>(i32, &'a i32);
|
||||
|
||||
fn main() {
|
||||
let x = 5;
|
||||
let a = A { x: 99, y: &x };
|
||||
assert_eq!(Some(a).map(Some), Some(Some(a)));
|
||||
let f = B;
|
||||
assert_eq!(Some(B(42, &x)), Some(f(42, &x)));
|
||||
// the following doesn't compile :(
|
||||
//let f: for<'a> fn(i32, &'a i32) -> B<'a> = B;
|
||||
//assert_eq!(Some(B(42, &x)), Some(f(42, &x)));
|
||||
assert_eq!(B(42, &x), foo(&x, B));
|
||||
}
|
||||
|
||||
fn foo<'a, F: Fn(i32, &'a i32) -> B<'a>>(i: &'a i32, f: F) -> B<'a> {
|
||||
f(42, i)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue