Auto merge of #52597 - oli-obk:promotion_simplify, r=nagisa
Promoteds are statics and statics have a place, not just a value r? @eddyb This makes everything around promoteds a little simpler
This commit is contained in:
commit
6a3db033ad
57 changed files with 376 additions and 585 deletions
|
|
@ -122,19 +122,15 @@ unsafe impl<'a, #[may_dangle] 'b> Drop for D1<'a, 'b> {
|
|||
// let mut _6: &'10s S1;
|
||||
// let mut _7: &'10s S1;
|
||||
// let mut _8: S1;
|
||||
// let mut _9: &'10s S1;
|
||||
// let mut _10: &'12ds S1;
|
||||
// bb0: {
|
||||
// StorageLive(_2);
|
||||
// StorageLive(_3);
|
||||
// StorageLive(_4);
|
||||
// _10 = promoted[1];
|
||||
// _4 = &'12ds (*_10);
|
||||
// _4 = &'12ds (promoted[1]: S1);
|
||||
// _3 = &'12ds (*_4);
|
||||
// StorageLive(_6);
|
||||
// StorageLive(_7);
|
||||
// _9 = promoted[0];
|
||||
// _7 = &'10s (*_9);
|
||||
// _7 = &'10s (promoted[0]: S1);
|
||||
// _6 = &'10s (*_7);
|
||||
// _2 = D1<'12ds, '10s>::{{constructor}}(move _3, move _6);
|
||||
// EndRegion('10s);
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ fn main() {
|
|||
// ...
|
||||
// _2 = std::option::Option<i32>::Some(const 42i32,);
|
||||
// _3 = discriminant(_2);
|
||||
// _14 = promoted[1];
|
||||
// _4 = &(*_14);
|
||||
// _4 = &(promoted[1]: std::option::Option<i32>);
|
||||
// _9 = discriminant(_2);
|
||||
// switchInt(move _9) -> [0isize: bb5, 1isize: bb3, otherwise: bb7];
|
||||
// }
|
||||
|
|
@ -86,8 +85,7 @@ fn main() {
|
|||
// }
|
||||
// bb8: { // binding1 and guard
|
||||
// StorageLive(_7);
|
||||
// _13 = promoted[0];
|
||||
// _7 = &(((*_13) as Some).0: i32);
|
||||
// _7 = &(((promoted[0]: std::option::Option<i32>) as Some).0: i32);
|
||||
// StorageLive(_10);
|
||||
// _10 = const guard() -> [return: bb9, unwind: bb1];
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -12,21 +12,6 @@ note: lint level defined here
|
|||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: referenced constant has errors
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ----- attempt to subtract with overflow
|
||||
...
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/conditional_array_execution.rs:19:14
|
||||
|
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
|||
|
||||
fn main() {
|
||||
println!("{}", FOO);
|
||||
//~^ WARN this expression will panic at runtime
|
||||
//~| WARN referenced constant
|
||||
//~| ERROR erroneous constant used
|
||||
//~^ ERROR erroneous constant used
|
||||
//~| E0080
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,21 +12,6 @@ note: lint level defined here
|
|||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: referenced constant has errors
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ----- attempt to subtract with overflow
|
||||
...
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
|
|
|
|||
|
|
@ -20,36 +20,6 @@ LL | const Y: u32 = foo(0-1);
|
|||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
||||
warning: referenced constant has errors
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| --- attempt to subtract with overflow
|
||||
...
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
warning: referenced constant has errors
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| --- attempt to subtract with overflow
|
||||
LL | //~^ WARN this constant cannot be used
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/issue-43197.rs:24:14
|
||||
|
|
||||
|
|
|
|||
|
|
@ -22,12 +22,8 @@ fn main() {
|
|||
const Y: u32 = foo(0-1);
|
||||
//~^ WARN this constant cannot be used
|
||||
println!("{} {}", X, Y);
|
||||
//~^ WARN this expression will panic at runtime
|
||||
//~| WARN this expression will panic at runtime
|
||||
//~| ERROR erroneous constant used
|
||||
//~^ ERROR erroneous constant used
|
||||
//~| ERROR erroneous constant used
|
||||
//~| ERROR E0080
|
||||
//~| ERROR E0080
|
||||
//~| WARN referenced constant
|
||||
//~| WARN referenced constant
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,36 +20,6 @@ LL | const Y: u32 = foo(0-1);
|
|||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
||||
warning: referenced constant has errors
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| --- attempt to subtract with overflow
|
||||
...
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
warning: referenced constant has errors
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| --- attempt to subtract with overflow
|
||||
LL | //~^ WARN this constant cannot be used
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-pass
|
||||
|
||||
#![feature(const_fn)]
|
||||
|
||||
#![deny(const_err)]
|
||||
|
|
@ -23,15 +25,13 @@ const fn bar() -> u8 {
|
|||
// is run on a system whose pointers need more
|
||||
// than 8 bits
|
||||
Bar { a: &42 }.b as u8
|
||||
//~^ ERROR this expression will panic at runtime
|
||||
//~| ERROR this expression will panic at runtime
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// FIXME(oli-obk): this should compile but panic at runtime
|
||||
// if we change the `const_err` lint to allow this will actually compile, but then
|
||||
// continue with undefined values.
|
||||
// FIXME(oli-obk): this should panic at runtime
|
||||
// this will actually compile, but then
|
||||
// abort at runtime (not panic, hard abort).
|
||||
let x: &'static u8 = &(bar() + 1);
|
||||
let y = *x;
|
||||
unreachable!();
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
error: this expression will panic at runtime
|
||||
--> $DIR/promoted_const_fn_fail.rs:25:9
|
||||
|
|
||||
LL | Bar { a: &42 }.b as u8
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/promoted_const_fn_fail.rs:13:9
|
||||
|
|
||||
LL | #![deny(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/promoted_const_fn_fail.rs:25:9
|
||||
|
|
||||
LL | Bar { a: &42 }.b as u8
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -18,13 +18,11 @@ fn main() {
|
|||
//~^ WARN const_err
|
||||
println!("{}", 1/(1-1));
|
||||
//~^ WARN const_err
|
||||
//~| WARN const_err
|
||||
let _x = 1/(1-1);
|
||||
//~^ WARN const_err
|
||||
//~| WARN const_err
|
||||
println!("{}", 1/(false as u32));
|
||||
//~^ WARN const_err
|
||||
//~| WARN const_err
|
||||
let _x = 1/(false as u32);
|
||||
//~^ WARN const_err
|
||||
//~| WARN const_err
|
||||
|
|
|
|||
|
|
@ -16,44 +16,32 @@ warning: attempt to divide by zero
|
|||
LL | println!("{}", 1/(1-1));
|
||||
| ^^^^^^^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:19:20
|
||||
|
|
||||
LL | println!("{}", 1/(1-1));
|
||||
| ^^^^^^^ attempt to divide by zero
|
||||
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:22:14
|
||||
--> $DIR/promoted_errors.rs:21:14
|
||||
|
|
||||
LL | let _x = 1/(1-1);
|
||||
| ^^^^^^^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:22:14
|
||||
--> $DIR/promoted_errors.rs:21:14
|
||||
|
|
||||
LL | let _x = 1/(1-1);
|
||||
| ^^^^^^^ attempt to divide by zero
|
||||
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:25:20
|
||||
--> $DIR/promoted_errors.rs:24:20
|
||||
|
|
||||
LL | println!("{}", 1/(false as u32));
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:25:20
|
||||
|
|
||||
LL | println!("{}", 1/(false as u32));
|
||||
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
|
||||
|
||||
warning: attempt to divide by zero
|
||||
--> $DIR/promoted_errors.rs:28:14
|
||||
--> $DIR/promoted_errors.rs:26:14
|
||||
|
|
||||
LL | let _x = 1/(false as u32);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/promoted_errors.rs:28:14
|
||||
--> $DIR/promoted_errors.rs:26:14
|
||||
|
|
||||
LL | let _x = 1/(false as u32);
|
||||
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue