From 6a6b3309e63854cbd0f0e2a0b9bd305f6b96cf81 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 4 Sep 2018 12:26:21 +0200 Subject: [PATCH] update tests to changes on rustc master --- .../const-pointer-values-in-various-types.rs | 14 ++--- ...nst-pointer-values-in-various-types.stderr | 58 +++++++++---------- src/test/ui/consts/const-eval/issue-52442.rs | 1 + .../ui/consts/const-eval/issue-52442.stderr | 13 ++++- .../ui/consts/const-eval/ref_to_int_match.rs | 4 +- .../consts/const-eval/ref_to_int_match.stderr | 20 +++++-- src/test/ui/consts/const-size_of-cycle.stderr | 10 ++-- src/test/ui/issues/issue-44415.stderr | 8 +-- .../issue-52023-array-size-pointer-cast.rs | 1 + ...issue-52023-array-size-pointer-cast.stderr | 13 ++++- 10 files changed, 85 insertions(+), 57 deletions(-) diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs index 05d79a7d633..23e1ab013ef 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs @@ -22,7 +22,7 @@ union Nonsense { fn main() { const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - //~^ ERROR this constant likely exhibits undefined behavior + //~^ ERROR it is undefined behavior to use this value const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; //~^ ERROR any use of this value will cause an error @@ -34,7 +34,7 @@ fn main() { //~^ ERROR any use of this value will cause an error const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - //~^ ERROR this constant likely exhibits undefined behavior + //~^ ERROR it is undefined behavior to use this value const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; //~^ ERROR any use of this value will cause an error @@ -49,7 +49,7 @@ fn main() { //~^ ERROR any use of this value will cause an error const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - //~^ ERROR this constant likely exhibits undefined behavior + //~^ ERROR it is undefined behavior to use this value const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; //~^ ERROR any use of this value will cause an error @@ -58,7 +58,7 @@ fn main() { //~^ ERROR any use of this value will cause an error const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - //~^ ERROR this constant likely exhibits undefined behavior + //~^ ERROR it is undefined behavior to use this value const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; //~^ ERROR any use of this value will cause an error @@ -76,7 +76,7 @@ fn main() { //~^ ERROR any use of this value will cause an error const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - //~^ ERROR this constant likely exhibits undefined behavior + //~^ ERROR it is undefined behavior to use this value const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; //~^ ERROR any use of this value will cause an error @@ -91,7 +91,7 @@ fn main() { //~^ ERROR any use of this value will cause an error const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - //~^ ERROR this constant likely exhibits undefined behavior + //~^ ERROR it is undefined behavior to use this value const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; //~^ ERROR any use of this value will cause an error @@ -100,7 +100,7 @@ fn main() { //~^ ERROR any use of this value will cause an error const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - //~^ ERROR this constant likely exhibits undefined behavior + //~^ ERROR it is undefined behavior to use this value const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; //~^ ERROR any use of this value will cause an error diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr index 7be9345b6b4..cc1db5db691 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr @@ -1,4 +1,4 @@ -error[E0080]: this constant likely exhibits undefined behavior +error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:24:5 | LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; @@ -6,7 +6,7 @@ LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 } | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:27:5 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; @@ -16,7 +16,7 @@ LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_ | = note: #[deny(const_err)] on by default -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:30:5 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; @@ -24,7 +24,7 @@ LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uin | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:33:5 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; @@ -32,7 +32,7 @@ LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uin | | | a raw memory access tried to access part of a pointer value as raw bytes -error[E0080]: this constant likely exhibits undefined behavior +error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:36:5 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; @@ -40,13 +40,13 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:39:5 | LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:42:5 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; @@ -54,7 +54,7 @@ LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:45:5 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; @@ -62,7 +62,7 @@ LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:48:5 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; @@ -70,7 +70,7 @@ LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int | | | a raw memory access tried to access part of a pointer value as raw bytes -error[E0080]: this constant likely exhibits undefined behavior +error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:51:5 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; @@ -78,13 +78,13 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:54:5 | LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:57:5 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; @@ -92,7 +92,7 @@ LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.flo | | | a raw memory access tried to access part of a pointer value as raw bytes -error[E0080]: this constant likely exhibits undefined behavior +error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:60:5 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; @@ -100,7 +100,7 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:63:5 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; @@ -108,7 +108,7 @@ LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.t | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:66:5 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; @@ -116,7 +116,7 @@ LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.c | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:69:5 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; @@ -124,7 +124,7 @@ LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:72:5 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; @@ -132,7 +132,7 @@ LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 } | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:75:5 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; @@ -140,7 +140,7 @@ LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 } | | | a raw memory access tried to access part of a pointer value as raw bytes -error[E0080]: this constant likely exhibits undefined behavior +error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:78:5 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; @@ -148,7 +148,7 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 } | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:81:5 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; @@ -156,7 +156,7 @@ LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_12 | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:84:5 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; @@ -164,7 +164,7 @@ LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:87:5 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; @@ -172,7 +172,7 @@ LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:90:5 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; @@ -180,7 +180,7 @@ LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; | | | a raw memory access tried to access part of a pointer value as raw bytes -error[E0080]: this constant likely exhibits undefined behavior +error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:93:5 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; @@ -188,7 +188,7 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:96:5 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; @@ -196,7 +196,7 @@ LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:99:5 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; @@ -204,7 +204,7 @@ LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 | | | a raw memory access tried to access part of a pointer value as raw bytes -error[E0080]: this constant likely exhibits undefined behavior +error[E0080]: it is undefined behavior to use this value --> $DIR/const-pointer-values-in-various-types.rs:102:5 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; @@ -212,7 +212,7 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:105:5 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; @@ -220,7 +220,7 @@ LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_ | | | a raw memory access tried to access part of a pointer value as raw bytes -error: this constant cannot be used +error: any use of this value will cause an error --> $DIR/const-pointer-values-in-various-types.rs:108:5 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; diff --git a/src/test/ui/consts/const-eval/issue-52442.rs b/src/test/ui/consts/const-eval/issue-52442.rs index 755dc153d40..8e207b712c3 100644 --- a/src/test/ui/consts/const-eval/issue-52442.rs +++ b/src/test/ui/consts/const-eval/issue-52442.rs @@ -10,4 +10,5 @@ fn main() { [(); { &loop { break } as *const _ as usize } ]; //~ ERROR unimplemented expression type + //~^ ERROR it is undefined behavior to use this value } diff --git a/src/test/ui/consts/const-eval/issue-52442.stderr b/src/test/ui/consts/const-eval/issue-52442.stderr index 586c9fa22ce..93fc4bea5ca 100644 --- a/src/test/ui/consts/const-eval/issue-52442.stderr +++ b/src/test/ui/consts/const-eval/issue-52442.stderr @@ -4,6 +4,15 @@ error[E0019]: constant contains unimplemented expression type LL | [(); { &loop { break } as *const _ as usize } ]; //~ ERROR unimplemented expression type | ^^^^^^^^^^^^^^ -error: aborting due to previous error +error[E0080]: it is undefined behavior to use this value + --> $DIR/issue-52442.rs:12:11 + | +LL | [(); { &loop { break } as *const _ as usize } ]; //~ ERROR unimplemented expression type + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type usize + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0019`. +Some errors occurred: E0019, E0080. +For more information about an error, try `rustc --explain E0019`. diff --git a/src/test/ui/consts/const-eval/ref_to_int_match.rs b/src/test/ui/consts/const-eval/ref_to_int_match.rs index cb942f465e4..2254ed5d9e3 100644 --- a/src/test/ui/consts/const-eval/ref_to_int_match.rs +++ b/src/test/ui/consts/const-eval/ref_to_int_match.rs @@ -14,7 +14,7 @@ fn main() { let n: Int = 40; match n { 0..=10 => {}, - 10..=BAR => {}, //~ ERROR lower range bound must be less than or equal to upper + 10..=BAR => {}, //~ ERROR could not evaluate constant pattern _ => {}, } } @@ -30,4 +30,4 @@ union Foo { #[cfg(target_pointer_width="32")] type Int = u32; -const BAR: Int = unsafe { Foo { r: &42 }.f }; +const BAR: Int = unsafe { Foo { r: &42 }.f }; //~ ERROR it is undefined behavior to use this value diff --git a/src/test/ui/consts/const-eval/ref_to_int_match.stderr b/src/test/ui/consts/const-eval/ref_to_int_match.stderr index e82a16c066f..1e65a871de4 100644 --- a/src/test/ui/consts/const-eval/ref_to_int_match.stderr +++ b/src/test/ui/consts/const-eval/ref_to_int_match.stderr @@ -1,9 +1,17 @@ -error[E0030]: lower range bound must be less than or equal to upper - --> $DIR/ref_to_int_match.rs:17:9 +error[E0080]: it is undefined behavior to use this value + --> $DIR/ref_to_int_match.rs:33:1 | -LL | 10..=BAR => {}, //~ ERROR lower range bound must be less than or equal to upper - | ^^ lower bound larger than upper bound +LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; //~ ERROR it is undefined behavior to use this value + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type u64 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error: could not evaluate constant pattern + --> $DIR/ref_to_int_match.rs:17:14 + | +LL | 10..=BAR => {}, //~ ERROR could not evaluate constant pattern + | ^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0030`. +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-size_of-cycle.stderr b/src/test/ui/consts/const-size_of-cycle.stderr index 0c8fdfb6da2..8e1e81f7735 100644 --- a/src/test/ui/consts/const-size_of-cycle.stderr +++ b/src/test/ui/consts/const-size_of-cycle.stderr @@ -1,5 +1,5 @@ error[E0391]: cycle detected when const-evaluating + checking `Foo::bytes::{{constant}}` - --> $DIR/const-size_of-cycle.rs:16:17 + --> $DIR/const-size_of-cycle.rs:14:17 | LL | bytes: [u8; std::mem::size_of::()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,18 +7,18 @@ LL | bytes: [u8; std::mem::size_of::()] note: ...which requires const-evaluating `Foo::bytes::{{constant}}`... --> $SRC_DIR/libcore/mem.rs:LL:COL | -LL | unsafe { intrinsics::size_of::() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::size_of::() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires computing layout of `Foo`... note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`... note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`... - --> $DIR/const-size_of-cycle.rs:16:17 + --> $DIR/const-size_of-cycle.rs:14:17 | LL | bytes: [u8; std::mem::size_of::()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}`, completing the cycle note: cycle used when processing `Foo` - --> $DIR/const-size_of-cycle.rs:15:1 + --> $DIR/const-size_of-cycle.rs:13:1 | LL | struct Foo { | ^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-44415.stderr b/src/test/ui/issues/issue-44415.stderr index 4345a5dbf43..e70dfe7ad4e 100644 --- a/src/test/ui/issues/issue-44415.stderr +++ b/src/test/ui/issues/issue-44415.stderr @@ -1,24 +1,24 @@ error[E0391]: cycle detected when const-evaluating + checking `Foo::bytes::{{constant}}` - --> $DIR/issue-44415.rs:17:17 + --> $DIR/issue-44415.rs:16:17 | LL | bytes: [u8; unsafe { intrinsics::size_of::() }], | ^^^^^^ | note: ...which requires const-evaluating `Foo::bytes::{{constant}}`... - --> $DIR/issue-44415.rs:17:26 + --> $DIR/issue-44415.rs:16:26 | LL | bytes: [u8; unsafe { intrinsics::size_of::() }], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires computing layout of `Foo`... note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`... note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`... - --> $DIR/issue-44415.rs:17:17 + --> $DIR/issue-44415.rs:16:17 | LL | bytes: [u8; unsafe { intrinsics::size_of::() }], | ^^^^^^ = note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}`, completing the cycle note: cycle used when processing `Foo` - --> $DIR/issue-44415.rs:16:1 + --> $DIR/issue-44415.rs:15:1 | LL | struct Foo { | ^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-52023-array-size-pointer-cast.rs b/src/test/ui/issues/issue-52023-array-size-pointer-cast.rs index 02bed69f0d4..46cbdb6ac22 100644 --- a/src/test/ui/issues/issue-52023-array-size-pointer-cast.rs +++ b/src/test/ui/issues/issue-52023-array-size-pointer-cast.rs @@ -10,4 +10,5 @@ fn main() { let _ = [0; (&0 as *const i32) as usize]; //~ ERROR casting pointers to integers in constants + //~^ ERROR it is undefined behavior to use this value } diff --git a/src/test/ui/issues/issue-52023-array-size-pointer-cast.stderr b/src/test/ui/issues/issue-52023-array-size-pointer-cast.stderr index 74270c2bef7..ba415d43a75 100644 --- a/src/test/ui/issues/issue-52023-array-size-pointer-cast.stderr +++ b/src/test/ui/issues/issue-52023-array-size-pointer-cast.stderr @@ -6,6 +6,15 @@ LL | let _ = [0; (&0 as *const i32) as usize]; //~ ERROR casting pointers to | = help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable -error: aborting due to previous error +error[E0080]: it is undefined behavior to use this value + --> $DIR/issue-52023-array-size-pointer-cast.rs:12:17 + | +LL | let _ = [0; (&0 as *const i32) as usize]; //~ ERROR casting pointers to integers in constants + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type usize + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0080, E0658. +For more information about an error, try `rustc --explain E0080`. -- GitLab