Skip to content

Commit e84fccd

Browse files
author
Carolyn Zech
committed
Upgrade toolchain to 2025-03-19
1 parent d12f10f commit e84fccd

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

kani-compiler/src/codegen_cprover_gotoc/codegen/foreign_function.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,35 @@ impl GotocCtx<'_> {
4949
/// handled later.
5050
pub fn codegen_foreign_fn(&mut self, instance: Instance) -> &Symbol {
5151
debug!(?instance, "codegen_foreign_function");
52-
let fn_name = instance.mangled_name().intern();
52+
let trimmed_fn_name = instance.trimmed_name().intern();
53+
let mangled_fn_name = instance.mangled_name().intern();
5354
let loc = self.codegen_span_stable(instance.def.span());
54-
if self.symbol_table.contains(fn_name) {
55-
// Symbol has been added (either a built-in CBMC function or a Rust allocation function).
56-
self.symbol_table.lookup(fn_name).unwrap()
57-
} else if RUST_ALLOC_FNS.contains(&fn_name)
58-
|| (self.is_cffi_enabled() && instance.fn_abi().unwrap().conv == CallConvention::C)
59-
{
55+
if self.symbol_table.contains(mangled_fn_name) {
56+
// Symbol has been added (a built-in CBMC function)
57+
self.symbol_table.lookup(mangled_fn_name).unwrap()
58+
} else if self.symbol_table.contains(trimmed_fn_name) {
59+
// Symbol has been added (a Rust allocation function)
60+
self.symbol_table.lookup(trimmed_fn_name).unwrap()
61+
} else if RUST_ALLOC_FNS.contains(&trimmed_fn_name) {
6062
// Add a Rust alloc lib function as is declared by core.
63+
// We use the trimmed name to ensure that it matches the function names in kani_lib.c
64+
self.ensure(trimmed_fn_name, |gcx, _| {
65+
let typ = gcx.codegen_ffi_type(instance);
66+
Symbol::function(trimmed_fn_name, typ, None, instance.name(), loc)
67+
.with_is_extern(true)
68+
})
69+
} else if self.is_cffi_enabled() && instance.fn_abi().unwrap().conv == CallConvention::C {
6170
// When C-FFI feature is enabled, we just trust the rust declaration.
6271
// TODO: Add proper casting and clashing definitions check.
6372
// https://github.com/model-checking/kani/issues/1350
6473
// https://github.com/model-checking/kani/issues/2426
65-
self.ensure(fn_name, |gcx, _| {
74+
self.ensure(mangled_fn_name, |gcx, _| {
6675
let typ = gcx.codegen_ffi_type(instance);
67-
Symbol::function(fn_name, typ, None, instance.name(), loc).with_is_extern(true)
76+
Symbol::function(mangled_fn_name, typ, None, instance.name(), loc)
77+
.with_is_extern(true)
6878
})
6979
} else {
70-
let shim_name = format!("{fn_name}_ffi_shim");
80+
let shim_name = format!("{mangled_fn_name}_ffi_shim");
7181
trace!(?shim_name, "codegen_foreign_function");
7282
self.ensure(&shim_name, |gcx, _| {
7383
// Generate a shim with an unsupported C-FFI error message.

kani-compiler/src/kani_middle/resolve.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,10 @@ fn resolve_relative(tcx: TyCtxt, current_module: LocalModDefId, name: &str) -> R
432432
let mut glob_imports = vec![];
433433
let result = tcx.hir_module_free_items(current_module).find_map(|item_id| {
434434
let item = tcx.hir_item(item_id);
435-
if item.ident.as_str() == name {
435+
if item.kind.ident().is_some_and(|ident| ident.as_str() == name) {
436436
match item.kind {
437-
ItemKind::Use(use_path, UseKind::Single) => use_path.res[0].opt_def_id(),
438-
ItemKind::ExternCrate(orig_name) => resolve_external(
437+
ItemKind::Use(use_path, UseKind::Single(_)) => use_path.res[0].opt_def_id(),
438+
ItemKind::ExternCrate(orig_name, _) => resolve_external(
439439
tcx,
440440
orig_name.as_ref().map(|sym| sym.as_str()).unwrap_or(name),
441441
),

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# SPDX-License-Identifier: Apache-2.0 OR MIT
33

44
[toolchain]
5-
channel = "nightly-2025-03-18"
5+
channel = "nightly-2025-03-19"
66
components = ["llvm-tools", "rustc-dev", "rust-src", "rustfmt"]

0 commit comments

Comments
 (0)