Skip to content

Commit 03ff281

Browse files
committed
Add feature gate tests
As part of the audit for #22820 the following feature gate tests have been added: * `negate_unsigned` * `on_unimplemented` * `optin_builtin_traits` * `plugin` * `rustc_attrs` * `slice_patterns`
1 parent 12e30f7 commit 03ff281

6 files changed

+117
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that negating unsigned integers is gated by `negate_unsigned` feature
12+
// gate
13+
14+
const MAX: usize = -1;
15+
//~^ ERROR unary negation of unsigned integers may be removed in the future
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that `#[rustc_on_unimplemented]` is gated by `on_unimplemented` feature
12+
// gate.
13+
14+
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}`"]
15+
//~^ ERROR the `#[rustc_on_unimplemented]` attribute is an experimental feature
16+
trait Foo<Bar>
17+
{}
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that default and negative trait implementations are gated by
12+
// `optin_builtin_traits` feature gate
13+
14+
struct DummyStruct;
15+
16+
trait DummyTrait {
17+
fn dummy(&self) {}
18+
}
19+
20+
impl DummyTrait for .. {}
21+
//~^ ERROR default trait implementations are experimental and possibly buggy
22+
23+
impl !DummyTrait for DummyStruct {}
24+
//~^ ERROR negative trait bounds are not yet fully implemented; use marker types for now
25+
26+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that `#![plugin(...)]` attribute is gated by `plugin` feature gate
12+
13+
#![plugin(foo)]
14+
//~^ ERROR compiler plugins are experimental and possibly buggy
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-tidy-linelength
12+
13+
// Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate.
14+
15+
#[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is an experimental feature
16+
#[rustc_error] //~ ERROR the `#[rustc_error]` attribute is an experimental feature
17+
#[rustc_move_fragments] //~ ERROR the `#[rustc_move_fragments]` attribute is an experimental feature
18+
#[rustc_foo]
19+
//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics
20+
21+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that slice pattern syntax is gated by `slice_patterns` feature gate
12+
13+
fn main() {
14+
let x = [1, 2, 3, 4, 5];
15+
match x {
16+
[1, 2, xs..] => {} //~ ERROR slice pattern syntax is experimental
17+
}
18+
}

0 commit comments

Comments
 (0)