about summary refs log tree commit diff
path: root/src/test/mir-opt
diff options
context:
space:
mode:
authorDan Robertson <dan@dlrobertson.com>2019-03-09 03:39:23 +0000
committerDan Robertson <dan@dlrobertson.com>2019-03-10 00:19:00 +0000
commit3a83cb2c9ba2acca0577a5f4a092d7fc5b243faf (patch)
treef6e94c4cbb1171d9088b0acafff726e7394c444c /src/test/mir-opt
parentb2ea6c86ae8b9f8845aaff5a1453e4f5ceb53d59 (diff)
downloadrust-3a83cb2c9ba2acca0577a5f4a092d7fc5b243faf.tar.gz
rust-3a83cb2c9ba2acca0577a5f4a092d7fc5b243faf.zip
Fix ICE in MIR pretty printing
A `Def::Variant` should be considered as a function in mir pretty
printing. Each variant has a constructor that we must print.

Given the following enum definition:

```
pub enum TestMe {
    X(usize),
}
```

We will need to generate a constructor for the variant `X` with a
signature that looks something like the following:

```
fn TestMe::X(_1: usize) -> TestMe;
```
Diffstat (limited to 'src/test/mir-opt')
-rw-r--r--src/test/mir-opt/unusual-item-types.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/mir-opt/unusual-item-types.rs b/src/test/mir-opt/unusual-item-types.rs
index fe85baa048e..ced30381fda 100644
--- a/src/test/mir-opt/unusual-item-types.rs
+++ b/src/test/mir-opt/unusual-item-types.rs
@@ -7,11 +7,18 @@ impl A {
     const ASSOCIATED_CONSTANT: i32 = 2;
 }
 
+// See #59021
+enum Test {
+    X(usize),
+    Y { a: usize },
+}
+
 enum E {
     V = 5,
 }
 
 fn main() {
+    let f = Test::X as fn(usize) -> Test;
     let v = Vec::<i32>::new();
 }
 
@@ -64,3 +71,14 @@ fn main() {
 //     _3 = const std::ops::Drop::drop(move _2) -> [return: bb6, unwind: bb5];
 // }
 // END rustc.ptr-real_drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir
+
+// START rustc.Test-X.mir_map.0.mir
+// fn Test::X(_1: usize) -> Test {
+//     let mut _0: Test;
+//
+//     bb0: {
+//         _0 = Test::X(move _1,);
+//         return;
+//     }
+// }
+// END rustc.Test-X.mir_map.0.mir