Skip to content

How to use code with proc-macro-error-2 in tests? #8

@Miha-Rozina

Description

@Miha-Rozina

I have unit tests written for all of my proc macros by using proc_macro2 in my implementation and running the code as a normal Rust test. However if I use proc-macro-error-2 I get errors like

proc-macro-error2 API cannot be used outside of `entry_point` invocation,

If I wrap my macro code in a proc_macro_error2::entry_point call I get this error

procedural macro API is used outside of a procedural macro

I think the problem stems from the fact that entry_point() returns a proc_macro::TokenStream instead of proc_macro2::TokenStream. Is there another supported way of how to invoke code that contains proc-macro-error-2 code in a test environment?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions