fix: Fix new nightly lints

This commit is contained in:
Lukas Wirth 2025-03-31 13:26:52 +02:00
parent 00191d8e91
commit 1e1571e1c8
26 changed files with 88 additions and 96 deletions

View file

@ -144,22 +144,21 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> {
let id_to_chalk = |id: hir_def::ImplId| id.to_chalk(self.db);
let mut result = vec![];
if fps.is_empty() {
debug!("Unrestricted search for {:?} impls...", trait_);
self.for_trait_impls(trait_, self_ty_fp, |impls| {
result.extend(impls.for_trait(trait_).map(id_to_chalk));
ControlFlow::Continue(())
})
} else {
self.for_trait_impls(trait_, self_ty_fp, |impls| {
result.extend(
fps.iter().flat_map(move |fp| {
_ =
if fps.is_empty() {
debug!("Unrestricted search for {:?} impls...", trait_);
self.for_trait_impls(trait_, self_ty_fp, |impls| {
result.extend(impls.for_trait(trait_).map(id_to_chalk));
ControlFlow::Continue(())
})
} else {
self.for_trait_impls(trait_, self_ty_fp, |impls| {
result.extend(fps.iter().flat_map(move |fp| {
impls.for_trait_and_self_ty(trait_, *fp).map(id_to_chalk)
}),
);
ControlFlow::Continue(())
})
};
}));
ControlFlow::Continue(())
})
};
debug!("impls_for_trait returned {} impls", result.len());
result

View file

@ -242,7 +242,7 @@ impl<'a> PatCtxt<'a> {
ty: &Ty,
subpatterns: Vec<FieldPat>,
) -> PatKind {
let kind = match self.infer.variant_resolution_for_pat(pat) {
match self.infer.variant_resolution_for_pat(pat) {
Some(variant_id) => {
if let VariantId::EnumVariantId(enum_variant) = variant_id {
let substs = match ty.kind(Interner) {
@ -266,8 +266,7 @@ impl<'a> PatCtxt<'a> {
self.errors.push(PatternError::UnresolvedVariant);
PatKind::Wild
}
};
kind
}
}
fn lower_path(&mut self, pat: PatId, _path: &hir_def::path::Path) -> Pat {

View file

@ -32,8 +32,8 @@ fn has_destructor(db: &dyn HirDatabase, adt: AdtId) -> bool {
},
None => db.trait_impls_in_crate(module.krate()),
};
let result = impls.for_trait_and_self_ty(drop_trait, TyFingerprint::Adt(adt)).next().is_some();
result
impls.for_trait_and_self_ty(drop_trait, TyFingerprint::Adt(adt)).next().is_some()
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]

View file

@ -115,7 +115,7 @@ pub fn dyn_compatibility_of_trait_query(
trait_: TraitId,
) -> Option<DynCompatibilityViolation> {
let mut res = None;
dyn_compatibility_of_trait_with_callback(db, trait_, &mut |osv| {
_ = dyn_compatibility_of_trait_with_callback(db, trait_, &mut |osv| {
res = Some(osv);
ControlFlow::Break(())
});
@ -592,7 +592,7 @@ fn contains_illegal_impl_trait_in_trait(
let ret = sig.skip_binders().ret();
let mut visitor = OpaqueTypeCollector(FxHashSet::default());
ret.visit_with(visitor.as_dyn(), DebruijnIndex::INNERMOST);
_ = ret.visit_with(visitor.as_dyn(), DebruijnIndex::INNERMOST);
// Since we haven't implemented RPITIT in proper way like rustc yet,
// just check whether `ret` contains RPIT for now

View file

@ -53,7 +53,7 @@ fn check_dyn_compatibility<'a>(
continue;
};
let mut osvs = FxHashSet::default();
dyn_compatibility_with_callback(&db, trait_id, &mut |osv| {
_ = dyn_compatibility_with_callback(&db, trait_id, &mut |osv| {
osvs.insert(match osv {
DynCompatibilityViolation::SizedSelf => SizedSelf,
DynCompatibilityViolation::SelfReferential => SelfReferential,

View file

@ -1143,7 +1143,7 @@ impl<'a> InferenceContext<'a> {
non_assocs: FxHashMap::default(),
};
for ty in tait_candidates {
ty.visit_with(collector.as_dyn(), DebruijnIndex::INNERMOST);
_ = ty.visit_with(collector.as_dyn(), DebruijnIndex::INNERMOST);
}
// Non-assoc TAITs can be define-used everywhere as long as they are

View file

@ -517,10 +517,9 @@ impl InferenceContext<'_> {
return None;
}
let hygiene = self.body.expr_or_pat_path_hygiene(id);
let result = self
.resolver
.resolve_path_in_value_ns_fully(self.db.upcast(), path, hygiene)
.and_then(|result| match result {
self.resolver.resolve_path_in_value_ns_fully(self.db.upcast(), path, hygiene).and_then(
|result| match result {
ValueNs::LocalBinding(binding) => {
let mir_span = match id {
ExprOrPatId::ExprId(id) => MirSpan::ExprId(id),
@ -530,8 +529,8 @@ impl InferenceContext<'_> {
Some(HirPlace { local: binding, projections: Vec::new() })
}
_ => None,
});
result
},
)
}
/// Changes `current_capture_span_stack` to contain the stack of spans for this expr.

View file

@ -472,8 +472,7 @@ impl InferenceContext<'_> {
let prev_diverges = mem::replace(&mut self.diverges, Diverges::Maybe);
let prev_closure = mem::replace(&mut self.current_closure, id);
let prev_ret_ty = mem::replace(&mut self.return_ty, ret_ty.clone());
let prev_ret_coercion =
mem::replace(&mut self.return_coercion, Some(CoerceMany::new(ret_ty)));
let prev_ret_coercion = self.return_coercion.replace(CoerceMany::new(ret_ty));
let prev_resume_yield_tys =
mem::replace(&mut self.resume_yield_tys, resume_yield_tys);
@ -1168,8 +1167,7 @@ impl InferenceContext<'_> {
let ret_ty = self.table.new_type_var();
let prev_diverges = mem::replace(&mut self.diverges, Diverges::Maybe);
let prev_ret_ty = mem::replace(&mut self.return_ty, ret_ty.clone());
let prev_ret_coercion =
mem::replace(&mut self.return_coercion, Some(CoerceMany::new(ret_ty.clone())));
let prev_ret_coercion = self.return_coercion.replace(CoerceMany::new(ret_ty.clone()));
// FIXME: We should handle async blocks like we handle closures
let expected = &Expectation::has_type(ret_ty);

View file

@ -1027,7 +1027,8 @@ mod resolve {
.assert_ty_ref(Interner)
.clone();
}
let result = if let Some(known_ty) = self.table.var_unification_table.probe_var(var) {
if let Some(known_ty) = self.table.var_unification_table.probe_var(var) {
// known_ty may contain other variables that are known by now
self.var_stack.push(var);
let result = known_ty.fold_with(self, outer_binder);
@ -1038,8 +1039,7 @@ mod resolve {
(self.fallback)(var, VariableKind::Ty(kind), default, outer_binder)
.assert_ty_ref(Interner)
.clone()
};
result
}
}
fn fold_inference_const(

View file

@ -1013,7 +1013,7 @@ where
T: ?Sized + TypeVisitable<Interner>,
{
let mut collector = PlaceholderCollector { db, placeholders: FxHashSet::default() };
value.visit_with(&mut collector, DebruijnIndex::INNERMOST);
_ = value.visit_with(&mut collector, DebruijnIndex::INNERMOST);
collector.placeholders.into_iter().collect()
}

View file

@ -585,7 +585,7 @@ pub(crate) fn iterate_method_candidates<T>(
mut callback: impl FnMut(ReceiverAdjustments, AssocItemId, bool) -> Option<T>,
) -> Option<T> {
let mut slot = None;
iterate_method_candidates_dyn(
_ = iterate_method_candidates_dyn(
ty,
db,
env,
@ -898,7 +898,10 @@ pub fn check_orphan_rules(db: &dyn HirDatabase, impl_: ImplId) -> bool {
}
};
// - At least one of the types `T0..=Tn`` must be a local type. Let `Ti`` be the first such type.
let is_not_orphan = trait_ref.substitution.type_parameters(Interner).any(|ty| {
// FIXME: param coverage
// - No uncovered type parameters `P1..=Pn` may appear in `T0..Ti`` (excluding `Ti`)
trait_ref.substitution.type_parameters(Interner).any(|ty| {
match unwrap_fundamental(ty).kind(Interner) {
&TyKind::Adt(AdtId(id), _) => is_local(id.module(db.upcast()).krate()),
TyKind::Error => true,
@ -907,10 +910,7 @@ pub fn check_orphan_rules(db: &dyn HirDatabase, impl_: ImplId) -> bool {
}),
_ => false,
}
});
// FIXME: param coverage
// - No uncovered type parameters `P1..=Pn` may appear in `T0..Ti`` (excluding `Ti`)
is_not_orphan
})
}
pub fn iterate_path_candidates(

View file

@ -1635,10 +1635,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
f: impl FnOnce(&mut MirLowerCtx<'_>, BasicBlockId) -> Result<()>,
) -> Result<Option<BasicBlockId>> {
let begin = self.new_basic_block();
let prev = mem::replace(
&mut self.current_loop_blocks,
Some(LoopBlocks { begin, end: None, place, drop_scope_index: self.drop_scopes.len() }),
);
let prev = self.current_loop_blocks.replace(LoopBlocks {
begin,
end: None,
place,
drop_scope_index: self.drop_scopes.len(),
});
let prev_label = if let Some(label) = label {
// We should generate the end now, to make sure that it wouldn't change later. It is
// bad as we may emit end (unnecessary unreachable block) for unterminating loop, but