How do I locate an error in an expanded macro?

⚓ Rust    📅 2025-04-28    👤 surdeus    👁️ 5      

surdeus

Warning

This post was published 115 days ago. The information described in this article may have changed.

Hi :slight_smile:

I'm trying to debug a function-like proc-macro, and I'm getting "error[E0782]: expected a type, found a trait" inside the macro expansion. How can I see where in the expanded macro this is happening?

Running cargo expand just dumps out everything (which, in my case, is a lot), but since the original error message contains no clue as to where in that giant pile of code the compiler expected a type instead of a trait, I don't know where to look.

I also tried RUSTFLAGS="-Zmacro-backtrace" cargo +nightly check as recommended by the error message, but that yields the same output as the original cargo check command.

2 posts - 2 participants

Read full topic

🏷️ rust_feed