Skip to content

Commit 5308b23

Browse files
authored
Merge pull request #19484 from Veykril/push-ttvnzlkvwssk
fix: Fix new nightly lints
2 parents 00191d8 + 1e1571e commit 5308b23

File tree

26 files changed

+88
-96
lines changed

26 files changed

+88
-96
lines changed

crates/hir-def/src/expr_store/lower.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,7 @@ impl ExprCollector<'_> {
13601360
else {
13611361
panic!("just expanded a macro, ExpansionSpanMap should be available");
13621362
};
1363-
let old_span_map =
1364-
mem::replace(&mut self.current_span_map, Some(new_span_map.clone()));
1363+
let old_span_map = self.current_span_map.replace(new_span_map.clone());
13651364
let id = collector(self, Some(expansion.tree()));
13661365
self.current_span_map = old_span_map;
13671366
self.ast_id_map = prev_ast_id_map;

crates/hir-def/src/generics.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,26 +329,30 @@ impl GenericParams {
329329
params.clone()
330330
} else {
331331
Arc::new(GenericParams {
332-
type_or_consts: all_type_or_consts_enabled
333-
.then(|| params.type_or_consts.clone())
334-
.unwrap_or_else(|| {
332+
type_or_consts: if all_type_or_consts_enabled {
333+
params.type_or_consts.clone()
334+
} else {
335+
{
335336
params
336337
.type_or_consts
337338
.iter()
338339
.filter(|&(idx, _)| enabled(attr_owner_ct(idx)))
339340
.map(|(_, param)| param.clone())
340341
.collect()
341-
}),
342-
lifetimes: all_lifetimes_enabled
343-
.then(|| params.lifetimes.clone())
344-
.unwrap_or_else(|| {
342+
}
343+
},
344+
lifetimes: if all_lifetimes_enabled {
345+
params.lifetimes.clone()
346+
} else {
347+
{
345348
params
346349
.lifetimes
347350
.iter()
348351
.filter(|&(idx, _)| enabled(attr_owner_lt(idx)))
349352
.map(|(_, param)| param.clone())
350353
.collect()
351-
}),
354+
}
355+
},
352356
where_predicates: params.where_predicates.clone(),
353357
types_map: params.types_map.clone(),
354358
})

crates/hir-expand/src/attrs.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,12 @@ impl Attr {
305305
Some(Box::new(AttrInput::TokenTree(tt::TopSubtree::from_subtree(tree))))
306306
}
307307
(Some(tt::TokenTree::Leaf(tt::Leaf::Punct(tt::Punct { char: '=', .. }))), _) => {
308-
let input = match input.flat_tokens().get(1) {
308+
match input.flat_tokens().get(1) {
309309
Some(tt::TokenTree::Leaf(tt::Leaf::Literal(lit))) => {
310310
Some(Box::new(AttrInput::Literal(lit.clone())))
311311
}
312312
_ => None,
313-
};
314-
input
313+
}
315314
}
316315
_ => None,
317316
};

crates/hir-expand/src/builtin/derive_macro.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,15 +1314,15 @@ fn coerce_pointee_expand(
13141314
}
13151315
})
13161316
});
1317-
let self_for_traits = make::path_from_segments(
1317+
1318+
make::path_from_segments(
13181319
[make::generic_ty_path_segment(
13191320
make::name_ref(&struct_name.text()),
13201321
self_params_for_traits,
13211322
)],
13221323
false,
13231324
)
1324-
.clone_for_update();
1325-
self_for_traits
1325+
.clone_for_update()
13261326
};
13271327

13281328
let mut span_map = span::SpanMap::empty();

