stabilise cfg_attr
This commit is contained in:
parent
21ac19d8fe
commit
1ef99f1353
@ -1,20 +0,0 @@
|
||||
# `cfg_attr_multi`
|
||||
|
||||
The tracking issue for this feature is: [#54881]
|
||||
The RFC for this feature is: [#2539]
|
||||
|
||||
[#54881]: https://github.com/rust-lang/rust/issues/54881
|
||||
[#2539]: https://github.com/rust-lang/rfcs/pull/2539
|
||||
|
||||
------------------------
|
||||
|
||||
This feature flag lets you put multiple attributes into a `cfg_attr` attribute.
|
||||
|
||||
Example:
|
||||
|
||||
```rust,ignore
|
||||
#[cfg_attr(all(), must_use, optimize)]
|
||||
```
|
||||
|
||||
Because `cfg_attr` resolves before procedural macros, this does not affect
|
||||
macro resolution at all.
|
@ -94,11 +94,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| {
|
||||
@ -130,21 +125,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) {
|
||||
|
@ -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),
|
||||
|
||||
@ -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
|
||||
|
@ -4,7 +4,7 @@
|
||||
// compile-pass
|
||||
|
||||
#![warn(unused_must_use)]
|
||||
#![feature(cfg_attr_multi)]
|
||||
#![cfg_attr(stage0, feature(cfg_attr_multi))]
|
||||
|
||||
#[cfg_attr(any(), deprecated, must_use)]
|
||||
struct Struct {}
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
// compile-flags: --cfg broken
|
||||
|
||||
#![feature(cfg_attr_multi)]
|
||||
#![crate_type = "lib"]
|
||||
#![cfg_attr(broken, no_std, no_core)] //~ ERROR no_core is experimental
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
// compile-pass
|
||||
|
||||
#![warn(unused_must_use)]
|
||||
#![feature(cfg_attr_multi)]
|
||||
#![cfg_attr(stage0, feature(cfg_attr_multi))]
|
||||
|
||||
#[cfg_attr(all(), deprecated, must_use)]
|
||||
struct MustUseDeprecated {}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Parse `cfg_attr` with varying numbers of attributes and trailing commas
|
||||
|
||||
#![feature(cfg_attr_multi)]
|
||||
#![cfg_attr(stage0, feature(cfg_attr_multi))]
|
||||
|
||||
// Completely empty `cfg_attr` input
|
||||
#[cfg_attr()] //~ error: expected identifier, found `)`
|
||||
|
@ -1,5 +0,0 @@
|
||||
// gate-test-cfg_attr_multi
|
||||
|
||||
#![cfg_attr(all(), warn(nonstandard_style), allow(unused_attributes))]
|
||||
//~^ ERROR cfg_attr with zero or more than one attributes is experimental
|
||||
fn main() {}
|
@ -1,11 +0,0 @@
|
||||
error[E0658]: cfg_attr with zero or more than one attributes is experimental (see issue #54881)
|
||||
--> $DIR/feature-gate-cfg-attr-multi-1.rs:3:1
|
||||
|
|
||||
LL | #![cfg_attr(all(), warn(nonstandard_style), allow(unused_attributes))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(cfg_attr_multi)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -1,3 +0,0 @@
|
||||
#![cfg_attr(all(),)]
|
||||
//~^ ERROR cfg_attr with zero or more than one attributes is experimental
|
||||
fn main() {}
|
@ -1,11 +0,0 @@
|
||||
error[E0658]: cfg_attr with zero or more than one attributes is experimental (see issue #54881)
|
||||
--> $DIR/feature-gate-cfg-attr-multi-2.rs:1:1
|
||||
|
|
||||
LL | #![cfg_attr(all(),)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(cfg_attr_multi)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -1,7 +0,0 @@
|
||||
// Test that settingt the featute gate while using its functionality doesn't error.
|
||||
|
||||
// compile-pass
|
||||
|
||||
#![cfg_attr(all(), feature(cfg_attr_multi), crate_type="bin")]
|
||||
|
||||
fn main() {}
|
@ -1,9 +0,0 @@
|
||||
// Test that settingt the featute gate while using its functionality doesn't error.
|
||||
// Specifically, if there's a cfg-attr *before* the feature gate.
|
||||
|
||||
// compile-pass
|
||||
|
||||
#![cfg_attr(all(),)]
|
||||
#![cfg_attr(all(), feature(cfg_attr_multi), crate_type="bin")]
|
||||
|
||||
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user