Skip to content

Commit b312ad7

Browse files
committed
Auto merge of rust-lang#8856 - xFrednet:rustup, r=Manishearth,Alexendoo
Rustup `@rust-lang/clippy,` `@Jarcho,` `@dswij,` `@Alexendoo.` Could someone review this? It should be pretty straight forward since it's just a sync. I think it's also fine if either one of `@Jarcho,` `@dswij,` `@Alexendoo` approves this, as these are usually not reviewed. I just want to make sure that I didn't break something obvious 🙃 It should be enough to look at the merge commit 🙃 changelog: none changelog: move [`significant_drop_in_scrutinee`] to `suspicious`
2 parents f26f117 + 7842dbc commit b312ad7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1538
-136
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3715,6 +3715,7 @@ Released 2018-09-13
37153715
[`short_circuit_statement`]: https://rust-lang.github.io/rust-clippy/master/index.html#short_circuit_statement
37163716
[`should_assert_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_assert_eq
37173717
[`should_implement_trait`]: https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
3718+
[`significant_drop_in_scrutinee`]: https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_in_scrutinee
37183719
[`similar_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#similar_names
37193720
[`single_char_add_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
37203721
[`single_char_lifetime_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_lifetime_names

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.62"
3+
version = "0.1.63"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.62"
3+
version = "0.1.63"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/src/collapsible_match.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::{is_lang_ctor, is_unit_expr, path_to_local, peel_blocks_with_s
55
use if_chain::if_chain;
66
use rustc_errors::MultiSpan;
77
use rustc_hir::LangItem::OptionNone;
8-
use rustc_hir::{Arm, Expr, Guard, HirId, Pat, PatKind};
8+
use rustc_hir::{Arm, Expr, Guard, HirId, Let, Pat, PatKind};
99
use rustc_lint::{LateContext, LateLintPass};
1010
use rustc_session::{declare_lint_pass, declare_tool_lint};
1111
use rustc_span::Span;
@@ -109,7 +109,10 @@ fn check_arm<'tcx>(
109109
(Some(a), Some(b)) => SpanlessEq::new(cx).eq_expr(a, b),
110110
};
111111
// the binding must not be used in the if guard
112-
if outer_guard.map_or(true, |(Guard::If(e) | Guard::IfLet(_, e))| !is_local_used(cx, *e, binding_id));
112+
if outer_guard.map_or(
113+
true,
114+
|(Guard::If(e) | Guard::IfLet(Let { init: e, .. }))| !is_local_used(cx, *e, binding_id)
115+
);
113116
// ...or anywhere in the inner expression
114117
if match inner {
115118
IfLetOrMatch::IfLet(_, _, body, els) => {

clippy_lints/src/derivable_impls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
2-
use clippy_utils::{is_automatically_derived, is_default_equivalent, peel_blocks};
2+
use clippy_utils::{is_default_equivalent, peel_blocks};
33
use rustc_hir::{
44
def::{DefKind, Res},
55
Body, Expr, ExprKind, GenericArg, Impl, ImplItemKind, Item, ItemKind, Node, PathSegment, QPath, TyKind,
@@ -71,8 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
7171
self_ty,
7272
..
7373
}) = item.kind;
74-
if let attrs = cx.tcx.hir().attrs(item.hir_id());
75-
if !is_automatically_derived(attrs);
74+
if !cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
7675
if !item.span.from_expansion();
7776
if let Some(def_id) = trait_ref.trait_def_id();
7877
if cx.tcx.is_diagnostic_item(sym::Default, def_id);
@@ -81,6 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
8180
if let ImplItemKind::Fn(_, b) = &impl_item.kind;
8281
if let Body { value: func_expr, .. } = cx.tcx.hir().body(*b);
8382
if let Some(adt_def) = cx.tcx.type_of(item.def_id).ty_adt_def();
83+
if let attrs = cx.tcx.hir().attrs(item.hir_id());
8484
if !attrs.iter().any(|attr| attr.doc_str().is_some());
8585
if let child_attrs = cx.tcx.hir().attrs(impl_item_hir);
8686
if !child_attrs.iter().any(|attr| attr.doc_str().is_some());

clippy_lints/src/derive.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then};
22
use clippy_utils::paths;
33
use clippy_utils::ty::{implements_trait, is_copy};
4-
use clippy_utils::{is_automatically_derived, is_lint_allowed, match_def_path};
4+
use clippy_utils::{is_lint_allowed, match_def_path};
55
use if_chain::if_chain;
66
use rustc_errors::Applicability;
77
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, Visitor};
@@ -205,8 +205,7 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
205205
}) = item.kind
206206
{
207207
let ty = cx.tcx.type_of(item.def_id);
208-
let attrs = cx.tcx.hir().attrs(item.hir_id());
209-
let is_automatically_derived = is_automatically_derived(attrs);
208+
let is_automatically_derived = cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
210209

211210
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
212211
check_ord_partial_ord(cx, item.span, trait_ref, ty, is_automatically_derived);
@@ -236,7 +235,7 @@ fn check_hash_peq<'tcx>(
236235
then {
237236
// Look for the PartialEq implementations for `ty`
238237
cx.tcx.for_each_relevant_impl(peq_trait_def_id, ty, |impl_id| {
239-
let peq_is_automatically_derived = is_automatically_derived(cx.tcx.get_attrs(impl_id));
238+
let peq_is_automatically_derived = cx.tcx.has_attr(impl_id, sym::automatically_derived);
240239

241240
if peq_is_automatically_derived == hash_is_automatically_derived {
242241
return;
@@ -290,7 +289,7 @@ fn check_ord_partial_ord<'tcx>(
290289
then {
291290
// Look for the PartialOrd implementations for `ty`
292291
cx.tcx.for_each_relevant_impl(partial_ord_trait_def_id, ty, |impl_id| {
293-
let partial_ord_is_automatically_derived = is_automatically_derived(cx.tcx.get_attrs(impl_id));
292+
let partial_ord_is_automatically_derived = cx.tcx.has_attr(impl_id, sym::automatically_derived);
294293

295294
if partial_ord_is_automatically_derived == ord_is_automatically_derived {
296295
return;

clippy_lints/src/entry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_errors::Applicability;
1111
use rustc_hir::{
1212
hir_id::HirIdSet,
1313
intravisit::{walk_expr, Visitor},
14-
Block, Expr, ExprKind, Guard, HirId, Pat, Stmt, StmtKind, UnOp,
14+
Block, Expr, ExprKind, Guard, HirId, Let, Pat, Stmt, StmtKind, UnOp,
1515
};
1616
use rustc_lint::{LateContext, LateLintPass};
1717
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -478,7 +478,7 @@ impl<'tcx> Visitor<'tcx> for InsertSearcher<'_, 'tcx> {
478478
let mut is_map_used = self.is_map_used;
479479
for arm in arms {
480480
self.visit_pat(arm.pat);
481-
if let Some(Guard::If(guard) | Guard::IfLet(_, guard)) = arm.guard {
481+
if let Some(Guard::If(guard) | Guard::IfLet(&Let { init: guard, .. })) = arm.guard {
482482
self.visit_non_tail_expr(guard);
483483
}
484484
is_map_used |= self.visit_cond_arm(arm.body);

clippy_lints/src/eta_reduction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
150150
if check_inputs(cx, body.params, args);
151151
let method_def_id = cx.typeck_results().type_dependent_def_id(body.value.hir_id).unwrap();
152152
let substs = cx.typeck_results().node_substs(body.value.hir_id);
153-
let call_ty = cx.tcx.type_of(method_def_id).subst(cx.tcx, substs);
153+
let call_ty = cx.tcx.bound_type_of(method_def_id).subst(cx.tcx, substs);
154154
if check_sig(cx, closure_ty, call_ty);
155155
then {
156156
span_lint_and_then(cx, REDUNDANT_CLOSURE_FOR_METHOD_CALLS, expr.span, "redundant closure", |diag| {

clippy_lints/src/functions/must_use.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ use clippy_utils::attrs::is_proc_macro;
1313
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then};
1414
use clippy_utils::source::snippet_opt;
1515
use clippy_utils::ty::is_must_use_ty;
16-
use clippy_utils::{match_def_path, must_use_attr, return_ty, trait_ref_of_method};
16+
use clippy_utils::{match_def_path, return_ty, trait_ref_of_method};
1717

1818
use super::{DOUBLE_MUST_USE, MUST_USE_CANDIDATE, MUST_USE_UNIT};
1919

2020
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
2121
let attrs = cx.tcx.hir().attrs(item.hir_id());
22-
let attr = must_use_attr(attrs);
22+
let attr = cx.tcx.get_attr(item.def_id.to_def_id(), sym::must_use);
2323
if let hir::ItemKind::Fn(ref sig, _generics, ref body_id) = item.kind {
2424
let is_public = cx.access_levels.is_exported(item.def_id);
2525
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
@@ -44,7 +44,7 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
4444
let is_public = cx.access_levels.is_exported(item.def_id);
4545
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
4646
let attrs = cx.tcx.hir().attrs(item.hir_id());
47-
let attr = must_use_attr(attrs);
47+
let attr = cx.tcx.get_attr(item.def_id.to_def_id(), sym::must_use);
4848
if let Some(attr) = attr {
4949
check_needless_must_use(cx, sig.decl, item.hir_id(), item.span, fn_header_span, attr);
5050
} else if is_public && !is_proc_macro(cx.sess(), attrs) && trait_ref_of_method(cx, item.def_id).is_none() {
@@ -67,7 +67,7 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
6767
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
6868

6969
let attrs = cx.tcx.hir().attrs(item.hir_id());
70-
let attr = must_use_attr(attrs);
70+
let attr = cx.tcx.get_attr(item.def_id.to_def_id(), sym::must_use);
7171
if let Some(attr) = attr {
7272
check_needless_must_use(cx, sig.decl, item.hir_id(), item.span, fn_header_span, attr);
7373
} else if let hir::TraitFn::Provided(eid) = *eid {

clippy_lints/src/future_not_send.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::{Body, FnDecl, HirId};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_middle::ty::subst::Subst;
8-
use rustc_middle::ty::{Opaque, PredicateKind::Trait};
8+
use rustc_middle::ty::{EarlyBinder, Opaque, PredicateKind::Trait};
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
1010
use rustc_span::{sym, Span};
1111
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;
@@ -67,7 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6767
let preds = cx.tcx.explicit_item_bounds(id);
6868
let mut is_future = false;
6969
for &(p, _span) in preds {
70-
let p = p.subst(cx.tcx, subst);
70+
let p = EarlyBinder(p).subst(cx.tcx, subst);
7171
if let Some(trait_pred) = p.to_opt_poly_trait_pred() {
7272
if Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() {
7373
is_future = true;

clippy_lints/src/lib.register_all.rs

+1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
278278
LintId::of(self_assignment::SELF_ASSIGNMENT),
279279
LintId::of(self_named_constructors::SELF_NAMED_CONSTRUCTORS),
280280
LintId::of(serde_api::SERDE_API_MISUSE),
281+
LintId::of(significant_drop_in_scrutinee::SIGNIFICANT_DROP_IN_SCRUTINEE),
281282
LintId::of(single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
282283
LintId::of(size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT),
283284
LintId::of(slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),

clippy_lints/src/lib.register_lints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ store.register_lints(&[
473473
shadow::SHADOW_REUSE,
474474
shadow::SHADOW_SAME,
475475
shadow::SHADOW_UNRELATED,
476+
significant_drop_in_scrutinee::SIGNIFICANT_DROP_IN_SCRUTINEE,
476477
single_char_lifetime_names::SINGLE_CHAR_LIFETIME_NAMES,
477478
single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS,
478479
size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT,

clippy_lints/src/lib.register_suspicious.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ store.register_group(true, "clippy::suspicious", Some("clippy_suspicious"), vec!
2727
LintId::of(mut_key::MUTABLE_KEY_TYPE),
2828
LintId::of(octal_escapes::OCTAL_ESCAPES),
2929
LintId::of(rc_clone_in_vec_init::RC_CLONE_IN_VEC_INIT),
30+
LintId::of(significant_drop_in_scrutinee::SIGNIFICANT_DROP_IN_SCRUTINEE),
3031
LintId::of(suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL),
3132
LintId::of(suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL),
3233
])

clippy_lints/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ mod self_named_constructors;
367367
mod semicolon_if_nothing_returned;
368368
mod serde_api;
369369
mod shadow;
370+
mod significant_drop_in_scrutinee;
370371
mod single_char_lifetime_names;
371372
mod single_component_path_imports;
372373
mod size_of_in_element_count;
@@ -886,6 +887,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
886887
store.register_late_pass(move || Box::new(manual_bits::ManualBits::new(msrv)));
887888
store.register_late_pass(|| Box::new(default_union_representation::DefaultUnionRepresentation));
888889
store.register_late_pass(|| Box::new(only_used_in_recursion::OnlyUsedInRecursion));
890+
store.register_late_pass(|| Box::new(significant_drop_in_scrutinee::SignificantDropInScrutinee));
889891
store.register_late_pass(|| Box::new(dbg_macro::DbgMacro));
890892
let cargo_ignore_publish = conf.cargo_ignore_publish;
891893
store.register_late_pass(move || {

clippy_lints/src/lifetimes.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use rustc_hir::intravisit::{
99
use rustc_hir::FnRetTy::Return;
1010
use rustc_hir::{
1111
BareFnTy, BodyId, FnDecl, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, Impl, ImplItem,
12-
ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, ParamName, PolyTraitRef, TraitBoundModifier,
13-
TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
12+
ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, ParamName, PolyTraitRef, PredicateOrigin,
13+
TraitBoundModifier, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
1414
};
1515
use rustc_lint::{LateContext, LateLintPass};
1616
use rustc_middle::hir::nested_filter as middle_nested_filter;
@@ -145,7 +145,7 @@ fn check_fn_inner<'tcx>(
145145
.filter(|param| matches!(param.kind, GenericParamKind::Type { .. }));
146146
for typ in types {
147147
for pred in generics.bounds_for_param(cx.tcx.hir().local_def_id(typ.hir_id)) {
148-
if pred.in_where_clause {
148+
if pred.origin == PredicateOrigin::WhereClause {
149149
// has_where_lifetimes checked that this predicate contains no lifetime.
150150
continue;
151151
}

clippy_lints/src/manual_non_exhaustive.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use clippy_utils::attrs::is_doc_hidden;
21
use clippy_utils::diagnostics::span_lint_and_then;
32
use clippy_utils::source::snippet_opt;
4-
use clippy_utils::{is_lint_allowed, meets_msrv, msrvs};
3+
use clippy_utils::{is_doc_hidden, is_lint_allowed, meets_msrv, msrvs};
54
use rustc_ast::ast::{self, VisibilityKind};
65
use rustc_data_structures::fx::FxHashSet;
76
use rustc_errors::Applicability;
@@ -161,7 +160,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustiveEnum {
161160
let id = cx.tcx.hir().local_def_id(v.id);
162161
(matches!(v.data, hir::VariantData::Unit(_))
163162
&& v.ident.as_str().starts_with('_')
164-
&& is_doc_hidden(cx.tcx.get_attrs(id.to_def_id())))
163+
&& is_doc_hidden(cx.tcx.hir().attrs(v.id)))
165164
.then(|| (id, v.span))
166165
});
167166
if let Some((id, span)) = iter.next()

clippy_lints/src/matches/match_wild_enum.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,5 @@ impl<'a> CommonPrefixSearcher<'a> {
192192
}
193193

194194
fn is_hidden(cx: &LateContext<'_>, variant_def: &VariantDef) -> bool {
195-
let attrs = cx.tcx.get_attrs(variant_def.def_id);
196-
clippy_utils::attrs::is_doc_hidden(attrs) || clippy_utils::attrs::is_unstable(attrs)
195+
cx.tcx.is_doc_hidden(variant_def.def_id) || cx.tcx.has_attr(variant_def.def_id, sym::unstable)
197196
}

clippy_lints/src/mut_reference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMutPassed {
4848
ExprKind::MethodCall(path, arguments, _) => {
4949
let def_id = cx.typeck_results().type_dependent_def_id(e.hir_id).unwrap();
5050
let substs = cx.typeck_results().node_substs(e.hir_id);
51-
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
51+
let method_type = cx.tcx.bound_type_of(def_id).subst(cx.tcx, substs);
5252
check_arguments(cx, arguments, method_type, path.ident.as_str(), "method");
5353
},
5454
_ => (),

clippy_lints/src/new_without_default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
8484
// can't be implemented for unsafe new
8585
return;
8686
}
87-
if clippy_utils::is_doc_hidden(cx.tcx.hir().attrs(id)) {
87+
if cx.tcx.is_doc_hidden(impl_item.def_id) {
8888
// shouldn't be implemented when it is hidden in docs
8989
return;
9090
}

clippy_lints/src/only_used_in_recursion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ impl<'tcx> SideEffectVisit<'tcx> {
596596
let mut vars = std::mem::take(&mut self.ret_vars);
597597
let _ = arm.guard.as_ref().map(|guard| {
598598
self.visit_expr(match guard {
599-
Guard::If(expr) | Guard::IfLet(_, expr) => expr,
599+
Guard::If(expr) | Guard::IfLet(Let { init: expr, .. }) => expr,
600600
});
601601
vars.append(&mut self.ret_vars);
602602
});

clippy_lints/src/partialeq_ne_impl.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clippy_utils::diagnostics::span_lint_hir;
2-
use clippy_utils::is_automatically_derived;
32
use if_chain::if_chain;
43
use rustc_hir::{Impl, Item, ItemKind};
54
use rustc_lint::{LateContext, LateLintPass};
@@ -37,8 +36,7 @@ impl<'tcx> LateLintPass<'tcx> for PartialEqNeImpl {
3736
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
3837
if_chain! {
3938
if let ItemKind::Impl(Impl { of_trait: Some(ref trait_ref), items: impl_items, .. }) = item.kind;
40-
let attrs = cx.tcx.hir().attrs(item.hir_id());
41-
if !is_automatically_derived(attrs);
39+
if !cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
4240
if let Some(eq_trait) = cx.tcx.lang_items().eq_trait();
4341
if trait_ref.path.res.def_id() == eq_trait;
4442
then {

clippy_lints/src/redundant_clone.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
113113
}
114114

115115
// Give up on loops
116-
if terminator.successors().any(|s| *s == bb) {
116+
if terminator.successors().any(|s| s == bb) {
117117
continue;
118118
}
119119

@@ -439,7 +439,7 @@ fn visit_clone_usage(cloned: mir::Local, clone: mir::Local, mir: &mir::Body<'_>,
439439
// Short-circuit
440440
if (usage.cloned_used && usage.clone_consumed_or_mutated) ||
441441
// Give up on loops
442-
tdata.terminator().successors().any(|s| *s == bb)
442+
tdata.terminator().successors().any(|s| s == bb)
443443
{
444444
return CloneUsage {
445445
cloned_used: true,

clippy_lints/src/same_name_method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
5151
let mut map = FxHashMap::<Res, ExistingName>::default();
5252

5353
for id in cx.tcx.hir().items() {
54-
if matches!(cx.tcx.hir().def_kind(id.def_id), DefKind::Impl)
54+
if matches!(cx.tcx.def_kind(id.def_id), DefKind::Impl)
5555
&& let item = cx.tcx.hir().item(id)
5656
&& let ItemKind::Impl(Impl {
5757
items,

0 commit comments

Comments
 (0)