Commit e429bde
authored
Manually fulfill lint expectations for all unsafe blocks with metavars (rust-lang#14501)
Fixes rust-lang#14488
Context: the `macro_metavars_in_unsafe` lint looks for unsafe blocks
with a macro span that then contain expressions with a root context span
(which means that it is a macro with an unsafe block expanding a
metavariable inside). In order to avoid emitting a warning for every
single macro invocation, it will deduplicate the unsafe blocks by the
span in the macro.
This leads to the linked issue where because of the deduplicating and
removing unsafe blocks that all belong to the same unsafe block in the
macro, only one of the unsafe blocks will actually have its lint
expectation fulfilled. This PR fixes that by manually fulfilling all of
the unsafe blocks from all expansions before deduplicating them.
changelog: [`macro_metavars_in_unsafe`]: fix unfulfilled `#[expect]` if
macro is invoked multiple timesFile tree
2 files changed
+26
-1
lines changed- clippy_lints/src
- tests/ui-toml/macro_metavars_in_unsafe/default
2 files changed
+26
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
252 | 261 | | |
253 | 262 | | |
254 | 263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
254 | 264 | | |
255 | 265 | | |
256 | 266 | | |
| |||
271 | 281 | | |
272 | 282 | | |
273 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
274 | 290 | | |
0 commit comments