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.
This commit is contained in:
Nicholas Nethercote 2025-03-25 15:50:31 +11:00
parent e576d8850d
commit 867da30cc7
2 changed files with 3 additions and 7 deletions

View file

@ -14,7 +14,7 @@ Erroneous code example:
#![unstable(feature = "foo_module", reason = "...", issue = "123")]
#[rustc_allowed_through_unstable_modules]
#[rustc_allowed_through_unstable_modules = "deprecation message"]
// #[stable(feature = "foo", since = "1.0")]
struct Foo;
// ^^^ error: `rustc_allowed_through_unstable_modules` attribute must be