Skip to content

Commit 6d70416

Browse files
committed
Upgrade toolchain to 2024-02-14
1 parent 6bea131 commit 6d70416

File tree

8 files changed

+38
-26
lines changed

8 files changed

+38
-26
lines changed

cprover_bindings/src/goto_program/builtin.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use self::BuiltinFn::*;
55
use super::{Expr, Location, Symbol, Type};
66

7+
use std::fmt::Display;
8+
79
#[derive(Debug, Clone, Copy)]
810
pub enum BuiltinFn {
911
Abort,
@@ -67,9 +69,9 @@ pub enum BuiltinFn {
6769
Unlink,
6870
}
6971

70-
impl ToString for BuiltinFn {
71-
fn to_string(&self) -> String {
72-
match self {
72+
impl Display for BuiltinFn {
73+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
74+
let func = match self {
7375
Abort => "abort",
7476
Assert => "assert",
7577
CProverAssume => "__CPROVER_assume",
@@ -129,8 +131,8 @@ impl ToString for BuiltinFn {
129131
Trunc => "trunc",
130132
Truncf => "truncf",
131133
Unlink => "unlink",
132-
}
133-
.to_string()
134+
};
135+
write!(f, "{func}")
134136
}
135137
}
136138

cprover_bindings/src/goto_program/symbol.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use super::super::utils::aggr_tag;
44
use super::{DatatypeComponent, Expr, Location, Parameter, Stmt, Type};
55
use crate::{InternStringOption, InternedString};
66

7+
use std::fmt::Display;
8+
79
/// Based off the CBMC symbol implementation here:
810
/// <https://github.com/diffblue/cbmc/blob/develop/src/util/symbol.h>
911
#[derive(Clone, Debug)]
@@ -452,14 +454,13 @@ impl SymbolValues {
452454
}
453455
}
454456

455-
/// ToString
456-
457-
impl ToString for SymbolModes {
458-
fn to_string(&self) -> String {
459-
match self {
457+
/// Display
458+
impl Display for SymbolModes {
459+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
460+
let mode = match self {
460461
SymbolModes::C => "C",
461462
SymbolModes::Rust => "Rust",
462-
}
463-
.to_string()
463+
};
464+
write!(f, "{mode}")
464465
}
465466
}

cprover_bindings/src/irep/irep_id.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use crate::cbmc_string::InternedString;
88
use crate::utils::NumUtils;
99
use num::bigint::{BigInt, BigUint, Sign};
1010

11+
use std::fmt::Display;
12+
1113
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug)]
1214
pub enum IrepId {
1315
/// In addition to the standard enums defined below, CBMC also allows ids to be strings.
@@ -872,15 +874,19 @@ impl IrepId {
872874
}
873875
}
874876

875-
impl ToString for IrepId {
876-
fn to_string(&self) -> String {
877+
impl Display for IrepId {
878+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
877879
match self {
878-
IrepId::FreeformString(s) => return s.to_string(),
879-
IrepId::FreeformInteger(i) => return i.to_string(),
880+
IrepId::FreeformString(s) => {
881+
return write!(f, "{s}");
882+
}
883+
IrepId::FreeformInteger(i) => {
884+
return write!(f, "{i}");
885+
}
880886
IrepId::FreeformBitPattern(i) => {
881-
return format!("{i:X}");
887+
return write!(f, "{i:X}");
882888
}
883-
_ => (),
889+
_ => {}
884890
}
885891

886892
let s = match self {
@@ -1708,7 +1714,7 @@ impl ToString for IrepId {
17081714
IrepId::VectorGt => "vector->",
17091715
IrepId::VectorLt => "vector-<",
17101716
};
1711-
s.to_string()
1717+
write!(f, "{s}")
17121718
}
17131719
}
17141720

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ impl<'tcx> GotocCtx<'tcx> {
725725
.bytes(),
726726
Type::size_t(),
727727
),
728+
NullOp::DebugAssertions => Expr::c_false(),
728729
}
729730
}
730731
Rvalue::ShallowInitBox(ref operand, content_ty) => {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,8 +1714,10 @@ impl<'tcx> GotocCtx<'tcx> {
17141714
/// metadata associated with it.
17151715
pub fn use_thin_pointer(&self, mir_type: Ty<'tcx>) -> bool {
17161716
// ptr_metadata_ty is not defined on all types, the projection of an associated type
1717-
let (metadata, _check_is_sized) = mir_type.ptr_metadata_ty(self.tcx, normalize_type);
1718-
!self.is_unsized(mir_type) || metadata == self.tcx.types.unit
1717+
let metadata = mir_type.ptr_metadata_ty_or_tail(self.tcx, normalize_type);
1718+
!self.is_unsized(mir_type)
1719+
|| metadata.is_err()
1720+
|| (metadata.unwrap() == self.tcx.types.unit)
17191721
}
17201722

17211723
/// We use fat pointer if not thin pointer.
@@ -1726,14 +1728,14 @@ impl<'tcx> GotocCtx<'tcx> {
17261728
/// A pointer to the mir type should be a slice fat pointer.
17271729
/// We use a slice fat pointer if the metadata is the slice length (type usize).
17281730
pub fn use_slice_fat_pointer(&self, mir_type: Ty<'tcx>) -> bool {
1729-
let (metadata, _check_is_sized) = mir_type.ptr_metadata_ty(self.tcx, normalize_type);
1731+
let metadata = mir_type.ptr_metadata_ty(self.tcx, normalize_type);
17301732
metadata == self.tcx.types.usize
17311733
}
17321734
/// A pointer to the mir type should be a vtable fat pointer.
17331735
/// We use a vtable fat pointer if this is a fat pointer to anything that is not a slice ptr.
17341736
/// I.e.: The metadata is not length (type usize).
17351737
pub fn use_vtable_fat_pointer(&self, mir_type: Ty<'tcx>) -> bool {
1736-
let (metadata, _check_is_sized) = mir_type.ptr_metadata_ty(self.tcx, normalize_type);
1738+
let metadata = mir_type.ptr_metadata_ty(self.tcx, normalize_type);
17371739
metadata != self.tcx.types.unit && metadata != self.tcx.types.usize
17381740
}
17391741

kani-compiler/src/kani_middle/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl<'tcx> KaniAttributes<'tcx> {
268268
.hir_id()
269269
};
270270

271-
let result = match hir_map.get_parent(hir_id) {
271+
let result = match self.tcx.parent_hir_node(hir_id) {
272272
Node::Item(Item { kind, .. }) => match kind {
273273
ItemKind::Mod(m) => find_in_mod(m),
274274
ItemKind::Impl(imp) => {

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-2024-02-09"
5+
channel = "nightly-2024-02-14"
66
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[TEST] Only codegen test...
22
Executable unittests src/lib.rs
33
[TEST] Only codegen test...
4-
Finished test
4+
Finished `test`
55
[TEST] Executable
66
debug/deps/sample_crate-

0 commit comments

Comments
 (0)