crates/hir-ty/src/chalk_db.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,21 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> {
144144
let id_to_chalk = |id: hir_def::ImplId| id.to_chalk(self.db);
145145

146146
let mut result = vec![];
147-
if fps.is_empty() {
148-
debug!("Unrestricted search for {:?} impls...", trait_);
149-
self.for_trait_impls(trait_, self_ty_fp, |impls| {
150-
result.extend(impls.for_trait(trait_).map(id_to_chalk));
151-
ControlFlow::Continue(())
152-
})
153-
} else {
154-
self.for_trait_impls(trait_, self_ty_fp, |impls| {
155-
result.extend(
156-
fps.iter().flat_map(move |fp| {
147+
_ =
148+
if fps.is_empty() {
149+
debug!("Unrestricted search for {:?} impls...", trait_);
150+
self.for_trait_impls(trait_, self_ty_fp, |impls| {
151+
result.extend(impls.for_trait(trait_).map(id_to_chalk));
152+
ControlFlow::Continue(())
153+
})
154+
} else {
155+
self.for_trait_impls(trait_, self_ty_fp, |impls| {
156+
result.extend(fps.iter().flat_map(move |fp| {
157157
impls.for_trait_and_self_ty(trait_, *fp).map(id_to_chalk)
158-
}),
159-
);
160-
ControlFlow::Continue(())
161-
})
162-
};
158+
}));
159+
ControlFlow::Continue(())
160+
})
161+
};
163162

164163
debug!("impls_for_trait returned {} impls", result.len());
165164
result

crates/hir-ty/src/diagnostics/match_check.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl<'a> PatCtxt<'a> {
242242
ty: &Ty,
243243
subpatterns: Vec<FieldPat>,
244244
) -> PatKind {
245-
let kind = match self.infer.variant_resolution_for_pat(pat) {
245+
match self.infer.variant_resolution_for_pat(pat) {
246246
Some(variant_id) => {
247247
if let VariantId::EnumVariantId(enum_variant) = variant_id {
248248
let substs = match ty.kind(Interner) {
@@ -266,8 +266,7 @@ impl<'a> PatCtxt<'a> {
266266
self.errors.push(PatternError::UnresolvedVariant);
267267
PatKind::Wild
268268
}
269-
};
270-
kind
269+
}
271270
}
272271

273272
fn lower_path(&mut self, pat: PatId, _path: &hir_def::path::Path) -> Pat {

crates/hir-ty/src/drop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ fn has_destructor(db: &dyn HirDatabase, adt: AdtId) -> bool {
3232
},
3333
None => db.trait_impls_in_crate(module.krate()),
3434
};
35-
let result = impls.for_trait_and_self_ty(drop_trait, TyFingerprint::Adt(adt)).next().is_some();
36-
result
35+
36+
impls.for_trait_and_self_ty(drop_trait, TyFingerprint::Adt(adt)).next().is_some()
3737
}
3838

3939
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]

crates/hir-ty/src/dyn_compatibility.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub fn dyn_compatibility_of_trait_query(
115115
trait_: TraitId,
116116
) -> Option<DynCompatibilityViolation> {
117117
let mut res = None;
118-
dyn_compatibility_of_trait_with_callback(db, trait_, &mut |osv| {
118+
_ = dyn_compatibility_of_trait_with_callback(db, trait_, &mut |osv| {
119119
res = Some(osv);
120120
ControlFlow::Break(())
121121
});
@@ -592,7 +592,7 @@ fn contains_illegal_impl_trait_in_trait(
592592

593593
let ret = sig.skip_binders().ret();
594594
let mut visitor = OpaqueTypeCollector(FxHashSet::default());
595-
ret.visit_with(visitor.as_dyn(), DebruijnIndex::INNERMOST);
595+
_ = ret.visit_with(visitor.as_dyn(), DebruijnIndex::INNERMOST);
596596

597597
// Since we haven't implemented RPITIT in proper way like rustc yet,
598598
// just check whether `ret` contains RPIT for now

crates/hir-ty/src/dyn_compatibility/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn check_dyn_compatibility<'a>(
5353
continue;
5454
};
5555
let mut osvs = FxHashSet::default();
56-
dyn_compatibility_with_callback(&db, trait_id, &mut |osv| {
56+
_ = dyn_compatibility_with_callback(&db, trait_id, &mut |osv| {
5757
osvs.insert(match osv {
5858
DynCompatibilityViolation::SizedSelf => SizedSelf,
5959
DynCompatibilityViolation::SelfReferential => SelfReferential,

crates/hir-ty/src/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ impl<'a> InferenceContext<'a> {
11431143
non_assocs: FxHashMap::default(),
11441144
};
11451145
for ty in tait_candidates {
1146-
ty.visit_with(collector.as_dyn(), DebruijnIndex::INNERMOST);
1146+
_ = ty.visit_with(collector.as_dyn(), DebruijnIndex::INNERMOST);
11471147
}
11481148

11491149
// Non-assoc TAITs can be define-used everywhere as long as they are

crates/hir-ty/src/infer/closure.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,9 @@ impl InferenceContext<'_> {
517517
return None;
518518
}
519519
let hygiene = self.body.expr_or_pat_path_hygiene(id);
520-
let result = self
521-
.resolver
522-
.resolve_path_in_value_ns_fully(self.db.upcast(), path, hygiene)
523-
.and_then(|result| match result {
520+
521+
self.resolver.resolve_path_in_value_ns_fully(self.db.upcast(), path, hygiene).and_then(
522+
|result| match result {
524523
ValueNs::LocalBinding(binding) => {
525524
let mir_span = match id {
526525
ExprOrPatId::ExprId(id) => MirSpan::ExprId(id),
@@ -530,8 +529,8 @@ impl InferenceContext<'_> {
530529
Some(HirPlace { local: binding, projections: Vec::new() })
531530
}
532531
_ => None,
533-
});
534-
result
532+
},
533+
)
535534
}
536535

537536
/// Changes `current_capture_span_stack` to contain the stack of spans for this expr.

crates/hir-ty/src/infer/expr.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@ impl InferenceContext<'_> {
472472
let prev_diverges = mem::replace(&mut self.diverges, Diverges::Maybe);
473473
let prev_closure = mem::replace(&mut self.current_closure, id);
474474
let prev_ret_ty = mem::replace(&mut self.return_ty, ret_ty.clone());
475-
let prev_ret_coercion =
476-
mem::replace(&mut self.return_coercion, Some(CoerceMany::new(ret_ty)));
475+
let prev_ret_coercion = self.return_coercion.replace(CoerceMany::new(ret_ty));
477476
let prev_resume_yield_tys =
478477
mem::replace(&mut self.resume_yield_tys, resume_yield_tys);
479478

@@ -1168,8 +1167,7 @@ impl InferenceContext<'_> {
11681167
let ret_ty = self.table.new_type_var();
11691168
let prev_diverges = mem::replace(&mut self.diverges, Diverges::Maybe);
11701169
let prev_ret_ty = mem::replace(&mut self.return_ty, ret_ty.clone());
1171-
let prev_ret_coercion =
1172-
mem::replace(&mut self.return_coercion, Some(CoerceMany::new(ret_ty.clone())));
1170+
let prev_ret_coercion = self.return_coercion.replace(CoerceMany::new(ret_ty.clone()));
11731171

11741172
// FIXME: We should handle async blocks like we handle closures
11751173
let expected = &Expectation::has_type(ret_ty);

crates/hir-ty/src/infer/unify.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,8 @@ mod resolve {
10271027
.assert_ty_ref(Interner)
10281028
.clone();
10291029
}
1030-
let result = if let Some(known_ty) = self.table.var_unification_table.probe_var(var) {
1030+
1031+
if let Some(known_ty) = self.table.var_unification_table.probe_var(var) {
10311032
// known_ty may contain other variables that are known by now
10321033
self.var_stack.push(var);
10331034
let result = known_ty.fold_with(self, outer_binder);
@@ -1038,8 +1039,7 @@ mod resolve {
10381039
(self.fallback)(var, VariableKind::Ty(kind), default, outer_binder)
10391040
.assert_ty_ref(Interner)
10401041
.clone()
1041-
};
1042-
result
1042+
}
10431043
}
10441044

10451045
fn fold_inference_const(

crates/hir-ty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ where
10131013
T: ?Sized + TypeVisitable<Interner>,
10141014
{
10151015
let mut collector = PlaceholderCollector { db, placeholders: FxHashSet::default() };
1016-
value.visit_with(&mut collector, DebruijnIndex::INNERMOST);
1016+
_ = value.visit_with(&mut collector, DebruijnIndex::INNERMOST);
10171017
collector.placeholders.into_iter().collect()
10181018
}
10191019

crates/hir-ty/src/method_resolution.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ pub(crate) fn iterate_method_candidates<T>(
585585
mut callback: impl FnMut(ReceiverAdjustments, AssocItemId, bool) -> Option<T>,
586586
) -> Option<T> {
587587
let mut slot = None;
588-
iterate_method_candidates_dyn(
588+
_ = iterate_method_candidates_dyn(
589589
ty,
590590
db,
591591
env,
@@ -898,7 +898,10 @@ pub fn check_orphan_rules(db: &dyn HirDatabase, impl_: ImplId) -> bool {
898898
}
899899
};
900900
// - At least one of the types `T0..=Tn`` must be a local type. Let `Ti`` be the first such type.
901-
let is_not_orphan = trait_ref.substitution.type_parameters(Interner).any(|ty| {
901+
902+
// FIXME: param coverage
903+
// - No uncovered type parameters `P1..=Pn` may appear in `T0..Ti`` (excluding `Ti`)
904+
trait_ref.substitution.type_parameters(Interner).any(|ty| {
902905
match unwrap_fundamental(ty).kind(Interner) {
903906
&TyKind::Adt(AdtId(id), _) => is_local(id.module(db.upcast()).krate()),
904907
TyKind::Error => true,
@@ -907,10 +910,7 @@ pub fn check_orphan_rules(db: &dyn HirDatabase, impl_: ImplId) -> bool {
907910
}),
908911
_ => false,
909912
}
910-
});
911-
// FIXME: param coverage
912-
// - No uncovered type parameters `P1..=Pn` may appear in `T0..Ti`` (excluding `Ti`)
913-
is_not_orphan
913+
})
914914
}
915915

916916
pub fn iterate_path_candidates(

crates/hir-ty/src/mir/lower.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,10 +1635,12 @@ impl<'ctx> MirLowerCtx<'ctx> {
16351635
f: impl FnOnce(&mut MirLowerCtx<'_>, BasicBlockId) -> Result<()>,
16361636
) -> Result<Option<BasicBlockId>> {
16371637
let begin = self.new_basic_block();
1638-
let prev = mem::replace(
1639-
&mut self.current_loop_blocks,
1640-
Some(LoopBlocks { begin, end: None, place, drop_scope_index: self.drop_scopes.len() }),
1641-
);
1638+
let prev = self.current_loop_blocks.replace(LoopBlocks {
1639+
begin,
1640+
end: None,
1641+
place,
1642+
drop_scope_index: self.drop_scopes.len(),
1643+
});
16421644
let prev_label = if let Some(label) = label {
16431645
// We should generate the end now, to make sure that it wouldn't change later. It is
16441646
// bad as we may emit end (unnecessary unreachable block) for unterminating loop, but

crates/hir/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,13 @@ impl Crate {
294294
}
295295

296296
fn core(db: &dyn HirDatabase) -> Option<Crate> {
297-
let result = db
298-
.all_crates()
297+
db.all_crates()
299298
.iter()
300299
.copied()
301300
.find(|&krate| {
302301
matches!(krate.data(db).origin, CrateOrigin::Lang(LangCrateOrigin::Core))
303302
})
304-
.map(Crate::from);
305-
result
303+
.map(Crate::from)
306304
}
307305
}
308306

crates/ide-assists/src/handlers/extract_expressions_from_format_string.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ pub(crate) fn extract_expressions_from_format_string(
7979
Some((NodeOrToken::Token(t), rest)) if t.kind() == WHITESPACE => rest,
8080
_ => arg,
8181
};
82-
let arg = match arg.split_last() {
82+
83+
match arg.split_last() {
8384
Some((NodeOrToken::Token(t), rest)) if t.kind() == WHITESPACE => rest,
8485
_ => arg,
85-
};
86-
arg
86+
}
8787
});
8888

8989
args.collect()

crates/ide-completion/src/render/pattern.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ pub(crate) fn render_variant_pat(
6464
),
6565
None => {
6666
let name = local_name.unwrap_or_else(|| variant.name(ctx.db()));
67-
let it = (
67+
68+
(
6869
name.as_str().to_smolstr(),
6970
name.display(ctx.db(), ctx.completion.edition).to_smolstr(),
70-
);
71-
it
71+
)
7272
}
7373
};
7474

crates/ide-ssr/src/matching.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,8 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
629629
let krate = self.sema.scope(expr.syntax()).map(|it| it.krate()).unwrap_or_else(|| {
630630
hir::Crate::from(*self.sema.db.all_crates().last().expect("no crate graph present"))
631631
});
632-
let res = code_type
632+
633+
code_type
633634
.autoderef(self.sema.db)
634635
.enumerate()
635636
.find(|(_, deref_code_type)| pattern_type == deref_code_type)
@@ -642,8 +643,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
642643
pattern_type.display(self.sema.db, display_target),
643644
code_type.display(self.sema.db, display_target)
644645
)
645-
});
646-
res
646+
})
647647
}
648648

649649
fn get_placeholder_for_node(&self, node: &SyntaxNode) -> Option<&Placeholder> {

crates/ide/src/goto_type_definition.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub(crate) fn goto_type_definition(
7171
sema.descend_into_macros_no_opaque(token)
7272
.into_iter()
7373
.filter_map(|token| {
74-
let ty = sema
74+
sema
7575
.token_ancestors_with_macros(token)
7676
// When `token` is within a macro call, we can't determine its type. Don't continue
7777
// this traversal because otherwise we'll end up returning the type of *that* macro
@@ -103,8 +103,7 @@ pub(crate) fn goto_type_definition(
103103
};
104104

105105
Some(ty)
106-
});
107-
ty
106+
})
108107
})
109108
.for_each(process_ty);
110109
Some(RangeInfo::new(range, res))

0 commit comments

Comments
 (0)