Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinleroy committed Aug 16, 2024
1 parent f28c069 commit 6d5c00b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
4 changes: 1 addition & 3 deletions crates/argus/src/aadebug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ impl<'tcx> Storage<'tcx> {
let tree_start = Instant::now();

let mut sets = vec![];
tree.for_correction_set(|conjunct| {
sets.push(tree.weight(&conjunct));
});
tree.for_correction_set(|conjunct| sets.push(tree.weight(conjunct)));

timer::elapsed("aadeg::into_results", tree_start);

Expand Down
26 changes: 13 additions & 13 deletions crates/argus/src/aadebug/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ impl<'a, 'tcx> Goal<'a, 'tcx> {
}

fn analyze(&self) -> Heuristic {
use std::cmp::Ordering;

// We should only be analyzing failed predicates
assert!(!self.result.is_yes());

Expand All @@ -188,16 +190,14 @@ impl<'a, 'tcx> Goal<'a, 'tcx> {
log::debug!("Fn Args {:?}", t.trait_ref.args.into_type_list(tcx));
log::debug!("{} v {}", fn_arity, trait_arity);

if fn_arity > trait_arity {
GoalKind::DeleteFnParams {
delta: fn_arity - trait_arity,
}
} else if fn_arity < trait_arity {
GoalKind::AddFnParams {
match fn_arity.cmp(&trait_arity) {
Ordering::Less => GoalKind::AddFnParams {
delta: trait_arity - fn_arity,
}
} else {
GoalKind::IncorrectParams { arity: fn_arity }
},
Ordering::Greater => GoalKind::DeleteFnParams {
delta: fn_arity - trait_arity,
},
Ordering::Equal => GoalKind::IncorrectParams { arity: fn_arity },
}
}

Expand Down Expand Up @@ -398,10 +398,6 @@ impl<'a, 'tcx: 'a> T<'a, 'tcx> {
}

pub fn dnf(&self) -> impl Deref<Target = Dnf<I>> + '_ {
if self.dnf.borrow().is_some() {
return self.expect_dnf();
}

fn _goal(this: &T, goal: &Goal) -> Option<Dnf<I>> {
if !((this.maybe_ambiguous && goal.result.is_maybe())
|| goal.result.is_no())
Expand Down Expand Up @@ -430,6 +426,10 @@ impl<'a, 'tcx: 'a> T<'a, 'tcx> {
Dnf::and(goals.filter_map(|g| _goal(this, &g)))
}

if self.dnf.borrow().is_some() {
return self.expect_dnf();
}

let dnf_report_msg =
format!("Normalizing to DNF from {} nodes", self.ns.len());
let dnf_start = Instant::now();
Expand Down
2 changes: 1 addition & 1 deletion crates/argus/src/analysis/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub fn process_obligation_for_tree<'tcx>(
log::error!("matching target tree not generated {e:?}");
}
}
})
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion crates/argus/src/analysis/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub fn find_most_enclosing_node(

/// Visitor for finding a `HirId` given a span.
///
/// Code taken from rustc_trait_selection::traits::error_reporting and modified
/// Code taken from `rustc_trait_selection::traits::error_reporting` and modified
/// to find items that enclose the span, not just match it exactly.
struct FindNodeBySpan {
pub span: Span,
Expand Down
4 changes: 2 additions & 2 deletions crates/argus/src/analysis/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl<'a, 'tcx: 'a> ObligationsBuilder<'a, 'tcx> {

self.trait_errors.push(TraitError {
idx: expr_id,
range: self.exprs[expr_id].range.clone(),
range: self.exprs[expr_id].range,
hashes,
});
continue;
Expand Down Expand Up @@ -380,7 +380,7 @@ impl<'a, 'tcx: 'a> ObligationsBuilder<'a, 'tcx> {
// Mark the found Expr as containing an error.
self.trait_errors.push(TraitError {
idx: *expr_id,
range: self.exprs[*expr_id].range.clone(),
range: self.exprs[*expr_id].range,
hashes: vec![],
});
}
Expand Down

0 comments on commit 6d5c00b

Please sign in to comment.