Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stabilize cfg_attr_multi #57332

Merged
merged 4 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/doc/unstable-book/src/language-features/cfg-attr-multi.md

This file was deleted.

25 changes: 2 additions & 23 deletions src/libsyntax/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use feature_gate::{
Features,
get_features,
GateIssue,
emit_feature_err,
};
use {fold, attr};
use ast;
Expand Down Expand Up @@ -94,13 +93,6 @@ impl<'a> StripUnconfigured<'a> {
return vec![attr];
}

let gate_cfg_attr_multi = if let Some(ref features) = self.features {
!features.cfg_attr_multi
} else {
false
};
let cfg_attr_span = attr.span;

let (cfg_predicate, expanded_attrs) = match attr.parse(self.sess, |parser| {
parser.expect(&token::OpenDelim(token::Paren))?;

Expand Down Expand Up @@ -130,21 +122,8 @@ impl<'a> StripUnconfigured<'a> {
// Check feature gate and lint on zero attributes in source. Even if the feature is gated,
// we still compute as if it wasn't, since the emitted error will stop compilation further
// along the compilation.
match (expanded_attrs.len(), gate_cfg_attr_multi) {
(0, false) => {
// FIXME: Emit unused attribute lint here.
},
(1, _) => {},
(_, true) => {
emit_feature_err(
self.sess,
"cfg_attr_multi",
cfg_attr_span,
GateIssue::Language,
"cfg_attr with zero or more than one attributes is experimental",
);
},
(_, false) => {}
if expanded_attrs.len() == 0 {
// FIXME: Emit unused attribute lint here.
}

if attr::cfg_matches(&cfg_predicate, self.sess, self.features) {
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,6 @@ declare_features! (
// Allows `impl Trait` in bindings (`let`, `const`, `static`).
(active, impl_trait_in_bindings, "1.30.0", Some(34511), None),

// `#[cfg_attr(predicate, multiple, attributes, here)]`
(active, cfg_attr_multi, "1.31.0", Some(54881), None),

// Allows `const _: TYPE = VALUE`.
(active, underscore_const_names, "1.31.0", Some(54912), None),

Expand Down Expand Up @@ -689,6 +686,8 @@ declare_features! (
(accepted, repr_packed, "1.33.0", Some(33158), None),
// Allows calling `const unsafe fn` inside `unsafe` blocks in `const fn` functions.
(accepted, min_const_unsafe_fn, "1.33.0", Some(55607), None),
// `#[cfg_attr(predicate, multiple, attributes, here)]`
(accepted, cfg_attr_multi, "1.33.0", Some(54881), None),
);

// If you change this, please modify `src/doc/unstable-book` as well. You must
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// compile-pass

#![warn(unused_must_use)]
#![feature(cfg_attr_multi)]

#[cfg_attr(any(), deprecated, must_use)]
struct Struct {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// compile-flags: --cfg broken

#![feature(cfg_attr_multi)]
#![crate_type = "lib"]
#![cfg_attr(broken, no_core, no_std)] //~ ERROR no_core is experimental

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: no_core is experimental (see issue #29639)
--> $DIR/cfg-attr-multi-invalid-1.rs:5:21
--> $DIR/cfg-attr-multi-invalid-1.rs:4:21
|
LL | #![cfg_attr(broken, no_core, no_std)] //~ ERROR no_core is experimental
| ^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// compile-flags: --cfg broken

#![feature(cfg_attr_multi)]
Centril marked this conversation as resolved.
Show resolved Hide resolved
#![crate_type = "lib"]
#![cfg_attr(broken, no_std, no_core)] //~ ERROR no_core is experimental

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: no_core is experimental (see issue #29639)
--> $DIR/cfg-attr-multi-invalid-2.rs:5:29
--> $DIR/cfg-attr-multi-invalid-2.rs:4:29
|
LL | #![cfg_attr(broken, no_std, no_core)] //~ ERROR no_core is experimental
| ^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/conditional-compilation/cfg-attr-multi-true.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// compile-pass

#![warn(unused_must_use)]
#![feature(cfg_attr_multi)]

#[cfg_attr(all(), deprecated, must_use)]
struct MustUseDeprecated {}
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
warning: use of deprecated item 'MustUseDeprecated'
--> $DIR/cfg-attr-multi-true.rs:13:6
--> $DIR/cfg-attr-multi-true.rs:12:6
|
LL | impl MustUseDeprecated { //~ warning: use of deprecated item
| ^^^^^^^^^^^^^^^^^
|
= note: #[warn(deprecated)] on by default

warning: use of deprecated item 'MustUseDeprecated'
--> $DIR/cfg-attr-multi-true.rs:20:5
--> $DIR/cfg-attr-multi-true.rs:19:5
|
LL | MustUseDeprecated::new(); //~ warning: use of deprecated item
| ^^^^^^^^^^^^^^^^^^^^^^

warning: use of deprecated item 'MustUseDeprecated'
--> $DIR/cfg-attr-multi-true.rs:14:17
--> $DIR/cfg-attr-multi-true.rs:13:17
|
LL | fn new() -> MustUseDeprecated { //~ warning: use of deprecated item
| ^^^^^^^^^^^^^^^^^

warning: use of deprecated item 'MustUseDeprecated'
--> $DIR/cfg-attr-multi-true.rs:15:9
--> $DIR/cfg-attr-multi-true.rs:14:9
|
LL | MustUseDeprecated {} //~ warning: use of deprecated item
| ^^^^^^^^^^^^^^^^^

warning: unused `MustUseDeprecated` that must be used
--> $DIR/cfg-attr-multi-true.rs:20:5
--> $DIR/cfg-attr-multi-true.rs:19:5
|
LL | MustUseDeprecated::new(); //~ warning: use of deprecated item
| ^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/conditional-compilation/cfg-attr-parse.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Parse `cfg_attr` with varying numbers of attributes and trailing commas

#![feature(cfg_attr_multi)]

// Completely empty `cfg_attr` input
#[cfg_attr()] //~ error: expected identifier, found `)`
struct NoConfigurationPredicate;
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/conditional-compilation/cfg-attr-parse.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
error: expected identifier, found `)`
--> $DIR/cfg-attr-parse.rs:6:12
--> $DIR/cfg-attr-parse.rs:4:12
|
LL | #[cfg_attr()] //~ error: expected identifier, found `)`
| ^ expected identifier

error: expected `,`, found `)`
--> $DIR/cfg-attr-parse.rs:10:17
--> $DIR/cfg-attr-parse.rs:8:17
|
LL | #[cfg_attr(all())] //~ error: expected `,`, found `)`
| ^ expected `,`

error: expected identifier, found `,`
--> $DIR/cfg-attr-parse.rs:18:18
--> $DIR/cfg-attr-parse.rs:16:18
|
LL | #[cfg_attr(all(),,)] //~ ERROR expected identifier
| ^ expected identifier

error: expected identifier, found `,`
--> $DIR/cfg-attr-parse.rs:30:28
--> $DIR/cfg-attr-parse.rs:28:28
|
LL | #[cfg_attr(all(), must_use,,)] //~ ERROR expected identifier
| ^ expected identifier

error: expected identifier, found `,`
--> $DIR/cfg-attr-parse.rs:42:40
--> $DIR/cfg-attr-parse.rs:40:40
|
LL | #[cfg_attr(all(), must_use, deprecated,,)] //~ ERROR expected identifier
| ^ expected identifier
Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.stderr

This file was deleted.

3 changes: 0 additions & 3 deletions src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.stderr

This file was deleted.

This file was deleted.

This file was deleted.