Add feature gate checks
This commit is contained in:
parent
3ef863bfdf
commit
fee07534bb
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// 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 Y: u32 = 0;
|
||||
|
22
src/test/ui/const-eval/feature-gate-const_fn_union.rs
Normal file
22
src/test/ui/const-eval/feature-gate-const_fn_union.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(const_fn)]
|
||||
|
||||
fn main() {}
|
||||
|
||||
union Foo {
|
||||
u: u32,
|
||||
i: i32,
|
||||
}
|
||||
|
||||
const unsafe fn foo(u: u32) -> i32 {
|
||||
Foo { u }.i //~ ERROR unions in const fn are unstable
|
||||
}
|
11
src/test/ui/const-eval/feature-gate-const_fn_union.stderr
Normal file
11
src/test/ui/const-eval/feature-gate-const_fn_union.stderr
Normal file
@ -0,0 +1,11 @@
|
||||
error[E0658]: unions in const fn are unstable (see issue #51909)
|
||||
--> $DIR/feature-gate-const_fn_union.rs:21:5
|
||||
|
|
||||
LL | Foo { u }.i //~ ERROR unions in const fn are unstable
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_fn_union)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// gate-test-const_raw_ptr_deref
|
||||
|
||||
const REG_ADDR: *const u8 = 0x5f3759df as *const u8;
|
||||
|
||||
const VALUE: u8 = unsafe { *REG_ADDR };
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0658]: dereferencing raw pointers in constants is unstable (see issue #51911)
|
||||
--> $DIR/E0396.rs:13:28
|
||||
--> $DIR/E0396.rs:15:28
|
||||
|
|
||||
LL | const VALUE: u8 = unsafe { *REG_ADDR };
|
||||
| ^^^^^^^^^
|
||||
|
Loading…
x
Reference in New Issue
Block a user