Skip to content

Commit 56f98c7

Browse files
fix TypeId handling
1 parent 533403e commit 56f98c7

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl GotocCtx<'_> {
152152
.args
153153
.iter()
154154
.enumerate()
155-
.filter(|&(_, arg)| (arg.mode != PassMode::Ignore))
155+
.filter(|&(_, arg)| arg.mode != PassMode::Ignore)
156156
.map(|(idx, arg)| {
157157
let arg_name = format!("{fn_name}::param_{idx}");
158158
let base_name = format!("param_{idx}");

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ impl<'tcx> GotocCtx<'tcx> {
204204
Some(self.codegen_const_ptr(alloc, ty, inner_ty, loc))
205205
}
206206
TyKind::RigidTy(RigidTy::Adt(adt, args)) if adt.kind().is_struct() => {
207+
//Special struct that is used to handle type_id function
208+
if adt.name().contains("any::TypeId") {
209+
let val = alloc.read_uint().unwrap();
210+
let u128_expr = Expr::int_constant(val, Type::unsigned_int(128));
211+
let typ = self.codegen_ty_stable(ty);
212+
return Some(u128_expr.transmute_to(typ, &self.symbol_table));
213+
}
207214
// Structs only have one variant.
208215
let variant = adt.variants_iter().next().unwrap();
209216
// There must be at least one field associated with the scalar data.
@@ -399,6 +406,7 @@ impl<'tcx> GotocCtx<'tcx> {
399406
let name = format!("{}::{alloc_id:?}", self.full_crate_name());
400407
self.codegen_const_allocation(&alloc, Some(name), loc)
401408
}
409+
GlobalAlloc::TypeId { ty: _ } => todo!(),
402410
};
403411
assert!(res_t.is_pointer() || res_t.is_transparent_type(&self.symbol_table));
404412
let offset_addr = base_addr

kani-compiler/src/kani_middle/reachability.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ fn collect_alloc_items(tcx: TyCtxt, alloc_id: AllocId) -> Vec<MonoItem> {
529529
let vtable_id = vtable_alloc.vtable_allocation().unwrap();
530530
items = collect_alloc_items(tcx, vtable_id);
531531
}
532+
GlobalAlloc::TypeId { ty: _ } => {}
532533
};
533534
items
534535
}

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-07-10"
5+
channel = "nightly-2025-07-11"
66
components = ["llvm-tools", "rustc-dev", "rust-src", "rustfmt"]

0 commit comments

Comments
 (0)