Skip to content

Commit 7893118

Browse files
committed
kani: #[allow(dead_code)]
1 parent 471ae43 commit 7893118

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/functions/kani/coercion.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ use stable_mir::ty::{RigidTy, Ty as TyStable, TyKind};
5858
/// - Extract the tail element of the struct which are of type `T` and `U`, respectively.
5959
/// 4. Coercion between smart pointers of wrapper structs.
6060
/// - Apply the logic from item 2 then item 3.
61+
#[allow(dead_code)]
6162
pub fn extract_unsize_casting_stable(
6263
tcx: TyCtxt,
6364
src_ty: TyStable,
@@ -89,14 +90,12 @@ pub fn extract_unsize_casting<'tcx>(
8990
.last()
9091
.unwrap();
9192
// Extract the pointee type that is being coerced.
92-
let src_pointee_ty = extract_pointee(tcx, coerce_info.src_ty).expect(&format!(
93-
"Expected source to be a pointer. Found {:?} instead",
94-
coerce_info.src_ty
95-
));
96-
let dst_pointee_ty = extract_pointee(tcx, coerce_info.dst_ty).expect(&format!(
97-
"Expected destination to be a pointer. Found {:?} instead",
98-
coerce_info.dst_ty
99-
));
93+
let src_pointee_ty = extract_pointee(tcx, coerce_info.src_ty).unwrap_or_else(|| {
94+
panic!("Expected source to be a pointer. Found {:?} instead", coerce_info.src_ty)
95+
});
96+
let dst_pointee_ty = extract_pointee(tcx, coerce_info.dst_ty).unwrap_or_else(|| {
97+
panic!("Expected destination to be a pointer. Found {:?} instead", coerce_info.dst_ty)
98+
});
10099
// Find the tail of the coercion that determines the type of metadata to be stored.
101100
let (src_base_ty, dst_base_ty) = tcx.struct_lockstep_tails_for_codegen(
102101
src_pointee_ty,
@@ -124,6 +123,7 @@ pub struct CoercionBase<'tcx> {
124123
}
125124

126125
#[derive(Debug)]
126+
#[allow(dead_code)]
127127
pub struct CoercionBaseStable {
128128
pub src_ty: TyStable,
129129
pub dst_ty: TyStable,
@@ -221,8 +221,8 @@ impl Iterator for CoerceUnsizedIterator<'_> {
221221
let coerce_index = coerce_index.as_usize();
222222
assert!(coerce_index < src_fields.len());
223223

224-
self.src_ty = Some(src_fields[coerce_index].ty_with_args(&src_args));
225-
self.dst_ty = Some(dst_fields[coerce_index].ty_with_args(&dst_args));
224+
self.src_ty = Some(src_fields[coerce_index].ty_with_args(src_args));
225+
self.dst_ty = Some(dst_fields[coerce_index].ty_with_args(dst_args));
226226
Some(src_fields[coerce_index].name.clone())
227227
}
228228
_ => {

src/functions/kani/reachability.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ pub fn collect_reachable_items(
8282

8383
/// Collect all (top-level) items in the crate that matches the given predicate.
8484
/// An item can only be a root if they are a non-generic function.
85+
#[allow(dead_code)]
8586
pub fn filter_crate_items<F>(tcx: TyCtxt, predicate: F) -> Vec<Instance>
8687
where
8788
F: Fn(TyCtxt, Instance) -> bool,
@@ -115,6 +116,7 @@ where
115116
///
116117
/// Probably only specifically useful with a predicate to find `TestDescAndFn` const declarations from
117118
/// tests and extract the closures from them.
119+
#[allow(dead_code)]
118120
pub fn filter_const_crate_items<F>(tcx: TyCtxt, mut predicate: F) -> Vec<MonoItem>
119121
where
120122
F: FnMut(TyCtxt, Instance) -> bool,
@@ -444,7 +446,7 @@ impl MirVisitor for MonoItemsFnCollector<'_, '_> {
444446
return;
445447
}
446448
};
447-
self.collect_allocation(&allocation);
449+
self.collect_allocation(allocation);
448450
}
449451

450452
/// Collect function calls.

0 commit comments

Comments
 (0)