You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
proc_macro_derive(attributes(path::to)) both does and doesn't work #55168
error[E0433]: failed to resolve. Use of undeclared type or module `well`
--> user\main.rs:3:3
|
3 | #[well::then]
| ^^^^ Use of undeclared type or module `well`
I would expect either for this to work or for #[proc_macro_derive(attributes(..))] to reject a path and only accept an ident, as specifying a path here doesn't work.
This may be an accidental regression from #50030, similarly to #53489.
This cannot work without significant work and introducing an entirely new entity into name resolution ("derive helper modules" or something), so #[proc_macro_derive(attributes(..))] needs to validate its arguments harder and reject non-identifier paths.
Actually, the derive macro itself could be able to introduce "tool modules" into scope (like rustfmt in rustfmt::skip, but not global to the whole crate). #[proc_macro_derive(Example, tools(example))] or something.
Right now this is almost trivial to add for "macro expanded" attribute targets, like the item itself, but some additional work is needed to support it for other targets, e.g. fields (as you can see #[rustfmt::skip] doesn't work on fields yet).
@petrochenkov Is there a reason we cannot let #[proc_macro_derive(Example, attributes(example::attr))] mean #[proc_macro_derive(Example, tools(example))] plus some validation for the ::attr part? handwave
From a user facing perspective at least, @shepmaster's #55168 (comment) example seems reasonable and "expected".
Activity
petrochenkov commentedon Oct 18, 2018
This may be an accidental regression from #50030, similarly to #53489.
This cannot work without significant work and introducing an entirely new entity into name resolution ("derive helper modules" or something), so
#[proc_macro_derive(attributes(..))]needs to validate its arguments harder and reject non-identifier paths.shepmaster commentedon Feb 27, 2019
I don't think you can do this, as these work for attributes within the type on stable 1.32:
petrochenkov commentedon Feb 27, 2019
Oh god.
If not reject, then issue a deprecation warning immediately.
Self-assigning, I should be able to fix it this weekend.
shepmaster commentedon Feb 27, 2019
Is there any suggested way to have my desired syntax of
petrochenkov commentedon Feb 27, 2019
@shepmaster
Not right now, but something like #57921 may help.
Actually, the derive macro itself could be able to introduce "tool modules" into scope (like
rustfmtinrustfmt::skip, but not global to the whole crate).#[proc_macro_derive(Example, tools(example))]or something.Right now this is almost trivial to add for "macro expanded" attribute targets, like the item itself, but some additional work is needed to support it for other targets, e.g. fields (as you can see
#[rustfmt::skip]doesn't work on fields yet).Centril commentedon Feb 28, 2019
@petrochenkov Is there a reason we cannot let
#[proc_macro_derive(Example, attributes(example::attr))]mean#[proc_macro_derive(Example, tools(example))]plus some validation for the::attrpart? handwaveFrom a user facing perspective at least, @shepmaster's #55168 (comment) example seems reasonable and "expected".
petrochenkov commentedon Mar 3, 2019
Fixed in #58899
I'd prefer to see crater results first.
Rollup merge of rust-lang#58899 - petrochenkov:derval2, r=estebank
Rollup merge of rust-lang#58899 - petrochenkov:derval2, r=estebank