Skip to content

Commit

Permalink
Update for clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Salzberg committed Aug 27, 2024
1 parent c236c20 commit cda8657
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'locals> CollectActions<'locals> {
// Direct reference to stack local
// x = &y;
let lvalue = to;
let rvalue = from.local.clone();
let rvalue = from.local;
self.actions.push(Action::NewStackReference { lvalue, rvalue });
}
[ProjectionElem::Deref] => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ impl Cache {
/// in the given compilation context, ctx
pub fn register(&mut self, ctx: &TyCtxt, sig: Signature) -> Result<&MirInstance, MirError> {
let Cache { cache } = self;
for i in 0..cache.len() {
if sig == cache[i].signature {
return Ok(&cache[i].instance);
for item in &cache {
if sig == item.signature {
return Ok(item.instance);
}
}
let fndef = find_fn_def(*ctx, &sig.diagnostic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<'tcx, 'cache> InstrumentationData<'tcx, 'cache> {
let tcx = &self.tcx;
let fn_pointers = &mut self.fn_pointers;
let body = &mut self.body;
let span = self.span.clone();
let span = *self.span;
let instance = cache.register(tcx, callee)?;
let func_local = fn_pointers
.entry(*instance)
Expand Down Expand Up @@ -210,13 +210,13 @@ impl<'tcx, 'cache> InstrumentationData<'tcx, 'cache> {
let kind = TerminatorKind::Goto { target: 0 };
let terminator = Terminator { kind, span };
let source = &mut self.min_processed.clone();
let enter_ghost_block = source.clone();
let enter_ghost_block = *source;
let body = &mut self.body;
body.replace_terminator(source, terminator.clone()); // replace terminator so you can instrument "after" it
body.insert_terminator(source, InsertPosition::After, terminator.clone());
let execute_terminator_block = source.clone();
let execute_terminator_block = *source;
body.insert_terminator(source, InsertPosition::After, terminator.clone());
let execute_ghost_block = source.clone();
let execute_ghost_block = *source;

// Instrument enter ghost:
let span = original_span;
Expand Down Expand Up @@ -398,7 +398,7 @@ impl<'tcx, 'cache> InstrumentationData<'tcx, 'cache> {
pub fn instrument_instructions(&mut self) -> Result<()> {
loop {
let actions = self.instruction_actions();
if actions.len() > 0 {
if !actions.is_empty() {
eprintln!("Instrumenting actions:");
self.process_instruction();
}
Expand All @@ -417,7 +417,7 @@ impl<'tcx, 'cache> InstrumentationData<'tcx, 'cache> {
SourceInstruction::Statement { idx: idx - 1, bb }
}
SourceInstruction::Terminator { bb }
if self.body.blocks()[bb].statements.len() > 0 =>
if !self.body.blocks()[bb].statements.is_empty() =>
{
SourceInstruction::Statement {
idx: self.body.blocks()[bb].statements.len() - 1,
Expand Down
7 changes: 3 additions & 4 deletions kani-compiler/src/kani_middle/transform/check_aliasing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,10 @@ impl GlobalPass for GlobalAliasingPass {
.def
.all_attrs()
.into_iter()
.fold(false, |is_proof, attr| is_proof || attr.as_str().contains("kanitool::proof"))
.all(|attr| attr.as_str().contains("kanitool::proof")) &&
found.insert(instance)
{
if found.insert(instance) {
queue.push_back(instance)
}
queue.push_back(instance)
}
}
while let Some(instance) = queue.pop_front() {
Expand Down

0 comments on commit cda8657

Please sign in to comment.