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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,19 @@ fn test_false_start() {
assert_eq!(x[0], 0);
}
}

macro_rules! crate_not_valid_identifier {
($module:ident) => {
struct $module;
};
() => {
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

}
}
}

#[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

}