Skip to content

Commit 55ce976

Browse files
Failing test
1 parent 19dd953 commit 55ce976

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
- // MIR for `call` before Inline
2+
+ // MIR for `call` after Inline
3+
4+
fn call(_1: &T) -> TypeId {
5+
debug s => _1;
6+
let mut _0: std::any::TypeId;
7+
let mut _2: &T;
8+
+ scope 1 (inlined <T as Any>::type_id) {
9+
+ debug self => _2;
10+
+ scope 2 (inlined TypeId::of::<T>) {
11+
+ let _3: u128;
12+
+ let mut _4: u128;
13+
+ scope 3 {
14+
+ debug t => _3;
15+
+ }
16+
+ }
17+
+ }
18+
19+
bb0: {
20+
StorageLive(_2);
21+
_2 = &(*_1);
22+
- _0 = <T as Any>::type_id(move _2) -> [return: bb1, unwind unreachable];
23+
+ StorageLive(_3);
24+
+ _3 = std::intrinsics::type_id::<T>() -> [return: bb1, unwind unreachable];
25+
}
26+
27+
bb1: {
28+
+ StorageLive(_4);
29+
+ _4 = _3;
30+
+ _0 = TypeId { t: move _4 };
31+
+ StorageDead(_4);
32+
+ StorageDead(_3);
33+
StorageDead(_2);
34+
return;
35+
}
36+
}
37+

tests/mir-opt/dont_inline_type_id.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// unit-test: Inline
2+
// compile-flags: --crate-type=lib -C panic=abort
3+
4+
use std::any::Any;
5+
use std::any::TypeId;
6+
7+
struct A<T: ?Sized + 'static> {
8+
a: i32,
9+
b: T,
10+
}
11+
12+
// EMIT_MIR dont_inline_type_id.call.Inline.diff
13+
fn call<T: ?Sized + 'static>(s: &T) -> TypeId {
14+
s.type_id()
15+
}

0 commit comments

Comments
 (0)