Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

demo crate not valid identifier #2

Closed

Conversation

softprops
Copy link

hi @dtolnay I ran into another issue after moving from mashup to lando. I'll open a separate issue but rather than pointing you through more complex code Ill wanted to whittle this down to a smaller case in a though away pull for testing

in short I'm trying to prefix my own macros with $crate:: allow for 2018 style macro imports but inside a paste::item! invocation I found that I'm not able to do so because I'll get the following error

    = help: message: `"$crate"` is not a valid identifier


#[test]
fn test_crate_not_valid_identifier() {
crate_not_valid_identifier!();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this currently fails with this error message

error: proc macro panicked
   --> tests/test.rs:154:9
    |
154 | /         paste::item! {
155 | |             $crate::crate_not_valid_identifier! { [<Lib env!("CARGO_PKG_NAME")>] }
156 | |         }
    | |_________^
...
162 |      crate_not_valid_identifier!();
    |      ------------------------------ in this macro invocation
    |
    = help: message: `"$crate"` is not a valid identifier

};
() => {
paste::item! {
$crate::crate_not_valid_identifier! { [<Lib env!("CARGO_PKG_NAME")>] }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$crate:: is needed to enable 2018 style imports

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, closing in favor of #3 to keep the discussion in one place.

@dtolnay dtolnay closed this Nov 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants