Add feature gate checks
This commit is contained in:
parent
3ef863bfdf
commit
fee07534bb
5 changed files with 38 additions and 1 deletions
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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue