dtolnay / paste

Macros for all your token pasting needs
Apache License 2.0
1.02k stars 56 forks source link

Build errors following the release of `1.0.9` #87

Closed jessebraham closed 2 years ago

jessebraham commented 2 years ago

Thank you for your work on this crate! It's very useful for building HALs :)

Unfortunately with the release of 1.0.9 our builds over at a esp-hal have begun failing. The builds were working yesterday, and today we get this output:
https://gist.github.com/jessebraham/8fe1d8575c923e788a799262736a7a5e

I cloned this repo and set a local path for [patch.crates-io.paste], and I'm able to reproduce the build errors. Changing let mut contains_paste = false to true instead results in the build succeeding. I'm not really familiar with the inner workings of the crate and this does not seem like a solution, but I'm hoping it may help locate the problem.

pub fn paste(input: TokenStream) -> TokenStream {
    let mut contains_paste = false;
    let flatten_single_interpolation = true;
    match expand(
        input.clone(),
        &mut contains_paste,
        flatten_single_interpolation,
    ) {
        Ok(expanded) => {
            if contains_paste {
                expanded
            } else {
                input
            }
        }
        Err(err) => err.to_compile_error(),
    }
}
dtolnay commented 2 years ago

This is going to need a minimal repro, since your gpio macro is hundreds of lines. But this part looks suspicious to me: https://github.com/esp-rs/esp-hal/blob/e9f22aca634a4ac107ac792297f00148e79cd616/esp-hal-common/src/gpio.rs#L567 You are using $iomux_reg, which is an expression ($iomux_reg:expr), as if it were a field name, which is not allowed in Rust. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9ce736206f1725404ce94f57e526809e

jessebraham commented 2 years ago

Thanks for your input, I actually managed to come up with a solution after seeing your comment.