Commit b821fd2
authored
Rollup merge of #157088 - ariagivens:deprecated-attr-forms, 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")]
| +++++++
```4 files changed
Lines changed: 83 additions & 15 deletions
File tree
- compiler/rustc_attr_parsing/src/attributes
- tests/ui
- deprecation
- error-codes
Lines changed: 50 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
79 | 112 | | |
80 | 113 | | |
81 | 114 | | |
| |||
133 | 166 | | |
134 | 167 | | |
135 | 168 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 169 | + | |
| 170 | + | |
145 | 171 | | |
146 | | - | |
147 | 172 | | |
| 173 | + | |
148 | 174 | | |
149 | 175 | | |
150 | 176 | | |
| |||
163 | 189 | | |
164 | 190 | | |
165 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
58 | 77 | | |
59 | 78 | | |
60 | | - | |
| 79 | + | |
61 | 80 | | |
62 | 81 | | |
63 | 82 | | |
64 | 83 | | |
65 | 84 | | |
66 | | - | |
| 85 | + | |
67 | 86 | | |
68 | 87 | | |
69 | 88 | | |
70 | 89 | | |
71 | 90 | | |
72 | | - | |
| 91 | + | |
73 | 92 | | |
74 | 93 | | |
75 | 94 | | |
76 | 95 | | |
77 | 96 | | |
78 | 97 | | |
79 | 98 | | |
80 | | - | |
| 99 | + | |
81 | 100 | | |
82 | 101 | | |
83 | 102 | | |
| |||
86 | 105 | | |
87 | 106 | | |
88 | 107 | | |
89 | | - | |
| 108 | + | |
90 | 109 | | |
91 | 110 | | |
92 | 111 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | 15 | | |
10 | 16 | | |
| |||
0 commit comments