Only suggest changing #[derive(mymacro)] to #[mymacro] for attribute macros

This commit is contained in:
Josh Triplett 2025-08-08 21:36:17 -07:00
parent d7b30bef7e
commit c81fcaca1c
2 changed files with 1 additions and 8 deletions

View file

@ -659,6 +659,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
if !path.span.from_expansion()
&& kind == MacroKind::Derive
&& !ext.macro_kinds().contains(MacroKinds::DERIVE)
&& ext.macro_kinds().contains(MacroKinds::ATTR)
{
err.remove_surrounding_derive = Some(RemoveSurroundingDerive { span: path.span });
err.add_as_non_derive = Some(AddAsNonDerive { macro_path: &path_str });

View file

@ -95,14 +95,6 @@ error: expected derive macro, found macro `crate::my_macro`
|
LL | #[derive(crate::my_macro)]
| ^^^^^^^^^^^^^^^ not a derive macro
|
help: remove from the surrounding `derive()`
--> $DIR/macro-namespace-reserved-2.rs:50:10
|
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