From 219288e769028d4a716ec16bbdbf391b95834ad0 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Thu, 19 Nov 2026 04:11:03 +0000 Subject: [PATCH 1/2] Upgrade Rust toolchain to nightly-2026-11-19 Resolves #5200. Relevant upstream changes: - rust-lang/rust#166037: reflection: enable tool attributes to be reflectable. `rustc_attr_ir::Attribute::Tool` is now a struct variant `Tool { item, opts }`; update pattern matches in kani_middle/attributes.rs accordingly. - rust-lang/rust#164544: Implement `rustc_intrinsic(llvm = "...")`. `IntrinsicDef::name` is now an `Intrinsic` enum (`Rustc(Symbol)` or `Backend { llvm }`) instead of a bare `Symbol`; compare against `Intrinsic::Rustc(sym::simd_bitmask)` in kani_middle/intrinsics.rs. Signed-off-by: Felipe Monteiro --- kani-compiler/src/kani_middle/attributes.rs | 10 ++++++---- kani-compiler/src/kani_middle/intrinsics.rs | 4 ++-- rust-toolchain.toml | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kani-compiler/src/kani_middle/attributes.rs b/kani-compiler/src/kani_middle/attributes.rs index 84d53b6df55..72d547ca00a 100644 --- a/kani-compiler/src/kani_middle/attributes.rs +++ b/kani-compiler/src/kani_middle/attributes.rs @@ -50,7 +50,9 @@ pub fn attrs_by_path<'tcx>( /// `Attribute::path_matches` (nightly-2026-11-17); this is the same test it used to perform. fn attr_path_matches(attr: &Attribute, path: &[Symbol]) -> bool { match attr { - Attribute::Tool(item) | Attribute::DeriveHelper(item) => item.path.segments.iter().eq(path), + Attribute::Tool { item, .. } | Attribute::DeriveHelper(item) => { + item.path.segments.iter().eq(path) + } _ => false, } } @@ -65,7 +67,7 @@ pub fn attr_value_str(attr: &Attribute) -> Option { /// always `Attribute::Tool`. fn normal_item(attr: &Attribute) -> &AttrItem { match attr { - Attribute::Tool(item) => item, + Attribute::Tool { item, .. } => item, Attribute::Parsed(_) | Attribute::DeriveHelper(_) => { unreachable!("Kani attributes are unparsed tool attributes: {attr:?}") } @@ -1001,7 +1003,7 @@ impl<'tcx> KaniAttributes<'tcx> { #[allow(deprecated)] let attrs = self.tcx.get_all_attrs(def_id); let stub_set_attr = attrs.iter().find(|a| { - if let Attribute::Tool(normal) = a { + if let Attribute::Tool { item: normal, .. } = a { let segments = &normal.path.segments; segments.len() == 2 && segments[0].as_str() == "kanitool" @@ -1370,7 +1372,7 @@ fn parse_key_values(attr: &Attribute) -> Result, String /// If the attribute is named `kanitool::name`, this extracts `name` fn attr_kind(tcx: TyCtxt, attr: &Attribute) -> Option { - if let Attribute::Tool(normal) = attr { + if let Attribute::Tool { item: normal, .. } = attr { let segments = &normal.path.segments; if (!segments.is_empty()) && segments[0].as_str() == "kanitool" { let ident_str = segments[1..] diff --git a/kani-compiler/src/kani_middle/intrinsics.rs b/kani-compiler/src/kani_middle/intrinsics.rs index 7ea442cedcc..3f8e0229a16 100644 --- a/kani-compiler/src/kani_middle/intrinsics.rs +++ b/kani-compiler/src/kani_middle/intrinsics.rs @@ -9,7 +9,7 @@ use rustc_index::IndexVec; use rustc_middle::mir::{Body, Const as mirConst, ConstValue, Operand, TerminatorKind}; use rustc_middle::mir::{Local, LocalDecl}; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_middle::ty::{Const, GenericArgs, IntrinsicDef}; +use rustc_middle::ty::{Const, GenericArgs, Intrinsic, IntrinsicDef}; use rustc_span::Spanned; use rustc_span::symbol::{Symbol, sym}; use tracing::{debug, trace}; @@ -39,7 +39,7 @@ impl<'tcx> ModelIntrinsics<'tcx> { if let Some((intrinsic, generics)) = resolve_rust_intrinsic(self.tcx, func_ty) { let intrinsic_name = intrinsic.name; trace!(?func, ?intrinsic_name, "run_pass"); - if intrinsic_name == sym::simd_bitmask { + if intrinsic_name == Intrinsic::Rustc(sym::simd_bitmask) { self.replace_simd_bitmask(func, args, generics) } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 1cdf94ea9b4..dffc0519fb9 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,5 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT [toolchain] -channel = "nightly-2026-11-18" +channel = "nightly-2026-11-19" components = ["llvm-tools", "rustc-dev", "rust-src", "rustfmt"] From ea49c9f7c77db6024a1daee9c288b612b1783969 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Thu, 19 Nov 2026 16:36:09 +0000 Subject: [PATCH 2/2] LLBC backend: take the alignment of i8 from rustc_abi::Integer nightly-2026-11-19 removes `TargetDataLayout::i8_align`: the alignment of `i8` is no longer part of the data layout, and `Integer::I8.align` always returns `Align::ONE`. Use `Integer::I8.align` for the `Bool`, `I8` and `U8` alignments that the LLBC backend reports to Charon. Signed-off-by: Felipe Monteiro --- kani-compiler/src/codegen_aeneas_llbc/mir_to_ullbc/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kani-compiler/src/codegen_aeneas_llbc/mir_to_ullbc/mod.rs b/kani-compiler/src/codegen_aeneas_llbc/mir_to_ullbc/mod.rs index 7b44ff4ca62..22b5ef18b5a 100644 --- a/kani-compiler/src/codegen_aeneas_llbc/mir_to_ullbc/mod.rs +++ b/kani-compiler/src/codegen_aeneas_llbc/mir_to_ullbc/mod.rs @@ -2363,17 +2363,19 @@ pub fn prepare_translated_crate(tcx: TyCtxt, translated: &mut CharonTranslatedCr // As in Charon's `register_target_info`. let target_data = &tcx.data_layout; + // The alignment of `i8` is not part of the data layout (it is always 1). + let i8_align = rustc_abi::Integer::I8.align(target_data).bytes(); let mut primitive_alignments = charon_lib::ast::SeqHashMap::new(); - primitive_alignments.insert(CharonLiteralTy::Bool, target_data.i8_align.bytes()); + primitive_alignments.insert(CharonLiteralTy::Bool, i8_align); let int = |ty| CharonLiteralTy::Integer(ty); for (ty, alignment) in [ - (CharonIntegerTy::Signed(CharonIntTy::I8), target_data.i8_align.bytes()), + (CharonIntegerTy::Signed(CharonIntTy::I8), i8_align), (CharonIntegerTy::Signed(CharonIntTy::I16), target_data.i16_align.bytes()), (CharonIntegerTy::Signed(CharonIntTy::I32), target_data.i32_align.bytes()), (CharonIntegerTy::Signed(CharonIntTy::I64), target_data.i64_align.bytes()), (CharonIntegerTy::Signed(CharonIntTy::I128), target_data.i128_align.bytes()), (CharonIntegerTy::Signed(CharonIntTy::Isize), target_data.pointer_align().bytes()), - (CharonIntegerTy::Unsigned(CharonUIntTy::U8), target_data.i8_align.bytes()), + (CharonIntegerTy::Unsigned(CharonUIntTy::U8), i8_align), (CharonIntegerTy::Unsigned(CharonUIntTy::U16), target_data.i16_align.bytes()), (CharonIntegerTy::Unsigned(CharonUIntTy::U32), target_data.i32_align.bytes()), (CharonIntegerTy::Unsigned(CharonUIntTy::U64), target_data.i64_align.bytes()),