Improve suggestions for malformed deprecated attribute#157088
Open
ariagivens wants to merge 2 commits into
Open
Improve suggestions for malformed deprecated attribute#157088ariagivens wants to merge 2 commits into
ariagivens wants to merge 2 commits into
Conversation
Collaborator
|
Some changes occurred in compiler/rustc_attr_parsing |
Collaborator
|
r? @Kivooeo rustbot has assigned @Kivooeo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
JonathanBrouwer
approved these changes
May 29, 2026
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
May 29, 2026
…r=JonathanBrouwer
Improve suggestions for malformed deprecated attribute
When the deprecated attribute is supplied a single string as an argument, suggest using the NameValueStr syntax.
```
error[E0565]: malformed `deprecated` attribute input
--> $DIR/deprecation-sanity.rs:24:5
|
LL | #[deprecated("test")]
| ^^^^^^^^^^^^^------^^
| |
| didn't expect a literal here
|
help: try using `=` instead
|
LL - #[deprecated("test")]
LL + #[deprecated = "test"]
|
```
If the string looked like a version (e.g. `"1.2.3"` or `"TBD"`), suggest using the since field instead.
```
error[E0565]: malformed `deprecated` attribute input
--> $DIR/deprecation-sanity.rs:27:5
|
LL | #[deprecated("1.2.3")]
| ^^^^^^^^^^^^^-------^^
| |
| didn't expect a literal here
|
help: try specifying a deprecated since version
|
LL | #[deprecated(since = "1.2.3")]
| +++++++
```
rust-bors Bot
pushed a commit
that referenced
this pull request
May 29, 2026
…uwer Rollup of 9 pull requests Successful merges: - #156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - #157053 (Eagerly resolve delegations in late resolution) - #157068 (NVPTX: Remove the unstable ptx linker flavor) - #157076 (Various proc-macro related code cleanups) - #157100 (Some more per owner things) - #157065 (Stabilize `Path::is_empty`) - #157070 (Remove `skip_arg` attribute from `Diagnostic` and `Subdiagnostic` proc-macros) - #157088 (Improve suggestions for malformed deprecated attribute) - #157103 (Add reproducibly failing tests for parallel frontend)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
May 29, 2026
…r=JonathanBrouwer
Improve suggestions for malformed deprecated attribute
When the deprecated attribute is supplied a single string as an argument, suggest using the NameValueStr syntax.
```
error[E0565]: malformed `deprecated` attribute input
--> $DIR/deprecation-sanity.rs:24:5
|
LL | #[deprecated("test")]
| ^^^^^^^^^^^^^------^^
| |
| didn't expect a literal here
|
help: try using `=` instead
|
LL - #[deprecated("test")]
LL + #[deprecated = "test"]
|
```
If the string looked like a version (e.g. `"1.2.3"` or `"TBD"`), suggest using the since field instead.
```
error[E0565]: malformed `deprecated` attribute input
--> $DIR/deprecation-sanity.rs:27:5
|
LL | #[deprecated("1.2.3")]
| ^^^^^^^^^^^^^-------^^
| |
| didn't expect a literal here
|
help: try specifying a deprecated since version
|
LL | #[deprecated(since = "1.2.3")]
| +++++++
```
rust-bors Bot
pushed a commit
that referenced
this pull request
May 29, 2026
…uwer Rollup of 11 pull requests Successful merges: - #156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - #156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - #157053 (Eagerly resolve delegations in late resolution) - #157068 (NVPTX: Remove the unstable ptx linker flavor) - #157076 (Various proc-macro related code cleanups) - #157106 (add ABI check logic for wasm) - #154835 (std::offload sharedmem) - #157065 (Stabilize `Path::is_empty`) - #157070 (Remove `skip_arg` attribute from `Diagnostic` and `Subdiagnostic` proc-macros) - #157088 (Improve suggestions for malformed deprecated attribute) - #157103 (Add reproducibly failing tests for parallel frontend) Failed merges: - #157100 (Some more per owner things)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
May 29, 2026
…r=JonathanBrouwer
Improve suggestions for malformed deprecated attribute
When the deprecated attribute is supplied a single string as an argument, suggest using the NameValueStr syntax.
```
error[E0565]: malformed `deprecated` attribute input
--> $DIR/deprecation-sanity.rs:24:5
|
LL | #[deprecated("test")]
| ^^^^^^^^^^^^^------^^
| |
| didn't expect a literal here
|
help: try using `=` instead
|
LL - #[deprecated("test")]
LL + #[deprecated = "test"]
|
```
If the string looked like a version (e.g. `"1.2.3"` or `"TBD"`), suggest using the since field instead.
```
error[E0565]: malformed `deprecated` attribute input
--> $DIR/deprecation-sanity.rs:27:5
|
LL | #[deprecated("1.2.3")]
| ^^^^^^^^^^^^^-------^^
| |
| didn't expect a literal here
|
help: try specifying a deprecated since version
|
LL | #[deprecated(since = "1.2.3")]
| +++++++
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the deprecated attribute is supplied a single string as an argument, suggest using the NameValueStr syntax.
If the string looked like a version (e.g.
"1.2.3"or"TBD"), suggest using the since field instead.