Repository navigation
Commit 29a229c
authored
Rollup merge of #164181 - estebank:issue-57966, r=khyperia
Tweak output on unused/unaccessible local macro
In unused macro lint, mention when its enclosing `mod` isn't annotated with `#[macro_use]`:
```
error: unused macro definition: `unused`
--> $DIR/unused-macros-decl.rs:17:11
|
LL | macro unused {
| ^^^^^^
|
note: the lint level is defined here
--> $DIR/unused-macros-decl.rs:16:12
|
LL | #[deny(unused_macros)]
| ^^^^^^^^^^^^^
help: consider annotating the enclosing module with `#[macro_use]`
|
LL + #[macro_use]
LL | mod bar {
|
```
On resolution error for unexported macro, point at macro of the same name and mention its enclosing scope could be marked with `#[macro_use]`:
```
error: cannot find macro `a_macro` in this scope
--> $DIR/unresolved-macro-missing-macro-use.rs:11:5
|
LL | a_macro!();
| ^^^^^^^
|
help: you might be missing a `#[macro_use]` attribute on a `mod` module or `use` import
--> $DIR/unresolved-macro-missing-macro-use.rs:5:5
|
LL | / mod has_a_macro {
LL | |
LL | | macro_rules! a_macro { () => {} }
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a macro with the same name is defined here
... |
LL | | }
| |_- consider annotating this `mod` with `#[macro_use]`
```
On ambiguous macro use, suggest removing invalid import:
```
error[E0659]: `a_macro` is ambiguous
--> $DIR/unresolved-macro-missing-macro-use-3.rs:15:5
|
LL | a_macro!();
| ^^^^^^^ ambiguous name
|
= note: ambiguous because of a conflict between a `macro_rules` name and a non-`macro_rules` name from another module
note: `a_macro` could refer to the macro defined here
--> $DIR/unresolved-macro-missing-macro-use-3.rs:5:5
|
LL | macro_rules! a_macro { () => {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `a_macro` could also refer to the unresolved item imported here
--> $DIR/unresolved-macro-missing-macro-use-3.rs:9:5
|
LL | use crate::has_a_macro::a_macro;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: consider removing this
```
Fix #57966.17 files changed
Lines changed: 375 additions & 32 deletions
File tree
- compiler/rustc_resolve/src
- diagnostics
- tests/ui
- attributes
- imports
- lint/unused
- macros
- resolve
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1294 | 1294 | | |
1295 | 1295 | | |
1296 | 1296 | | |
1297 | | - | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
1298 | 1300 | | |
1299 | 1301 | | |
1300 | 1302 | | |
| |||
1333 | 1335 | | |
1334 | 1336 | | |
1335 | 1337 | | |
1336 | | - | |
| 1338 | + | |
1337 | 1339 | | |
1338 | 1340 | | |
1339 | 1341 | | |
| |||
1430 | 1432 | | |
1431 | 1433 | | |
1432 | 1434 | | |
| 1435 | + | |
1433 | 1436 | | |
1434 | 1437 | | |
1435 | 1438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2031 | 2031 | | |
2032 | 2032 | | |
2033 | 2033 | | |
2034 | | - | |
| 2034 | + | |
2035 | 2035 | | |
2036 | 2036 | | |
2037 | 2037 | | |
| |||
2166 | 2166 | | |
2167 | 2167 | | |
2168 | 2168 | | |
2169 | | - | |
2170 | | - | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
2171 | 2184 | | |
2172 | 2185 | | |
2173 | 2186 | | |
| |||
2439 | 2452 | | |
2440 | 2453 | | |
2441 | 2454 | | |
2442 | | - | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
2443 | 2458 | | |
2444 | 2459 | | |
2445 | 2460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
773 | | - | |
774 | | - | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
775 | 778 | | |
776 | 779 | | |
777 | 780 | | |
| |||
1472 | 1475 | | |
1473 | 1476 | | |
1474 | 1477 | | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
1475 | 1486 | | |
1476 | 1487 | | |
1477 | 1488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1445 | 1445 | | |
1446 | 1446 | | |
1447 | 1447 | | |
1448 | | - | |
| 1448 | + | |
1449 | 1449 | | |
1450 | 1450 | | |
1451 | 1451 | | |
| |||
1459 | 1459 | | |
1460 | 1460 | | |
1461 | 1461 | | |
1462 | | - | |
| 1462 | + | |
| 1463 | + | |
1463 | 1464 | | |
1464 | 1465 | | |
1465 | 1466 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
370 | 384 | | |
371 | 385 | | |
372 | 386 | | |
373 | 387 | | |
374 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
375 | 393 | | |
376 | 394 | | |
377 | 395 | | |
| |||
0 commit comments