1
Fork 0

Auto merge of #109638 - NotStirred:suggest/non-derive, r=davidtwco

Add suggestion to remove `derive()` if invoked macro is non-derive

Adds to the existing `expected derive macro, found {}` error message:
```
help: remove the surrounding "derive()":
  --> $DIR/macro-path-prelude-fail-4.rs:1:3
   |
LL | #[derive(inline)]
   |   ^^^^^^^      ^
```

This suggestion will either fix the issue, in the case that the macro was valid, or provide a better error message if not

Not ready for merge yet, as the highlighted span is only valid for trivial formatting. Is there a nice way to get the parent span of the macro path within `smart_resolve_macro_path`?

Closes #109589
This commit is contained in:
bors 2023-04-10 21:50:46 +00:00
commit 194a0bb5d6
8 changed files with 133 additions and 6 deletions

View file

@ -213,3 +213,13 @@ resolve_tool_module_imported =
resolve_module_only =
visibility must resolve to a module
resolve_macro_expected_found =
expected {$expected}, found {$found} `{$macro_path}`
resolve_remove_surrounding_derive =
remove from the surrounding `derive()`
resolve_add_as_non_derive =
add as non-Derive macro
`#[{$macro_path}]`