Skip to content

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

Closed
@yrp604

Description

@yrp604

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.

Activity

yrp604

yrp604 commented on Feb 23, 2025

@yrp604
Author

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

schmitch

schmitch commented on Feb 27, 2025

@schmitch

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

AzHicham

AzHicham commented on Mar 11, 2025

@AzHicham

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

Fireronin commented on Mar 25, 2025

@Fireronin

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

wentasah

wentasah commented on Mar 27, 2025

@wentasah

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

MarijnS95 commented on Apr 24, 2025

@MarijnS95
Contributor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @wentasah@schmitch@MarijnS95@yrp604@Fireronin

        Issue actions

          bindgen 0.71 introduces regression referencing proc_macro2::Literal::c_string · Issue #3149 · rust-lang/rust-bindgen