Auto merge of #53821 - oli-obk:sanity_query, r=RalfJung

Report const eval error inside the query

Functional changes: We no longer warn about bad constants embedded in unused types. This relied on being able to report just a warning, not a hard error on that case, which we cannot do any more now that error reporting is consistently centralized.

r? @RalfJung

fixes #53561
This commit is contained in:
bors 2018-10-26 11:05:00 +00:00
commit 694cf75298
148 changed files with 1133 additions and 1232 deletions

View file

@ -15,6 +15,7 @@ enum Foo {
enum Bar {
A = Foo::A as isize
//~^ ERROR evaluation of constant value failed
}
fn main() {}

View file

@ -6,6 +6,13 @@ LL | A = "" + 1
|
= note: an implementation of `std::ops::Add` might be missing for `&str`
error: aborting due to previous error
error[E0080]: evaluation of constant value failed
--> $DIR/issue-41394.rs:17:9
|
LL | A = Foo::A as isize
| ^^^^^^^^^^^^^^^ referenced constant has errors
For more information about this error, try `rustc --explain E0369`.
error: aborting due to 2 previous errors
Some errors occurred: E0080, E0369.
For more information about an error, try `rustc --explain E0080`.

View file

@ -8,15 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//~^^^^^^^^^^ ERROR cycle detected when computing layout of
#![feature(core_intrinsics)]
use std::intrinsics;
struct Foo {
bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
//~^ ERROR cycle detected when const-evaluating + checking
x: usize,
}

View file

@ -1,17 +1,27 @@
error[E0391]: cycle detected when computing layout of `Foo`
error[E0391]: cycle detected when const-evaluating + checking `Foo::bytes::{{constant}}`
--> $DIR/issue-44415.rs:16:17
|
LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
| ^^^^^^
|
note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`...
note: ...which requires const-evaluating `Foo::bytes::{{constant}}`...
--> $DIR/issue-44415.rs:19:26
--> $DIR/issue-44415.rs:16:26
|
LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires computing layout of `Foo`, completing the cycle
note: cycle used when const-evaluating `Foo::bytes::{{constant}}`
--> $DIR/issue-44415.rs:19:26
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:16:17
|
LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^
= note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}`, completing the cycle
note: cycle used when processing `Foo`
--> $DIR/issue-44415.rs:15:1
|
LL | struct Foo {
| ^^^^^^^^^^
error: aborting due to previous error

View file

@ -12,4 +12,5 @@ fn main() {
const N: u32 = 1_000;
const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; //~ ERROR cannot find value
let mut digits = [0u32; M];
//~^ ERROR evaluation of constant value failed
}

View file

@ -10,6 +10,13 @@ LL | use std::f32::consts::LOG10_2;
LL | use std::f64::consts::LOG10_2;
|
error: aborting due to previous error
error[E0080]: evaluation of constant value failed
--> $DIR/issue-50599.rs:14:29
|
LL | let mut digits = [0u32; M];
| ^ referenced constant has errors
For more information about this error, try `rustc --explain E0425`.
error: aborting due to 2 previous errors
Some errors occurred: E0080, E0425.
For more information about an error, try `rustc --explain E0080`.

View file

@ -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
}

View file

@ -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 initialized plain bits
|
= 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
For more information about this error, try `rustc --explain E0658`.
error: aborting due to 2 previous errors
Some errors occurred: E0080, E0658.
For more information about an error, try `rustc --explain E0080`.