Skip to content

Commit

Permalink
Upgrade toolchain to nightly-2024-04-15
Browse files Browse the repository at this point in the history
  - rust-lang/rust#120131:
    Add support to `Pat` pattern type
  - rust-lang/rust#122935:
    Rename CastKind::PointerWithExposedProvenance
  - rust-lang/rust#123097:
    Adapt to changes to local_def_path_hash_to_def_id
  • Loading branch information
celinval committed Apr 15, 2024
1 parent def3a09 commit 6045e60
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
5 changes: 5 additions & 0 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ impl<'tcx> GotocCtx<'tcx> {
"element of {parent_ty:?} is not accessed via field projection"
)
}
TyKind::RigidTy(RigidTy::Pat(..)) => {
// See https://github.com/rust-lang/types-team/issues/126
// for what is currently supported.
unreachable!("projection inside a pattern is not supported, only transmute")
}
}
}
// if we fall here, then we are handling an enum
Expand Down
2 changes: 1 addition & 1 deletion kani-compiler/src/codegen_cprover_gotoc/codegen/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ impl<'tcx> GotocCtx<'tcx> {
| CastKind::FnPtrToPtr
| CastKind::PtrToPtr
| CastKind::PointerExposeAddress
| CastKind::PointerFromExposedAddress,
| CastKind::PointerWithExposedProvenance,
e,
t,
) => self.codegen_misc_cast(e, *t),
Expand Down
8 changes: 8 additions & 0 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,13 @@ impl<'tcx> GotocCtx<'tcx> {
)
}
}
// This object has the same layout as base. For now, translate this into `(base)`.
// The only difference is the niche.
ty::Pat(base_ty, ..) => {
self.ensure_struct(self.ty_mangled_name(ty), self.ty_pretty_name(ty), |tcx, _| {
tcx.codegen_ty_tuple_like(ty, vec![*base_ty])
})
}
ty::Alias(..) => {
unreachable!("Type should've been normalized already")
}
Expand Down Expand Up @@ -995,6 +1002,7 @@ impl<'tcx> GotocCtx<'tcx> {
| ty::Int(_)
| ty::RawPtr(_, _)
| ty::Ref(..)
| ty::Pat(..)
| ty::Tuple(_)
| ty::Uint(_) => self.codegen_ty(pointee_type).to_pointer(),

Expand Down
2 changes: 1 addition & 1 deletion kani-compiler/src/kani_middle/stubbing/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn update_stub_mapping(
"duplicate stub mapping: {} mapped to {} and {}",
tcx.def_path_str(orig_id),
tcx.def_path_str(stub_id),
tcx.def_path_str(tcx.def_path_hash_to_def_id(other, &mut || panic!()))
tcx.def_path_str(tcx.def_path_hash_to_def_id(other, &()))
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion kani-compiler/src/kani_middle/stubbing/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ fn deserialize_mapping(tcx: TyCtxt, val: &str) -> HashMap<DefId, DefId> {
type Item = (u64, u64);
let item_to_def_id = |item: Item| -> DefId {
let hash = DefPathHash(Fingerprint::new(item.0, item.1));
tcx.def_path_hash_to_def_id(hash, &mut || panic!())
tcx.def_path_hash_to_def_id(hash, &())
};
let pairs: Vec<(Item, Item)> = serde_json::from_str(val).unwrap();
let mut m = HashMap::default();
Expand Down
8 changes: 7 additions & 1 deletion kani-compiler/src/kani_middle/transform/check_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ impl<'a> MirVisitor for CheckValueVisitor<'a> {
ty: (rvalue.ty(self.locals).unwrap()),
}),
CastKind::PointerExposeAddress
| CastKind::PointerFromExposedAddress
| CastKind::PointerWithExposedProvenance
| CastKind::PointerCoercion(_)
| CastKind::IntToInt
| CastKind::FloatToInt
Expand Down Expand Up @@ -898,6 +898,12 @@ fn ty_validity_per_offset(
}
}
}
RigidTy::Pat(base_ty, ..) => {
// This is similar to a structure with one field and with niche defined.
let mut pat_validity = ty_req();
pat_validity.append(&mut ty_validity_per_offset(machine_info, *base_ty, 0)?);
Ok(pat_validity)
}
RigidTy::Tuple(tys) => {
let mut tuple_validity = vec![];
for idx in layout.fields.fields_by_offset_order() {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT

[toolchain]
channel = "nightly-2024-04-03"
channel = "nightly-2024-04-15"
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]

0 comments on commit 6045e60

Please sign in to comment.