mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Rollup merge of #86566 - fee1-dead:mir-pretty-print, r=oli-obk
Use `use_verbose` for `mir::Constant` Fixes #79799.
This commit is contained in:
commit
64c9712cf3
@ -426,14 +426,14 @@ impl ExtraComments<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn use_verbose(ty: &&TyS<'tcx>) -> bool {
|
||||
fn use_verbose(ty: &&TyS<'tcx>, fn_def: bool) -> bool {
|
||||
match ty.kind() {
|
||||
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char | ty::Float(_) => false,
|
||||
// Unit type
|
||||
ty::Tuple(g_args) if g_args.is_empty() => false,
|
||||
ty::Tuple(g_args) => g_args.iter().any(|g_arg| use_verbose(&g_arg.expect_ty())),
|
||||
ty::Array(ty, _) => use_verbose(ty),
|
||||
ty::FnDef(..) => false,
|
||||
ty::Tuple(g_args) => g_args.iter().any(|g_arg| use_verbose(&g_arg.expect_ty(), fn_def)),
|
||||
ty::Array(ty, _) => use_verbose(ty, fn_def),
|
||||
ty::FnDef(..) => fn_def,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
@ -442,11 +442,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
|
||||
fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
|
||||
self.super_constant(constant, location);
|
||||
let Constant { span, user_ty, literal } = constant;
|
||||
match literal.ty().kind() {
|
||||
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {}
|
||||
// Unit type
|
||||
ty::Tuple(tys) if tys.is_empty() => {}
|
||||
_ => {
|
||||
if use_verbose(&literal.ty(), true) {
|
||||
self.push("mir::Constant");
|
||||
self.push(&format!(
|
||||
"+ span: {}",
|
||||
@ -459,11 +455,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
|
||||
ConstantKind::Ty(literal) => self.push(&format!("+ literal: {:?}", literal)),
|
||||
ConstantKind::Val(val, ty) => {
|
||||
// To keep the diffs small, we render this almost like we render ty::Const
|
||||
self.push(&format!(
|
||||
"+ literal: Const {{ ty: {}, val: Value({:?}) }}",
|
||||
ty, val
|
||||
))
|
||||
}
|
||||
self.push(&format!("+ literal: Const {{ ty: {}, val: Value({:?}) }}", ty, val))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -472,7 +464,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
|
||||
fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, _: Location) {
|
||||
self.super_const(constant);
|
||||
let ty::Const { ty, val, .. } = constant;
|
||||
if use_verbose(ty) {
|
||||
if use_verbose(ty, false) {
|
||||
self.push("ty::Const");
|
||||
self.push(&format!("+ ty: {:?}", ty));
|
||||
let val = match val {
|
||||
|
@ -14,9 +14,6 @@
|
||||
- _2 = CheckedAdd(const 1_u32, const 1_u32); // scope 0 at $DIR/checked_add.rs:5:18: 5:23
|
||||
- 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
|
||||
+ _2 = const (2_u32, false); // scope 0 at $DIR/checked_add.rs:5:18: 5:23
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/checked_add.rs:5:18: 5:23
|
||||
+ // + 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 } }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
|
||||
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> bb1; // scope 0 at $DIR/checked_add.rs:5:18: 5:23
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,6 @@
|
||||
- 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
|
||||
+ _2 = const 2_u8; // scope 0 at $DIR/indirect.rs:5:13: 5:25
|
||||
+ _3 = const (3_u8, false); // scope 0 at $DIR/indirect.rs:5:13: 5:29
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/indirect.rs:5:13: 5:29
|
||||
+ // + 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 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
|
||||
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u8, const 1_u8) -> bb1; // scope 0 at $DIR/indirect.rs:5:13: 5:29
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,6 @@
|
||||
(_3.1: u8) = const 2_u8; // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
|
||||
- (_2.0: (u8, u8)) = move _3; // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
|
||||
+ (_2.0: (u8, u8)) = const (1_u8, 2_u8); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/issue-67019.rs:11:10: 11:19
|
||||
+ // + 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 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
|
||||
StorageDead(_3); // scope 0 at $DIR/issue-67019.rs:11:18: 11:19
|
||||
_1 = test(move _2) -> bb1; // scope 0 at $DIR/issue-67019.rs:11:5: 11:20
|
||||
// mir::Constant
|
||||
|
@ -20,9 +20,6 @@
|
||||
StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:7:9: 7:10
|
||||
- _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:7:13: 7:14
|
||||
+ _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:7:13: 7:14
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/mutable_variable_aggregate.rs:7:13: 7:14
|
||||
+ // + 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 } }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
|
||||
nop; // scope 0 at $DIR/mutable_variable_aggregate.rs:4:11: 8:2
|
||||
StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:8:1: 8:2
|
||||
StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:8:1: 8:2
|
||||
|
@ -27,9 +27,6 @@
|
||||
- _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
|
||||
- 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
|
||||
+ _2 = const (4_i32, false); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
|
||||
+ // + 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 } }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
|
||||
+ assert(!const false, "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
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,6 @@
|
||||
- _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
|
||||
- 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
|
||||
+ _2 = const (4_i32, false); // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
|
||||
+ // + 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 } }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
|
||||
+ assert(!const false, "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
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,6 @@
|
||||
- _1 = CheckedAdd(const 2_u32, const 2_u32); // scope 0 at $DIR/return_place.rs:6:5: 6:10
|
||||
- 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
|
||||
+ _1 = const (4_u32, false); // scope 0 at $DIR/return_place.rs:6:5: 6:10
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/return_place.rs:6:5: 6:10
|
||||
+ // + 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 } }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
|
||||
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; // scope 0 at $DIR/return_place.rs:6:5: 6:10
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,6 @@
|
||||
StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14
|
||||
- _3 = _1; // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14
|
||||
+ _3 = const (1_u32, 2_u32); // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/tuple_literal_propagation.rs:5:13: 5:14
|
||||
+ // + 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 } }, align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
|
||||
_2 = consume(move _3) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:5:5: 5:15
|
||||
// mir::Constant
|
||||
// + span: $DIR/tuple_literal_propagation.rs:5:5: 5:12
|
||||
|
@ -12,9 +12,6 @@
|
||||
- _0 = Baz { x: move _2, y: const 0f32, z: const false }; // scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35
|
||||
+ (_0.0: usize) = move _2; // scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35
|
||||
+ (_0.1: f32) = const 0f32; // scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35
|
||||
// mir::Constant
|
||||
// + span: $DIR/deaggregator_test.rs:9:20: 9:23
|
||||
// + literal: Const { ty: f32, val: Value(Scalar(0x00000000)) }
|
||||
+ (_0.2: bool) = const false; // scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35
|
||||
StorageDead(_2); // scope 0 at $DIR/deaggregator_test.rs:9:34: 9:35
|
||||
return; // scope 0 at $DIR/deaggregator_test.rs:10:2: 10:2
|
||||
|
@ -12,9 +12,6 @@
|
||||
StorageLive(_3); // scope 0 at $DIR/if-condition-int.rs:53:8: 53:9
|
||||
_3 = _1; // scope 0 at $DIR/if-condition-int.rs:53:8: 53:9
|
||||
_2 = Eq(move _3, const -42f32); // scope 0 at $DIR/if-condition-int.rs:53:8: 53:18
|
||||
// mir::Constant
|
||||
// + span: $DIR/if-condition-int.rs:53:13: 53:18
|
||||
// + literal: Const { ty: f32, val: Value(Scalar(0xc2280000)) }
|
||||
StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:53:17: 53:18
|
||||
switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:53:5: 53:35
|
||||
}
|
||||
|
@ -38,9 +38,6 @@
|
||||
// mir::Constant
|
||||
// + span: $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:12
|
||||
// + literal: Const { ty: fn(((), ())) {use_zst}, val: Value(Scalar(<ZST>)) }
|
||||
// mir::Constant
|
||||
// + span: $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
|
||||
// + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) }
|
||||
}
|
||||
|
||||
bb1: {
|
||||
|
Loading…
Reference in New Issue
Block a user