about summary refs log tree commit diff
path: root/src/test/mir-opt/inline-trait-method_2.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/mir-opt/inline-trait-method_2.rs')
-rw-r--r--src/test/mir-opt/inline-trait-method_2.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/mir-opt/inline-trait-method_2.rs b/src/test/mir-opt/inline-trait-method_2.rs
new file mode 100644
index 00000000000..aa756f4a233
--- /dev/null
+++ b/src/test/mir-opt/inline-trait-method_2.rs
@@ -0,0 +1,36 @@
+// compile-flags: -Z span_free_formats -Z mir-opt-level=3
+
+#[inline]
+fn test(x: &dyn X) -> bool {
+    x.y()
+}
+
+fn test2(x: &dyn X) -> bool {
+    test(x)
+}
+
+trait X {
+    fn y(&self) -> bool {
+        false
+    }
+}
+
+impl X for () {
+    fn y(&self) -> bool {
+        true
+    }
+}
+
+fn main() {
+    println!("Should be true: {}", test2(&()));
+}
+
+// END RUST SOURCE
+// START rustc.test2.Inline.after.mir
+// ...
+// bb0: {
+// ...
+//     _0 = const X::y(move _2) -> bb1;
+// }
+// ...
+// END rustc.test2.Inline.after.mir