-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryA-proc-macrosArea: Procedural macrosArea: Procedural macros
Description
I have this test:
mod tests {
use crate::str2code;
#[test]
fn test() {
str2code!(r#"println!("Hello, world!");"#);
}
}
The str2code
macro is a procedural macro that I made.
#[proc_macro]
pub fn str2code(input: TokenStream) -> TokenStream
It gives this error:
error: can't use a procedural macro from the same crate that defines it
--> src\lib.rs:31:9
|
31 | str2code!(r#"println!("Hello, world!");"#);
| ^^^^^^^^
Why does the compiler not let me test my macros and why does this exist?
Metadata
Metadata
Assignees
Labels
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryA-proc-macrosArea: Procedural macrosArea: Procedural macros