Reject registration of downcasts for now

This commit is contained in:
Jannis Christopher Köhl 2022-09-01 15:05:53 +02:00
parent 47a00d5337
commit 8a789ce009
3 changed files with 92 additions and 87 deletions

View File

@ -462,8 +462,8 @@ impl Map {
filter: &mut impl FnMut(Ty<'tcx>) -> bool,
) {
if filter(ty) {
self.register(local, projection)
.expect("projection should only contain convertible elements");
// Since downcasts are currently not allowed, this might fail.
let _ = self.register(local, projection);
}
if max_derefs > 0 {
if let Some(ty::TypeAndMut { ty, .. }) = ty.builtin_deref(false) {
@ -496,6 +496,11 @@ impl Map {
// Apply the projection.
for &elem in projection {
// For now, downcast is not allowed (see #101168).
match elem {
PlaceElem::Downcast(..) => return Err(()),
_ => (),
}
let elem = elem.try_into()?;
index = *self.projections.entry((index, elem)).or_insert_with(|| {
// Prepend new child to the linked list.

View File

@ -3,40 +3,40 @@
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/recursive.rs:+0:11: +0:11
let _1: S; // in scope 0 at $DIR/recursive.rs:+1:9: +1:10
let mut _3: &S; // in scope 0 at $DIR/recursive.rs:+2:20: +2:22
let _4: &S; // in scope 0 at $DIR/recursive.rs:+2:20: +2:22
let mut _6: &S; // in scope 0 at $DIR/recursive.rs:+3:20: +3:22
let _7: &S; // in scope 0 at $DIR/recursive.rs:+3:20: +3:22
let mut _9: isize; // in scope 0 at $DIR/recursive.rs:+5:9: +5:18
let mut _11: isize; // in scope 0 at $DIR/recursive.rs:+6:13: +6:22
let mut _13: isize; // in scope 0 at $DIR/recursive.rs:+7:17: +7:28
let mut _15: !; // in scope 0 at $DIR/recursive.rs:+8:22: +8:43
let mut _16: !; // in scope 0 at $DIR/recursive.rs:+10:18: +10:39
let mut _17: !; // in scope 0 at $DIR/recursive.rs:+12:14: +12:35
let mut _18: &S; // in scope 0 at $DIR/recursive.rs:+6:20: +6:21
let mut _19: &S; // in scope 0 at $DIR/recursive.rs:+6:20: +6:21
let _1: S; // in scope 0 at $DIR/recursive.rs:+2:9: +2:10
let mut _3: &S; // in scope 0 at $DIR/recursive.rs:+3:20: +3:22
let _4: &S; // in scope 0 at $DIR/recursive.rs:+3:20: +3:22
let mut _6: &S; // in scope 0 at $DIR/recursive.rs:+4:20: +4:22
let _7: &S; // in scope 0 at $DIR/recursive.rs:+4:20: +4:22
let mut _9: isize; // in scope 0 at $DIR/recursive.rs:+6:9: +6:18
let mut _11: isize; // in scope 0 at $DIR/recursive.rs:+7:13: +7:22
let mut _13: isize; // in scope 0 at $DIR/recursive.rs:+8:17: +8:28
let mut _15: !; // in scope 0 at $DIR/recursive.rs:+9:22: +9:43
let mut _16: !; // in scope 0 at $DIR/recursive.rs:+11:18: +11:39
let mut _17: !; // in scope 0 at $DIR/recursive.rs:+13:14: +13:35
let mut _18: &S; // in scope 0 at $DIR/recursive.rs:+7:20: +7:21
let mut _19: &S; // in scope 0 at $DIR/recursive.rs:+7:20: +7:21
scope 1 {
debug a => _1; // in scope 1 at $DIR/recursive.rs:+1:9: +1:10
let _2: S; // in scope 1 at $DIR/recursive.rs:+2:9: +2:10
debug a => _1; // in scope 1 at $DIR/recursive.rs:+2:9: +2:10
let _2: S; // in scope 1 at $DIR/recursive.rs:+3:9: +3:10
scope 2 {
debug b => _2; // in scope 2 at $DIR/recursive.rs:+2:9: +2:10
let _5: S; // in scope 2 at $DIR/recursive.rs:+3:9: +3:10
debug b => _2; // in scope 2 at $DIR/recursive.rs:+3:9: +3:10
let _5: S; // in scope 2 at $DIR/recursive.rs:+4:9: +4:10
scope 3 {
debug c => _5; // in scope 3 at $DIR/recursive.rs:+3:9: +3:10
let _8: u32; // in scope 3 at $DIR/recursive.rs:+4:9: +4:10
let _10: &S; // in scope 3 at $DIR/recursive.rs:+5:16: +5:17
debug c => _5; // in scope 3 at $DIR/recursive.rs:+4:9: +4:10
let _8: u32; // in scope 3 at $DIR/recursive.rs:+5:9: +5:10
let _10: &S; // in scope 3 at $DIR/recursive.rs:+6:16: +6:17
scope 4 {
debug d => _8; // in scope 4 at $DIR/recursive.rs:+4:9: +4:10
debug d => _8; // in scope 4 at $DIR/recursive.rs:+5:9: +5:10
}
scope 5 {
debug b => _10; // in scope 5 at $DIR/recursive.rs:+5:16: +5:17
let _12: &&S; // in scope 5 at $DIR/recursive.rs:+6:20: +6:21
debug b => _10; // in scope 5 at $DIR/recursive.rs:+6:16: +6:17
let _12: &&S; // in scope 5 at $DIR/recursive.rs:+7:20: +7:21
scope 6 {
debug a => _12; // in scope 6 at $DIR/recursive.rs:+6:20: +6:21
let _14: &u32; // in scope 6 at $DIR/recursive.rs:+7:24: +7:27
debug a => _12; // in scope 6 at $DIR/recursive.rs:+7:20: +7:21
let _14: &u32; // in scope 6 at $DIR/recursive.rs:+8:24: +8:27
scope 7 {
debug num => _14; // in scope 7 at $DIR/recursive.rs:+7:24: +7:27
debug num => _14; // in scope 7 at $DIR/recursive.rs:+8:24: +8:27
}
}
}
@ -45,89 +45,88 @@
}
bb0: {
StorageLive(_1); // scope 0 at $DIR/recursive.rs:+1:9: +1:10
Deinit(_1); // scope 0 at $DIR/recursive.rs:+1:13: +1:22
((_1 as Num).0: u32) = const 0_u32; // scope 0 at $DIR/recursive.rs:+1:13: +1:22
discriminant(_1) = 1; // scope 0 at $DIR/recursive.rs:+1:13: +1:22
StorageLive(_2); // scope 1 at $DIR/recursive.rs:+2:9: +2:10
StorageLive(_3); // scope 1 at $DIR/recursive.rs:+2:20: +2:22
StorageLive(_4); // scope 1 at $DIR/recursive.rs:+2:20: +2:22
_4 = &_1; // scope 1 at $DIR/recursive.rs:+2:20: +2:22
_3 = &(*_4); // scope 1 at $DIR/recursive.rs:+2:20: +2:22
Deinit(_2); // scope 1 at $DIR/recursive.rs:+2:13: +2:23
((_2 as Rec).0: &S) = move _3; // scope 1 at $DIR/recursive.rs:+2:13: +2:23
discriminant(_2) = 0; // scope 1 at $DIR/recursive.rs:+2:13: +2:23
StorageDead(_3); // scope 1 at $DIR/recursive.rs:+2:22: +2:23
StorageDead(_4); // scope 1 at $DIR/recursive.rs:+2:23: +2:24
StorageLive(_5); // scope 2 at $DIR/recursive.rs:+3:9: +3:10
StorageLive(_6); // scope 2 at $DIR/recursive.rs:+3:20: +3:22
StorageLive(_7); // scope 2 at $DIR/recursive.rs:+3:20: +3:22
_7 = &_2; // scope 2 at $DIR/recursive.rs:+3:20: +3:22
_6 = &(*_7); // scope 2 at $DIR/recursive.rs:+3:20: +3:22
Deinit(_5); // scope 2 at $DIR/recursive.rs:+3:13: +3:23
((_5 as Rec).0: &S) = move _6; // scope 2 at $DIR/recursive.rs:+3:13: +3:23
discriminant(_5) = 0; // scope 2 at $DIR/recursive.rs:+3:13: +3:23
StorageDead(_6); // scope 2 at $DIR/recursive.rs:+3:22: +3:23
StorageDead(_7); // scope 2 at $DIR/recursive.rs:+3:23: +3:24
StorageLive(_8); // scope 3 at $DIR/recursive.rs:+4:9: +4:10
_9 = discriminant(_5); // scope 3 at $DIR/recursive.rs:+4:19: +4:20
switchInt(move _9) -> [0_isize: bb2, otherwise: bb1]; // scope 3 at $DIR/recursive.rs:+4:13: +4:20
StorageLive(_1); // scope 0 at $DIR/recursive.rs:+2:9: +2:10
Deinit(_1); // scope 0 at $DIR/recursive.rs:+2:13: +2:22
((_1 as Num).0: u32) = const 0_u32; // scope 0 at $DIR/recursive.rs:+2:13: +2:22
discriminant(_1) = 1; // scope 0 at $DIR/recursive.rs:+2:13: +2:22
StorageLive(_2); // scope 1 at $DIR/recursive.rs:+3:9: +3:10
StorageLive(_3); // scope 1 at $DIR/recursive.rs:+3:20: +3:22
StorageLive(_4); // scope 1 at $DIR/recursive.rs:+3:20: +3:22
_4 = &_1; // scope 1 at $DIR/recursive.rs:+3:20: +3:22
_3 = &(*_4); // scope 1 at $DIR/recursive.rs:+3:20: +3:22
Deinit(_2); // scope 1 at $DIR/recursive.rs:+3:13: +3:23
((_2 as Rec).0: &S) = move _3; // scope 1 at $DIR/recursive.rs:+3:13: +3:23
discriminant(_2) = 0; // scope 1 at $DIR/recursive.rs:+3:13: +3:23
StorageDead(_3); // scope 1 at $DIR/recursive.rs:+3:22: +3:23
StorageDead(_4); // scope 1 at $DIR/recursive.rs:+3:23: +3:24
StorageLive(_5); // scope 2 at $DIR/recursive.rs:+4:9: +4:10
StorageLive(_6); // scope 2 at $DIR/recursive.rs:+4:20: +4:22
StorageLive(_7); // scope 2 at $DIR/recursive.rs:+4:20: +4:22
_7 = &_2; // scope 2 at $DIR/recursive.rs:+4:20: +4:22
_6 = &(*_7); // scope 2 at $DIR/recursive.rs:+4:20: +4:22
Deinit(_5); // scope 2 at $DIR/recursive.rs:+4:13: +4:23
((_5 as Rec).0: &S) = move _6; // scope 2 at $DIR/recursive.rs:+4:13: +4:23
discriminant(_5) = 0; // scope 2 at $DIR/recursive.rs:+4:13: +4:23
StorageDead(_6); // scope 2 at $DIR/recursive.rs:+4:22: +4:23
StorageDead(_7); // scope 2 at $DIR/recursive.rs:+4:23: +4:24
StorageLive(_8); // scope 3 at $DIR/recursive.rs:+5:9: +5:10
_9 = discriminant(_5); // scope 3 at $DIR/recursive.rs:+5:19: +5:20
switchInt(move _9) -> [0_isize: bb2, otherwise: bb1]; // scope 3 at $DIR/recursive.rs:+5:13: +5:20
}
bb1: {
StorageLive(_17); // scope 3 at $DIR/recursive.rs:+12:14: +12:35
_17 = exit(const 0_i32); // scope 3 at $DIR/recursive.rs:+12:14: +12:35
StorageLive(_17); // scope 3 at $DIR/recursive.rs:+13:14: +13:35
_17 = exit(const 0_i32); // scope 3 at $DIR/recursive.rs:+13:14: +13:35
// mir::Constant
// + span: $DIR/recursive.rs:21:14: 21:32
// + span: $DIR/recursive.rs:22:14: 22:32
// + literal: Const { ty: fn(i32) -> ! {exit}, val: Value(<ZST>) }
}
bb2: {
StorageLive(_10); // scope 3 at $DIR/recursive.rs:+5:16: +5:17
_10 = ((_5 as Rec).0: &S); // scope 3 at $DIR/recursive.rs:+5:16: +5:17
_11 = discriminant((*_10)); // scope 5 at $DIR/recursive.rs:+5:28: +5:29
switchInt(move _11) -> [0_isize: bb4, otherwise: bb3]; // scope 5 at $DIR/recursive.rs:+5:22: +5:29
StorageLive(_10); // scope 3 at $DIR/recursive.rs:+6:16: +6:17
_10 = ((_5 as Rec).0: &S); // scope 3 at $DIR/recursive.rs:+6:16: +6:17
_11 = discriminant((*_10)); // scope 5 at $DIR/recursive.rs:+6:28: +6:29
switchInt(move _11) -> [0_isize: bb4, otherwise: bb3]; // scope 5 at $DIR/recursive.rs:+6:22: +6:29
}
bb3: {
StorageLive(_16); // scope 5 at $DIR/recursive.rs:+10:18: +10:39
_16 = exit(const 0_i32); // scope 5 at $DIR/recursive.rs:+10:18: +10:39
StorageLive(_16); // scope 5 at $DIR/recursive.rs:+11:18: +11:39
_16 = exit(const 0_i32); // scope 5 at $DIR/recursive.rs:+11:18: +11:39
// mir::Constant
// + span: $DIR/recursive.rs:19:18: 19:36
// + span: $DIR/recursive.rs:20:18: 20:36
// + literal: Const { ty: fn(i32) -> ! {exit}, val: Value(<ZST>) }
}
bb4: {
StorageLive(_12); // scope 5 at $DIR/recursive.rs:+6:20: +6:21
_12 = &(((*_10) as Rec).0: &S); // scope 5 at $DIR/recursive.rs:+6:20: +6:21
_18 = deref_copy (*_12); // scope 6 at $DIR/recursive.rs:+6:32: +6:33
_13 = discriminant((*_18)); // scope 6 at $DIR/recursive.rs:+6:32: +6:33
switchInt(move _13) -> [1_isize: bb6, otherwise: bb5]; // scope 6 at $DIR/recursive.rs:+6:26: +6:33
StorageLive(_12); // scope 5 at $DIR/recursive.rs:+7:20: +7:21
_12 = &(((*_10) as Rec).0: &S); // scope 5 at $DIR/recursive.rs:+7:20: +7:21
_18 = deref_copy (*_12); // scope 6 at $DIR/recursive.rs:+7:32: +7:33
_13 = discriminant((*_18)); // scope 6 at $DIR/recursive.rs:+7:32: +7:33
switchInt(move _13) -> [1_isize: bb6, otherwise: bb5]; // scope 6 at $DIR/recursive.rs:+7:26: +7:33
}
bb5: {
StorageLive(_15); // scope 6 at $DIR/recursive.rs:+8:22: +8:43
_15 = exit(const 0_i32); // scope 6 at $DIR/recursive.rs:+8:22: +8:43
StorageLive(_15); // scope 6 at $DIR/recursive.rs:+9:22: +9:43
_15 = exit(const 0_i32); // scope 6 at $DIR/recursive.rs:+9:22: +9:43
// mir::Constant
// + span: $DIR/recursive.rs:17:22: 17:40
// + span: $DIR/recursive.rs:18:22: 18:40
// + literal: Const { ty: fn(i32) -> ! {exit}, val: Value(<ZST>) }
}
bb6: {
StorageLive(_14); // scope 6 at $DIR/recursive.rs:+7:24: +7:27
_19 = deref_copy (*_12); // scope 6 at $DIR/recursive.rs:+7:24: +7:27
_14 = &(((*_19) as Num).0: u32); // scope 6 at $DIR/recursive.rs:+7:24: +7:27
- _8 = (*_14); // scope 7 at $DIR/recursive.rs:+7:32: +7:36
+ _8 = const 0_u32; // scope 7 at $DIR/recursive.rs:+7:32: +7:36
StorageDead(_14); // scope 6 at $DIR/recursive.rs:+7:35: +7:36
StorageDead(_12); // scope 5 at $DIR/recursive.rs:+9:13: +9:14
StorageDead(_10); // scope 3 at $DIR/recursive.rs:+11:9: +11:10
_0 = const (); // scope 0 at $DIR/recursive.rs:+0:11: +14:2
StorageDead(_8); // scope 3 at $DIR/recursive.rs:+14:1: +14:2
StorageDead(_5); // scope 2 at $DIR/recursive.rs:+14:1: +14:2
StorageDead(_2); // scope 1 at $DIR/recursive.rs:+14:1: +14:2
StorageDead(_1); // scope 0 at $DIR/recursive.rs:+14:1: +14:2
return; // scope 0 at $DIR/recursive.rs:+14:2: +14:2
StorageLive(_14); // scope 6 at $DIR/recursive.rs:+8:24: +8:27
_19 = deref_copy (*_12); // scope 6 at $DIR/recursive.rs:+8:24: +8:27
_14 = &(((*_19) as Num).0: u32); // scope 6 at $DIR/recursive.rs:+8:24: +8:27
_8 = (*_14); // scope 7 at $DIR/recursive.rs:+8:32: +8:36
StorageDead(_14); // scope 6 at $DIR/recursive.rs:+8:35: +8:36
StorageDead(_12); // scope 5 at $DIR/recursive.rs:+10:13: +10:14
StorageDead(_10); // scope 3 at $DIR/recursive.rs:+12:9: +12:10
_0 = const (); // scope 0 at $DIR/recursive.rs:+0:11: +15:2
StorageDead(_8); // scope 3 at $DIR/recursive.rs:+15:1: +15:2
StorageDead(_5); // scope 2 at $DIR/recursive.rs:+15:1: +15:2
StorageDead(_2); // scope 1 at $DIR/recursive.rs:+15:1: +15:2
StorageDead(_1); // scope 0 at $DIR/recursive.rs:+15:1: +15:2
return; // scope 0 at $DIR/recursive.rs:+15:2: +15:2
}
}

View File

@ -7,6 +7,7 @@ enum S<'a> {
// EMIT_MIR recursive.main.DataflowConstProp.diff
fn main() {
// FIXME: This currently does not work, because downcasts are rejected.
let a = S::Num(0);
let b = S::Rec(&a);
let c = S::Rec(&b);