Implement feature-gating for the compiler
A few features are now hidden behind various #[feature(...)] directives. These include struct-like enum variants, glob imports, and macro_rules! invocations. Closes #9304 Closes #9305 Closes #9306 Closes #9331
This commit is contained in:
parent
acf9783879
commit
dd98f7089f
15 changed files with 320 additions and 0 deletions
24
src/test/compile-fail/gated-bad-feature.rs
Normal file
24
src/test/compile-fail/gated-bad-feature.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2013 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(
|
||||
foo_bar_baz,
|
||||
foo(bar),
|
||||
foo = "baz"
|
||||
)];
|
||||
//~^^^^ ERROR: unknown feature
|
||||
//~^^^^ ERROR: malformed feature
|
||||
//~^^^^ ERROR: malformed feature
|
||||
|
||||
#[feature]; //~ ERROR: malformed feature
|
||||
#[feature = "foo"]; //~ ERROR: malformed feature
|
||||
|
||||
#[feature(test_removed_feature)]; //~ ERROR: feature has been removed
|
||||
#[feature(test_accepted_feature)]; //~ WARNING: feature has added
|
||||
14
src/test/compile-fail/gated-glob-imports.rs
Normal file
14
src/test/compile-fail/gated-glob-imports.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2013 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.
|
||||
|
||||
use std::*;
|
||||
//~^ ERROR: glob import statements are experimental
|
||||
|
||||
fn main() {}
|
||||
14
src/test/compile-fail/gated-macro-rules.rs
Normal file
14
src/test/compile-fail/gated-macro-rules.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2013 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.
|
||||
|
||||
macro_rules! foo(() => ())
|
||||
//~^ ERROR: macro definitions are not stable enough for use
|
||||
|
||||
fn main() {}
|
||||
15
src/test/compile-fail/gated-struct-enums.rs
Normal file
15
src/test/compile-fail/gated-struct-enums.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2013 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.
|
||||
|
||||
enum A { B { foo: int } }
|
||||
//~^ ERROR: enum struct variants are experimental
|
||||
|
||||
fn main() {}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue