Skip to content

Commit b6e79db

Browse files
committed
fix some ICEs
1 parent 8f7e492 commit b6e79db

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/eval_context.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
223223
}
224224

225225
pub fn monomorphize(&self, ty: Ty<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
226-
let substituted = ty.subst(self.tcx, substs);
226+
// miri doesn't care about lifetimes, and will choke on some crazy ones
227+
// let's simply get rid of them
228+
let without_lifetimes = self.tcx.erase_regions(&ty);
229+
let substituted = without_lifetimes.subst(self.tcx, substs);
227230
self.tcx.normalize_associated_type(&substituted)
228231
}
229232

tests/run-pass/tuple_like_enum_variant_constructor_struct_pointer_opt.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ struct A<'a> {
44
y: &'a i32,
55
}
66

7+
#[derive(Copy, Clone, PartialEq, Debug)]
8+
struct B<'a>(i32, &'a i32);
9+
710
fn main() {
811
let x = 5;
912
let a = A { x: 99, y: &x };
1013
assert_eq!(Some(a).map(Some), Some(Some(a)));
14+
let f = B;
15+
assert_eq!(Some(B(42, &x)), Some(f(42, &x)));
16+
// the following doesn't compile :(
17+
//let f: for<'a> fn(i32, &'a i32) -> B<'a> = B;
18+
//assert_eq!(Some(B(42, &x)), Some(f(42, &x)));
19+
assert_eq!(B(42, &x), foo(&x, B));
20+
}
21+
22+
fn foo<'a, F: Fn(i32, &'a i32) -> B<'a>>(i: &'a i32, f: F) -> B<'a> {
23+
f(42, i)
1124
}

0 commit comments

Comments
 (0)