Declare some unconst operations as unsafe in const fn
This commit is contained in:
parent
64afc6b517
commit
aedc3a51df
17 changed files with 187 additions and 98 deletions
|
|
@ -1,7 +1,11 @@
|
|||
// gate-test-const_raw_ptr_to_usize_cast
|
||||
|
||||
fn main() {
|
||||
const X: u32 = main as u32; //~ ERROR casting pointers to integers in constants is unstable
|
||||
const X: u32 = unsafe {
|
||||
main as u32 //~ ERROR casting pointers to integers in constants is unstable
|
||||
};
|
||||
const Y: u32 = 0;
|
||||
const Z: u32 = &Y as *const u32 as u32; //~ ERROR is unstable
|
||||
const Z: u32 = unsafe {
|
||||
&Y as *const u32 as u32 //~ ERROR is unstable
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
error[E0658]: casting pointers to integers in constants is unstable (see issue #51910)
|
||||
--> $DIR/cast-ptr-to-int-const.rs:4:20
|
||||
--> $DIR/cast-ptr-to-int-const.rs:5:9
|
||||
|
|
||||
LL | const X: u32 = main as u32; //~ ERROR casting pointers to integers in constants is unstable
|
||||
| ^^^^^^^^^^^
|
||||
LL | main as u32 //~ ERROR casting pointers to integers in constants is unstable
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: casting pointers to integers in constants is unstable (see issue #51910)
|
||||
--> $DIR/cast-ptr-to-int-const.rs:6:20
|
||||
--> $DIR/cast-ptr-to-int-const.rs:9:9
|
||||
|
|
||||
LL | const Z: u32 = &Y as *const u32 as u32; //~ ERROR is unstable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | &Y as *const u32 as u32 //~ ERROR is unstable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
fn main() {}
|
||||
|
||||
// unconst and bad, will thus error in miri
|
||||
const X: bool = &1 as *const i32 == &2 as *const i32; //~ ERROR any use of this value will cause
|
||||
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR any use of this
|
||||
// unconst and fine
|
||||
const X2: bool = 42 as *const i32 == 43 as *const i32;
|
||||
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
|
||||
// unconst and fine
|
||||
const Y: usize = 42usize as *const i32 as usize + 1;
|
||||
const Y: usize = unsafe { 42usize as *const i32 as usize + 1 };
|
||||
// unconst and bad, will thus error in miri
|
||||
const Y2: usize = &1 as *const i32 as usize + 1; //~ ERROR any use of this value will cause
|
||||
const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; //~ ERROR any use of this
|
||||
// unconst and fine
|
||||
const Z: i32 = unsafe { *(&1 as *const i32) };
|
||||
// unconst and bad, will thus error in miri
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
error: any use of this value will cause an error
|
||||
--> $DIR/const_raw_ptr_ops.rs:6:1
|
||||
|
|
||||
LL | const X: bool = &1 as *const i32 == &2 as *const i32; //~ ERROR any use of this value will cause
|
||||
| ^^^^^^^^^^^^^^^^------------------------------------^
|
||||
| |
|
||||
| "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
|
||||
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR any use of this
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^
|
||||
| |
|
||||
| "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_raw_ptr_ops.rs:12:1
|
||||
|
|
||||
LL | const Y2: usize = &1 as *const i32 as usize + 1; //~ ERROR any use of this value will cause
|
||||
| ^^^^^^^^^^^^^^^^^^-----------------------------^
|
||||
| |
|
||||
| "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
|
||||
LL | const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; //~ ERROR any use of this
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------^^^
|
||||
| |
|
||||
| "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_raw_ptr_ops.rs:16:1
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const fn cmp(x: fn(), y: fn()) -> bool { //~ ERROR function pointers in const fn are unstable
|
||||
x == y
|
||||
unsafe { x == y }
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -95,97 +95,109 @@ LL | const fn foo30(x: *const u32) -> usize { x as usize }
|
|||
| ^^^^^^^^^^
|
||||
|
||||
error: casting pointers to ints is unstable in const fn
|
||||
--> $DIR/min_const_fn.rs:94:42
|
||||
--> $DIR/min_const_fn.rs:94:63
|
||||
|
|
||||
LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: casting pointers to ints is unstable in const fn
|
||||
--> $DIR/min_const_fn.rs:96:42
|
||||
|
|
||||
LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: casting pointers to ints is unstable in const fn
|
||||
--> $DIR/min_const_fn.rs:98:63
|
||||
|
|
||||
LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:96:38
|
||||
--> $DIR/min_const_fn.rs:100:38
|
||||
|
|
||||
LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:98:29
|
||||
--> $DIR/min_const_fn.rs:102:29
|
||||
|
|
||||
LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:100:44
|
||||
--> $DIR/min_const_fn.rs:104:44
|
||||
|
|
||||
LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
|
||||
| ^^^^^^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:102:44
|
||||
--> $DIR/min_const_fn.rs:106:44
|
||||
|
|
||||
LL | const fn foo37(a: bool, b: bool) -> bool { a || b }
|
||||
| ^^^^^^
|
||||
|
||||
error: mutable references in const fn are unstable
|
||||
--> $DIR/min_const_fn.rs:104:14
|
||||
--> $DIR/min_const_fn.rs:108:14
|
||||
|
|
||||
LL | const fn inc(x: &mut i32) { *x += 1 }
|
||||
| ^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:109:6
|
||||
--> $DIR/min_const_fn.rs:113:6
|
||||
|
|
||||
LL | impl<T: std::fmt::Debug> Foo<T> {
|
||||
| ^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:114:6
|
||||
--> $DIR/min_const_fn.rs:118:6
|
||||
|
|
||||
LL | impl<T: std::fmt::Debug + Sized> Foo<T> {
|
||||
| ^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:119:6
|
||||
--> $DIR/min_const_fn.rs:123:6
|
||||
|
|
||||
LL | impl<T: Sync + Sized> Foo<T> {
|
||||
| ^
|
||||
|
||||
error: `impl Trait` in const fn is unstable
|
||||
--> $DIR/min_const_fn.rs:125:24
|
||||
--> $DIR/min_const_fn.rs:129:24
|
||||
|
|
||||
LL | const fn no_rpit2() -> AlanTuring<impl std::fmt::Debug> { AlanTuring(0) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:127:34
|
||||
--> $DIR/min_const_fn.rs:131:34
|
||||
|
|
||||
LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:129:22
|
||||
--> $DIR/min_const_fn.rs:133:22
|
||||
|
|
||||
LL | const fn no_apit(_x: impl std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized`
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `impl Trait` in const fn is unstable
|
||||
--> $DIR/min_const_fn.rs:130:23
|
||||
--> $DIR/min_const_fn.rs:134:23
|
||||
|
|
||||
LL | const fn no_rpit() -> impl std::fmt::Debug {} //~ ERROR `impl Trait` in const fn is unstable
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:131:23
|
||||
--> $DIR/min_const_fn.rs:135:23
|
||||
|
|
||||
LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized`
|
||||
| ^^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:132:32
|
||||
--> $DIR/min_const_fn.rs:136:32
|
||||
|
|
||||
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning[E0515]: cannot return reference to temporary value
|
||||
--> $DIR/min_const_fn.rs:132:63
|
||||
--> $DIR/min_const_fn.rs:136:63
|
||||
|
|
||||
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
|
||||
| ^--
|
||||
|
|
@ -197,24 +209,24 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
|
|||
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:137:41
|
||||
--> $DIR/min_const_fn.rs:141:41
|
||||
|
|
||||
LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: function pointers in const fn are unstable
|
||||
--> $DIR/min_const_fn.rs:140:21
|
||||
--> $DIR/min_const_fn.rs:144:21
|
||||
|
|
||||
LL | const fn no_fn_ptrs(_x: fn()) {}
|
||||
| ^^
|
||||
|
||||
error: function pointers in const fn are unstable
|
||||
--> $DIR/min_const_fn.rs:142:27
|
||||
--> $DIR/min_const_fn.rs:146:27
|
||||
|
|
||||
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 34 previous errors
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
Some errors occurred: E0493, E0515.
|
||||
For more information about an error, try `rustc --explain E0493`.
|
||||
|
|
|
|||
|
|
@ -90,9 +90,13 @@ static BAR: u32 = 42;
|
|||
const fn foo25() -> u32 { BAR } //~ ERROR cannot access `static` items in const fn
|
||||
const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot access `static` items
|
||||
const fn foo30(x: *const u32) -> usize { x as usize }
|
||||
//~^ ERROR casting pointers to int
|
||||
//~^ ERROR casting pointers to ints is unstable
|
||||
const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
|
||||
//~^ ERROR casting pointers to ints is unstable
|
||||
const fn foo30_2(x: *mut u32) -> usize { x as usize }
|
||||
//~^ ERROR casting pointers to int
|
||||
//~^ ERROR casting pointers to ints is unstable
|
||||
const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
|
||||
//~^ ERROR casting pointers to ints is unstable
|
||||
const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
|
||||
//~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn
|
||||
|
|
|
|||
|
|
@ -95,113 +95,125 @@ LL | const fn foo30(x: *const u32) -> usize { x as usize }
|
|||
| ^^^^^^^^^^
|
||||
|
||||
error: casting pointers to ints is unstable in const fn
|
||||
--> $DIR/min_const_fn.rs:94:42
|
||||
--> $DIR/min_const_fn.rs:94:63
|
||||
|
|
||||
LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: casting pointers to ints is unstable in const fn
|
||||
--> $DIR/min_const_fn.rs:96:42
|
||||
|
|
||||
LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: casting pointers to ints is unstable in const fn
|
||||
--> $DIR/min_const_fn.rs:98:63
|
||||
|
|
||||
LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:96:38
|
||||
--> $DIR/min_const_fn.rs:100:38
|
||||
|
|
||||
LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:98:29
|
||||
--> $DIR/min_const_fn.rs:102:29
|
||||
|
|
||||
LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:100:44
|
||||
--> $DIR/min_const_fn.rs:104:44
|
||||
|
|
||||
LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
|
||||
| ^^^^^^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:102:44
|
||||
--> $DIR/min_const_fn.rs:106:44
|
||||
|
|
||||
LL | const fn foo37(a: bool, b: bool) -> bool { a || b }
|
||||
| ^^^^^^
|
||||
|
||||
error: mutable references in const fn are unstable
|
||||
--> $DIR/min_const_fn.rs:104:14
|
||||
--> $DIR/min_const_fn.rs:108:14
|
||||
|
|
||||
LL | const fn inc(x: &mut i32) { *x += 1 }
|
||||
| ^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:109:6
|
||||
--> $DIR/min_const_fn.rs:113:6
|
||||
|
|
||||
LL | impl<T: std::fmt::Debug> Foo<T> {
|
||||
| ^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:114:6
|
||||
--> $DIR/min_const_fn.rs:118:6
|
||||
|
|
||||
LL | impl<T: std::fmt::Debug + Sized> Foo<T> {
|
||||
| ^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:119:6
|
||||
--> $DIR/min_const_fn.rs:123:6
|
||||
|
|
||||
LL | impl<T: Sync + Sized> Foo<T> {
|
||||
| ^
|
||||
|
||||
error: `impl Trait` in const fn is unstable
|
||||
--> $DIR/min_const_fn.rs:125:24
|
||||
--> $DIR/min_const_fn.rs:129:24
|
||||
|
|
||||
LL | const fn no_rpit2() -> AlanTuring<impl std::fmt::Debug> { AlanTuring(0) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:127:34
|
||||
--> $DIR/min_const_fn.rs:131:34
|
||||
|
|
||||
LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:129:22
|
||||
--> $DIR/min_const_fn.rs:133:22
|
||||
|
|
||||
LL | const fn no_apit(_x: impl std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized`
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `impl Trait` in const fn is unstable
|
||||
--> $DIR/min_const_fn.rs:130:23
|
||||
--> $DIR/min_const_fn.rs:134:23
|
||||
|
|
||||
LL | const fn no_rpit() -> impl std::fmt::Debug {} //~ ERROR `impl Trait` in const fn is unstable
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:131:23
|
||||
--> $DIR/min_const_fn.rs:135:23
|
||||
|
|
||||
LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized`
|
||||
| ^^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:132:32
|
||||
--> $DIR/min_const_fn.rs:136:32
|
||||
|
|
||||
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait bounds other than `Sized` on const fn parameters are unstable
|
||||
--> $DIR/min_const_fn.rs:137:41
|
||||
--> $DIR/min_const_fn.rs:141:41
|
||||
|
|
||||
LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: function pointers in const fn are unstable
|
||||
--> $DIR/min_const_fn.rs:140:21
|
||||
--> $DIR/min_const_fn.rs:144:21
|
||||
|
|
||||
LL | const fn no_fn_ptrs(_x: fn()) {}
|
||||
| ^^
|
||||
|
||||
error: function pointers in const fn are unstable
|
||||
--> $DIR/min_const_fn.rs:142:27
|
||||
--> $DIR/min_const_fn.rs:146:27
|
||||
|
|
||||
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 34 previous errors
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0493`.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
static FOO: i32 = 42;
|
||||
static BAR: i32 = 42;
|
||||
|
||||
static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR issue #53020
|
||||
static BAZ: bool = unsafe { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR issue #53020
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0658]: comparing raw pointers inside static (see issue #53020)
|
||||
--> $DIR/E0395.rs:6:22
|
||||
--> $DIR/E0395.rs:6:29
|
||||
|
|
||||
LL | static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR issue #53020
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | static BAZ: bool = unsafe { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR issue #53020
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_compare_raw_pointers)] to the crate attributes to enable
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
static X: usize = 0 as *const usize as usize;
|
||||
static X: usize = unsafe { 0 as *const usize as usize };
|
||||
//~^ ERROR: casting pointers to integers in statics is unstable
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0658]: casting pointers to integers in statics is unstable (see issue #51910)
|
||||
--> $DIR/issue-17458.rs:1:19
|
||||
--> $DIR/issue-17458.rs:1:28
|
||||
|
|
||||
LL | static X: usize = 0 as *const usize as usize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | static X: usize = unsafe { 0 as *const usize as usize };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
fn main() {
|
||||
const X: u32 = 1;
|
||||
const Y: usize = &X as *const u32 as usize; //~ ERROR is unstable
|
||||
const Y: usize = unsafe { &X as *const u32 as usize }; //~ ERROR is unstable
|
||||
println!("{}", Y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0658]: casting pointers to integers in constants is unstable (see issue #51910)
|
||||
--> $DIR/issue-18294.rs:3:22
|
||||
--> $DIR/issue-18294.rs:3:31
|
||||
|
|
||||
LL | const Y: usize = &X as *const u32 as usize; //~ ERROR is unstable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | const Y: usize = unsafe { &X as *const u32 as usize }; //~ ERROR is unstable
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
fn id<T>(t: T) -> T { t }
|
||||
fn main() {
|
||||
const A: bool = id::<u8> as *const () < id::<u16> as *const ();
|
||||
const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
|
||||
//~^ ERROR comparing raw pointers inside constant
|
||||
println!("{}", A);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0658]: comparing raw pointers inside constant (see issue #53020)
|
||||
--> $DIR/issue-25826.rs:3:21
|
||||
--> $DIR/issue-25826.rs:3:30
|
||||
|
|
||||
LL | const A: bool = id::<u8> as *const () < id::<u16> as *const ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_compare_raw_pointers)] to the crate attributes to enable
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue