Skip to content

Commit

Permalink
Fix unused_must_use warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSeulArtichaut committed Nov 5, 2020
1 parent 98ad703 commit a9dc61c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion chalk-solve/src/clauses/builtin_traits/unsize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn outer_binder_parameters_used<I: Interner>(
interner,
parameters: HashSet::new(),
};
v.visit_with(&mut visitor, DebruijnIndex::INNERMOST);
let _ = v.visit_with(&mut visitor, DebruijnIndex::INNERMOST);
visitor.parameters
}

Expand Down
2 changes: 1 addition & 1 deletion chalk-solve/src/clauses/env_elaborator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(super) fn elaborate_env_clauses<I: Interner>(
environment: &Environment<I>,
) {
let mut this_round = vec![];
in_clauses.visit_with(
let _ = in_clauses.visit_with(
&mut EnvElaborator::new(db, &mut this_round, environment),
DebruijnIndex::INNERMOST,
);
Expand Down
2 changes: 1 addition & 1 deletion chalk-solve/src/infer/ucanonicalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<I: Interner> InferenceTable<I> {
universes.add(*universe.skip_kind());
}

value0.value.visit_with(
let _ = value0.value.visit_with(
&mut UCollector {
universes: &mut universes,
interner,
Expand Down
1 change: 1 addition & 0 deletions chalk-solve/src/logging_db/id_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use std::collections::BTreeSet;
/// references parent. IdCollector solves this by collecting all of the directly
/// related identifiers, allowing those to be rendered as well, ensuring name
/// resolution is successful.
#[allow(unused_must_use)] // unused `Result`s from `Visitor`s
pub fn collect_unrecorded_ids<'i, I: Interner, DB: RustIrDatabase<I>>(
db: &'i DB,
identifiers: &'_ BTreeSet<RecordedItemId<I>>,
Expand Down
10 changes: 5 additions & 5 deletions chalk-solve/src/solve/truncate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn needs_truncation<I: Interner>(
value: impl Visit<I>,
) -> bool {
let mut visitor = TySizeVisitor::new(interner, infer);
value.visit_with(&mut visitor, DebruijnIndex::INNERMOST);
let _ = value.visit_with(&mut visitor, DebruijnIndex::INNERMOST);

visitor.max_size > max_size
}
Expand Down Expand Up @@ -45,15 +45,15 @@ impl<'infer, 'i, I: Interner> Visitor<'i, I> for TySizeVisitor<'infer, 'i, I> {

fn visit_ty(&mut self, ty: &Ty<I>, outer_binder: DebruijnIndex) -> ControlFlow<()> {
if let Some(normalized_ty) = self.infer.normalize_ty_shallow(self.interner, ty) {
normalized_ty.visit_with(self, outer_binder);
normalized_ty.visit_with(self, outer_binder)?;
return ControlFlow::Ok(());
}

self.size += 1;
self.max_size = max(self.size, self.max_size);

self.depth += 1;
ty.super_visit_with(self, outer_binder);
ty.super_visit_with(self, outer_binder)?;
self.depth -= 1;

// When we get back to the first invocation, clear the counters.
Expand Down Expand Up @@ -89,7 +89,7 @@ mod tests {
(placeholder 1)))));

let mut visitor = TySizeVisitor::new(interner, &mut table);
ty0.visit_with(&mut visitor, DebruijnIndex::INNERMOST);
let _ = ty0.visit_with(&mut visitor, DebruijnIndex::INNERMOST);
assert!(visitor.max_size == 5);
}

Expand All @@ -113,7 +113,7 @@ mod tests {
(placeholder 1))));

let mut visitor = TySizeVisitor::new(interner, &mut table);
vec![&ty0, &ty1].visit_with(&mut visitor, DebruijnIndex::INNERMOST);
let _ = vec![&ty0, &ty1].visit_with(&mut visitor, DebruijnIndex::INNERMOST);
assert!(visitor.max_size == 5);
}
}
20 changes: 10 additions & 10 deletions chalk-solve/src/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<'i, I: Interner> InputTypeCollector<'i, I> {

fn types_in(interner: &'i I, value: impl Visit<I>) -> Vec<Ty<I>> {
let mut collector = Self::new(interner);
value.visit_with(&mut collector, DebruijnIndex::INNERMOST);
let _ = value.visit_with(&mut collector, DebruijnIndex::INNERMOST);
collector.types
}
}
Expand Down Expand Up @@ -104,12 +104,12 @@ impl<'i, I: Interner> Visitor<'i, I> for InputTypeCollector<'i, I> {
match ty.kind(interner) {
TyKind::Adt(id, substitution) => {
push_ty();
id.visit_with(self, outer_binder);
id.visit_with(self, outer_binder)?;
substitution.visit_with(self, outer_binder)
}
TyKind::AssociatedType(assoc_ty, substitution) => {
push_ty();
assoc_ty.visit_with(self, outer_binder);
assoc_ty.visit_with(self, outer_binder)?;
substitution.visit_with(self, outer_binder)
}
TyKind::Scalar(scalar) => {
Expand All @@ -122,12 +122,12 @@ impl<'i, I: Interner> Visitor<'i, I> for InputTypeCollector<'i, I> {
}
TyKind::Tuple(arity, substitution) => {
push_ty();
arity.visit_with(self, outer_binder);
arity.visit_with(self, outer_binder)?;
substitution.visit_with(self, outer_binder)
}
TyKind::OpaqueType(opaque_ty, substitution) => {
push_ty();
opaque_ty.visit_with(self, outer_binder);
opaque_ty.visit_with(self, outer_binder)?;
substitution.visit_with(self, outer_binder)
}
TyKind::Slice(substitution) => {
Expand All @@ -136,18 +136,18 @@ impl<'i, I: Interner> Visitor<'i, I> for InputTypeCollector<'i, I> {
}
TyKind::FnDef(fn_def, substitution) => {
push_ty();
fn_def.visit_with(self, outer_binder);
fn_def.visit_with(self, outer_binder)?;
substitution.visit_with(self, outer_binder)
}
TyKind::Ref(mutability, lifetime, ty) => {
push_ty();
mutability.visit_with(self, outer_binder);
lifetime.visit_with(self, outer_binder);
mutability.visit_with(self, outer_binder)?;
lifetime.visit_with(self, outer_binder)?;
ty.visit_with(self, outer_binder)
}
TyKind::Raw(mutability, substitution) => {
push_ty();
mutability.visit_with(self, outer_binder);
mutability.visit_with(self, outer_binder)?;
substitution.visit_with(self, outer_binder)
}
TyKind::Never => {
Expand All @@ -156,7 +156,7 @@ impl<'i, I: Interner> Visitor<'i, I> for InputTypeCollector<'i, I> {
}
TyKind::Array(ty, const_) => {
push_ty();
ty.visit_with(self, outer_binder);
ty.visit_with(self, outer_binder)?;
const_.visit_with(self, outer_binder)
}
TyKind::Closure(_id, substitution) => {
Expand Down

0 comments on commit a9dc61c

Please sign in to comment.