Skip to content

Commit ce75405

Browse files
committed
Only suggest changing #[derive(mymacro)] to #[mymacro] for attribute macros
1 parent cbe3e14 commit ce75405

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

compiler/rustc_resolve/src/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
659659
if !path.span.from_expansion()
660660
&& kind == MacroKind::Derive
661661
&& !ext.macro_kinds().contains(MacroKinds::DERIVE)
662+
&& ext.macro_kinds().contains(MacroKinds::ATTR)
662663
{
663664
err.remove_surrounding_derive = Some(RemoveSurroundingDerive { span: path.span });
664665
err.add_as_non_derive = Some(AddAsNonDerive { macro_path: &path_str });

tests/ui/proc-macro/macro-namespace-reserved-2.stderr

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@ error: expected derive macro, found macro `crate::my_macro`
9595
|
9696
LL | #[derive(crate::my_macro)]
9797
| ^^^^^^^^^^^^^^^ not a derive macro
98-
|
99-
help: remove from the surrounding `derive()`
100-
--> $DIR/macro-namespace-reserved-2.rs:50:10
101-
|
102-
LL | #[derive(crate::my_macro)]
103-
| ^^^^^^^^^^^^^^^
104-
= help: add as non-Derive macro
105-
`#[crate::my_macro]`
10698

10799
error: cannot find macro `my_macro_attr` in this scope
108100
--> $DIR/macro-namespace-reserved-2.rs:28:5

0 commit comments

Comments
 (0)