Skip to content

Commit 1385472

Browse files
committed
Rollup merge of rust-lang#24749 - lstat:feature-gate-22820, r=nrc
As part of the audit for rust-lang#22820 the following feature gate tests have been added: * `negate_unsigned` * `on_unimplemented` * `optin_builtin_traits` * `plugin` * `rustc_attrs` * `rustc_diagnostic_macros` * `slice_patterns` In addition some feature gate error message typos fixed.
2 parents c632bdc + 0cae315 commit 1385472

8 files changed

+142
-2
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ impl<'a> Context<'a> {
394394
are reserved for internal compiler diagnostics");
395395
} else if name.starts_with("derive_") {
396396
self.gate_feature("custom_derive", attr.span,
397-
"attributes of the form `#[derive_*]` are reserved
397+
"attributes of the form `#[derive_*]` are reserved \
398398
for the compiler");
399399
} else {
400400
self.gate_feature("custom_attribute", attr.span,
@@ -620,7 +620,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
620620
pattern.span,
621621
"multiple-element slice matches anywhere \
622622
but at the end of a slice (e.g. \
623-
`[0, ..xs, 0]` are experimental")
623+
`[0, ..xs, 0]`) are experimental")
624624
}
625625
ast::PatVec(..) => {
626626
self.gate_feature("slice_patterns",
Lines changed: 17 additions & 0 deletions
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() {}
Lines changed: 19 additions & 0 deletions
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() {}
Lines changed: 26 additions & 0 deletions
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() {}
Lines changed: 16 additions & 0 deletions
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() {}
Lines changed: 21 additions & 0 deletions
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() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 diagnostic macros are gated by `rustc_diagnostic_macros` feature
12+
// gate
13+
14+
__register_diagnostic!(E0001);
15+
//~^ ERROR macro undefined: '__register_diagnostic!'
16+
17+
fn main() {
18+
__diagnostic_used!(E0001);
19+
//~^ ERROR macro undefined: '__diagnostic_used!'
20+
}
21+
22+
__build_diagnostic_array!(DIAGNOSTICS);
23+
//~^ ERROR macro undefined: '__build_diagnostic_array!'
Lines changed: 18 additions & 0 deletions
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)