about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2020-03-08 01:47:54 +0100
committerJonas Schievink <jonasschievink@gmail.com>2020-03-08 02:01:41 +0100
commit2cbccced0856260c6acafabecb3030465dff28c2 (patch)
treed80184fa56c7ee34698fac87946898d5ef9f6b0d /src
parent8d9f633f4d78777487010ae119454dc9674e42ee (diff)
downloadrust-2cbccced0856260c6acafabecb3030465dff28c2.tar.gz
rust-2cbccced0856260c6acafabecb3030465dff28c2.zip
Add test for unnecessary panic branches
Diffstat (limited to 'src')
-rw-r--r--src/test/mir-opt/generator-tiny.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/mir-opt/generator-tiny.rs b/src/test/mir-opt/generator-tiny.rs
new file mode 100644
index 00000000000..09e943bd962
--- /dev/null
+++ b/src/test/mir-opt/generator-tiny.rs
@@ -0,0 +1,34 @@
+//! Tests that generators that cannot return or unwind don't have unnecessary
+//! panic branches.
+
+// compile-flags: -Zno-landing-pads
+
+#![feature(generators, generator_trait)]
+
+struct HasDrop;
+
+impl Drop for HasDrop {
+    fn drop(&mut self) {}
+}
+
+fn callee() {}
+
+fn main() {
+    let _gen = |_x: u8| {
+        let _d = HasDrop;
+        loop {
+            yield;
+            callee();
+        }
+    };
+}
+
+// END RUST SOURCE
+
+// START rustc.main-{{closure}}.generator_resume.0.mir
+// bb0: {
+//     ...
+//     switchInt(move _11) -> [0u32: bb1, 3u32: bb5, otherwise: bb6];
+// }
+// ...
+// END rustc.main-{{closure}}.generator_resume.0.mir