Add feature gate checks

This commit is contained in:
Oliver Schneider 2018-07-02 19:59:39 +02:00
parent 3ef863bfdf
commit fee07534bb
5 changed files with 38 additions and 1 deletions

View File

@ -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;

View 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
}

View 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`.

View File

@ -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 };

View File

@ -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 };
| ^^^^^^^^^