Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of undeclared crate or module proc_macro #57

Closed
dblock opened this issue Sep 2, 2021 · 4 comments
Closed

use of undeclared crate or module proc_macro #57

dblock opened this issue Sep 2, 2021 · 4 comments

Comments

@dblock
Copy link

dblock commented Sep 2, 2021

Trying to use dry run in lycheeverse/lychee#304 seeing this:

rustc --edition=2018 --crate-name typed_builder /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/src/lib.rs --color always --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C debuginfo=2 -C metadata=72ebad225c590f6d -C extra-filename=-72ebad225c590f6d --out-dir /home/ubuntu/source/lychee/dblock-lychee/target/package/lychee-lib-0.7.1/target/debug/deps -L dependency=/home/ubuntu/source/lychee/dblock-lychee/target/package/lychee-lib-0.7.1/target/debug/deps --extern proc_macro2=/home/ubuntu/source/lychee/dblock-lychee/target/package/lychee-lib-0.7.1/target/debug/deps/libproc_macro2-6f5ad8ea0bdf5b2f.rlib --extern quote=/home/ubuntu/source/lychee/dblock-lychee/target/package/lychee-lib-0.7.1/target/debug/deps/libquote-9b9b7563b6863207.rlib --extern syn=/home/ubuntu/source/lychee/dblock-lychee/target/package/lychee-lib-0.7.1/target/debug/deps/libsyn-c3d8aa50fc12e127.rlib --cap-lints allow
   Verifying lychee-lib
error[E0433]: failed to resolve: use of undeclared crate or module `proc_macro`
   --> /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/src/lib.rs:138:36
    |
138 | pub fn derive_typed_builder(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
    |                                    ^^^^^^^^^^ use of undeclared crate or module `proc_macro`

error[E0433]: failed to resolve: use of undeclared crate or module `proc_macro`
   --> /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/src/lib.rs:138:64
    |
138 | pub fn derive_typed_builder(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
    |                                                                ^^^^^^^^^^ use of undeclared crate or module `proc_macro`

Ideas?

@idanarye
Copy link
Owner

idanarye commented Sep 3, 2021

This is weird. When I try to run this command (paths adjusted):

rustc --edition=2018 \
    --crate-name typed_builder \
    /home/idanarye/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/src/lib.rs \
    --color always \
    --crate-type proc-macro \
    --emit=dep-info,link \
    -C prefer-dynamic \
    -C debuginfo=2 \
    -C metadata=72ebad225c590f6d \
    -C extra-filename=-72ebad225c590f6d \
    --out-dir /tmp/ \
    -L dependency=/media/d/Programming/Projects/rust-typed-builder/target/debug/deps/ \
    --extern /home/idanarye/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/target/debug/deps/libproc_macro2-5c21d599c997d506.rlib \
    --extern /home/idanarye/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/target/debug/deps/libquote-5643644f696ec073.rlib \
    --extern /home/idanarye/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/target/debug/deps/libsyn-aa7c69dcc752b5dd.rlib \
    --cap-lints allow

I get a long list of complaints about not finding proc_macro2, syn and quote. Which I can fix by putting name on the --extern targets:

rustc --edition=2018 \
    --crate-name typed_builder \
    /home/idanarye/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/src/lib.rs \
    --color always \
    --crate-type proc-macro \
    --emit=dep-info,link \
    -C prefer-dynamic \
    -C debuginfo=2 \
    -C metadata=72ebad225c590f6d \
    -C extra-filename=-72ebad225c590f6d \
    --out-dir /tmp/ \
    -L dependency=/media/d/Programming/Projects/rust-typed-builder/target/debug/deps/ \
    --extern proc_macro2=/home/idanarye/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/target/debug/deps/libproc_macro2-5c21d599c997d506.rlib \
    --extern quote=/home/idanarye/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/target/debug/deps/libquote-5643644f696ec073.rlib \
    --extern syn=/home/idanarye/.cargo/registry/src/github.com-1ecc6299db9ec823/typed-builder-0.9.0/target/debug/deps/libsyn-aa7c69dcc752b5dd.rlib \
    --cap-lints allow

And now I only get complaints about proc_macro.

But... proc_macro is part of the standard library, and --crate-type proc-macro should have exposed it to the code.

An

extern crate proc_macro;

Seems to fix this. Which is very weird, because the 2018 edition should mean we don't need to declare extern crate anymore. I guess proc_macro is a special case? And in regular builds Cargo is doing something about it in the background?

@dblock
Copy link
Author

dblock commented Sep 3, 2021

Thank you for fixing this! Care to cut a release please?

@idanarye
Copy link
Owner

idanarye commented Sep 3, 2021

Already have

@dblock
Copy link
Author

dblock commented Sep 29, 2021

Seems like this is happening again in lycheeverse/lychee#346, I think they could use some help, I don't understand what's going on - maybe you do @idanarye?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants