Skip to content

Commit f459b0f

Browse files
committed
Addressed feedbacks
Also updated the mir-opt test output files.
1 parent b66eb69 commit f459b0f

10 files changed

+3
-44
lines changed

compiler/rustc_mir/src/util/pretty.rs

+3-17
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use rustc_middle::mir::interpret::{
1717
};
1818
use rustc_middle::mir::visit::Visitor;
1919
use rustc_middle::mir::*;
20-
use rustc_middle::ty::subst::GenericArgKind;
2120
use rustc_middle::ty::{self, TyCtxt, TyS, TypeFoldable, TypeVisitor};
2221
use rustc_target::abi::Size;
2322
use std::ops::ControlFlow;
@@ -414,22 +413,9 @@ fn use_verbose(ty: &&TyS<'tcx>) -> bool {
414413
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char | ty::Float(_) => false,
415414
// Unit type
416415
ty::Tuple(g_args) if g_args.is_empty() => false,
417-
ty::Tuple(g_args) => {
418-
// could have used `try_fold` here but it seems a bit silly that
419-
// the accumulator is useless
420-
let mut should_be_verbose = false;
421-
for g_arg in g_args.iter() {
422-
if match g_arg.unpack() {
423-
GenericArgKind::Type(ty) => use_verbose(&ty),
424-
GenericArgKind::Const(ty::Const { ty, val: _ }) => use_verbose(ty),
425-
_ => false,
426-
} {
427-
should_be_verbose = true;
428-
break;
429-
}
430-
}
431-
should_be_verbose
432-
}
416+
ty::Tuple(g_args) => g_args.iter().any(|g_arg| {
417+
use_verbose(&g_arg.expect_ty())
418+
}),
433419
ty::Array(ty, _) => use_verbose(ty),
434420
ty::FnDef(..) => false,
435421
_ => true,

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

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
- _2 = CheckedAdd(const 1_u32, const 1_u32); // scope 0 at $DIR/checked_add.rs:5:18: 5:23
1515
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> bb1; // scope 0 at $DIR/checked_add.rs:5:18: 5:23
1616
+ _2 = const (2_u32, false); // scope 0 at $DIR/checked_add.rs:5:18: 5:23
17-
+ // ty::Const
18-
+ // + ty: (u32, bool)
19-
+ // + val: Value(ByRef { alloc: Allocation { bytes: [2, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } })
2017
+ // mir::Constant
2118
+ // + span: $DIR/checked_add.rs:5:18: 5:23
2219
+ // + literal: Const { ty: (u32, bool), val: Value(ByRef { alloc: Allocation { bytes: [2, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }

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

-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
- assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> bb1; // scope 0 at $DIR/indirect.rs:5:13: 5:29
1919
+ _2 = const 2_u8; // scope 0 at $DIR/indirect.rs:5:13: 5:25
2020
+ _3 = const (3_u8, false); // scope 0 at $DIR/indirect.rs:5:13: 5:29
21-
+ // ty::Const
22-
+ // + ty: (u8, bool)
23-
+ // + val: Value(ByRef { alloc: Allocation { bytes: [3, 0], 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 } })
2421
+ // mir::Constant
2522
+ // + span: $DIR/indirect.rs:5:13: 5:29
2623
+ // + literal: Const { ty: (u8, bool), val: Value(ByRef { alloc: Allocation { bytes: [3, 0], 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 } }) }

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

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
(_3.1: u8) = const 2_u8; // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
1616
- (_2.0: (u8, u8)) = move _3; // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
1717
+ (_2.0: (u8, u8)) = const (1_u8, 2_u8); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
18-
+ // ty::Const
19-
+ // + ty: (u8, u8)
20-
+ // + 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 } })
2118
+ // mir::Constant
2219
+ // + span: $DIR/issue-67019.rs:11:10: 11:19
2320
+ // + 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 } }) }

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

-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:7:9: 7:10
2121
- _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:7:13: 7:14
2222
+ _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:7:13: 7:14
23-
+ // ty::Const
24-
+ // + ty: (i32, i32)
25-
+ // + val: Value(ByRef { alloc: Allocation { bytes: [42, 0, 0, 0, 99, 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 } })
2623
+ // mir::Constant
2724
+ // + span: $DIR/mutable_variable_aggregate.rs:7:13: 7:14
2825
+ // + literal: Const { ty: (i32, i32), val: Value(ByRef { alloc: Allocation { bytes: [42, 0, 0, 0, 99, 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 } }) }

src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
- _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
2828
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
2929
+ _2 = const (4_i32, false); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
30-
+ // ty::Const
31-
+ // + ty: (i32, bool)
32-
+ // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } })
3330
+ // mir::Constant
3431
+ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
3532
+ // + literal: Const { ty: (i32, bool), val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }

src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
- _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
2828
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
2929
+ _2 = const (4_i32, false); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
30-
+ // ty::Const
31-
+ // + ty: (i32, bool)
32-
+ // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } })
3330
+ // mir::Constant
3431
+ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
3532
+ // + literal: Const { ty: (i32, bool), val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }

src/test/mir-opt/const_prop/return_place.add.ConstProp.diff

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
- _1 = CheckedAdd(const 2_u32, const 2_u32); // scope 0 at $DIR/return_place.rs:6:5: 6:10
1010
- assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; // scope 0 at $DIR/return_place.rs:6:5: 6:10
1111
+ _1 = const (4_u32, false); // scope 0 at $DIR/return_place.rs:6:5: 6:10
12-
+ // ty::Const
13-
+ // + ty: (u32, bool)
14-
+ // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } })
1512
+ // mir::Constant
1613
+ // + span: $DIR/return_place.rs:6:5: 6:10
1714
+ // + literal: Const { ty: (u32, bool), val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [31], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }

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

-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14
1919
- _3 = _1; // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14
2020
+ _3 = const (1_u32, 2_u32); // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14
21-
+ // ty::Const
22-
+ // + ty: (u32, u32)
23-
+ // + 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 } })
2421
+ // mir::Constant
2522
+ // + span: $DIR/tuple_literal_propagation.rs:5:13: 5:14
2623
+ // + 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 } }) }

src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff

-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
// mir::Constant
4343
// + span: $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:12
4444
// + literal: Const { ty: fn(((), ())) {use_zst}, val: Value(Scalar(<ZST>)) }
45-
// ty::Const
46-
// + ty: ((), ())
47-
// + val: Value(Scalar(<ZST>))
4845
// mir::Constant
4946
// + span: $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
5047
// + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) }

0 commit comments

Comments
 (0)