Skip to content

bindgen 0.71 introduces regression referencing proc_macro2::Literal::c_string #3149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yrp604 opened this issue Feb 23, 2025 · 6 comments
Closed

Comments

@yrp604
Copy link

yrp604 commented Feb 23, 2025

When updating a crate of mine to bindgen 0.71, I started receiving this error:

C:\Users\x\OneDrive\Documents\bad64\bad64-sys>cargo check
    Updating crates.io index
     Locking 2 packages to latest compatible versions
    Updating bindgen v0.70.1 -> v0.71.1
    Updating rustc-hash v1.1.0 -> v2.1.1
   Compiling proc-macro2 v1.0.69
   Compiling clang-sys v1.8.1
   Compiling bindgen v0.71.1
   Compiling rustc-hash v2.1.1
   Compiling quote v1.0.33
   Compiling syn v2.0.39
   Compiling prettyplease v0.2.15
error[E0599]: no function or associated item named `c_string` found for struct `proc_macro2::Literal` in the current scope
    --> C:\Users\x\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\bindgen-0.71.1\codegen\mod.rs:734:62
     |
734  | ...                   let cstr = proc_macro2::Literal::c_string(cstr);
     |                                                        ^^^^^^^^ function or associated item not found in `Literal`
     |
note: if you're trying to build a new `proc_macro2::Literal` consider using one of the following associated functions:
      proc_macro2::Literal::u8_suffixed
      proc_macro2::Literal::u16_suffixed
      proc_macro2::Literal::u32_suffixed
      proc_macro2::Literal::u64_suffixed
      and 28 others
    --> C:\Users\x\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\proc-macro2-1.0.69\src\lib.rs:1097:5
     |
1097 | /     suffixed_int_literals! {
1098 | |         u8_suffixed => u8,
1099 | |         u16_suffixed => u16,
1100 | |         u32_suffixed => u32,
...    |
1109 | |         isize_suffixed => isize,
1110 | |     }
     | |_____^
     = note: this error originates in the macro `suffixed_int_literals` (in Nightly builds, run with -Z macro-backtrace for more info)
help: there is an associated function `string` with a similar name
     |
734  -                             let cstr = proc_macro2::Literal::c_string(cstr);
734  +                             let cstr = proc_macro2::Literal::string(cstr);
     |

For more information about this error, try `rustc --explain E0599`.
error: could not compile `bindgen` (lib) due to 1 previous error

This does not occur with bindgen 0.70.

I've pushed the relevant repro branch here: https://github.com/yrp604/bad64-sys/tree/bindgen-repro, and it should repro with cargo check. This repros on both Windows and Linux, nightly and stable.

@yrp604
Copy link
Author

yrp604 commented Feb 23, 2025

This has stopped reproducing on my machine after reporting this.... I am very confused as to how or why, but apologies for the noise.

@yrp604 yrp604 closed this as completed Feb 23, 2025
@schmitch
Copy link

actually I have exactly the same problem, after updaing a dependency which updates bindgen to 0.7 hm

@AzHicham
Copy link

Hello I have the same exact issue on Ubuntu 22.04 & Macos 14.
On a Renovate deps update bindgen 0.70 -> 0.71

https://github.com/AzHicham/openslide-sys/actions/runs/13652045388/job/38162635083?pr=96#step:6:71

@Fireronin
Copy link

I also have this issue, on ubuntu with rust nightly 1.87

@wentasah
Copy link

This was fixed by #3048, which was merged just after 0.71.1 release. In my project, the problem disappeared after running cargo update proc-macro2 --precise 1.0.80.

@MarijnS95
Copy link
Contributor

MarijnS95 commented Apr 24, 2025

Would it make sense to add a cargo +nightly -Zminimal-versions generate-lockfile step to the CI to prevent similar mistakes in the future? This fix still hasn't made it into a subsequent (patch) release, requiring downstream crates that do check their minimum version bounds to manually make an exception and bump the proc-macro2 crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants