mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 09:33:26 +00:00
deduplicate warnings
This commit is contained in:
parent
9273962aef
commit
c7eb91652f
@ -253,7 +253,7 @@ impl Validator<'mir, 'tcx> {
|
|||||||
let is_unleashable = O::IS_SUPPORTED_IN_MIRI;
|
let is_unleashable = O::IS_SUPPORTED_IN_MIRI;
|
||||||
|
|
||||||
if is_unleashable && self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you {
|
if is_unleashable && self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you {
|
||||||
self.tcx.sess.span_warn(span, "skipping const checks");
|
self.tcx.sess.span_warn(self.tcx.def_span(self.def_id), "skipping const checks");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,16 +8,16 @@ const fn double_const(x: usize) -> usize { x * 2 }
|
|||||||
const X: fn(usize) -> usize = double;
|
const X: fn(usize) -> usize = double;
|
||||||
const X_CONST: fn(usize) -> usize = double_const;
|
const X_CONST: fn(usize) -> usize = double_const;
|
||||||
|
|
||||||
const fn bar(x: usize) -> usize {
|
const fn bar(x: usize) -> usize { //~ WARNING skipping const checks
|
||||||
X(x) //~ WARNING skipping const checks
|
X(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn bar_const(x: usize) -> usize {
|
const fn bar_const(x: usize) -> usize { //~ WARNING skipping const checks
|
||||||
X_CONST(x) //~ WARNING skipping const checks
|
X_CONST(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
|
const fn foo(x: fn(usize) -> usize, y: usize) -> usize { //~ WARNING skipping const checks
|
||||||
x(y) //~ WARNING skipping const checks
|
x(y)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,20 +1,26 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_fn_ptr.rs:12:5
|
--> $DIR/const_fn_ptr.rs:11:1
|
||||||
|
|
|
|
||||||
LL | X(x)
|
LL | / const fn bar(x: usize) -> usize {
|
||||||
| ^^^^
|
LL | | X(x)
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_fn_ptr.rs:16:5
|
--> $DIR/const_fn_ptr.rs:15:1
|
||||||
|
|
|
|
||||||
LL | X_CONST(x)
|
LL | / const fn bar_const(x: usize) -> usize {
|
||||||
| ^^^^^^^^^^
|
LL | | X_CONST(x)
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_fn_ptr.rs:20:5
|
--> $DIR/const_fn_ptr.rs:19:1
|
||||||
|
|
|
|
||||||
LL | x(y)
|
LL | / const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
|
||||||
| ^^^^
|
LL | | x(y)
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
warning: 3 warnings emitted
|
warning: 3 warnings emitted
|
||||||
|
|
||||||
|
@ -6,9 +6,8 @@
|
|||||||
fn double(x: usize) -> usize { x * 2 }
|
fn double(x: usize) -> usize { x * 2 }
|
||||||
const X: fn(usize) -> usize = double;
|
const X: fn(usize) -> usize = double;
|
||||||
|
|
||||||
const fn bar(x: usize) -> usize {
|
const fn bar(x: usize) -> usize { //~ WARNING skipping const checks
|
||||||
X(x) // FIXME: this should error someday
|
X(x) // FIXME: this should error someday
|
||||||
//~^ WARN: skipping const checks
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_fn_ptr_fail.rs:10:5
|
--> $DIR/const_fn_ptr_fail.rs:9:1
|
||||||
|
|
|
|
||||||
LL | X(x) // FIXME: this should error someday
|
LL | / const fn bar(x: usize) -> usize {
|
||||||
| ^^^^
|
LL | | X(x) // FIXME: this should error someday
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
warning: 1 warning emitted
|
warning: 1 warning emitted
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ fn double(x: usize) -> usize {
|
|||||||
}
|
}
|
||||||
const X: fn(usize) -> usize = double;
|
const X: fn(usize) -> usize = double;
|
||||||
|
|
||||||
const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
|
const fn bar(x: fn(usize) -> usize, y: usize) -> usize { //~ WARN skipping const checks
|
||||||
x(y) //~ WARN skipping const checks
|
x(y)
|
||||||
}
|
}
|
||||||
|
|
||||||
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
|
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_fn_ptr_fail2.rs:13:5
|
--> $DIR/const_fn_ptr_fail2.rs:12:1
|
||||||
|
|
|
|
||||||
LL | x(y)
|
LL | / const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
|
||||||
| ^^^^
|
LL | | x(y)
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant expression failed
|
error[E0080]: evaluation of constant expression failed
|
||||||
--> $DIR/const_fn_ptr_fail2.rs:20:5
|
--> $DIR/const_fn_ptr_fail2.rs:20:5
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const-points-to-static.rs:5:20
|
--> $DIR/const-points-to-static.rs:5:1
|
||||||
|
|
|
|
||||||
LL | const TEST: &u8 = &MY_STATIC;
|
LL | const TEST: &u8 = &MY_STATIC;
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/const-points-to-static.rs:5:1
|
--> $DIR/const-points-to-static.rs:5:1
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const-prop-read-static-in-const.rs:5:18
|
--> $DIR/const-prop-read-static-in-const.rs:5:1
|
||||||
|
|
|
|
||||||
LL | const TEST: u8 = MY_STATIC;
|
LL | const TEST: u8 = MY_STATIC;
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: any use of this value will cause an error
|
error: any use of this value will cause an error
|
||||||
--> $DIR/const-prop-read-static-in-const.rs:5:18
|
--> $DIR/const-prop-read-static-in-const.rs:5:18
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
const extern "C" fn c_fn() {}
|
const extern "C" fn c_fn() {}
|
||||||
|
|
||||||
const fn call_rust_fn(my_fn: extern "Rust" fn()) {
|
const fn call_rust_fn(my_fn: extern "Rust" fn()) {
|
||||||
|
//~^ WARN skipping const checks
|
||||||
my_fn();
|
my_fn();
|
||||||
//~^ WARN skipping const checks
|
//~^ ERROR could not evaluate static initializer
|
||||||
//~| ERROR could not evaluate static initializer
|
|
||||||
//~| NOTE calling a function with ABI C using caller ABI Rust
|
//~| NOTE calling a function with ABI C using caller ABI Rust
|
||||||
//~| NOTE inside `call_rust_fn`
|
//~| NOTE inside `call_rust_fn`
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,29 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/abi-mismatch.rs:10:5
|
--> $DIR/abi-mismatch.rs:9:1
|
||||||
|
|
|
|
||||||
LL | my_fn();
|
LL | / const fn call_rust_fn(my_fn: extern "Rust" fn()) {
|
||||||
| ^^^^^^^
|
LL | |
|
||||||
|
LL | | my_fn();
|
||||||
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/abi-mismatch.rs:17:40
|
--> $DIR/abi-mismatch.rs:17:1
|
||||||
|
|
|
|
||||||
LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
|
LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: could not evaluate static initializer
|
error[E0080]: could not evaluate static initializer
|
||||||
--> $DIR/abi-mismatch.rs:10:5
|
--> $DIR/abi-mismatch.rs:11:5
|
||||||
|
|
|
|
||||||
LL | my_fn();
|
LL | my_fn();
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
| |
|
| |
|
||||||
| calling a function with ABI C using caller ABI Rust
|
| calling a function with ABI C using caller ABI Rust
|
||||||
| inside `call_rust_fn` at $DIR/abi-mismatch.rs:10:5
|
| inside `call_rust_fn` at $DIR/abi-mismatch.rs:11:5
|
||||||
...
|
...
|
||||||
LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
|
LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
|
||||||
| --------------------------------------------------------------------- inside `VAL` at $DIR/abi-mismatch.rs:17:18
|
| --------------------------------------------------------------------- inside `VAL` at $DIR/abi-mismatch.rs:17:18
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/assoc_const.rs:14:20
|
--> $DIR/assoc_const.rs:14:5
|
||||||
|
|
|
|
||||||
LL | const F: u32 = (U::X, 42).1;
|
LL | const F: u32 = (U::X, 42).1;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
error[E0080]: erroneous constant used
|
||||||
--> $DIR/assoc_const.rs:31:13
|
--> $DIR/assoc_const.rs:31:13
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![allow(const_err)]
|
#![allow(const_err)]
|
||||||
|
|
||||||
@ -6,12 +6,8 @@ use std::mem::ManuallyDrop;
|
|||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
static TEST_BAD: &mut i32 = {
|
static TEST_BAD: &mut i32 = { //~ WARN skipping const checks
|
||||||
&mut *(box 0)
|
&mut *(box 0)
|
||||||
//~^ WARN skipping const check
|
//~^ ERROR could not evaluate static initializer
|
||||||
//~| ERROR could not evaluate static initializer
|
|
||||||
//~| NOTE heap allocations
|
//~| NOTE heap allocations
|
||||||
//~| WARN skipping const checks
|
|
||||||
//~| WARN skipping const checks
|
|
||||||
//~| WARN skipping const checks
|
|
||||||
};
|
};
|
||||||
|
@ -1,26 +1,12 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/box.rs:10:11
|
--> $DIR/box.rs:9:1
|
||||||
|
|
|
|
||||||
LL | &mut *(box 0)
|
LL | / static TEST_BAD: &mut i32 = {
|
||||||
| ^^^^^^^
|
LL | | &mut *(box 0)
|
||||||
|
LL | |
|
||||||
warning: skipping const checks
|
LL | |
|
||||||
--> $DIR/box.rs:10:16
|
LL | | };
|
||||||
|
|
| |__^
|
||||||
LL | &mut *(box 0)
|
|
||||||
| ^
|
|
||||||
|
|
||||||
warning: skipping const checks
|
|
||||||
--> $DIR/box.rs:10:5
|
|
||||||
|
|
|
||||||
LL | &mut *(box 0)
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: skipping const checks
|
|
||||||
--> $DIR/box.rs:10:5
|
|
||||||
|
|
|
||||||
LL | &mut *(box 0)
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error[E0080]: could not evaluate static initializer
|
error[E0080]: could not evaluate static initializer
|
||||||
--> $DIR/box.rs:10:11
|
--> $DIR/box.rs:10:11
|
||||||
@ -28,6 +14,6 @@ error[E0080]: could not evaluate static initializer
|
|||||||
LL | &mut *(box 0)
|
LL | &mut *(box 0)
|
||||||
| ^^^^^^^ "heap allocations via `box` keyword" needs an rfc before being allowed inside constants
|
| ^^^^^^^ "heap allocations via `box` keyword" needs an rfc before being allowed inside constants
|
||||||
|
|
||||||
error: aborting due to previous error; 4 warnings emitted
|
error: aborting due to previous error; 1 warning emitted
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// build-fail
|
// build-fail
|
||||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
|
||||||
#![allow(const_err)]
|
#![allow(const_err)]
|
||||||
|
|
||||||
use std::sync::atomic::AtomicUsize;
|
use std::sync::atomic::AtomicUsize;
|
||||||
@ -9,23 +9,20 @@ use std::sync::atomic::Ordering;
|
|||||||
// when *using* the const.
|
// when *using* the const.
|
||||||
|
|
||||||
const MUTATE_INTERIOR_MUT: usize = {
|
const MUTATE_INTERIOR_MUT: usize = {
|
||||||
|
//~^ WARN skipping const checks
|
||||||
static FOO: AtomicUsize = AtomicUsize::new(0);
|
static FOO: AtomicUsize = AtomicUsize::new(0);
|
||||||
FOO.fetch_add(1, Ordering::Relaxed)
|
FOO.fetch_add(1, Ordering::Relaxed)
|
||||||
//~^ WARN skipping const checks
|
|
||||||
//~| WARN skipping const checks
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const READ_INTERIOR_MUT: usize = {
|
const READ_INTERIOR_MUT: usize = {
|
||||||
|
//~^ WARN skipping const checks
|
||||||
static FOO: AtomicUsize = AtomicUsize::new(0);
|
static FOO: AtomicUsize = AtomicUsize::new(0);
|
||||||
unsafe { *(&FOO as *const _ as *const usize) }
|
unsafe { *(&FOO as *const _ as *const usize) }
|
||||||
//~^ WARN skipping const checks
|
|
||||||
//~| WARN skipping const checks
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static mut MUTABLE: u32 = 0;
|
static mut MUTABLE: u32 = 0;
|
||||||
const READ_MUT: u32 = unsafe { MUTABLE };
|
const READ_MUT: u32 = unsafe { MUTABLE };
|
||||||
//~^ WARN skipping const checks
|
//~^ WARN skipping const checks
|
||||||
//~| WARN skipping const checks
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
MUTATE_INTERIOR_MUT;
|
MUTATE_INTERIOR_MUT;
|
||||||
|
@ -1,57 +1,47 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_refers_to_static.rs:13:5
|
--> $DIR/const_refers_to_static.rs:11:1
|
||||||
|
|
|
|
||||||
LL | FOO.fetch_add(1, Ordering::Relaxed)
|
LL | / const MUTATE_INTERIOR_MUT: usize = {
|
||||||
| ^^^
|
LL | |
|
||||||
|
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
LL | | FOO.fetch_add(1, Ordering::Relaxed)
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_refers_to_static.rs:13:5
|
--> $DIR/const_refers_to_static.rs:17:1
|
||||||
|
|
|
|
||||||
LL | FOO.fetch_add(1, Ordering::Relaxed)
|
LL | / const READ_INTERIOR_MUT: usize = {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
LL | |
|
||||||
|
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
LL | | unsafe { *(&FOO as *const _ as *const usize) }
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_refers_to_static.rs:20:17
|
--> $DIR/const_refers_to_static.rs:24:1
|
||||||
|
|
|
||||||
LL | unsafe { *(&FOO as *const _ as *const usize) }
|
|
||||||
| ^^^
|
|
||||||
|
|
||||||
warning: skipping const checks
|
|
||||||
--> $DIR/const_refers_to_static.rs:20:14
|
|
||||||
|
|
|
||||||
LL | unsafe { *(&FOO as *const _ as *const usize) }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: skipping const checks
|
|
||||||
--> $DIR/const_refers_to_static.rs:26:32
|
|
||||||
|
|
|
|
||||||
LL | const READ_MUT: u32 = unsafe { MUTABLE };
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
|
||||||
| ^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: skipping const checks
|
|
||||||
--> $DIR/const_refers_to_static.rs:26:32
|
|
||||||
|
|
|
||||||
LL | const READ_MUT: u32 = unsafe { MUTABLE };
|
|
||||||
| ^^^^^^^
|
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
error[E0080]: erroneous constant used
|
||||||
--> $DIR/const_refers_to_static.rs:31:5
|
--> $DIR/const_refers_to_static.rs:28:5
|
||||||
|
|
|
|
||||||
LL | MUTATE_INTERIOR_MUT;
|
LL | MUTATE_INTERIOR_MUT;
|
||||||
| ^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
error[E0080]: erroneous constant used
|
||||||
--> $DIR/const_refers_to_static.rs:33:5
|
--> $DIR/const_refers_to_static.rs:30:5
|
||||||
|
|
|
|
||||||
LL | READ_INTERIOR_MUT;
|
LL | READ_INTERIOR_MUT;
|
||||||
| ^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^ referenced constant has errors
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
error[E0080]: erroneous constant used
|
||||||
--> $DIR/const_refers_to_static.rs:35:5
|
--> $DIR/const_refers_to_static.rs:32:5
|
||||||
|
|
|
|
||||||
LL | READ_MUT;
|
LL | READ_MUT;
|
||||||
| ^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^ referenced constant has errors
|
||||||
|
|
||||||
error: aborting due to 3 previous errors; 6 warnings emitted
|
error: aborting due to 3 previous errors; 3 warnings emitted
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
|
||||||
#![allow(const_err)]
|
#![allow(const_err)]
|
||||||
|
|
||||||
use std::sync::atomic::AtomicUsize;
|
use std::sync::atomic::AtomicUsize;
|
||||||
@ -8,21 +8,20 @@ use std::sync::atomic::Ordering;
|
|||||||
// so they cause an immediate error when *defining* the const.
|
// so they cause an immediate error when *defining* the const.
|
||||||
|
|
||||||
const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this value
|
const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this value
|
||||||
|
//~^ WARN skipping const checks
|
||||||
//~| NOTE encountered a reference pointing to a static variable
|
//~| NOTE encountered a reference pointing to a static variable
|
||||||
//~| NOTE
|
//~| NOTE
|
||||||
static FOO: AtomicUsize = AtomicUsize::new(0);
|
static FOO: AtomicUsize = AtomicUsize::new(0);
|
||||||
unsafe { &*(&FOO as *const _ as *const usize) }
|
unsafe { &*(&FOO as *const _ as *const usize) }
|
||||||
//~^ WARN skipping const checks
|
|
||||||
//~| WARN skipping const checks
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ok some day perhaps
|
// ok some day perhaps
|
||||||
const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this value
|
const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this value
|
||||||
|
//~^ WARN skipping const checks
|
||||||
//~| NOTE encountered a reference pointing to a static variable
|
//~| NOTE encountered a reference pointing to a static variable
|
||||||
//~| NOTE
|
//~| NOTE
|
||||||
static FOO: usize = 0;
|
static FOO: usize = 0;
|
||||||
&FOO
|
&FOO
|
||||||
//~^ WARN skipping const checks
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,20 +1,26 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_refers_to_static2.rs:14:18
|
--> $DIR/const_refers_to_static2.rs:10:1
|
||||||
|
|
|
|
||||||
LL | unsafe { &*(&FOO as *const _ as *const usize) }
|
LL | / const REF_INTERIOR_MUT: &usize = {
|
||||||
| ^^^
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
LL | | unsafe { &*(&FOO as *const _ as *const usize) }
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_refers_to_static2.rs:14:14
|
--> $DIR/const_refers_to_static2.rs:19:1
|
||||||
|
|
|
|
||||||
LL | unsafe { &*(&FOO as *const _ as *const usize) }
|
LL | / const READ_IMMUT: &usize = {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
LL | |
|
||||||
|
LL | |
|
||||||
warning: skipping const checks
|
LL | |
|
||||||
--> $DIR/const_refers_to_static2.rs:24:6
|
LL | | static FOO: usize = 0;
|
||||||
|
|
LL | | &FOO
|
||||||
LL | &FOO
|
LL | | };
|
||||||
| ^^^
|
| |__^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/const_refers_to_static2.rs:10:1
|
--> $DIR/const_refers_to_static2.rs:10:1
|
||||||
@ -22,28 +28,28 @@ error[E0080]: it is undefined behavior to use this value
|
|||||||
LL | / const REF_INTERIOR_MUT: &usize = {
|
LL | / const REF_INTERIOR_MUT: &usize = {
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
LL | |
|
||||||
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
|
|
||||||
... |
|
|
||||||
LL | |
|
LL | |
|
||||||
|
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
LL | | unsafe { &*(&FOO as *const _ as *const usize) }
|
||||||
LL | | };
|
LL | | };
|
||||||
| |__^ type validation failed: encountered a reference pointing to a static variable
|
| |__^ type validation failed: encountered a reference pointing to a static variable
|
||||||
|
|
|
|
||||||
= 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 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.
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/const_refers_to_static2.rs:20:1
|
--> $DIR/const_refers_to_static2.rs:19:1
|
||||||
|
|
|
|
||||||
LL | / const READ_IMMUT: &usize = {
|
LL | / const READ_IMMUT: &usize = {
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
LL | |
|
||||||
|
LL | |
|
||||||
LL | | static FOO: usize = 0;
|
LL | | static FOO: usize = 0;
|
||||||
LL | | &FOO
|
LL | | &FOO
|
||||||
LL | |
|
|
||||||
LL | | };
|
LL | | };
|
||||||
| |__^ type validation failed: encountered a reference pointing to a static variable
|
| |__^ type validation failed: encountered a reference pointing to a static variable
|
||||||
|
|
|
|
||||||
= 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 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.
|
||||||
|
|
||||||
error: aborting due to 2 previous errors; 3 warnings emitted
|
error: aborting due to 2 previous errors; 2 warnings emitted
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
@ -9,33 +9,32 @@ extern crate static_cross_crate;
|
|||||||
// Sneaky: reference to a mutable static.
|
// Sneaky: reference to a mutable static.
|
||||||
// Allowing this would be a disaster for pattern matching, we could violate exhaustiveness checking!
|
// Allowing this would be a disaster for pattern matching, we could violate exhaustiveness checking!
|
||||||
const SLICE_MUT: &[u8; 1] = { //~ ERROR undefined behavior to use this value
|
const SLICE_MUT: &[u8; 1] = { //~ ERROR undefined behavior to use this value
|
||||||
|
//~^ WARN skipping const checks
|
||||||
//~| NOTE encountered a reference pointing to a static variable
|
//~| NOTE encountered a reference pointing to a static variable
|
||||||
//~| NOTE
|
//~| NOTE
|
||||||
unsafe { &static_cross_crate::ZERO }
|
unsafe { &static_cross_crate::ZERO }
|
||||||
//~^ WARN skipping const checks
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const U8_MUT: &u8 = { //~ ERROR undefined behavior to use this value
|
const U8_MUT: &u8 = { //~ ERROR undefined behavior to use this value
|
||||||
|
//~^ WARN skipping const checks
|
||||||
//~| NOTE encountered a reference pointing to a static variable
|
//~| NOTE encountered a reference pointing to a static variable
|
||||||
//~| NOTE
|
//~| NOTE
|
||||||
unsafe { &static_cross_crate::ZERO[0] }
|
unsafe { &static_cross_crate::ZERO[0] }
|
||||||
//~^ WARN skipping const checks
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Also test indirection that reads from other static. This causes a const_err.
|
// Also test indirection that reads from other static. This causes a const_err.
|
||||||
#[warn(const_err)] //~ NOTE
|
#[warn(const_err)] //~ NOTE
|
||||||
const U8_MUT2: &u8 = { //~ NOTE
|
const U8_MUT2: &u8 = { //~ NOTE
|
||||||
|
//~^ WARN skipping const checks
|
||||||
unsafe { &(*static_cross_crate::ZERO_REF)[0] }
|
unsafe { &(*static_cross_crate::ZERO_REF)[0] }
|
||||||
//~^ WARN skipping const checks
|
//~^ WARN [const_err]
|
||||||
//~| WARN [const_err]
|
|
||||||
//~| NOTE constant accesses static
|
//~| NOTE constant accesses static
|
||||||
};
|
};
|
||||||
#[warn(const_err)] //~ NOTE
|
#[warn(const_err)] //~ NOTE
|
||||||
const U8_MUT3: &u8 = { //~ NOTE
|
const U8_MUT3: &u8 = { //~ NOTE
|
||||||
|
//~^ WARN skipping const checks
|
||||||
unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
||||||
//~^ WARN skipping const checks
|
//~^ WARN [const_err]
|
||||||
//~| WARN skipping const checks
|
|
||||||
//~| WARN [const_err]
|
|
||||||
//~| NOTE constant accesses static
|
//~| NOTE constant accesses static
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:14:15
|
--> $DIR/const_refers_to_static_cross_crate.rs:11:1
|
||||||
|
|
|
|
||||||
LL | unsafe { &static_cross_crate::ZERO }
|
LL | / const SLICE_MUT: &[u8; 1] = {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | | unsafe { &static_cross_crate::ZERO }
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:11:1
|
--> $DIR/const_refers_to_static_cross_crate.rs:11:1
|
||||||
@ -10,24 +15,29 @@ error[E0080]: it is undefined behavior to use this value
|
|||||||
LL | / const SLICE_MUT: &[u8; 1] = {
|
LL | / const SLICE_MUT: &[u8; 1] = {
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
LL | |
|
||||||
LL | | unsafe { &static_cross_crate::ZERO }
|
|
||||||
LL | |
|
LL | |
|
||||||
|
LL | | unsafe { &static_cross_crate::ZERO }
|
||||||
LL | | };
|
LL | | };
|
||||||
| |__^ type validation failed: encountered a reference pointing to a static variable
|
| |__^ type validation failed: encountered a reference pointing to a static variable
|
||||||
|
|
|
|
||||||
= 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 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.
|
||||||
|
|
||||||
error: could not evaluate constant pattern
|
error: could not evaluate constant pattern
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:44:9
|
--> $DIR/const_refers_to_static_cross_crate.rs:43:9
|
||||||
|
|
|
|
||||||
LL | SLICE_MUT => true,
|
LL | SLICE_MUT => true,
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:21:15
|
--> $DIR/const_refers_to_static_cross_crate.rs:18:1
|
||||||
|
|
|
|
||||||
LL | unsafe { &static_cross_crate::ZERO[0] }
|
LL | / const U8_MUT: &u8 = {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | | unsafe { &static_cross_crate::ZERO[0] }
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:18:1
|
--> $DIR/const_refers_to_static_cross_crate.rs:18:1
|
||||||
@ -35,34 +45,39 @@ error[E0080]: it is undefined behavior to use this value
|
|||||||
LL | / const U8_MUT: &u8 = {
|
LL | / const U8_MUT: &u8 = {
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
LL | |
|
||||||
LL | | unsafe { &static_cross_crate::ZERO[0] }
|
|
||||||
LL | |
|
LL | |
|
||||||
|
LL | | unsafe { &static_cross_crate::ZERO[0] }
|
||||||
LL | | };
|
LL | | };
|
||||||
| |__^ type validation failed: encountered a reference pointing to a static variable
|
| |__^ type validation failed: encountered a reference pointing to a static variable
|
||||||
|
|
|
|
||||||
= 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 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.
|
||||||
|
|
||||||
error: could not evaluate constant pattern
|
error: could not evaluate constant pattern
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:52:9
|
--> $DIR/const_refers_to_static_cross_crate.rs:51:9
|
||||||
|
|
|
|
||||||
LL | U8_MUT => true,
|
LL | U8_MUT => true,
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:28:17
|
--> $DIR/const_refers_to_static_cross_crate.rs:27:1
|
||||||
|
|
|
||||||
LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: any use of this value will cause an error
|
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:28:14
|
|
||||||
|
|
|
|
||||||
LL | / const U8_MUT2: &u8 = {
|
LL | / const U8_MUT2: &u8 = {
|
||||||
|
LL | |
|
||||||
|
LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
|
||||||
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
|
warning: any use of this value will cause an error
|
||||||
|
--> $DIR/const_refers_to_static_cross_crate.rs:29:14
|
||||||
|
|
|
||||||
|
LL | / const U8_MUT2: &u8 = {
|
||||||
|
LL | |
|
||||||
LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
|
LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
|
||||||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
|
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
|
||||||
LL | | };
|
LL | | };
|
||||||
| |__-
|
| |__-
|
||||||
|
|
|
|
||||||
@ -73,35 +88,31 @@ LL | #[warn(const_err)]
|
|||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error: could not evaluate constant pattern
|
error: could not evaluate constant pattern
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:62:9
|
--> $DIR/const_refers_to_static_cross_crate.rs:61:9
|
||||||
|
|
|
|
||||||
LL | U8_MUT2 => true,
|
LL | U8_MUT2 => true,
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:35:20
|
--> $DIR/const_refers_to_static_cross_crate.rs:34:1
|
||||||
|
|
|
||||||
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: skipping const checks
|
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:35:77
|
|
||||||
|
|
|
||||||
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
|
||||||
| ^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
warning: any use of this value will cause an error
|
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:35:51
|
|
||||||
|
|
|
|
||||||
LL | / const U8_MUT3: &u8 = {
|
LL | / const U8_MUT3: &u8 = {
|
||||||
|
LL | |
|
||||||
|
LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
||||||
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
|
warning: any use of this value will cause an error
|
||||||
|
--> $DIR/const_refers_to_static_cross_crate.rs:36:51
|
||||||
|
|
|
||||||
|
LL | / const U8_MUT3: &u8 = {
|
||||||
|
LL | |
|
||||||
LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
|
||||||
| | ^^^^^^^^^^^ constant accesses static
|
| | ^^^^^^^^^^^ constant accesses static
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
LL | |
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | };
|
LL | | };
|
||||||
| |__-
|
| |__-
|
||||||
|
|
|
|
||||||
@ -112,11 +123,11 @@ LL | #[warn(const_err)]
|
|||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error: could not evaluate constant pattern
|
error: could not evaluate constant pattern
|
||||||
--> $DIR/const_refers_to_static_cross_crate.rs:69:9
|
--> $DIR/const_refers_to_static_cross_crate.rs:68:9
|
||||||
|
|
|
|
||||||
LL | U8_MUT3 => true,
|
LL | U8_MUT3 => true,
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 6 previous errors; 7 warnings emitted
|
error: aborting due to 6 previous errors; 6 warnings emitted
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
@ -13,7 +13,6 @@ static TEST_OK: () = {
|
|||||||
|
|
||||||
// Make sure we catch executing bad drop functions.
|
// Make sure we catch executing bad drop functions.
|
||||||
// The actual error is tested by the error-pattern above.
|
// The actual error is tested by the error-pattern above.
|
||||||
static TEST_BAD: () = {
|
static TEST_BAD: () = { //~ WARN skipping const checks
|
||||||
let _v: Vec<i32> = Vec::new();
|
let _v: Vec<i32> = Vec::new();
|
||||||
//~^ WARN skipping const check
|
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/drop.rs:17:9
|
--> $DIR/drop.rs:16:1
|
||||||
|
|
|
|
||||||
LL | let _v: Vec<i32> = Vec::new();
|
LL | / static TEST_BAD: () = {
|
||||||
| ^^
|
LL | | let _v: Vec<i32> = Vec::new();
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
error[E0080]: could not evaluate static initializer
|
error[E0080]: could not evaluate static initializer
|
||||||
--> $SRC_DIR/libcore/ptr/mod.rs:LL:COL
|
--> $SRC_DIR/libcore/ptr/mod.rs:LL:COL
|
||||||
@ -17,10 +19,10 @@ LL | | }
|
|||||||
| |_calling non-const function `<std::vec::Vec<i32> as std::ops::Drop>::drop`
|
| |_calling non-const function `<std::vec::Vec<i32> as std::ops::Drop>::drop`
|
||||||
| inside `std::intrinsics::drop_in_place::<std::vec::Vec<i32>> - shim(Some(std::vec::Vec<i32>))` at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
|
| inside `std::intrinsics::drop_in_place::<std::vec::Vec<i32>> - shim(Some(std::vec::Vec<i32>))` at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
|
||||||
|
|
|
|
||||||
::: $DIR/drop.rs:19:1
|
::: $DIR/drop.rs:18:1
|
||||||
|
|
|
|
||||||
LL | };
|
LL | };
|
||||||
| - inside `TEST_BAD` at $DIR/drop.rs:19:1
|
| - inside `TEST_BAD` at $DIR/drop.rs:18:1
|
||||||
|
|
||||||
error: aborting due to previous error; 1 warning emitted
|
error: aborting due to previous error; 1 warning emitted
|
||||||
|
|
||||||
|
@ -6,11 +6,9 @@
|
|||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
// Make sure we catch executing inline assembly.
|
// Make sure we catch executing inline assembly.
|
||||||
static TEST_BAD: () = {
|
static TEST_BAD: () = { //~ WARN skipping const checks
|
||||||
unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
|
unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
|
||||||
//~^ ERROR could not evaluate static initializer
|
//~^ ERROR could not evaluate static initializer
|
||||||
//~| NOTE in this expansion of llvm_asm!
|
|
||||||
//~| NOTE inline assembly is not supported
|
//~| NOTE inline assembly is not supported
|
||||||
//~| WARN skipping const checks
|
|
||||||
//~| NOTE in this expansion of llvm_asm!
|
//~| NOTE in this expansion of llvm_asm!
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/inline_asm.rs:10:14
|
--> $DIR/inline_asm.rs:9:1
|
||||||
|
|
|
|
||||||
LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
|
LL | / static TEST_BAD: () = {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
LL | | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
|
||||||
|
|
LL | |
|
||||||
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
LL | |
|
||||||
|
LL | |
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
error[E0080]: could not evaluate static initializer
|
error[E0080]: could not evaluate static initializer
|
||||||
--> $DIR/inline_asm.rs:10:14
|
--> $DIR/inline_asm.rs:10:14
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
|
||||||
// normalize-stderr-test "alloc[0-9]+" -> "allocN"
|
// normalize-stderr-test "alloc[0-9]+" -> "allocN"
|
||||||
|
|
||||||
#![deny(const_err)] // The `allow` variant is tested by `mutable_const2`.
|
#![deny(const_err)] // The `allow` variant is tested by `mutable_const2`.
|
||||||
@ -14,12 +14,11 @@ const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
|||||||
//~^ WARN: skipping const checks
|
//~^ WARN: skipping const checks
|
||||||
|
|
||||||
const MUTATING_BEHIND_RAW: () = { //~ NOTE
|
const MUTATING_BEHIND_RAW: () = { //~ NOTE
|
||||||
|
//~^ WARN skipping const checks
|
||||||
// Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
|
// Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
|
||||||
unsafe {
|
unsafe {
|
||||||
*MUTABLE_BEHIND_RAW = 99 //~ ERROR any use of this value will cause an error
|
*MUTABLE_BEHIND_RAW = 99 //~ ERROR any use of this value will cause an error
|
||||||
//~^ NOTE: which is read-only
|
//~^ NOTE: which is read-only
|
||||||
//~| WARN skipping const checks
|
|
||||||
//~| WARN skipping const checks
|
|
||||||
// FIXME would be good to match more of the error message here, but looks like we
|
// FIXME would be good to match more of the error message here, but looks like we
|
||||||
// normalize *after* checking the annoations here.
|
// normalize *after* checking the annoations here.
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,26 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/mutable_const.rs:13:38
|
--> $DIR/mutable_const.rs:13:1
|
||||||
|
|
|
|
||||||
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/mutable_const.rs:19:9
|
--> $DIR/mutable_const.rs:16:1
|
||||||
|
|
|
||||||
LL | *MUTABLE_BEHIND_RAW = 99
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: skipping const checks
|
|
||||||
--> $DIR/mutable_const.rs:19:9
|
|
||||||
|
|
|
||||||
LL | *MUTABLE_BEHIND_RAW = 99
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: any use of this value will cause an error
|
|
||||||
--> $DIR/mutable_const.rs:19:9
|
|
||||||
|
|
|
|
||||||
LL | / const MUTATING_BEHIND_RAW: () = {
|
LL | / const MUTATING_BEHIND_RAW: () = {
|
||||||
|
LL | |
|
||||||
|
LL | | // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
|
||||||
|
LL | | unsafe {
|
||||||
|
... |
|
||||||
|
LL | | }
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
|
error: any use of this value will cause an error
|
||||||
|
--> $DIR/mutable_const.rs:20:9
|
||||||
|
|
|
||||||
|
LL | / const MUTATING_BEHIND_RAW: () = {
|
||||||
|
LL | |
|
||||||
LL | | // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
|
LL | | // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
|
||||||
LL | | unsafe {
|
LL | | unsafe {
|
||||||
LL | | *MUTABLE_BEHIND_RAW = 99
|
LL | | *MUTABLE_BEHIND_RAW = 99
|
||||||
@ -35,5 +36,5 @@ note: the lint level is defined here
|
|||||||
LL | #![deny(const_err)] // The `allow` variant is tested by `mutable_const2`.
|
LL | #![deny(const_err)] // The `allow` variant is tested by `mutable_const2`.
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error; 3 warnings emitted
|
error: aborting due to previous error; 2 warnings emitted
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/mutable_const2.rs:13:38
|
--> $DIR/mutable_const2.rs:13:1
|
||||||
|
|
|
|
||||||
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: 1 warning emitted
|
warning: 1 warning emitted
|
||||||
|
|
||||||
|
@ -26,9 +26,8 @@ struct Meh {
|
|||||||
|
|
||||||
unsafe impl Sync for Meh {}
|
unsafe impl Sync for Meh {}
|
||||||
|
|
||||||
static MEH: Meh = Meh {
|
static MEH: Meh = Meh { //~ WARN skipping const checks
|
||||||
x: &UnsafeCell::new(42),
|
x: &UnsafeCell::new(42),
|
||||||
//~^ WARN: skipping const checks
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// this is fine for the same reason as `BAR`.
|
// this is fine for the same reason as `BAR`.
|
||||||
|
@ -1,35 +1,37 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/mutable_references.rs:9:26
|
--> $DIR/mutable_references.rs:9:1
|
||||||
|
|
|
|
||||||
LL | static FOO: &&mut u32 = &&mut 42;
|
LL | static FOO: &&mut u32 = &&mut 42;
|
||||||
| ^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/mutable_references.rs:14:23
|
--> $DIR/mutable_references.rs:14:1
|
||||||
|
|
|
|
||||||
LL | static BAR: &mut () = &mut ();
|
LL | static BAR: &mut () = &mut ();
|
||||||
| ^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/mutable_references.rs:20:28
|
--> $DIR/mutable_references.rs:20:1
|
||||||
|
|
|
|
||||||
LL | static BOO: &mut Foo<()> = &mut Foo(());
|
LL | static BOO: &mut Foo<()> = &mut Foo(());
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/mutable_references.rs:30:8
|
--> $DIR/mutable_references.rs:29:1
|
||||||
|
|
|
|
||||||
LL | x: &UnsafeCell::new(42),
|
LL | / static MEH: Meh = Meh {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
LL | | x: &UnsafeCell::new(42),
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/mutable_references.rs:35:27
|
--> $DIR/mutable_references.rs:34:1
|
||||||
|
|
|
|
||||||
LL | static OH_YES: &mut i32 = &mut 42;
|
LL | static OH_YES: &mut i32 = &mut 42;
|
||||||
| ^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
|
error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
|
||||||
--> $DIR/mutable_references.rs:42:5
|
--> $DIR/mutable_references.rs:41:5
|
||||||
|
|
|
|
||||||
LL | *OH_YES = 99;
|
LL | *OH_YES = 99;
|
||||||
| ^^^^^^^^^^^^ cannot assign
|
| ^^^^^^^^^^^^ cannot assign
|
||||||
|
@ -18,8 +18,8 @@ struct Meh {
|
|||||||
unsafe impl Sync for Meh {}
|
unsafe impl Sync for Meh {}
|
||||||
|
|
||||||
// the following will never be ok!
|
// the following will never be ok!
|
||||||
const MUH: Meh = Meh {
|
const MUH: Meh = Meh { //~ WARN skipping const checks
|
||||||
x: &UnsafeCell::new(42), //~ WARN: skipping const checks
|
x: &UnsafeCell::new(42),
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/mutable_references_ice.rs:22:8
|
--> $DIR/mutable_references_ice.rs:21:1
|
||||||
|
|
|
|
||||||
LL | x: &UnsafeCell::new(42),
|
LL | / const MUH: Meh = Meh {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
LL | | x: &UnsafeCell::new(42),
|
||||||
|
LL | | };
|
||||||
|
| |__^
|
||||||
|
|
||||||
thread 'rustc' panicked at 'assertion failed: `(left != right)`
|
thread 'rustc' panicked at 'assertion failed: `(left != right)`
|
||||||
left: `Const`,
|
left: `Const`,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/non_const_fn.rs:9:16
|
--> $DIR/non_const_fn.rs:9:1
|
||||||
|
|
|
|
||||||
LL | static C: () = foo();
|
LL | static C: () = foo();
|
||||||
| ^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: could not evaluate static initializer
|
error[E0080]: could not evaluate static initializer
|
||||||
--> $DIR/non_const_fn.rs:9:16
|
--> $DIR/non_const_fn.rs:9:16
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/read_from_static.rs:5:27
|
--> $DIR/read_from_static.rs:5:1
|
||||||
|
|
|
|
||||||
LL | static OH_YES: &mut i32 = &mut 42;
|
LL | static OH_YES: &mut i32 = &mut 42;
|
||||||
| ^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: 1 warning emitted
|
warning: 1 warning emitted
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@ const fn attributed() -> L {
|
|||||||
std::intrinsics::caller_location()
|
std::intrinsics::caller_location()
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn calling_attributed() -> L {
|
const fn calling_attributed() -> L { //~ WARN skipping const checks
|
||||||
// We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers.
|
// We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers.
|
||||||
let ptr: fn() -> L = attributed;
|
let ptr: fn() -> L = attributed;
|
||||||
ptr() //~ WARN skipping const checks
|
ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
--> $DIR/caller-location-fnptr-rt-ctfe-equiv.rs:21:5
|
--> $DIR/caller-location-fnptr-rt-ctfe-equiv.rs:18:1
|
||||||
|
|
|
|
||||||
LL | ptr()
|
LL | / const fn calling_attributed() -> L {
|
||||||
| ^^^^^
|
LL | | // We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers.
|
||||||
|
LL | | let ptr: fn() -> L = attributed;
|
||||||
|
LL | | ptr()
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
warning: 1 warning emitted
|
warning: 1 warning emitted
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user