about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-08-17 17:43:38 +0000
committerMichael Goulet <michael@errs.io>2023-09-19 04:55:51 +0000
commit55ce976e06e1dc9590a41cdc262688d4db8d93e4 (patch)
tree400e26721b1221b2fe4a5acc12952b2526ec50b0
parent19dd9535408db0f1ff3d16613619076aef524d19 (diff)
downloadrust-55ce976e06e1dc9590a41cdc262688d4db8d93e4.tar.gz
rust-55ce976e06e1dc9590a41cdc262688d4db8d93e4.zip
Failing test
-rw-r--r--tests/mir-opt/dont_inline_type_id.call.Inline.diff37
-rw-r--r--tests/mir-opt/dont_inline_type_id.rs15
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/mir-opt/dont_inline_type_id.call.Inline.diff b/tests/mir-opt/dont_inline_type_id.call.Inline.diff
new file mode 100644
index 00000000000..d67235ddbd2
--- /dev/null
+++ b/tests/mir-opt/dont_inline_type_id.call.Inline.diff
@@ -0,0 +1,37 @@
+- // MIR for `call` before Inline
++ // MIR for `call` after Inline
+  
+  fn call(_1: &T) -> TypeId {
+      debug s => _1;
+      let mut _0: std::any::TypeId;
+      let mut _2: &T;
++     scope 1 (inlined <T as Any>::type_id) {
++         debug self => _2;
++         scope 2 (inlined TypeId::of::<T>) {
++             let _3: u128;
++             let mut _4: u128;
++             scope 3 {
++                 debug t => _3;
++             }
++         }
++     }
+  
+      bb0: {
+          StorageLive(_2);
+          _2 = &(*_1);
+-         _0 = <T as Any>::type_id(move _2) -> [return: bb1, unwind unreachable];
++         StorageLive(_3);
++         _3 = std::intrinsics::type_id::<T>() -> [return: bb1, unwind unreachable];
+      }
+  
+      bb1: {
++         StorageLive(_4);
++         _4 = _3;
++         _0 = TypeId { t: move _4 };
++         StorageDead(_4);
++         StorageDead(_3);
+          StorageDead(_2);
+          return;
+      }
+  }
+  
diff --git a/tests/mir-opt/dont_inline_type_id.rs b/tests/mir-opt/dont_inline_type_id.rs
new file mode 100644
index 00000000000..6f4c21a3ab1
--- /dev/null
+++ b/tests/mir-opt/dont_inline_type_id.rs
@@ -0,0 +1,15 @@
+// unit-test: Inline
+// compile-flags: --crate-type=lib -C panic=abort
+
+use std::any::Any;
+use std::any::TypeId;
+
+struct A<T: ?Sized + 'static> {
+    a: i32,
+    b: T,
+}
+
+// EMIT_MIR dont_inline_type_id.call.Inline.diff
+fn call<T: ?Sized + 'static>(s: &T) -> TypeId {
+    s.type_id()
+}