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

Make it possible to use indoc with explicit use indoc::indoc; #24

Closed
RReverser opened this issue Nov 28, 2018 · 7 comments
Closed

Make it possible to use indoc with explicit use indoc::indoc; #24

RReverser opened this issue Nov 28, 2018 · 7 comments

Comments

@RReverser
Copy link

Currently indoc works only with #[macro_use] attribute but it would be nice to be able to use it with Rust 2018 style of explicit use statements. E.g. this fails:

extern crate indoc;
use indoc::indoc;
...
indoc!("test");

with

error: cannot find derive macro `indoc_impl` in this scope
   --> ffi/src/lib.rs:336:9
    |
336 |         indoc!("test");
    |         ^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: cannot find macro `proc_macro_call!` in this scope
   --> ffi/src/lib.rs:336:9
    |
336 |         indoc!("test");
    |         ^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
@RReverser
Copy link
Author

Looks like use indoc::{indoc, indoc_impl}; works, but that shouldn't be necessary as the second one is an implementation detail.

@dtolnay
Copy link
Owner

dtolnay commented Nov 29, 2018

Thanks! I believe this would be fixed by updating to proc-macro-hack 0.5.

@dtolnay
Copy link
Owner

dtolnay commented Nov 29, 2018

Fixed in 0.3.0.

@RReverser
Copy link
Author

Hmm after upgrading fails with a hard compilation error:

error: unexpected end of macro invocation
   --> /Users/rreverser/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro-hack-0.5.2/src/lib.rs:247:60
    |
247 |     proc_macro::TokenStream::from(match parse_macro_input!(input) {
    |                                                            ^^^^^

error: aborting due to previous error

error: Could not compile `proc-macro-hack`.

@RReverser
Copy link
Author

Recalled I had a similar issue with quote in the past, and indeed force-upgrading syn helped:

$ cargo update -p syn:0.15.4
    Updating crates.io index
    Updating syn v0.15.4 -> v0.15.22

It feels like dependencies of syn should be stricter regarding minimal version to help Cargo resolve, e.g. here https://github.com/dtolnay/proc-macro-hack/blob/master/Cargo.toml#L17 would be nice to set to some minimal version that is actually known to work.

@dtolnay
Copy link
Owner

dtolnay commented Nov 30, 2018

Thanks for letting me know. Should be fixed in 0.3.1.

@RReverser
Copy link
Author

Thanks!

grenade added a commit to grenade/structure that referenced this issue Feb 1, 2021
note that using `use structure::structure` should be sufficient (see: [macro-changes](https://doc.rust-lang.org/edition-guide/rust-2018/macros/macro-changes.html)), but requires an update to the `proc-macro-hack` dependency (see: dtolnay/indoc#24).
shymega pushed a commit to Cosmo-CoDiOS/structure that referenced this issue Sep 27, 2022
note that using `use structure::structure` should be sufficient (see: [macro-changes](https://doc.rust-lang.org/edition-guide/rust-2018/macros/macro-changes.html)), but requires an update to the `proc-macro-hack` dependency (see: dtolnay/indoc#24).
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