about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Mark Martin <ericmarkmartin@gmail.com>2023-07-01 15:15:22 -0400
committerEric Mark Martin <ericmarkmartin@gmail.com>2023-07-01 15:15:22 -0400
commitb9e991a105f36060a7ed501aa7f5897cc43685ae (patch)
treee087f3e969cbdd955918ad67e880fda1d9f16041
parent7dfb9eda25d1973fd8b70f95174e31c1443dde6a (diff)
downloadrust-b9e991a105f36060a7ed501aa7f5897cc43685ae.tar.gz
rust-b9e991a105f36060a7ed501aa7f5897cc43685ae.zip
add thir-print test
-rw-r--r--tests/ui/thir-print/thir-flat-const-variant.rs18
-rw-r--r--tests/ui/thir-print/thir-flat-const-variant.stdout399
2 files changed, 417 insertions, 0 deletions
diff --git a/tests/ui/thir-print/thir-flat-const-variant.rs b/tests/ui/thir-print/thir-flat-const-variant.rs
new file mode 100644
index 00000000000..2cd87a5cbb2
--- /dev/null
+++ b/tests/ui/thir-print/thir-flat-const-variant.rs
@@ -0,0 +1,18 @@
+// compile-flags: -Z unpretty=thir-flat
+// check-pass
+
+// Previously, the constants with `Self::Bar(())` would be `Call`s instead of
+// `Adt`s in THIR.
+
+pub enum Foo {
+    Bar(()),
+}
+
+impl Foo {
+    const BAR1: Foo = Foo::Bar(());
+    const BAR2: Foo = Self::Bar(());
+    const BAR3: Self = Foo::Bar(());
+    const BAR4: Self = Self::Bar(());
+}
+
+fn main() {}
diff --git a/tests/ui/thir-print/thir-flat-const-variant.stdout b/tests/ui/thir-print/thir-flat-const-variant.stdout
new file mode 100644
index 00000000000..1b76f07c318
--- /dev/null
+++ b/tests/ui/thir-print/thir-flat-const-variant.stdout
@@ -0,0 +1,399 @@
+DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1):
+Thir {
+    body_type: Const(
+        Foo,
+    ),
+    arms: [],
+    blocks: [],
+    exprs: [
+        Expr {
+            kind: Tuple {
+                fields: [],
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:12:32: 12:34 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Node(7),
+                lint_level: Explicit(
+                    HirId(DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1).7),
+                ),
+                value: e0,
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:12:32: 12:34 (#0),
+        },
+        Expr {
+            kind: Adt(
+                AdtExpr {
+                    adt_def: Foo,
+                    variant_index: 0,
+                    substs: [],
+                    user_ty: None,
+                    fields: [
+                        FieldExpr {
+                            name: 0,
+                            expr: e1,
+                        },
+                    ],
+                    base: None,
+                },
+            ),
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Node(3),
+                lint_level: Explicit(
+                    HirId(DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1).3),
+                ),
+                value: e2,
+            },
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Destruction(3),
+                lint_level: Inherited,
+                value: e3,
+            },
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0),
+        },
+    ],
+    stmts: [],
+    params: [],
+}
+
+DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2):
+Thir {
+    body_type: Const(
+        Foo,
+    ),
+    arms: [],
+    blocks: [],
+    exprs: [
+        Expr {
+            kind: Tuple {
+                fields: [],
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:13:33: 13:35 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Node(8),
+                lint_level: Explicit(
+                    HirId(DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2).8),
+                ),
+                value: e0,
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:13:33: 13:35 (#0),
+        },
+        Expr {
+            kind: Adt(
+                AdtExpr {
+                    adt_def: Foo,
+                    variant_index: 0,
+                    substs: [],
+                    user_ty: None,
+                    fields: [
+                        FieldExpr {
+                            name: 0,
+                            expr: e1,
+                        },
+                    ],
+                    base: None,
+                },
+            ),
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Node(3),
+                lint_level: Explicit(
+                    HirId(DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2).3),
+                ),
+                value: e2,
+            },
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Destruction(3),
+                lint_level: Inherited,
+                value: e3,
+            },
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0),
+        },
+    ],
+    stmts: [],
+    params: [],
+}
+
+DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3):
+Thir {
+    body_type: Const(
+        Foo,
+    ),
+    arms: [],
+    blocks: [],
+    exprs: [
+        Expr {
+            kind: Tuple {
+                fields: [],
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:14:33: 14:35 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Node(7),
+                lint_level: Explicit(
+                    HirId(DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3).7),
+                ),
+                value: e0,
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:14:33: 14:35 (#0),
+        },
+        Expr {
+            kind: Adt(
+                AdtExpr {
+                    adt_def: Foo,
+                    variant_index: 0,
+                    substs: [],
+                    user_ty: None,
+                    fields: [
+                        FieldExpr {
+                            name: 0,
+                            expr: e1,
+                        },
+                    ],
+                    base: None,
+                },
+            ),
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Node(3),
+                lint_level: Explicit(
+                    HirId(DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3).3),
+                ),
+                value: e2,
+            },
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Destruction(3),
+                lint_level: Inherited,
+                value: e3,
+            },
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0),
+        },
+    ],
+    stmts: [],
+    params: [],
+}
+
+DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4):
+Thir {
+    body_type: Const(
+        Foo,
+    ),
+    arms: [],
+    blocks: [],
+    exprs: [
+        Expr {
+            kind: Tuple {
+                fields: [],
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:15:34: 15:36 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Node(8),
+                lint_level: Explicit(
+                    HirId(DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4).8),
+                ),
+                value: e0,
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:15:34: 15:36 (#0),
+        },
+        Expr {
+            kind: Adt(
+                AdtExpr {
+                    adt_def: Foo,
+                    variant_index: 0,
+                    substs: [],
+                    user_ty: None,
+                    fields: [
+                        FieldExpr {
+                            name: 0,
+                            expr: e1,
+                        },
+                    ],
+                    base: None,
+                },
+            ),
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Node(3),
+                lint_level: Explicit(
+                    HirId(DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4).3),
+                ),
+                value: e2,
+            },
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Destruction(3),
+                lint_level: Inherited,
+                value: e3,
+            },
+            ty: Foo,
+            temp_lifetime: Some(
+                Node(3),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0),
+        },
+    ],
+    stmts: [],
+    params: [],
+}
+
+DefId(0:12 ~ thir_flat_const_variant[1f54]::main):
+Thir {
+    body_type: Fn(
+        fn(),
+    ),
+    arms: [],
+    blocks: [
+        Block {
+            targeted_by_break: false,
+            region_scope: Node(1),
+            opt_destruction_scope: None,
+            span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
+            stmts: [],
+            expr: None,
+            safety_mode: Safe,
+        },
+    ],
+    exprs: [
+        Expr {
+            kind: Block {
+                block: b0,
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(2),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Node(2),
+                lint_level: Explicit(
+                    HirId(DefId(0:12 ~ thir_flat_const_variant[1f54]::main).2),
+                ),
+                value: e0,
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(2),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
+        },
+        Expr {
+            kind: Scope {
+                region_scope: Destruction(2),
+                lint_level: Inherited,
+                value: e1,
+            },
+            ty: (),
+            temp_lifetime: Some(
+                Node(2),
+            ),
+            span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
+        },
+    ],
+    stmts: [],
+    params: [],
+}
+