about summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src/attributes/confusables.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-08-11 01:46:34 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-08-11 16:00:49 +0000
commit189f264926ff70b58c8907473de60766477e7dd6 (patch)
tree39ec2fed72b9826301c68bbc3ca4529e93e8aa14 /compiler/rustc_attr_parsing/src/attributes/confusables.rs
parent577166503aee7290e09374da21f4045c455acfd5 (diff)
downloadrust-189f264926ff70b58c8907473de60766477e7dd6.tar.gz
rust-189f264926ff70b58c8907473de60766477e7dd6.zip
Allow attr entries to declare list of alternatives for `List` and `NamedValueStr`
Modify `AttributeTemplate` to support list of alternatives for list and name value attribute styles.

Suggestions now provide more correct suggested code:

```
error[E0805]: malformed `used` attribute input
  --> $DIR/used_with_multi_args.rs:3:1
   |
LL | #[used(compiler, linker)]
   | ^^^^^^------------------^
   |       |
   |       expected a single argument here
   |
help: try changing it to one of the following valid forms of the attribute
   |
LL - #[used(compiler, linker)]
LL + #[used(compiler)]
   |
LL - #[used(compiler, linker)]
LL + #[used(linker)]
   |
LL - #[used(compiler, linker)]
LL + #[used]
   |
```

instead of the prior "masking" of the lack of this feature by suggesting pipe-separated lists:

```
error[E0805]: malformed `used` attribute input
  --> $DIR/used_with_multi_args.rs:3:1
   |
LL | #[used(compiler, linker)]
   | ^^^^^^------------------^
   |       |
   |       expected a single argument here
   |
help: try changing it to one of the following valid forms of the attribute
   |
LL - #[used(compiler, linker)]
LL + #[used(compiler|linker)]
   |
LL - #[used(compiler, linker)]
LL + #[used]
   |
```
Diffstat (limited to 'compiler/rustc_attr_parsing/src/attributes/confusables.rs')
-rw-r--r--compiler/rustc_attr_parsing/src/attributes/confusables.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_attr_parsing/src/attributes/confusables.rs b/compiler/rustc_attr_parsing/src/attributes/confusables.rs
index 7d24c89a6e8..edd22172ca2 100644
--- a/compiler/rustc_attr_parsing/src/attributes/confusables.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/confusables.rs
@@ -16,7 +16,7 @@ pub(crate) struct ConfusablesParser {
 impl<S: Stage> AttributeParser<S> for ConfusablesParser {
     const ATTRIBUTES: AcceptMapping<Self, S> = &[(
         &[sym::rustc_confusables],
-        template!(List: r#""name1", "name2", ..."#),
+        template!(List: &[r#""name1", "name2", ..."#]),
         |this, cx, args| {
             let Some(list) = args.list() else {
                 cx.expected_list(cx.attr_span);