Expand derive macros in the MacroExpander#39442
Conversation
|
r? @jseyfried |
src/librustc_resolve/macros.rs
Outdated
There was a problem hiding this comment.
Can you just the original path here directly?
Eventually we'll allow e.g. #![derive(foo::bar)].
path.segments[0].identifier.name would also work for now, but I see no reason to collect a path: Vec<_>.
There was a problem hiding this comment.
Also, how about "cannot find derive macro {} in this scope"?
c.f. this error
79db0dc to
a3d0d48
Compare
src/libsyntax/ext/derive.rs
Outdated
There was a problem hiding this comment.
Could we switch the order here (i.e. ProcMacro first, then add_derived_markers/Builtin) for back-compat?
Since we want the input of proc macro derives to be fully expanded, we'll want to move in the direction of not including builtin derives, but I'd like to do that all at once with a Crater run.
b94a0c3 to
2c2505e
Compare
|
So this PR has removed |
|
@keeperofdakeys |
2c2505e to
b117bee
Compare
|
@bors r+ |
|
📌 Commit b117bee has been approved by |
…eyfried Expand derive macros in the MacroExpander This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver. r? @jseyfried
…eyfried Expand derive macros in the MacroExpander This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver. r? @jseyfried
|
This PR might have resulted in this error during the rollup: https://travis-ci.org/rust-lang/rust/jobs/198341670 |
This allows builtin derives to be registered and resolved, just like other derive types.
This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver.
|
@jseyfried So it looks like travis didn't run the pretty tests, one of which I'm failing (which I've confirmed locally). It involves parsing and pretty printing derive attributes? I'm not sure how the pretty printer is linked to the invocation collector though. Any thoughts? |
|
Oh I think I understand now. With the The simple fix would be to remove the derives, or change them to builtin variants. Then maybe rename the |
Remove attr-variant-data.rs since it relies on quirks in legacy custom derive resolution (undefined derives only print a warning). Add a new test which uses a defined proc macro derive, and tests pretty printing of proc macro derive attributes.
b117bee to
a201348
Compare
|
I deleted the failing test, since it didn't seem to add much after removing the custom derive parts (other tests test custom attributes). I also added a new test using a |
|
@keeperofdakeys Great, thanks! |
|
📌 Commit a201348 has been approved by |
…eyfried Expand derive macros in the MacroExpander This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver. Fixes rust-lang#39326 r? @jseyfried
[beta] Give a better error message for unknown derive messages This PR improves the error message for unknown derive macros. Currently unknown derives give the following error, which is very misleading: ``` `#[derive]` for custom traits is not stable enough for use. It is deprecated and will be removed in v1.15 (see issue #29644) ``` I'm currently working on a PR that will change this (#39442) to the following: ``` cannot find derive macro `Foo` in this scope ``` This PR backports the (as yet unmerged) error message to beta/1.16 (it's a pity that this is probably too late for 1.15). r? @jseyfried
This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver.
Fixes #39326
r? @jseyfried