Skip to content

Commit 521db88

Browse files
committed
Auto merge of #75697 - lzutao:mir-dumb-const-prefix, r=oli-obk
Suppress "const" prefix of FnDef constants in MIR dump I [was asked][1] to suppress the `const` infront of `FnDef`. I tried to suppress comments for other types, but turned out that `const ()` and `()` is different: #75697 (comment) [1]: #75670 (comment)
2 parents 32cb8d4 + c4c017a commit 521db88

File tree

70 files changed

+132
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+132
-129
lines changed

src/librustc_middle/mir/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,10 @@ impl<'tcx> Debug for Constant<'tcx> {
24522452

24532453
impl<'tcx> Display for Constant<'tcx> {
24542454
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
2455-
write!(fmt, "const ")?;
2455+
match self.literal.ty.kind {
2456+
ty::FnDef(..) => {}
2457+
_ => write!(fmt, "const ")?,
2458+
}
24562459
pretty_print_const(self.literal, fmt, true)
24572460
}
24582461
}

src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir.32bit

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() -> () {
3636
StorageLive(_5); // scope 3 at $DIR/array-index-is-temporary.rs:16:12: 16:29
3737
StorageLive(_6); // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
3838
_6 = _3; // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
39-
_5 = const foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
39+
_5 = foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
4040
// mir::Constant
4141
// + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
4242
// + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir.64bit

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() -> () {
3636
StorageLive(_5); // scope 3 at $DIR/array-index-is-temporary.rs:16:12: 16:29
3737
StorageLive(_6); // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
3838
_6 = _3; // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
39-
_5 = const foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
39+
_5 = foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
4040
// mir::Constant
4141
// + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
4242
// + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() -> () {
1414
StorageLive(_1); // scope 0 at $DIR/box_expr.rs:7:9: 7:10
1515
StorageLive(_2); // scope 0 at $DIR/box_expr.rs:7:13: 7:25
1616
_2 = Box(S); // scope 0 at $DIR/box_expr.rs:7:13: 7:25
17-
(*_2) = const S::new() -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25
17+
(*_2) = S::new() -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25
1818
// mir::Constant
1919
// + span: $DIR/box_expr.rs:7:17: 7:23
2020
// + literal: Const { ty: fn() -> S {S::new}, val: Value(Scalar(<ZST>)) }
@@ -38,7 +38,7 @@ fn main() -> () {
3838
StorageLive(_3); // scope 1 at $DIR/box_expr.rs:8:5: 8:12
3939
StorageLive(_4); // scope 1 at $DIR/box_expr.rs:8:10: 8:11
4040
_4 = move _1; // scope 1 at $DIR/box_expr.rs:8:10: 8:11
41-
_3 = const std::mem::drop::<std::boxed::Box<S>>(move _4) -> [return: bb5, unwind: bb7]; // scope 1 at $DIR/box_expr.rs:8:5: 8:12
41+
_3 = std::mem::drop::<std::boxed::Box<S>>(move _4) -> [return: bb5, unwind: bb7]; // scope 1 at $DIR/box_expr.rs:8:5: 8:12
4242
// mir::Constant
4343
// + span: $DIR/box_expr.rs:8:5: 8:9
4444
// + literal: Const { ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
+ // + literal: Const { ty: &[&i32; 1], val: Unevaluated(WithOptConstParam { did: DefId(0:6 ~ const_promotion_extern_static[317d]::BAR[0]), const_param_did: None }, [], Some(promoted[0])) }
3434
+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
3535
_1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
36-
_0 = const core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:44
36+
_0 = core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:44
3737
// mir::Constant
3838
// + span: $DIR/const-promotion-extern-static.rs:9:36: 9:42
3939
// + literal: Const { ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
+ // + literal: Const { ty: &[&i32; 1], val: Unevaluated(WithOptConstParam { did: DefId(0:7 ~ const_promotion_extern_static[317d]::FOO[0]), const_param_did: None }, [], Some(promoted[0])) }
3636
+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
3737
_1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
38-
_0 = const core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:55
38+
_0 = core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:55
3939
// mir::Constant
4040
// + span: $DIR/const-promotion-extern-static.rs:13:47: 13:53
4141
// + literal: Const { ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
StorageLive(_4); // scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12
3131
StorageLive(_5); // scope 1 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11
3232
_5 = _1; // scope 1 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11
33-
_4 = const read(move _5) -> bb1; // scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12
33+
_4 = read(move _5) -> bb1; // scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12
3434
// mir::Constant
3535
// + span: $DIR/const_prop_fails_gracefully.rs:8:5: 8:9
3636
// + literal: Const { ty: fn(usize) {read}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
bb2: {
2424
StorageLive(_2); // scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL
25-
const std::rt::begin_panic::<&str>(const "explicit panic"); // scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL
25+
std::rt::begin_panic::<&str>(const "explicit panic"); // scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL
2626
// mir::Constant
2727
// + span: $SRC_DIR/std/src/macros.rs:LL:COL
2828
// + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
(_2.1: u8) = const 0_u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
1717
(_2.2: u8) = const 0_u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
1818
StorageDead(_3); // scope 0 at $DIR/issue-66971.rs:16:21: 16:22
19-
_1 = const encode(move _2) -> bb1; // scope 0 at $DIR/issue-66971.rs:16:5: 16:23
19+
_1 = encode(move _2) -> bb1; // scope 0 at $DIR/issue-66971.rs:16:5: 16:23
2020
// mir::Constant
2121
// + span: $DIR/issue-66971.rs:16:5: 16:11
2222
// + literal: Const { ty: fn(((), u8, u8)) {encode}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
+ // + span: $DIR/issue-67019.rs:11:10: 11:19
2323
+ // + literal: Const { ty: (u8, u8), val: Value(ByRef { alloc: Allocation { bytes: [1, 2], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
2424
StorageDead(_3); // scope 0 at $DIR/issue-67019.rs:11:18: 11:19
25-
_1 = const test(move _2) -> bb1; // scope 0 at $DIR/issue-67019.rs:11:5: 11:20
25+
_1 = test(move _2) -> bb1; // scope 0 at $DIR/issue-67019.rs:11:5: 11:20
2626
// mir::Constant
2727
// + span: $DIR/issue-67019.rs:11:5: 11:9
2828
// + literal: Const { ty: fn(((u8, u8),)) {test}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
bb0: {
1616
StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:5:9: 5:14
17-
_1 = const foo() -> bb1; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:5:29: 5:34
17+
_1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:5:29: 5:34
1818
// mir::Constant
1919
// + span: $DIR/mutable_variable_aggregate_partial_read.rs:5:29: 5:32
2020
// + literal: Const { ty: fn() -> (i32, i32) {foo}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
bb0: {
2525
StorageLive(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:5:9: 5:10
26-
_1 = const foo() -> bb1; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:5:13: 5:18
26+
_1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:5:13: 5:18
2727
// mir::Constant
2828
// + span: $DIR/mutable_variable_unprop_assign.rs:5:13: 5:16
2929
// + literal: Const { ty: fn() -> i32 {foo}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41
1414
StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26
1515
StorageLive(_3); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17
16-
_3 = const main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17
16+
_3 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17
1717
// mir::Constant
1818
// + span: $DIR/reify_fn_ptr.rs:4:13: 4:17
1919
// + literal: Const { ty: fn() {main}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
StorageLive(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:4:5: 4:15
1717
StorageLive(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:4:13: 4:14
1818
- _3 = _1; // scope 1 at $DIR/scalar_literal_propagation.rs:4:13: 4:14
19-
- _2 = const consume(move _3) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:4:5: 4:15
19+
- _2 = consume(move _3) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:4:5: 4:15
2020
+ _3 = const 1_u32; // scope 1 at $DIR/scalar_literal_propagation.rs:4:13: 4:14
21-
+ _2 = const consume(const 1_u32) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:4:5: 4:15
21+
+ _2 = consume(const 1_u32) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:4:5: 4:15
2222
// mir::Constant
2323
// + span: $DIR/scalar_literal_propagation.rs:4:5: 4:12
2424
// + literal: Const { ty: fn(u32) {consume}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/switch_int.main.ConstProp.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
}
1414

1515
bb1: {
16-
_0 = const foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:9:14: 9:21
16+
_0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:9:14: 9:21
1717
// mir::Constant
1818
// + span: $DIR/switch_int.rs:9:14: 9:17
1919
// + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) }
2020
}
2121

2222
bb2: {
23-
_0 = const foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:8:14: 8:20
23+
_0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:8:14: 8:20
2424
// mir::Constant
2525
// + span: $DIR/switch_int.rs:8:14: 8:17
2626
// + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/switch_int.main.SimplifyBranches-after-const-prop.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
}
1414

1515
bb1: {
16-
_0 = const foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:9:14: 9:21
16+
_0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:9:14: 9:21
1717
// mir::Constant
1818
// + span: $DIR/switch_int.rs:9:14: 9:17
1919
// + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) }
2020
}
2121

2222
bb2: {
23-
_0 = const foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:8:14: 8:20
23+
_0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:8:14: 8:20
2424
// mir::Constant
2525
// + span: $DIR/switch_int.rs:8:14: 8:17
2626
// + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
+ // mir::Constant
2525
+ // + span: $DIR/tuple_literal_propagation.rs:5:13: 5:14
2626
+ // + literal: Const { ty: (u32, u32), val: Value(ByRef { alloc: Allocation { bytes: [1, 0, 0, 0, 2, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
27-
_2 = const consume(move _3) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:5:5: 5:15
27+
_2 = consume(move _3) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:5:5: 5:15
2828
// mir::Constant
2929
// + span: $DIR/tuple_literal_propagation.rs:5:5: 5:12
3030
// + literal: Const { ty: fn((u32, u32)) {consume}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/copy_propagation_arg.bar.CopyPropagation.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13
1212
StorageLive(_3); // scope 0 at $DIR/copy_propagation_arg.rs:16:11: 16:12
1313
_3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:16:11: 16:12
14-
_2 = const dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13
14+
_2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13
1515
// mir::Constant
1616
// + span: $DIR/copy_propagation_arg.rs:16:5: 16:10
1717
// + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/copy_propagation_arg.foo.CopyPropagation.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:11:9: 11:17
1212
StorageLive(_3); // scope 0 at $DIR/copy_propagation_arg.rs:11:15: 11:16
1313
_3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:11:15: 11:16
14-
_2 = const dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:11:9: 11:17
14+
_2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:11:9: 11:17
1515
// mir::Constant
1616
// + span: $DIR/copy_propagation_arg.rs:11:9: 11:14
1717
// + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(Scalar(<ZST>)) }

0 commit comments

Comments
 (0)