-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Tweak invalid builtin attribute output #145238
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
base: master
Are you sure you want to change the base?
Conversation
estebank
commented
Aug 11, 2025
- Add link to reference/docs when possible
- More accurate suggestions by supporting multiple alternative suggestions
Some changes occurred in compiler/rustc_attr_parsing This PR modifies |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a good change, just gotta fix the CI :)
@@ -298,35 +298,42 @@ fn emit_malformed_attribute( | |||
suggestions.push(format!("#{inner}[{name}]")); | |||
} | |||
if let Some(descr) = template.list { | |||
suggestions.push(format!("#{inner}[{name}({descr})]")); | |||
for descr in descr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this code will disappear soon, still a good change for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most malformed attr errors are now emitted here: https://github.com/rust-lang/rust/pull/145238/files#diff-1e3857964b49daddd7568a3cc24d19c769660f5cb79accecbe72495c1da7eb02L693. Does this PR also improve those diagnostics? I'm not entirely sure it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does because of the change to AttributeTemplate::suggestions
in https://github.com/rust-lang/rust/pull/145238/files#diff-09c366d3ad3ec9a42125253b610ca83cad6b156aa2a723f6c7e83eddef7b1e8fR135-R152 (compiler/rustc_feature/src/builtin_attrs.rs:142
)
…medValueStr` 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] | ```
c8a9206
to
413ca5d
Compare
r=me on green CI |
This comment has been minimized.
This comment has been minimized.
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
@bors r=jdonszelmann |