Skip to content

Commit 18c3cb2

Browse files
Bless mir-opt tests for new InitMask Debug impl
1 parent 60a95f1 commit 18c3cb2

16 files changed

+55
-32
lines changed

compiler/rustc_index/src/interval.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,31 @@ use smallvec::SmallVec;
1212
mod tests;
1313

1414
/// Stores a set of intervals on the indices.
15-
#[derive(Debug, Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
15+
#[derive(Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
1616
pub struct IntervalSet<I> {
1717
// Start, end
1818
map: SmallVec<[(I, I); 4]>,
1919
domain: usize,
2020
_data: PhantomData<I>,
2121
}
2222

23+
impl<I: Ord + Idx + Step> std::fmt::Debug for IntervalSet<I> {
24+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25+
struct AsList<'a, I>(&'a IntervalSet<I>);
26+
27+
impl<'a, I: Idx + Ord + Step> std::fmt::Debug for AsList<'a, I> {
28+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29+
f.debug_list().entries(self.0.iter_intervals()).finish()
30+
}
31+
}
32+
33+
let mut s = f.debug_struct("IntervalSet");
34+
s.field("domain_size", &self.domain);
35+
s.field("set", &AsList(&self));
36+
Ok(())
37+
}
38+
}
39+
2340
#[inline]
2441
fn inclusive_start<T: Idx>(range: impl RangeBounds<T>) -> T {
2542
match range.start_bound() {

compiler/rustc_middle/src/mir/interpret/allocation.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,18 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
568568

569569
/// A bitmask where each bit refers to the byte with the same index. If the bit is `true`, the byte
570570
/// is initialized. If it is `false` the byte is uninitialized.
571-
#[derive(Clone, Debug, Eq, PartialEq, Hash, TyEncodable, TyDecodable)]
571+
#[derive(Clone, Eq, PartialEq, Hash, TyEncodable, TyDecodable)]
572572
#[derive(HashStable)]
573573
pub struct InitMask {
574574
set: IntervalSet<usize>,
575575
}
576576

577+
impl std::fmt::Debug for InitMask {
578+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
579+
f.debug_tuple("InitMask").field(&self.set).finish()
580+
}
581+
}
582+
577583
impl Ord for InitMask {
578584
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
579585
self.set

src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
_9 = const "hello, world!"; // scope 4 at $DIR/const_debuginfo.rs:14:13: 14:28
7878
// mir::Constant
7979
// + span: $DIR/const_debuginfo.rs:14:13: 14:28
80-
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [8191], len: Size { raw: 13 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 13 }) }
80+
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask(IntervalSet { domain_size: 13, set: [0..14]), align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 13 }) }
8181
StorageLive(_10); // scope 5 at $DIR/const_debuginfo.rs:16:9: 16:10
8282
(_10.0: bool) = const true; // scope 5 at $DIR/const_debuginfo.rs:16:13: 16:34
8383
(_10.1: bool) = const false; // scope 5 at $DIR/const_debuginfo.rs:16:13: 16:34

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value(Scalar(<ZST>)) }
2323
// mir::Constant
2424
// + span: $SRC_DIR/std/src/panic.rs:LL:COL
25-
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [16383], len: Size { raw: 14 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
25+
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask(IntervalSet { domain_size: 14, set: [0..15]), align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
2626
}
2727

2828
bb2: {

src/test/mir-opt/inline/inline_diverging.g.Inline.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
+ // + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value(Scalar(<ZST>)) }
4444
+ // mir::Constant
4545
+ // + span: $SRC_DIR/std/src/panic.rs:LL:COL
46-
+ // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [16383], len: Size { raw: 14 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
46+
+ // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask(IntervalSet { domain_size: 14, set: [0..15]), align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
4747
}
4848
}
4949

src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
- bb2: {
4545
+ // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
4646
+ // + user_ty: UserType(0)
47-
+ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 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 } }) }
47+
+ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask(IntervalSet { domain_size: 9, set: [0..8]), align: Align { pow2: 2 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
4848
+ ((*_7).1: usize) = const 0_usize; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
4949
+ StorageDead(_7); // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43
5050
_1 = move _5; // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43

src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
- bb2: {
4545
+ // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
4646
+ // + user_ty: UserType(0)
47-
+ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
47+
+ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask(IntervalSet { domain_size: 17, set: [0..16]), align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
4848
+ ((*_7).1: usize) = const 0_usize; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
4949
+ StorageDead(_7); // scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43
5050
_1 = move _5; // scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43

src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
7474
// mir::Constant
7575
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
76-
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [105, 110, 116, 101, 114, 110, 97, 108, 32, 101, 114, 114, 111, 114, 58, 32, 101, 110, 116, 101, 114, 101, 100, 32, 117, 110, 114, 101, 97, 99, 104, 97, 98, 108, 101, 32, 99, 111, 100, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [1099511627775], len: Size { raw: 40 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 40 }) }
76+
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [105, 110, 116, 101, 114, 110, 97, 108, 32, 101, 114, 114, 111, 114, 58, 32, 101, 110, 116, 101, 114, 101, 100, 32, 117, 110, 114, 101, 97, 99, 104, 97, 98, 108, 101, 32, 99, 111, 100, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask(IntervalSet { domain_size: 40, set: [0..41]), align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 40 }) }
7777
}
7878

7979
bb2: {

src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn num_to_digit(_1: char) -> u32 {
9292
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
9393
// mir::Constant
9494
// + span: $SRC_DIR/core/src/option.rs:LL:COL
95-
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [99, 97, 108, 108, 101, 100, 32, 96, 79, 112, 116, 105, 111, 110, 58, 58, 117, 110, 119, 114, 97, 112, 40, 41, 96, 32, 111, 110, 32, 97, 32, 96, 78, 111, 110, 101, 96, 32, 118, 97, 108, 117, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [8796093022207], len: Size { raw: 43 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 43 }) }
95+
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [99, 97, 108, 108, 101, 100, 32, 96, 79, 112, 116, 105, 111, 110, 58, 58, 117, 110, 119, 114, 97, 112, 40, 41, 96, 32, 111, 110, 32, 97, 32, 96, 78, 111, 110, 101, 96, 32, 118, 97, 108, 117, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask(IntervalSet { domain_size: 43, set: [0..44]), align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 43 }) }
9696
}
9797

9898
bb7: {

src/test/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn unwrap(_1: Option<T>) -> T {
2626
// + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value(Scalar(<ZST>)) }
2727
// mir::Constant
2828
// + span: $SRC_DIR/std/src/panic.rs:LL:COL
29-
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [16383], len: Size { raw: 14 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
29+
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask(IntervalSet { domain_size: 14, set: [0..15]), align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) }
3030
}
3131

3232
bb2: {

0 commit comments

Comments
 (0)