From f7fe9fd3d1e64f2918f0291a20362c88f5de9ba2 Mon Sep 17 00:00:00 2001 From: Michael VanBemmel Date: Mon, 4 May 2026 13:44:22 -0700 Subject: [PATCH] Adapt to unstable rustc API changes 1. The `HashStable` trait was renamed to `StableHash`, and its method was also renamed to match. https://github.com/rust-lang/rust/pull/156030 2. `rustc_hir::attrs::AttributeKind::{NoStd, NoCore}` are now fieldless. https://github.com/rust-lang/rust/pull/156065 PiperOrigin-RevId: 910219736 --- cc_bindings_from_rs/generate_bindings/lib.rs | 13 ++++++++++++- cc_bindings_from_rs/lib.rs | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cc_bindings_from_rs/generate_bindings/lib.rs b/cc_bindings_from_rs/generate_bindings/lib.rs index fd37b51c0..eba93f37c 100644 --- a/cc_bindings_from_rs/generate_bindings/lib.rs +++ b/cc_bindings_from_rs/generate_bindings/lib.rs @@ -1905,11 +1905,22 @@ impl NodeSortKey { TemplateSpecialization::RsStdEnum(e) => { let ty = e.core.self_ty_rs; - use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; + use rustc_data_structures::stable_hasher::StableHasher; + // Old name up to nightly 2026-05-02. + #[cfg_accessible(rustc_data_structures::stable_hasher::HashStable)] + use rustc_data_structures::stable_hasher::HashStable; + // New name since nightly 2026-05-03. + #[cfg_accessible(rustc_data_structures::stable_hasher::StableHash)] + use rustc_data_structures::stable_hasher::StableHash; let hash = tcx.with_stable_hashing_context(|mut hcx| { let mut hasher = StableHasher::new(); + // Old name up to nightly 2026-05-02. + #[cfg_accessible(rustc_data_structures::stable_hasher::HashStable)] ty.hash_stable(&mut hcx, &mut hasher); + // New name since nightly 2026-05-03. + #[cfg_accessible(rustc_data_structures::stable_hasher::StableHash)] + ty.stable_hash(&mut hcx, &mut hasher); hasher .finish::() .to_smaller_hash() diff --git a/cc_bindings_from_rs/lib.rs b/cc_bindings_from_rs/lib.rs index 624eda9e2..e49fae601 100644 --- a/cc_bindings_from_rs/lib.rs +++ b/cc_bindings_from_rs/lib.rs @@ -234,10 +234,10 @@ fn run_with_rmetas(cmdline: &Cmdline) -> Result<()> { // bindings for it and we'll generate the relevant error below. return Ok(()); }; - if rustc_hir::find_attr!(tcx, cnum.as_def_id(), AttributeKind::NoStd(_)) { + if rustc_hir::find_attr!(tcx, cnum.as_def_id(), AttributeKind::NoStd { .. }) { crate_attrs.push("#![no_std]"); } - if rustc_hir::find_attr!(tcx, cnum.as_def_id(), AttributeKind::NoCore(_)) { + if rustc_hir::find_attr!(tcx, cnum.as_def_id(), AttributeKind::NoCore { .. }) { crate_attrs.extend([ "#![allow(internal_features)]", "#![feature(no_core)]",