From 2472e04291c6f69ce3f469838ebbeeefcbe2e529 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 17 Apr 2020 03:54:13 +0300 Subject: [PATCH 1/3] ty/print/pretty: use `comma_sep` instead of replicating it. --- src/librustc_middle/ty/print/pretty.rs | 48 +++++++------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs index a8b7b6a4b97a4..0cabd201a95bb 100644 --- a/src/librustc_middle/ty/print/pretty.rs +++ b/src/librustc_middle/ty/print/pretty.rs @@ -498,16 +498,9 @@ pub trait PrettyPrinter<'tcx>: } ty::Never => p!(write("!")), ty::Tuple(ref tys) => { - p!(write("(")); - let mut tys = tys.iter(); - if let Some(&ty) = tys.next() { - p!(print(ty), write(",")); - if let Some(&ty) = tys.next() { - p!(write(" "), print(ty)); - for &ty in tys { - p!(write(", "), print(ty)); - } - } + p!(write("("), comma_sep(tys.iter().copied())); + if tys.len() == 1 { + p!(write(",")); } p!(write(")")) } @@ -570,15 +563,10 @@ pub trait PrettyPrinter<'tcx>: let def_key = self.tcx().def_key(def_id); if let Some(name) = def_key.disambiguated_data.data.get_opt_name() { p!(write("{}", name)); - let mut substs = substs.iter(); // FIXME(eddyb) print this with `print_def_path`. - if let Some(first) = substs.next() { - p!(write("::<")); - p!(print(first)); - for subst in substs { - p!(write(", "), print(subst)); - } - p!(write(">")); + if !substs.is_empty() { + p!(write("::")); + p!(generic_delimiters(|cx| cx.comma_sep(substs.iter().copied()))); } return Ok(self); } @@ -854,16 +842,12 @@ pub trait PrettyPrinter<'tcx>: ) -> Result { define_scoped_cx!(self); - p!(write("(")); - let mut inputs = inputs.iter(); - if let Some(&ty) = inputs.next() { - p!(print(ty)); - for &ty in inputs { - p!(write(", "), print(ty)); - } - if c_variadic { - p!(write(", ...")); + p!(write("("), comma_sep(inputs.iter().copied())); + if c_variadic { + if !inputs.is_empty() { + p!(write(", ")); } + p!(write("...")); } p!(write(")")); if !output.is_unit() { @@ -1913,15 +1897,7 @@ define_print_and_forward_display! { (self, cx): &'tcx ty::List> { - p!(write("{{")); - let mut tys = self.iter(); - if let Some(&ty) = tys.next() { - p!(print(ty)); - for &ty in tys { - p!(write(", "), print(ty)); - } - } - p!(write("}}")) + p!(write("{{"), comma_sep(self.iter().copied()), write("}}")) } ty::TypeAndMut<'tcx> { From aabed9322e78b280d54fe7a90bb088932731d967 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 17 Apr 2020 03:54:58 +0300 Subject: [PATCH 2/3] mir: pretty-print `Rvalue::Aggregate` correctly. --- src/librustc_middle/mir/mod.rs | 32 ++++++++++--------- .../32bit/rustc.main.ConstProp.diff | 2 +- .../64bit/rustc.main.ConstProp.diff | 2 +- .../rustc.test1.Deaggregator.diff | 4 +-- .../rustc.test.Deaggregator.diff | 4 +-- ...main-{{closure}}.StateTransform.before.mir | 4 +-- ...tc.main-{{closure}}.generator_resume.0.mir | 2 +- .../rustc.main.ElaborateDrops.after.mir | 2 +- .../rustc.test.ElaborateDrops.before.mir | 2 +- ...c.full_tested_match.PromoteTemps.after.mir | 2 +- ...full_tested_match2.PromoteTemps.before.mir | 2 +- .../rustc.main.PromoteTemps.before.mir | 2 +- ...main.SimplifyCfg-elaborate-drops.after.mir | 10 +++--- ...main.SimplifyCfg-elaborate-drops.after.mir | 10 +++--- ...main.SimplifyCfg-elaborate-drops.after.mir | 4 +-- .../storage_ranges/rustc.main.nll.0.mir | 2 +- 16 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index 212061cfd824f..2d3f8b4b25120 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -2242,39 +2242,41 @@ impl<'tcx> Debug for Rvalue<'tcx> { } Aggregate(ref kind, ref places) => { - fn fmt_tuple(fmt: &mut Formatter<'_>, places: &[Operand<'_>]) -> fmt::Result { - let mut tuple_fmt = fmt.debug_tuple(""); + let fmt_tuple = |fmt: &mut Formatter<'_>, name: &str| { + let mut tuple_fmt = fmt.debug_tuple(name); for place in places { tuple_fmt.field(place); } tuple_fmt.finish() - } + }; match **kind { AggregateKind::Array(_) => write!(fmt, "{:?}", places), - AggregateKind::Tuple => match places.len() { - 0 => write!(fmt, "()"), - 1 => write!(fmt, "({:?},)", places[0]), - _ => fmt_tuple(fmt, places), - }, + AggregateKind::Tuple => { + if places.is_empty() { + write!(fmt, "()") + } else { + fmt_tuple(fmt, "") + } + } AggregateKind::Adt(adt_def, variant, substs, _user_ty, _) => { let variant_def = &adt_def.variants[variant]; - let f = &mut *fmt; - ty::tls::with(|tcx| { + let name = ty::tls::with(|tcx| { + let mut name = String::new(); let substs = tcx.lift(&substs).expect("could not lift for printing"); - FmtPrinter::new(tcx, f, Namespace::ValueNS) + FmtPrinter::new(tcx, &mut name, Namespace::ValueNS) .print_def_path(variant_def.def_id, substs)?; - Ok(()) + Ok(name) })?; match variant_def.ctor_kind { - CtorKind::Const => Ok(()), - CtorKind::Fn => fmt_tuple(fmt, places), + CtorKind::Const => fmt.write_str(&name), + CtorKind::Fn => fmt_tuple(fmt, &name), CtorKind::Fictive => { - let mut struct_fmt = fmt.debug_struct(""); + let mut struct_fmt = fmt.debug_struct(&name); for (field, place) in variant_def.fields.iter().zip(places) { struct_fmt.field(&field.ident.as_str(), place); } diff --git a/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff index f89d869cab504..d5566b9d761dd 100644 --- a/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff @@ -15,7 +15,7 @@ StorageLive(_1); // bb0[0]: scope 0 at $DIR/discriminant.rs:6:9: 6:10 StorageLive(_2); // bb0[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 StorageLive(_3); // bb0[2]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 -- _3 = std::option::Option::::Some(const true,); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 +- _3 = std::option::Option::::Some(const true); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 + _3 = const {transmute(0x01): std::option::Option}; // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 // ty::Const - // + ty: bool diff --git a/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff index 06f43db50f486..bdd9c020c9557 100644 --- a/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff @@ -15,7 +15,7 @@ StorageLive(_1); // bb0[0]: scope 0 at $DIR/discriminant.rs:6:9: 6:10 StorageLive(_2); // bb0[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 StorageLive(_3); // bb0[2]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 -- _3 = std::option::Option::::Some(const true,); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 +- _3 = std::option::Option::::Some(const true); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 + _3 = const {transmute(0x01): std::option::Option}; // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 // ty::Const - // + ty: bool diff --git a/src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff b/src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff index a72a679b2090c..3256e59e3eba9 100644 --- a/src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff +++ b/src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff @@ -18,7 +18,7 @@ bb1: { StorageLive(_5); // bb1[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17 _5 = _2; // bb1[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17 -- _0 = Foo::B(move _5,); // bb1[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 +- _0 = Foo::B(move _5); // bb1[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 - StorageDead(_5); // bb1[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:17: 13:18 - goto -> bb3; // bb1[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 + ((_0 as B).0: i32) = move _5; // bb1[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 @@ -30,7 +30,7 @@ bb2: { StorageLive(_4); // bb2[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17 _4 = _2; // bb2[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17 -- _0 = Foo::A(move _4,); // bb2[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18 +- _0 = Foo::A(move _4); // bb2[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18 - StorageDead(_4); // bb2[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:17: 11:18 - goto -> bb3; // bb2[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 + ((_0 as A).0: i32) = move _4; // bb2[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18 diff --git a/src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff b/src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff index 126dfc1ac91a6..7d3ae6a16b2a8 100644 --- a/src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff +++ b/src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff @@ -13,12 +13,12 @@ StorageLive(_2); // bb0[0]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15 StorageLive(_3); // bb0[1]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:13: 10:14 _3 = _1; // bb0[2]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:13: 10:14 -- _2 = Foo::A(move _3,); // bb0[3]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15 +- _2 = Foo::A(move _3); // bb0[3]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15 - StorageDead(_3); // bb0[4]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:14: 10:15 - StorageLive(_4); // bb0[5]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26 - StorageLive(_5); // bb0[6]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25 - _5 = _1; // bb0[7]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25 -- _4 = Foo::A(move _5,); // bb0[8]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26 +- _4 = Foo::A(move _5); // bb0[8]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26 - StorageDead(_5); // bb0[9]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:25: 10:26 - _0 = [move _2, move _4]; // bb0[10]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:5: 10:27 - StorageDead(_4); // bb0[11]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:26: 10:27 diff --git a/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir b/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir index 50a48f2eee414..5d5f9dcc61d79 100644 --- a/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir +++ b/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir @@ -21,7 +21,7 @@ yields () bb0: { StorageLive(_3); // bb0[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14 - _3 = Foo(const 5i32,); // bb0[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23 + _3 = Foo(const 5i32); // bb0[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000005)) @@ -29,7 +29,7 @@ yields () // + span: $DIR/generator-storage-dead-unwind.rs:23:21: 23:22 // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } StorageLive(_4); // bb0[2]: scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14 - _4 = Bar(const 6i32,); // bb0[3]: scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23 + _4 = Bar(const 6i32); // bb0[3]: scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000006)) diff --git a/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir b/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir index 2e3354699fbaa..dbab6ceffdcff 100644 --- a/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir +++ b/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir @@ -34,7 +34,7 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs: StorageLive(_6); // bb2[0]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 StorageLive(_7); // bb2[1]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 _7 = (); // bb2[2]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 - _0 = std::ops::GeneratorState::<(), ()>::Yielded(move _7,); // bb2[3]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 + _0 = std::ops::GeneratorState::<(), ()>::Yielded(move _7); // bb2[3]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}]))) = 3; // bb2[4]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 return; // bb2[5]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 } diff --git a/src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir index ee05bf48d6273..fe376f2a0486d 100644 --- a/src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir @@ -80,7 +80,7 @@ fn main() -> () { StorageLive(_3); // bb5[0]: scope 1 at $DIR/issue-41888.rs:9:13: 9:20 StorageLive(_4); // bb5[1]: scope 1 at $DIR/issue-41888.rs:9:18: 9:19 _4 = K; // bb5[2]: scope 1 at $DIR/issue-41888.rs:9:18: 9:19 - _3 = E::F(move _4,); // bb5[3]: scope 1 at $DIR/issue-41888.rs:9:13: 9:20 + _3 = E::F(move _4); // bb5[3]: scope 1 at $DIR/issue-41888.rs:9:13: 9:20 StorageDead(_4); // bb5[4]: scope 1 at $DIR/issue-41888.rs:9:19: 9:20 goto -> bb14; // bb5[5]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 } diff --git a/src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir b/src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir index c2f9198002117..8970cc83f2b3c 100644 --- a/src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir +++ b/src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir @@ -115,7 +115,7 @@ fn test() -> std::option::Option> { bb12: { StorageDead(_2); // bb12[0]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21 - _0 = std::option::Option::>::Some(move _1,); // bb12[1]: scope 0 at $DIR/issue-62289.rs:9:5: 9:22 + _0 = std::option::Option::>::Some(move _1); // bb12[1]: scope 0 at $DIR/issue-62289.rs:9:5: 9:22 drop(_1) -> bb13; // bb12[2]: scope 0 at $DIR/issue-62289.rs:9:21: 9:22 } diff --git a/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir b/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir index a296bd053121c..0f8b6cc9c841b 100644 --- a/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir +++ b/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir @@ -26,7 +26,7 @@ fn full_tested_match() -> () { bb0: { StorageLive(_1); // bb0[0]: scope 0 at $DIR/match_false_edges.rs:15:13: 19:6 StorageLive(_2); // bb0[1]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 - _2 = std::option::Option::::Some(const 42i32,); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 + _2 = std::option::Option::::Some(const 42i32); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000002a)) diff --git a/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir index 567e3ebdd9310..2cf6c97ae2265 100644 --- a/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir +++ b/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir @@ -25,7 +25,7 @@ fn full_tested_match2() -> () { bb0: { StorageLive(_1); // bb0[0]: scope 0 at $DIR/match_false_edges.rs:26:13: 30:6 StorageLive(_2); // bb0[1]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 - _2 = std::option::Option::::Some(const 42i32,); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 + _2 = std::option::Option::::Some(const 42i32); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000002a)) diff --git a/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir index a24fa9dedb39f..7bba0b20d8ebc 100644 --- a/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir +++ b/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir @@ -36,7 +36,7 @@ fn main() -> () { bb0: { StorageLive(_1); // bb0[0]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 StorageLive(_2); // bb0[1]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 - _2 = std::option::Option::::Some(const 1i32,); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 + _2 = std::option::Option::::Some(const 1i32); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000001)) diff --git a/src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir index cea1087294298..cf423d06efb5f 100644 --- a/src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -16,27 +16,27 @@ fn main() -> () { StorageLive(_1); // bb0[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14 StorageLive(_2); // bb0[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 StorageLive(_3); // bb0[2]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 - _3 = Droppy(const 0usize,); // bb0[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 + _3 = Droppy(const 0usize); // bb0[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 // ty::Const // + ty: usize // + val: Value(Scalar(0x00000000)) // mir::Constant // + span: $DIR/packed-struct-drop-aligned.rs:6:39: 6:40 // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) } - _2 = Aligned(move _3,); // bb0[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 + _2 = Aligned(move _3); // bb0[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 StorageDead(_3); // bb0[5]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:41: 6:42 - _1 = Packed(move _2,); // bb0[6]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:17: 6:43 + _1 = Packed(move _2); // bb0[6]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:17: 6:43 StorageDead(_2); // bb0[7]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:42: 6:43 StorageLive(_4); // bb0[8]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 StorageLive(_5); // bb0[9]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 - _5 = Droppy(const 0usize,); // bb0[10]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 + _5 = Droppy(const 0usize); // bb0[10]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 // ty::Const // + ty: usize // + val: Value(Scalar(0x00000000)) // mir::Constant // + span: $DIR/packed-struct-drop-aligned.rs:7:26: 7:27 // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) } - _4 = Aligned(move _5,); // bb0[11]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 + _4 = Aligned(move _5); // bb0[11]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 StorageDead(_5); // bb0[12]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29 StorageLive(_6); // bb0[13]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 _6 = move (_1.0: Aligned); // bb0[14]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 diff --git a/src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir index 432f91d91e576..09b398e960420 100644 --- a/src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -16,27 +16,27 @@ fn main() -> () { StorageLive(_1); // bb0[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14 StorageLive(_2); // bb0[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 StorageLive(_3); // bb0[2]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 - _3 = Droppy(const 0usize,); // bb0[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 + _3 = Droppy(const 0usize); // bb0[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 // ty::Const // + ty: usize // + val: Value(Scalar(0x0000000000000000)) // mir::Constant // + span: $DIR/packed-struct-drop-aligned.rs:6:39: 6:40 // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } - _2 = Aligned(move _3,); // bb0[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 + _2 = Aligned(move _3); // bb0[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 StorageDead(_3); // bb0[5]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:41: 6:42 - _1 = Packed(move _2,); // bb0[6]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:17: 6:43 + _1 = Packed(move _2); // bb0[6]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:17: 6:43 StorageDead(_2); // bb0[7]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:42: 6:43 StorageLive(_4); // bb0[8]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 StorageLive(_5); // bb0[9]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 - _5 = Droppy(const 0usize,); // bb0[10]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 + _5 = Droppy(const 0usize); // bb0[10]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 // ty::Const // + ty: usize // + val: Value(Scalar(0x0000000000000000)) // mir::Constant // + span: $DIR/packed-struct-drop-aligned.rs:7:26: 7:27 // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } - _4 = Aligned(move _5,); // bb0[11]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 + _4 = Aligned(move _5); // bb0[11]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 StorageDead(_5); // bb0[12]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29 StorageLive(_6); // bb0[13]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 _6 = move (_1.0: Aligned); // bb0[14]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 diff --git a/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir index 727c271a47832..125f69b0bc288 100644 --- a/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -67,7 +67,7 @@ fn main() -> () { StorageLive(_3); // bb0[3]: scope 1 at $DIR/retag.rs:32:13: 32:14 StorageLive(_4); // bb0[4]: scope 1 at $DIR/retag.rs:32:17: 32:24 StorageLive(_5); // bb0[5]: scope 1 at $DIR/retag.rs:32:17: 32:24 - _5 = Test(const 0i32,); // bb0[6]: scope 1 at $DIR/retag.rs:32:17: 32:24 + _5 = Test(const 0i32); // bb0[6]: scope 1 at $DIR/retag.rs:32:17: 32:24 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000000)) @@ -170,7 +170,7 @@ fn main() -> () { StorageLive(_19); // bb5[4]: scope 7 at $DIR/retag.rs:47:5: 47:24 StorageLive(_20); // bb5[5]: scope 7 at $DIR/retag.rs:47:5: 47:12 StorageLive(_21); // bb5[6]: scope 7 at $DIR/retag.rs:47:5: 47:12 - _21 = Test(const 0i32,); // bb5[7]: scope 7 at $DIR/retag.rs:47:5: 47:12 + _21 = Test(const 0i32); // bb5[7]: scope 7 at $DIR/retag.rs:47:5: 47:12 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000000)) diff --git a/src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir b/src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir index e455a27642d36..799521b09a6fe 100644 --- a/src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir +++ b/src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir @@ -50,7 +50,7 @@ fn main() -> () { StorageLive(_4); // bb0[5]: scope 1 at $DIR/storage_ranges.rs:6:18: 6:25 StorageLive(_5); // bb0[6]: scope 1 at $DIR/storage_ranges.rs:6:23: 6:24 _5 = _1; // bb0[7]: scope 1 at $DIR/storage_ranges.rs:6:23: 6:24 - _4 = std::option::Option::::Some(move _5,); // bb0[8]: scope 1 at $DIR/storage_ranges.rs:6:18: 6:25 + _4 = std::option::Option::::Some(move _5); // bb0[8]: scope 1 at $DIR/storage_ranges.rs:6:18: 6:25 StorageDead(_5); // bb0[9]: scope 1 at $DIR/storage_ranges.rs:6:24: 6:25 _3 = &_4; // bb0[10]: scope 1 at $DIR/storage_ranges.rs:6:17: 6:25 FakeRead(ForLet, _3); // bb0[11]: scope 1 at $DIR/storage_ranges.rs:6:13: 6:14 From eccb28e3d67460f77331eb5ecceab36181831946 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 17 Apr 2020 03:55:39 +0300 Subject: [PATCH 3/3] ty/print: pretty-print constant aggregates (arrays, tuples and ADTs). --- src/librustc_middle/query/mod.rs | 2 +- src/librustc_middle/ty/print/pretty.rs | 79 +++++++++++++++---- .../32bit/rustc.main.ConstProp.diff | 2 +- .../64bit/rustc.main.ConstProp.diff | 2 +- .../32bit/rustc.main.Inline.diff | 2 +- .../64bit/rustc.main.Inline.diff | 2 +- .../rustc.main.SimplifyLocals.diff | 8 +- 7 files changed, 72 insertions(+), 25 deletions(-) diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index 3ddb290fc8d1e..1b94966c3477d 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -574,7 +574,7 @@ rustc_queries! { desc { "extract field of const" } } - /// Destructure a constant ADT or array into its variant indent and its + /// Destructure a constant ADT or array into its variant index and its /// field values. query destructure_const( key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>> diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs index 0cabd201a95bb..85c05515bd73c 100644 --- a/src/librustc_middle/ty/print/pretty.rs +++ b/src/librustc_middle/ty/print/pretty.rs @@ -9,7 +9,7 @@ use rustc_apfloat::Float; use rustc_ast::ast; use rustc_attr::{SignedInt, UnsignedInt}; use rustc_hir as hir; -use rustc_hir::def::{DefKind, Namespace}; +use rustc_hir::def::{CtorKind, DefKind, Namespace}; use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; use rustc_span::symbol::{kw, Symbol}; @@ -1037,19 +1037,6 @@ pub trait PrettyPrinter<'tcx>: } // For function type zsts just printing the path is enough (Scalar::Raw { size: 0, .. }, ty::FnDef(d, s)) => p!(print_value_path(*d, s)), - // Empty tuples are frequently occurring, so don't print the fallback. - (Scalar::Raw { size: 0, .. }, ty::Tuple(ts)) if ts.is_empty() => p!(write("()")), - // Zero element arrays have a trivial representation. - ( - Scalar::Raw { size: 0, .. }, - ty::Array( - _, - ty::Const { - val: ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data: 0, .. })), - .. - }, - ), - ) => p!(write("[]")), // Nontrivial types with scalar bit representation (Scalar::Raw { data, size }, _) => { let print = |mut this: Self| { @@ -1118,14 +1105,14 @@ pub trait PrettyPrinter<'tcx>: define_scoped_cx!(self); if self.tcx().sess.verbose() { - p!(write("ConstValue({:?}: {:?})", ct, ty)); + p!(write("ConstValue({:?}: ", ct), print(ty), write(")")); return Ok(self); } let u8_type = self.tcx().types.u8; match (ct, &ty.kind) { - (ConstValue::Scalar(scalar), _) => self.pretty_print_const_scalar(scalar, ty, print_ty), + // Byte/string slices, printed as (byte) string literals. ( ConstValue::Slice { data, start, end }, ty::Ref(_, ty::TyS { kind: ty::Slice(t), .. }, _), @@ -1159,6 +1146,66 @@ pub trait PrettyPrinter<'tcx>: p!(pretty_print_byte_str(byte_str)); Ok(self) } + + // Aggregates, printed as array/tuple/struct/variant construction syntax. + // + // NB: the `has_param_types_or_consts` check ensures that we can use + // the `destructure_const` query with an empty `ty::ParamEnv` without + // introducing ICEs (e.g. via `layout_of`) from missing bounds. + // E.g. `transmute([0usize; 2]): (u8, *mut T)` needs to know `T: Sized` + // to be able to destructure the tuple into `(0u8, *mut T) + // + // FIXME(eddyb) for `--emit=mir`/`-Z dump-mir`, we should provide the + // correct `ty::ParamEnv` to allow printing *all* constant values. + (_, ty::Array(..) | ty::Tuple(..) | ty::Adt(..)) if !ty.has_param_types_or_consts() => { + let contents = self.tcx().destructure_const( + ty::ParamEnv::reveal_all() + .and(self.tcx().mk_const(ty::Const { val: ty::ConstKind::Value(ct), ty })), + ); + let fields = contents.fields.iter().copied(); + + match ty.kind { + ty::Array(..) => { + p!(write("["), comma_sep(fields), write("]")); + } + ty::Tuple(..) => { + p!(write("("), comma_sep(fields)); + if contents.fields.len() == 1 { + p!(write(",")); + } + p!(write(")")); + } + ty::Adt(def, substs) => { + let variant_def = &def.variants[contents.variant]; + p!(print_value_path(variant_def.def_id, substs)); + + match variant_def.ctor_kind { + CtorKind::Const => {} + CtorKind::Fn => { + p!(write("("), comma_sep(fields), write(")")); + } + CtorKind::Fictive => { + p!(write(" {{ ")); + let mut first = true; + for (field_def, field) in variant_def.fields.iter().zip(fields) { + if !first { + p!(write(", ")); + } + p!(write("{}: ", field_def.ident), print(field)); + first = false; + } + p!(write(" }}")); + } + } + } + _ => unreachable!(), + } + + Ok(self) + } + + (ConstValue::Scalar(scalar), _) => self.pretty_print_const_scalar(scalar, ty, print_ty), + // FIXME(oli-obk): also pretty print arrays and other aggregate constants by reading // their fields instead of just dumping the memory. _ => { diff --git a/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff index d5566b9d761dd..753c64d6c3298 100644 --- a/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff @@ -16,7 +16,7 @@ StorageLive(_2); // bb0[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 StorageLive(_3); // bb0[2]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 - _3 = std::option::Option::::Some(const true); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 -+ _3 = const {transmute(0x01): std::option::Option}; // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 ++ _3 = const std::option::Option::::Some(true); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 // ty::Const - // + ty: bool + // + ty: std::option::Option diff --git a/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff index bdd9c020c9557..1d8e945f87a6d 100644 --- a/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff @@ -16,7 +16,7 @@ StorageLive(_2); // bb0[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 StorageLive(_3); // bb0[2]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 - _3 = std::option::Option::::Some(const true); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 -+ _3 = const {transmute(0x01): std::option::Option}; // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 ++ _3 = const std::option::Option::::Some(true); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 // ty::Const - // + ty: bool + // + ty: std::option::Option diff --git a/src/test/mir-opt/inline/inline-into-box-place/32bit/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-into-box-place/32bit/rustc.main.Inline.diff index 6983e94ff8d77..7f2f7cdb17668 100644 --- a/src/test/mir-opt/inline/inline-into-box-place/32bit/rustc.main.Inline.diff +++ b/src/test/mir-opt/inline/inline-into-box-place/32bit/rustc.main.Inline.diff @@ -19,7 +19,7 @@ _2 = Box(std::vec::Vec); // bb0[2]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 - (*_2) = const std::vec::Vec::::new() -> [return: bb2, unwind: bb4]; // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 + _4 = &mut (*_2); // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 -+ ((*_4).0: alloc::raw_vec::RawVec) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::; // bb0[4]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL ++ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: std::ptr::Unique:: { pointer: {0x4 as *const u32}, _marker: std::marker::PhantomData:: }, cap: 0usize, alloc: std::alloc::Global }; // bb0[4]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL // ty::Const - // + ty: fn() -> std::vec::Vec {std::vec::Vec::::new} - // + val: Value(Scalar()) diff --git a/src/test/mir-opt/inline/inline-into-box-place/64bit/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-into-box-place/64bit/rustc.main.Inline.diff index 38ab9ce9926c0..b968b33ac5274 100644 --- a/src/test/mir-opt/inline/inline-into-box-place/64bit/rustc.main.Inline.diff +++ b/src/test/mir-opt/inline/inline-into-box-place/64bit/rustc.main.Inline.diff @@ -19,7 +19,7 @@ _2 = Box(std::vec::Vec); // bb0[2]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 - (*_2) = const std::vec::Vec::::new() -> [return: bb2, unwind: bb4]; // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 + _4 = &mut (*_2); // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 -+ ((*_4).0: alloc::raw_vec::RawVec) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::; // bb0[4]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL ++ ((*_4).0: alloc::raw_vec::RawVec) = const alloc::raw_vec::RawVec:: { ptr: std::ptr::Unique:: { pointer: {0x4 as *const u32}, _marker: std::marker::PhantomData:: }, cap: 0usize, alloc: std::alloc::Global }; // bb0[4]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL // ty::Const - // + ty: fn() -> std::vec::Vec {std::vec::Vec::::new} - // + val: Value(Scalar()) diff --git a/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff b/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff index 8613a812a834b..855ead7ea0554 100644 --- a/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff @@ -24,7 +24,7 @@ - StorageLive(_2); // bb0[1]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 - _2 = const (); // bb0[2]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 + StorageLive(_1); // bb0[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 -+ _1 = const use_zst(const {transmute(()): ((), ())}) -> bb1; // bb0[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 ++ _1 = const use_zst(const ((), ())) -> bb1; // bb0[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 // ty::Const - // + ty: () - // + val: Value(Scalar()) @@ -39,7 +39,7 @@ - // mir::Constant - // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 - // + literal: Const { ty: (), val: Value(Scalar()) } -- _1 = const {transmute(()): ((), ())}; // bb0[5]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 +- _1 = const ((), ()); // bb0[5]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 - // ty::Const - // + ty: ((), ()) - // + val: Value(Scalar()) @@ -68,7 +68,7 @@ - // + literal: Const { ty: (), val: Value(Scalar()) } - StorageDead(_7); // bb0[14]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21 - StorageDead(_6); // bb0[15]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21 -- _4 = const use_zst(const {transmute(()): ((), ())}) -> bb1; // bb0[16]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 +- _4 = const use_zst(const ((), ())) -> bb1; // bb0[16]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 - // ty::Const // + ty: fn(((), ())) {use_zst} // + val: Value(Scalar()) @@ -88,7 +88,7 @@ - StorageLive(_8); // bb1[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 - StorageLive(_10); // bb1[2]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30 - StorageLive(_11); // bb1[3]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 -- _11 = const {transmute(0x28): Temp}; // bb1[4]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 +- _11 = const Temp { x: 40u8 }; // bb1[4]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 + StorageDead(_1); // bb1[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:22: 14:23 + StorageLive(_2); // bb1[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 + _2 = const use_u8(const 42u8) -> bb2; // bb1[2]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35