diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index d29b731e4f1..c9d0b12e739 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -688,7 +688,7 @@ impl Primitive { /// /// This is intended specifically to mirror LLVM’s `!range` metadata, /// semantics. -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash)] #[derive(HashStable_Generic)] pub struct WrappingRange { pub start: u128, @@ -714,6 +714,13 @@ impl WrappingRange { } } +impl fmt::Debug for WrappingRange { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(fmt, "{}..={}", self.start, self.end)?; + Ok(()) + } +} + /// Information about one scalar component of a Rust type. #[derive(Clone, PartialEq, Eq, Hash, Debug)] #[derive(HashStable_Generic)] diff --git a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr index 01403a61e5e..e44f3249454 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr @@ -52,7 +52,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-nonnull.rs:41:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range AllocationRange { start: 10, end: 30 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30 | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr index 41de900f164..1ce87bc7c1c 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr @@ -52,7 +52,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-nonnull.rs:41:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range AllocationRange { start: 10, end: 30 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30 | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/src/test/ui/layout/debug.stderr b/src/test/ui/layout/debug.stderr index cbe9b6400c3..1a371c6b170 100644 --- a/src/test/ui/layout/debug.stderr +++ b/src/test/ui/layout/debug.stderr @@ -15,10 +15,7 @@ error: layout_of(E) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 0, - end: 0, - }, + valid_range: 0..=0, }, tag_encoding: Direct, tag_field: 0, @@ -94,10 +91,7 @@ error: layout_of(E) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 0, - end: 0, - }, + valid_range: 0..=0, }, }, ), @@ -144,20 +138,14 @@ error: layout_of(S) = Layout { I32, true, ), - valid_range: AllocationRange { - start: 0, - end: 4294967295, - }, + valid_range: 0..=4294967295, }, Scalar { value: Int( I32, true, ), - valid_range: AllocationRange { - start: 0, - end: 4294967295, - }, + valid_range: 0..=4294967295, }, ), largest_niche: None, @@ -219,10 +207,7 @@ error: layout_of(std::result::Result) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 0, - end: 1, - }, + valid_range: 0..=1, }, tag_encoding: Direct, tag_field: 0, @@ -291,20 +276,14 @@ error: layout_of(std::result::Result) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 0, - end: 1, - }, + valid_range: 0..=1, }, Scalar { value: Int( I32, true, ), - valid_range: AllocationRange { - start: 0, - end: 4294967295, - }, + valid_range: 0..=4294967295, }, ), largest_niche: Some( @@ -317,10 +296,7 @@ error: layout_of(std::result::Result) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 0, - end: 1, - }, + valid_range: 0..=1, }, }, ), @@ -350,10 +326,7 @@ error: layout_of(i32) = Layout { I32, true, ), - valid_range: AllocationRange { - start: 0, - end: 4294967295, - }, + valid_range: 0..=4294967295, }, ), largest_niche: None, diff --git a/src/test/ui/layout/hexagon-enum.stderr b/src/test/ui/layout/hexagon-enum.stderr index 520ba12c39f..d4676a5afb2 100644 --- a/src/test/ui/layout/hexagon-enum.stderr +++ b/src/test/ui/layout/hexagon-enum.stderr @@ -15,10 +15,7 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 0, - end: 0, - }, + valid_range: 0..=0, }, tag_encoding: Direct, tag_field: 0, @@ -55,10 +52,7 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 0, - end: 0, - }, + valid_range: 0..=0, }, ), largest_niche: Some( @@ -71,10 +65,7 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 0, - end: 0, - }, + valid_range: 0..=0, }, }, ), @@ -112,10 +103,7 @@ error: layout_of(B) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 255, - end: 255, - }, + valid_range: 255..=255, }, tag_encoding: Direct, tag_field: 0, @@ -152,10 +140,7 @@ error: layout_of(B) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 255, - end: 255, - }, + valid_range: 255..=255, }, ), largest_niche: Some( @@ -168,10 +153,7 @@ error: layout_of(B) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 255, - end: 255, - }, + valid_range: 255..=255, }, }, ), @@ -209,10 +191,7 @@ error: layout_of(C) = Layout { I16, false, ), - valid_range: AllocationRange { - start: 256, - end: 256, - }, + valid_range: 256..=256, }, tag_encoding: Direct, tag_field: 0, @@ -249,10 +228,7 @@ error: layout_of(C) = Layout { I16, false, ), - valid_range: AllocationRange { - start: 256, - end: 256, - }, + valid_range: 256..=256, }, ), largest_niche: Some( @@ -265,10 +241,7 @@ error: layout_of(C) = Layout { I16, false, ), - valid_range: AllocationRange { - start: 256, - end: 256, - }, + valid_range: 256..=256, }, }, ), @@ -306,10 +279,7 @@ error: layout_of(P) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 268435456, - end: 268435456, - }, + valid_range: 268435456..=268435456, }, tag_encoding: Direct, tag_field: 0, @@ -346,10 +316,7 @@ error: layout_of(P) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 268435456, - end: 268435456, - }, + valid_range: 268435456..=268435456, }, ), largest_niche: Some( @@ -362,10 +329,7 @@ error: layout_of(P) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 268435456, - end: 268435456, - }, + valid_range: 268435456..=268435456, }, }, ), @@ -403,10 +367,7 @@ error: layout_of(T) = Layout { I32, true, ), - valid_range: AllocationRange { - start: 2164260864, - end: 2164260864, - }, + valid_range: 2164260864..=2164260864, }, tag_encoding: Direct, tag_field: 0, @@ -443,10 +404,7 @@ error: layout_of(T) = Layout { I32, true, ), - valid_range: AllocationRange { - start: 2164260864, - end: 2164260864, - }, + valid_range: 2164260864..=2164260864, }, ), largest_niche: Some( @@ -459,10 +417,7 @@ error: layout_of(T) = Layout { I32, true, ), - valid_range: AllocationRange { - start: 2164260864, - end: 2164260864, - }, + valid_range: 2164260864..=2164260864, }, }, ), diff --git a/src/test/ui/layout/thumb-enum.stderr b/src/test/ui/layout/thumb-enum.stderr index 50e37c54116..898a61b904d 100644 --- a/src/test/ui/layout/thumb-enum.stderr +++ b/src/test/ui/layout/thumb-enum.stderr @@ -15,10 +15,7 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 0, - end: 0, - }, + valid_range: 0..=0, }, tag_encoding: Direct, tag_field: 0, @@ -55,10 +52,7 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 0, - end: 0, - }, + valid_range: 0..=0, }, ), largest_niche: Some( @@ -71,10 +65,7 @@ error: layout_of(A) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 0, - end: 0, - }, + valid_range: 0..=0, }, }, ), @@ -112,10 +103,7 @@ error: layout_of(B) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 255, - end: 255, - }, + valid_range: 255..=255, }, tag_encoding: Direct, tag_field: 0, @@ -152,10 +140,7 @@ error: layout_of(B) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 255, - end: 255, - }, + valid_range: 255..=255, }, ), largest_niche: Some( @@ -168,10 +153,7 @@ error: layout_of(B) = Layout { I8, false, ), - valid_range: AllocationRange { - start: 255, - end: 255, - }, + valid_range: 255..=255, }, }, ), @@ -209,10 +191,7 @@ error: layout_of(C) = Layout { I16, false, ), - valid_range: AllocationRange { - start: 256, - end: 256, - }, + valid_range: 256..=256, }, tag_encoding: Direct, tag_field: 0, @@ -249,10 +228,7 @@ error: layout_of(C) = Layout { I16, false, ), - valid_range: AllocationRange { - start: 256, - end: 256, - }, + valid_range: 256..=256, }, ), largest_niche: Some( @@ -265,10 +241,7 @@ error: layout_of(C) = Layout { I16, false, ), - valid_range: AllocationRange { - start: 256, - end: 256, - }, + valid_range: 256..=256, }, }, ), @@ -306,10 +279,7 @@ error: layout_of(P) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 268435456, - end: 268435456, - }, + valid_range: 268435456..=268435456, }, tag_encoding: Direct, tag_field: 0, @@ -346,10 +316,7 @@ error: layout_of(P) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 268435456, - end: 268435456, - }, + valid_range: 268435456..=268435456, }, ), largest_niche: Some( @@ -362,10 +329,7 @@ error: layout_of(P) = Layout { I32, false, ), - valid_range: AllocationRange { - start: 268435456, - end: 268435456, - }, + valid_range: 268435456..=268435456, }, }, ), @@ -403,10 +367,7 @@ error: layout_of(T) = Layout { I32, true, ), - valid_range: AllocationRange { - start: 2164260864, - end: 2164260864, - }, + valid_range: 2164260864..=2164260864, }, tag_encoding: Direct, tag_field: 0, @@ -443,10 +404,7 @@ error: layout_of(T) = Layout { I32, true, ), - valid_range: AllocationRange { - start: 2164260864, - end: 2164260864, - }, + valid_range: 2164260864..=2164260864, }, ), largest_niche: Some( @@ -459,10 +417,7 @@ error: layout_of(T) = Layout { I32, true, ), - valid_range: AllocationRange { - start: 2164260864, - end: 2164260864, - }, + valid_range: 2164260864..=2164260864, }, }, ),