diff options
| -rw-r--r-- | compiler/rustc_resolve/src/macros.rs | 12 | ||||
| -rw-r--r-- | tests/ui/macros/macro-path-prelude-fail-4.stderr | 12 | ||||
| -rw-r--r-- | tests/ui/proc-macro/macro-namespace-reserved-2.stderr | 24 | ||||
| -rw-r--r-- | tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr | 12 |
4 files changed, 27 insertions, 33 deletions
diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 38e8cf8cd2f..082c051e21e 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -549,15 +549,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { err.span_label(path.span, format!("not {} {}", article, expected)); if kind == MacroKind::Derive && ext.macro_kind() != MacroKind::Derive { - // Suggest removing the derive() as the macro isn't Derive - let opening_span = - path.span.shrink_to_lo().with_lo(path.span.lo() - rustc_span::BytePos(7)); - let closing_span = - path.span.shrink_to_hi().with_hi(path.span.hi() + rustc_span::BytePos(1)); - err.span_help( - vec![opening_span, closing_span], - "remove the surrounding \"derive()\":", - ); + // Suggest moving the macro our of the derive() as the macro isn't Derive + err.span_help(path.span, "Remove from the surrounding `derive()`"); + err.help(format!("Add as non-Derive macro\n`#[{}]`", path_str)); } err.emit(); diff --git a/tests/ui/macros/macro-path-prelude-fail-4.stderr b/tests/ui/macros/macro-path-prelude-fail-4.stderr index fb4e19d8565..cefe655b0f7 100644 --- a/tests/ui/macros/macro-path-prelude-fail-4.stderr +++ b/tests/ui/macros/macro-path-prelude-fail-4.stderr @@ -2,13 +2,13 @@ error: expected derive macro, found built-in attribute `inline` --> $DIR/macro-path-prelude-fail-4.rs:1:10 | LL | #[derive(inline)] - | ^^^^^^ not a derive macro + | ^^^^^^ + | | + | not a derive macro + | help: Remove from the surrounding `derive()` | -help: remove the surrounding "derive()": - --> $DIR/macro-path-prelude-fail-4.rs:1:3 - | -LL | #[derive(inline)] - | ^^^^^^^ ^ + = help: Add as non-Derive macro + `#[inline]` error: aborting due to previous error diff --git a/tests/ui/proc-macro/macro-namespace-reserved-2.stderr b/tests/ui/proc-macro/macro-namespace-reserved-2.stderr index 6e7adc2e3b1..01814a30237 100644 --- a/tests/ui/proc-macro/macro-namespace-reserved-2.stderr +++ b/tests/ui/proc-macro/macro-namespace-reserved-2.stderr @@ -56,13 +56,13 @@ error: expected derive macro, found attribute macro `my_macro_attr` --> $DIR/macro-namespace-reserved-2.rs:53:10 | LL | #[derive(my_macro_attr)] - | ^^^^^^^^^^^^^ not a derive macro - | -help: remove the surrounding "derive()": - --> $DIR/macro-namespace-reserved-2.rs:53:3 + | ^^^^^^^^^^^^^ + | | + | not a derive macro + | help: Remove from the surrounding `derive()` | -LL | #[derive(my_macro_attr)] - | ^^^^^^^ ^ + = help: Add as non-Derive macro + `#[my_macro_attr]` error: can't use a procedural macro from the same crate that defines it --> $DIR/macro-namespace-reserved-2.rs:56:10 @@ -92,13 +92,13 @@ error: expected derive macro, found macro `crate::my_macro` --> $DIR/macro-namespace-reserved-2.rs:50:10 | LL | #[derive(crate::my_macro)] - | ^^^^^^^^^^^^^^^ not a derive macro - | -help: remove the surrounding "derive()": - --> $DIR/macro-namespace-reserved-2.rs:50:3 + | ^^^^^^^^^^^^^^^ + | | + | not a derive macro + | help: Remove from the surrounding `derive()` | -LL | #[derive(crate::my_macro)] - | ^^^^^^^ ^ + = help: Add as non-Derive macro + `#[crate::my_macro]` error: cannot find macro `my_macro_attr` in this scope --> $DIR/macro-namespace-reserved-2.rs:28:5 diff --git a/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr b/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr index 6befa99f583..c1ed2618b2a 100644 --- a/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr +++ b/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr @@ -2,13 +2,13 @@ error: expected derive macro, found tool attribute `rustfmt::skip` --> $DIR/tool-attributes-misplaced-2.rs:1:10 | LL | #[derive(rustfmt::skip)] - | ^^^^^^^^^^^^^ not a derive macro + | ^^^^^^^^^^^^^ + | | + | not a derive macro + | help: Remove from the surrounding `derive()` | -help: remove the surrounding "derive()": - --> $DIR/tool-attributes-misplaced-2.rs:1:3 - | -LL | #[derive(rustfmt::skip)] - | ^^^^^^^ ^ + = help: Add as non-Derive macro + `#[rustfmt::skip]` error: expected macro, found tool attribute `rustfmt::skip` --> $DIR/tool-attributes-misplaced-2.rs:5:5 |
