Auto merge of #67000 - spastorino:remove-promoted-from-place, r=oli-obk
Promote references to constants instead of statics r? @oli-obk
This commit is contained in:
commit
1389494ac1
100 changed files with 1118 additions and 1595 deletions
|
|
@ -1,7 +1,10 @@
|
|||
// build-fail
|
||||
// build-pass
|
||||
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
&{[1, 2, 3][4]};
|
||||
//~^ ERROR index out of bounds
|
||||
//~| ERROR reaching this expression at runtime will panic or abort
|
||||
&{ [1, 2, 3][4] };
|
||||
//~^ WARN index out of bounds
|
||||
//~| WARN reaching this expression at runtime will panic or abort
|
||||
//~| WARN erroneous constant used [const_err]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,26 @@
|
|||
error: index out of bounds: the len is 3 but the index is 4
|
||||
--> $DIR/array-literal-index-oob.rs:4:7
|
||||
warning: index out of bounds: the len is 3 but the index is 4
|
||||
--> $DIR/array-literal-index-oob.rs:6:8
|
||||
|
|
||||
LL | &{[1, 2, 3][4]};
|
||||
| ^^^^^^^^^^^^
|
||||
LL | &{ [1, 2, 3][4] };
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
error: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/array-literal-index-oob.rs:4:7
|
||||
note: lint level defined here
|
||||
--> $DIR/array-literal-index-oob.rs:3:9
|
||||
|
|
||||
LL | &{[1, 2, 3][4]};
|
||||
| --^^^^^^^^^^^^-
|
||||
| |
|
||||
| indexing out of bounds: the len is 3 but the index is 4
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/array-literal-index-oob.rs:6:8
|
||||
|
|
||||
LL | &{ [1, 2, 3][4] };
|
||||
| ---^^^^^^^^^^^^--
|
||||
| |
|
||||
| indexing out of bounds: the len is 3 but the index is 4
|
||||
|
||||
warning: erroneous constant used
|
||||
--> $DIR/array-literal-index-oob.rs:6:5
|
||||
|
|
||||
LL | &{ [1, 2, 3][4] };
|
||||
| ^^^^^^^^^^^^^^^^^ referenced constant has errors
|
||||
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@ const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
|||
fn main() {
|
||||
println!("{}", FOO);
|
||||
//~^ ERROR
|
||||
//~| WARN erroneous constant used [const_err]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ error[E0080]: evaluation of constant expression failed
|
|||
LL | println!("{}", FOO);
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
warning: erroneous constant used
|
||||
--> $DIR/conditional_array_execution.rs:11:20
|
||||
|
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
#![feature(const_fn)]
|
||||
#![allow(const_err)]
|
||||
|
||||
fn double(x: usize) -> usize { x * 2 }
|
||||
fn double(x: usize) -> usize {
|
||||
x * 2
|
||||
}
|
||||
const X: fn(usize) -> usize = double;
|
||||
|
||||
const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
warning: skipping const checks
|
||||
--> $DIR/const_fn_ptr_fail2.rs:11:5
|
||||
--> $DIR/const_fn_ptr_fail2.rs:13:5
|
||||
|
|
||||
LL | x(y)
|
||||
| ^^^^
|
||||
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/const_fn_ptr_fail2.rs:18:5
|
||||
--> $DIR/const_fn_ptr_fail2.rs:20:5
|
||||
|
|
||||
LL | assert_eq!(Y, 4);
|
||||
| ^^^^^^^^^^^-^^^^^
|
||||
|
|
@ -15,7 +15,7 @@ LL | assert_eq!(Y, 4);
|
|||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/const_fn_ptr_fail2.rs:20:5
|
||||
--> $DIR/const_fn_ptr_fail2.rs:22:5
|
||||
|
|
||||
LL | assert_eq!(Z, 4);
|
||||
| ^^^^^^^^^^^-^^^^^
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ const fn foo(x: u32) -> u32 {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
const X: u32 = 0-1;
|
||||
const X: u32 = 0 - 1;
|
||||
//~^ WARN any use of this value will cause
|
||||
const Y: u32 = foo(0-1);
|
||||
const Y: u32 = foo(0 - 1);
|
||||
//~^ WARN any use of this value will cause
|
||||
println!("{} {}", X, Y);
|
||||
//~^ ERROR evaluation of constant expression failed
|
||||
//~| ERROR evaluation of constant expression failed
|
||||
//~| WARN erroneous constant used [const_err]
|
||||
//~| WARN erroneous constant used [const_err]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
warning: any use of this value will cause an error
|
||||
--> $DIR/issue-43197.rs:10:20
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| ---------------^^^-
|
||||
LL | const X: u32 = 0 - 1;
|
||||
| ---------------^^^^^-
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
|
||||
|
|
@ -15,8 +15,8 @@ LL | #![warn(const_err)]
|
|||
warning: any use of this value will cause an error
|
||||
--> $DIR/issue-43197.rs:12:24
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| -------------------^^^--
|
||||
LL | const Y: u32 = foo(0 - 1);
|
||||
| -------------------^^^^^--
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
||||
|
|
@ -26,12 +26,24 @@ error[E0080]: evaluation of constant expression failed
|
|||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
warning: erroneous constant used
|
||||
--> $DIR/issue-43197.rs:14:23
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/issue-43197.rs:14:26
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
warning: erroneous constant used
|
||||
--> $DIR/issue-43197.rs:14:26
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -25,5 +25,5 @@ impl Foo for u16 {
|
|||
|
||||
fn main() {
|
||||
println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
||||
//~^ ERROR E0080
|
||||
//~^ ERROR evaluation of constant expression failed [E0080]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@ impl Unsigned for U8 {
|
|||
struct Sum<A,B>(A,B);
|
||||
|
||||
impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A,B> {
|
||||
const MAX: u8 = A::MAX + B::MAX; //~ ERROR any use of this value will cause an error
|
||||
const MAX: u8 = A::MAX + B::MAX;
|
||||
//~^ ERROR any use of this value will cause an error [const_err]
|
||||
}
|
||||
|
||||
fn foo<T>(_: T) -> &'static u8 {
|
||||
&Sum::<U8,U8>::MAX //~ ERROR E0080
|
||||
&Sum::<U8,U8>::MAX
|
||||
//~^ ERROR E0080
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ LL | const MAX: u8 = A::MAX + B::MAX;
|
|||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/issue-50814.rs:19:5
|
||||
--> $DIR/issue-50814.rs:20:5
|
||||
|
|
||||
LL | &Sum::<U8,U8>::MAX
|
||||
| ^-----------------
|
||||
|
|
|
|||
|
|
@ -1,20 +1,22 @@
|
|||
// build-fail
|
||||
// build-pass
|
||||
// compile-flags: -O
|
||||
|
||||
#![deny(const_err)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
println!("{}", 0u32 - 1);
|
||||
let _x = 0u32 - 1;
|
||||
//~^ ERROR const_err
|
||||
println!("{}", 1/(1-1));
|
||||
//~^ ERROR attempt to divide by zero [const_err]
|
||||
//~| ERROR const_err
|
||||
let _x = 1/(1-1);
|
||||
//~^ ERROR const_err
|
||||
println!("{}", 1/(false as u32));
|
||||
//~^ ERROR attempt to divide by zero [const_err]
|
||||
//~| ERROR const_err
|
||||
let _x = 1/(false as u32);
|
||||
//~^ ERROR const_err
|
||||
//~^ WARN const_err
|
||||
println!("{}", 1 / (1 - 1));
|
||||
//~^ WARN attempt to divide by zero [const_err]
|
||||
//~| WARN const_err
|
||||
//~| WARN erroneous constant used [const_err]
|
||||
let _x = 1 / (1 - 1);
|
||||
//~^ WARN const_err
|
||||
println!("{}", 1 / (false as u32));
|
||||
//~^ WARN attempt to divide by zero [const_err]
|
||||
//~| WARN const_err
|
||||
//~| WARN erroneous constant used [const_err]
|
||||
let _x = 1 / (false as u32);
|
||||
//~^ WARN const_err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: this expression will panic at runtime
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:8:14
|
||||
|
|
||||
LL | let _x = 0u32 - 1;
|
||||
|
|
@ -7,44 +7,54 @@ LL | let _x = 0u32 - 1;
|
|||
note: lint level defined here
|
||||
--> $DIR/promoted_errors.rs:4:9
|
||||
|
|
||||
LL | #![deny(const_err)]
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:10:20
|
||||
|
|
||||
LL | println!("{}", 1/(1-1));
|
||||
| ^^^^^^^
|
||||
LL | println!("{}", 1 / (1 - 1));
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: reaching this expression at runtime will panic or abort
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:10:20
|
||||
|
|
||||
LL | println!("{}", 1/(1-1));
|
||||
| ^^^^^^^ dividing by zero
|
||||
LL | println!("{}", 1 / (1 - 1));
|
||||
| ^^^^^^^^^^^ dividing by zero
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:13:14
|
||||
warning: erroneous constant used
|
||||
--> $DIR/promoted_errors.rs:10:20
|
||||
|
|
||||
LL | let _x = 1/(1-1);
|
||||
| ^^^^^^^
|
||||
LL | println!("{}", 1 / (1 - 1));
|
||||
| ^^^^^^^^^^^ referenced constant has errors
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:15:20
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:14:14
|
||||
|
|
||||
LL | println!("{}", 1/(false as u32));
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _x = 1 / (1 - 1);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:15:20
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:16:20
|
||||
|
|
||||
LL | println!("{}", 1/(false as u32));
|
||||
| ^^^^^^^^^^^^^^^^ dividing by zero
|
||||
LL | println!("{}", 1 / (false as u32));
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:18:14
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:16:20
|
||||
|
|
||||
LL | let _x = 1/(false as u32);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | println!("{}", 1 / (false as u32));
|
||||
| ^^^^^^^^^^^^^^^^^^ dividing by zero
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
warning: erroneous constant used
|
||||
--> $DIR/promoted_errors.rs:16:20
|
||||
|
|
||||
LL | println!("{}", 1 / (false as u32));
|
||||
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
||||
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:20:14
|
||||
|
|
||||
LL | let _x = 1 / (false as u32);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
// build-fail
|
||||
// build-pass
|
||||
// compile-flags: -C overflow-checks=on -O
|
||||
|
||||
#![deny(const_err)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
println!("{}", 0u32 - 1);
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
let _x = 0u32 - 1;
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
println!("{}", 1/(1-1));
|
||||
//~^ ERROR attempt to divide by zero [const_err]
|
||||
//~| ERROR const_err
|
||||
let _x = 1/(1-1);
|
||||
//~^ ERROR const_err
|
||||
println!("{}", 1/(false as u32));
|
||||
//~^ ERROR attempt to divide by zero [const_err]
|
||||
//~| ERROR const_err
|
||||
let _x = 1/(false as u32);
|
||||
//~^ ERROR const_err
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
println!("{}", 1 / (1 - 1));
|
||||
//~^ WARN attempt to divide by zero [const_err]
|
||||
//~| WARN const_err
|
||||
//~| WARN erroneous constant used [const_err]
|
||||
let _x = 1 / (1 - 1);
|
||||
//~^ WARN const_err
|
||||
println!("{}", 1 / (false as u32));
|
||||
//~^ WARN attempt to divide by zero [const_err]
|
||||
//~| WARN const_err
|
||||
//~| WARN erroneous constant used [const_err]
|
||||
let _x = 1 / (false as u32);
|
||||
//~^ WARN const_err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: attempt to subtract with overflow
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/promoted_errors2.rs:7:20
|
||||
|
|
||||
LL | println!("{}", 0u32 - 1);
|
||||
|
|
@ -7,50 +7,60 @@ LL | println!("{}", 0u32 - 1);
|
|||
note: lint level defined here
|
||||
--> $DIR/promoted_errors2.rs:4:9
|
||||
|
|
||||
LL | #![deny(const_err)]
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: attempt to subtract with overflow
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/promoted_errors2.rs:9:14
|
||||
|
|
||||
LL | let _x = 0u32 - 1;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors2.rs:11:20
|
||||
|
|
||||
LL | println!("{}", 1/(1-1));
|
||||
| ^^^^^^^
|
||||
LL | println!("{}", 1 / (1 - 1));
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: reaching this expression at runtime will panic or abort
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors2.rs:11:20
|
||||
|
|
||||
LL | println!("{}", 1/(1-1));
|
||||
| ^^^^^^^ dividing by zero
|
||||
LL | println!("{}", 1 / (1 - 1));
|
||||
| ^^^^^^^^^^^ dividing by zero
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/promoted_errors2.rs:14:14
|
||||
warning: erroneous constant used
|
||||
--> $DIR/promoted_errors2.rs:11:20
|
||||
|
|
||||
LL | let _x = 1/(1-1);
|
||||
| ^^^^^^^
|
||||
LL | println!("{}", 1 / (1 - 1));
|
||||
| ^^^^^^^^^^^ referenced constant has errors
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/promoted_errors2.rs:16:20
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors2.rs:15:14
|
||||
|
|
||||
LL | println!("{}", 1/(false as u32));
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | let _x = 1 / (1 - 1);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors2.rs:16:20
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors2.rs:17:20
|
||||
|
|
||||
LL | println!("{}", 1/(false as u32));
|
||||
| ^^^^^^^^^^^^^^^^ dividing by zero
|
||||
LL | println!("{}", 1 / (false as u32));
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/promoted_errors2.rs:19:14
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors2.rs:17:20
|
||||
|
|
||||
LL | let _x = 1/(false as u32);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
LL | println!("{}", 1 / (false as u32));
|
||||
| ^^^^^^^^^^^^^^^^^^ dividing by zero
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
warning: erroneous constant used
|
||||
--> $DIR/promoted_errors2.rs:17:20
|
||||
|
|
||||
LL | println!("{}", 1 / (false as u32));
|
||||
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
||||
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors2.rs:21:14
|
||||
|
|
||||
LL | let _x = 1 / (false as u32);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ LL | / const OUT_OF_BOUNDS_PTR: NonNull<u8> = { unsafe {
|
|||
LL | | let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle
|
||||
LL | | // Use address-of-element for pointer arithmetic. This could wrap around to NULL!
|
||||
LL | | let out_of_bounds_ptr = &ptr[255];
|
||||
| | ^^^^^^^^^ Memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of allocation 6 which has size 1
|
||||
| | ^^^^^^^^^ Memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of allocation 9 which has size 1
|
||||
LL | | mem::transmute(out_of_bounds_ptr)
|
||||
LL | | } };
|
||||
| |____-
|
||||
|
|
|
|||
|
|
@ -11,5 +11,7 @@ const C: () = foo(); //~ WARN: skipping const checks
|
|||
//~^ WARN any use of this value will cause an error
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", C); //~ ERROR: evaluation of constant expression failed
|
||||
println!("{:?}", C);
|
||||
//~^ ERROR: evaluation of constant expression failed
|
||||
//~| WARN: erroneous constant used [const_err]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ error[E0080]: evaluation of constant expression failed
|
|||
LL | println!("{:?}", C);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
warning: erroneous constant used
|
||||
--> $DIR/non_const_fn.rs:14:22
|
||||
|
|
||||
LL | println!("{:?}", C);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -7,13 +7,15 @@ static FOO: Foo = Foo;
|
|||
|
||||
fn main() {
|
||||
let x: &'static () = &();
|
||||
assert_eq!(x as *const () as usize, 1);
|
||||
assert_ne!(x as *const () as usize, 1);
|
||||
let x: &'static Foo = &Foo;
|
||||
assert_eq!(x as *const Foo as usize, 4);
|
||||
assert_ne!(x as *const Foo as usize, 4);
|
||||
|
||||
// statics must have a unique address
|
||||
assert_ne!(&FOO as *const Foo as usize, 4);
|
||||
|
||||
assert_eq!(<Vec<i32>>::new().as_ptr(), <&[i32]>::default().as_ptr());
|
||||
assert_eq!(<Box<[i32]>>::default().as_ptr(), (&[]).as_ptr());
|
||||
// FIXME this two tests should be assert_eq!
|
||||
// this stopped working since we are promoting to constants instead of statics
|
||||
assert_ne!(<Vec<i32>>::new().as_ptr(), <&[i32]>::default().as_ptr());
|
||||
assert_ne!(<Box<[i32]>>::default().as_ptr(), (&[]).as_ptr());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
// run-pass
|
||||
|
||||
#![allow(unused_mut)]
|
||||
// ignore-wasm32
|
||||
// ignore-emscripten
|
||||
// ignore-sgx no processes
|
||||
|
||||
// compile-flags: -C debug_assertions=yes
|
||||
|
||||
#![stable(feature = "rustc", since = "1.0.0")]
|
||||
#![feature(const_fn, rustc_private, staged_api, rustc_attrs)]
|
||||
#![allow(const_err)]
|
||||
|
||||
extern crate libc;
|
||||
|
||||
use std::env;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
// this will panic in debug mode and overflow in release mode
|
||||
//
|
||||
// NB we give bar an unused argument because otherwise memoization
|
||||
// of the const fn kicks in, causing a different code path in the
|
||||
// compiler to be executed (see PR #66294).
|
||||
#[stable(feature = "rustc", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "rustc", since = "1.0.0")]
|
||||
#[rustc_promotable]
|
||||
const fn bar(_: bool) -> usize { 0 - 1 }
|
||||
|
||||
fn foo() {
|
||||
let _: &'static _ = &bar(true);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn check_status(status: std::process::ExitStatus)
|
||||
{
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
|
||||
assert!(status.signal() == Some(libc::SIGILL)
|
||||
|| status.signal() == Some(libc::SIGTRAP)
|
||||
|| status.signal() == Some(libc::SIGABRT));
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
fn check_status(status: std::process::ExitStatus)
|
||||
{
|
||||
assert!(!status.success());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() > 1 && args[1] == "test" {
|
||||
foo();
|
||||
return;
|
||||
}
|
||||
|
||||
let mut p = Command::new(&args[0])
|
||||
.stdout(Stdio::piped())
|
||||
.stdin(Stdio::piped())
|
||||
.arg("test").output().unwrap();
|
||||
check_status(p.status);
|
||||
}
|
||||
|
|
@ -46,13 +46,13 @@ error: def-path(bar::<impl foo::Foo>::baz)
|
|||
LL | #[rustc_def_path]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$_$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17h92c563325b7ff21aE)
|
||||
error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$_$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17hf07584432cd4d8beE)
|
||||
--> $DIR/impl1.rs:62:13
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method::h92c563325b7ff21a)
|
||||
error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method::hf07584432cd4d8be)
|
||||
--> $DIR/impl1.rs:62:13
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue