mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 13:40:15 +03:00
fix some ICEs
This commit is contained in:
+4
-1
@@ -223,7 +223,10 @@ pub fn load_mir(&self, def_id: DefId) -> EvalResult<'tcx, MirRef<'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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user