Skip to content

Commit 867da30

Browse files
committed
Avoid kw::Empty when dealing with rustc_allowed_through_unstable_modules.
The existing code produces `Some(kw::Empty)` for these invalid forms: - a non-name-value, e.g. `#[rustc_allowed_through_unstable_modules]` - a non-string arg, e.g. `#[rustc_allowed_through_unstable_modules = 3]` The new code avoids the `kw::Empty` and is a little shorter. It will produce `None` in those cases, which means E0789 won't be produced if the `stable` attribute is missing for these invalid forms. This doesn't matter, because these invalid forms will trigger an "malformed `rustc_allowed_through_unstable_modules` attribute" anyway.
1 parent e576d88 commit 867da30

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Diff for: compiler/rustc_attr_parsing/src/attributes/stability.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_attr_data_structures::{
55
StableSince, UnstableReason, VERSION_PLACEHOLDER,
66
};
77
use rustc_errors::ErrorGuaranteed;
8-
use rustc_span::{Span, Symbol, kw, sym};
8+
use rustc_span::{Span, Symbol, sym};
99

1010
use super::util::parse_version;
1111
use super::{AcceptMapping, AttributeParser, SingleAttributeParser};
@@ -61,11 +61,7 @@ impl AttributeParser for StabilityParser {
6161
}),
6262
(&[sym::rustc_allowed_through_unstable_modules], |this, cx, args| {
6363
reject_outside_std!(cx);
64-
this.allowed_through_unstable_modules =
65-
Some(match args.name_value().and_then(|i| i.value_as_str()) {
66-
Some(msg) => msg,
67-
None => kw::Empty,
68-
});
64+
this.allowed_through_unstable_modules = args.name_value().and_then(|i| i.value_as_str())
6965
}),
7066
];
7167

Diff for: compiler/rustc_error_codes/src/error_codes/E0789.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Erroneous code example:
1414
1515
#![unstable(feature = "foo_module", reason = "...", issue = "123")]
1616
17-
#[rustc_allowed_through_unstable_modules]
17+
#[rustc_allowed_through_unstable_modules = "deprecation message"]
1818
// #[stable(feature = "foo", since = "1.0")]
1919
struct Foo;
2020
// ^^^ error: `rustc_allowed_through_unstable_modules` attribute must be

0 commit comments

Comments
 (0)