Skip to content
/ rust Public
forked from rust-lang/rust

Commit 8703661

Browse files
committed
Auto merge of rust-lang#11316 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` cc `@max-niederman` With the latest sync, I'm getting a lot of FP in the `redundant_locals` lint you recently added. Any ideas where this could come from? changelog: none
2 parents bd1554c + 3927677 commit 8703661

Some content is hidden

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

60 files changed

+156
-148
lines changed

clippy_lints/src/dereference.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ fn in_postfix_position<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> boo
800800
&& parent.span.ctxt() == e.span.ctxt()
801801
{
802802
match parent.kind {
803-
ExprKind::Call(child, _) | ExprKind::MethodCall(_, child, _, _) | ExprKind::Index(child, _)
803+
ExprKind::Call(child, _) | ExprKind::MethodCall(_, child, _, _) | ExprKind::Index(child, _, _)
804804
if child.hir_id == e.hir_id => true,
805805
ExprKind::Field(_, _) | ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar) => true,
806806
_ => false,
@@ -1170,7 +1170,7 @@ fn referent_used_exactly_once<'tcx>(
11701170
&& let [location] = *local_assignments(mir, local).as_slice()
11711171
&& let Some(statement) = mir.basic_blocks[location.block].statements.get(location.statement_index)
11721172
&& let StatementKind::Assign(box (_, Rvalue::Ref(_, _, place))) = statement.kind
1173-
&& !place.has_deref()
1173+
&& !place.is_indirect_first_projection()
11741174
// Ensure not in a loop (https://github.com/rust-lang/rust-clippy/issues/9710)
11751175
&& TriColorDepthFirstSearch::new(&mir.basic_blocks).run_from(location.block, &mut CycleDetector).is_none()
11761176
{

clippy_lints/src/derive.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ use rustc_errors::Applicability;
66
use rustc_hir::def_id::DefId;
77
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, Visitor};
88
use rustc_hir::{
9-
self as hir, BlockCheckMode, BodyId, Constness, Expr, ExprKind, FnDecl, Impl, Item, ItemKind, UnsafeSource,
10-
Unsafety,
9+
self as hir, BlockCheckMode, BodyId, Expr, ExprKind, FnDecl, Impl, Item, ItemKind, UnsafeSource, Unsafety,
1110
};
1211
use rustc_lint::{LateContext, LateLintPass};
1312
use rustc_middle::hir::nested_filter;
1413
use rustc_middle::traits::Reveal;
1514
use rustc_middle::ty::{
16-
self, BoundConstness, ClauseKind, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv, ToPredicate,
17-
TraitPredicate, Ty, TyCtxt,
15+
self, ClauseKind, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv, ToPredicate, TraitPredicate, Ty,
16+
TyCtxt,
1817
};
1918
use rustc_session::{declare_lint_pass, declare_tool_lint};
2019
use rustc_span::def_id::LocalDefId;
@@ -346,9 +345,10 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
346345
if !is_copy(cx, ty) {
347346
if ty_subs.non_erasable_generics().next().is_some() {
348347
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).map_or(false, |impls| {
349-
impls
350-
.iter()
351-
.any(|&id| matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _) if ty_adt.did() == adt.did()))
348+
impls.iter().any(|&id| {
349+
matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _)
350+
if ty_adt.did() == adt.did())
351+
})
352352
});
353353
if !has_copy_impl {
354354
return;
@@ -507,7 +507,6 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
507507
if let ClauseKind::Trait(p) = p.kind().skip_binder()
508508
&& p.trait_ref.def_id == eq_trait_id
509509
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
510-
&& p.constness == BoundConstness::NotConst
511510
{
512511
// Flag types which already have an `Eq` bound.
513512
params[self_ty.index as usize].1 = false;
@@ -519,13 +518,11 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
519518
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
520519
ClauseKind::Trait(TraitPredicate {
521520
trait_ref: ty::TraitRef::new(tcx, eq_trait_id, [tcx.mk_param_from_def(param)]),
522-
constness: BoundConstness::NotConst,
523521
polarity: ImplPolarity::Positive,
524522
})
525523
.to_predicate(tcx)
526524
}),
527525
)),
528526
Reveal::UserFacing,
529-
Constness::NotConst,
530527
)
531528
}

clippy_lints/src/doc.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_ast::token::CommentKind;
1616
use rustc_data_structures::fx::FxHashSet;
1717
use rustc_data_structures::sync::Lrc;
1818
use rustc_errors::emitter::EmitterWriter;
19-
use rustc_errors::{Applicability, Handler, SuggestionStyle, TerminalUrl};
19+
use rustc_errors::{Applicability, Handler, SuggestionStyle};
2020
use rustc_hir as hir;
2121
use rustc_hir::intravisit::{self, Visitor};
2222
use rustc_hir::{AnonConst, Expr};
@@ -716,19 +716,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
716716
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
717717
let fallback_bundle =
718718
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
719-
let emitter = EmitterWriter::new(
720-
Box::new(io::sink()),
721-
None,
722-
None,
723-
fallback_bundle,
724-
false,
725-
false,
726-
false,
727-
None,
728-
false,
729-
false,
730-
TerminalUrl::No,
731-
);
719+
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
732720
let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings();
733721
let sess = ParseSess::with_span_handler(handler, sm);
734722

clippy_lints/src/eta_reduction.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rustc_hir::{BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, QPat
1010
use rustc_infer::infer::TyCtxtInferExt;
1111
use rustc_lint::{LateContext, LateLintPass};
1212
use rustc_middle::ty::{
13-
self, Binder, BoundConstness, ClosureArgs, ClosureKind, EarlyBinder, FnSig, GenericArg, GenericArgKind,
14-
GenericArgsRef, ImplPolarity, List, Region, RegionKind, Ty, TypeVisitableExt, TypeckResults,
13+
self, Binder, ClosureArgs, ClosureKind, EarlyBinder, FnSig, GenericArg, GenericArgKind, GenericArgsRef,
14+
ImplPolarity, List, Region, RegionKind, Ty, TypeVisitableExt, TypeckResults,
1515
};
1616
use rustc_session::{declare_lint_pass, declare_tool_lint};
1717
use rustc_span::symbol::sym;
@@ -171,7 +171,6 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
171171
= cx.tcx.infer_ctxt().build().type_implements_fn_trait(
172172
cx.param_env,
173173
Binder::bind_with_vars(callee_ty_adjusted, List::empty()),
174-
BoundConstness::NotConst,
175174
ImplPolarity::Positive,
176175
) && path_to_local(callee)
177176
.map_or(

clippy_lints/src/functions/must_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ fn is_mutated_static(e: &hir::Expr<'_>) -> bool {
221221
match e.kind {
222222
Path(QPath::Resolved(_, path)) => !matches!(path.res, Res::Local(_)),
223223
Path(_) => true,
224-
Field(inner, _) | Index(inner, _) => is_mutated_static(inner),
224+
Field(inner, _) | Index(inner, _, _) => is_mutated_static(inner),
225225
_ => false,
226226
}
227227
}

clippy_lints/src/index_refutable_slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> {
254254
// Checking for slice indexing
255255
let parent_id = map.parent_id(expr.hir_id);
256256
if let Some(hir::Node::Expr(parent_expr)) = map.find(parent_id);
257-
if let hir::ExprKind::Index(_, index_expr) = parent_expr.kind;
257+
if let hir::ExprKind::Index(_, index_expr, _) = parent_expr.kind;
258258
if let Some(Constant::Int(index_value)) = constant(cx, cx.typeck_results(), index_expr);
259259
if let Ok(index_value) = index_value.try_into();
260260
if index_value < max_suggested_slice;

clippy_lints/src/indexing_slicing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
103103
return;
104104
}
105105

106-
if let ExprKind::Index(array, index) = &expr.kind {
106+
if let ExprKind::Index(array, index, _) = &expr.kind {
107107
let note = "the suggestion might not be applicable in constant blocks";
108108
let ty = cx.typeck_results().expr_ty(array).peel_refs();
109109
if let Some(range) = higher::Range::hir(index) {

clippy_lints/src/init_numbered_fields.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for NumberedFields {
5050
&& fields
5151
.iter()
5252
.all(|f| f.ident.as_str().as_bytes().iter().all(u8::is_ascii_digit))
53-
&& !matches!(cx.qpath_res(path, e.hir_id), Res::Def(DefKind::TyAlias, ..))
53+
&& !matches!(cx.qpath_res(path, e.hir_id), Res::Def(DefKind::TyAlias { .. }, ..))
5454
{
5555
let expr_spans = fields
5656
.iter()

clippy_lints/src/large_const_arrays.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
5050
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
5151
if_chain! {
5252
if !item.span.from_expansion();
53-
if let ItemKind::Const(hir_ty, _) = &item.kind;
53+
if let ItemKind::Const(hir_ty, generics, _) = &item.kind;
54+
// Since static items may not have generics, skip generic const items.
55+
// FIXME(generic_const_items): I don't think checking `generics.hwcp` suffices as it
56+
// doesn't account for empty where-clauses that only consist of keyword `where` IINM.
57+
if generics.params.is_empty() && !generics.has_where_clause_predicates;
5458
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
5559
if let ty::Array(element_type, cst) = ty.kind();
5660
if let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind();

clippy_lints/src/loops/manual_memcpy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ pub(super) fn check<'tcx>(
6060
o.and_then(|(lhs, rhs)| {
6161
let rhs = fetch_cloned_expr(rhs);
6262
if_chain! {
63-
if let ExprKind::Index(base_left, idx_left) = lhs.kind;
64-
if let ExprKind::Index(base_right, idx_right) = rhs.kind;
63+
if let ExprKind::Index(base_left, idx_left, _) = lhs.kind;
64+
if let ExprKind::Index(base_right, idx_right, _) = rhs.kind;
6565
if let Some(ty) = get_slice_like_element_ty(cx, cx.typeck_results().expr_ty(base_left));
6666
if get_slice_like_element_ty(cx, cx.typeck_results().expr_ty(base_right)).is_some();
6767
if let Some((start_left, offset_left)) = get_details_from_idx(cx, idx_left, &starts);

clippy_lints/src/loops/needless_range_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
319319

320320
if_chain! {
321321
// an index op
322-
if let ExprKind::Index(seqexpr, idx) = expr.kind;
322+
if let ExprKind::Index(seqexpr, idx, _) = expr.kind;
323323
if !self.check(idx, seqexpr, expr);
324324
then {
325325
return;

clippy_lints/src/loops/never_loop.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ fn never_loop_expr<'tcx>(
162162
ExprKind::Binary(_, e1, e2)
163163
| ExprKind::Assign(e1, e2, _)
164164
| ExprKind::AssignOp(_, e1, e2)
165-
| ExprKind::Index(e1, e2) => never_loop_expr_all(cx, &mut [e1, e2].iter().copied(), ignore_ids, main_loop_id),
165+
| ExprKind::Index(e1, e2, _) => {
166+
never_loop_expr_all(cx, &mut [e1, e2].iter().copied(), ignore_ids, main_loop_id)
167+
},
166168
ExprKind::Loop(b, _, _, _) => {
167169
// Break can come from the inner loop so remove them.
168170
absorb_break(never_loop_block(cx, b, ignore_ids, main_loop_id))

clippy_lints/src/loops/while_let_on_iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn try_parse_iter_expr(cx: &LateContext<'_>, mut e: &Expr<'_>) -> Option<IterExp
113113

114114
// Shouldn't have side effects, but there's no way to trace which field is used. So forget which fields have
115115
// already been seen.
116-
ExprKind::Index(base, idx) if !idx.can_have_side_effects() => {
116+
ExprKind::Index(base, idx, _) if !idx.can_have_side_effects() => {
117117
can_move = false;
118118
fields.clear();
119119
e = base;

clippy_lints/src/manual_float_methods.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
33
use clippy_utils::source::snippet_opt;
44
use clippy_utils::{is_from_proc_macro, path_to_local};
55
use rustc_errors::Applicability;
6-
use rustc_hir::{BinOpKind, Expr, ExprKind};
6+
use rustc_hir::{BinOpKind, Constness, Expr, ExprKind};
77
use rustc_lint::{LateContext, LateLintPass, Lint, LintContext};
88
use rustc_middle::lint::in_external_macro;
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -83,8 +83,10 @@ impl Variant {
8383
impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods {
8484
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
8585
if !in_external_macro(cx.sess(), expr.span)
86-
&& (!cx.param_env.is_const() || cx.tcx.features().active(sym!(const_float_classify)))
87-
&& let ExprKind::Binary(kind, lhs, rhs) = expr.kind
86+
&& (
87+
matches!(cx.tcx.constness(cx.tcx.hir().enclosing_body_owner(expr.hir_id)), Constness::NotConst)
88+
|| cx.tcx.features().active(sym!(const_float_classify))
89+
) && let ExprKind::Binary(kind, lhs, rhs) = expr.kind
8890
&& let ExprKind::Binary(lhs_kind, lhs_lhs, lhs_rhs) = lhs.kind
8991
&& let ExprKind::Binary(rhs_kind, rhs_lhs, rhs_rhs) = rhs.kind
9092
// Checking all possible scenarios using a function would be a hopeless task, as we have

clippy_lints/src/manual_strip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn find_stripping<'tcx>(
204204
if_chain! {
205205
if is_ref_str(self.cx, ex);
206206
let unref = peel_ref(ex);
207-
if let ExprKind::Index(indexed, index) = &unref.kind;
207+
if let ExprKind::Index(indexed, index, _) = &unref.kind;
208208
if let Some(higher::Range { start, end, .. }) = higher::Range::hir(index);
209209
if let ExprKind::Path(path) = &indexed.kind;
210210
if self.cx.qpath_res(path, ex.hir_id) == self.target;

clippy_lints/src/matches/match_on_vec_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::MATCH_ON_VEC_ITEMS;
1212
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, scrutinee: &'tcx Expr<'_>) {
1313
if_chain! {
1414
if let Some(idx_expr) = is_vec_indexing(cx, scrutinee);
15-
if let ExprKind::Index(vec, idx) = idx_expr.kind;
15+
if let ExprKind::Index(vec, idx, _) = idx_expr.kind;
1616

1717
then {
1818
// FIXME: could be improved to suggest surrounding every pattern with Some(_),
@@ -36,7 +36,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, scrutinee: &'tcx Expr<'_>) {
3636

3737
fn is_vec_indexing<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> {
3838
if_chain! {
39-
if let ExprKind::Index(array, index) = expr.kind;
39+
if let ExprKind::Index(array, index, _) = expr.kind;
4040
if is_vector(cx, array);
4141
if !is_full_range(cx, index);
4242

clippy_lints/src/methods/filter_next.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::FILTER_NEXT;
1212
fn path_to_local(expr: &hir::Expr<'_>) -> Option<hir::HirId> {
1313
match expr.kind {
1414
hir::ExprKind::Field(f, _) => path_to_local(f),
15-
hir::ExprKind::Index(recv, _) => path_to_local(recv),
15+
hir::ExprKind::Index(recv, _, _) => path_to_local(recv),
1616
hir::ExprKind::Path(hir::QPath::Resolved(
1717
_,
1818
hir::Path {

clippy_lints/src/methods/iter_next_slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, cal
2727
if derefs_to_slice(cx, caller_expr, cx.typeck_results().expr_ty(caller_expr)).is_some() {
2828
// caller is a Slice
2929
if_chain! {
30-
if let hir::ExprKind::Index(caller_var, index_expr) = &caller_expr.kind;
30+
if let hir::ExprKind::Index(caller_var, index_expr, _) = &caller_expr.kind;
3131
if let Some(higher::Range { start: Some(start_expr), end: None, limits: ast::RangeLimits::HalfOpen })
3232
= higher::Range::hir(index_expr);
3333
if let hir::ExprKind::Lit(start_lit) = &start_expr.kind;

clippy_lints/src/mixed_read_write_in_expression.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ fn check_expr<'tcx>(vis: &mut ReadVisitor<'_, 'tcx>, expr: &'tcx Expr<'_>) -> St
239239
| ExprKind::MethodCall(..)
240240
| ExprKind::Call(_, _)
241241
| ExprKind::Assign(..)
242-
| ExprKind::Index(_, _)
242+
| ExprKind::Index(..)
243243
| ExprKind::Repeat(_, _)
244244
| ExprKind::Struct(_, _, _) => {
245245
walk_expr(vis, expr);

clippy_lints/src/needless_bool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ fn condition_needs_parentheses(e: &Expr<'_>) -> bool {
119119
| ExprKind::Call(i, _)
120120
| ExprKind::Cast(i, _)
121121
| ExprKind::Type(i, _)
122-
| ExprKind::Index(i, _) = inner.kind
122+
| ExprKind::Index(i, _, _) = inner.kind
123123
{
124124
if matches!(
125125
i.kind,

clippy_lints/src/no_effect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
160160
match peel_blocks(expr).kind {
161161
ExprKind::Lit(..) | ExprKind::Closure { .. } => true,
162162
ExprKind::Path(..) => !has_drop(cx, cx.typeck_results().expr_ty(expr)),
163-
ExprKind::Index(a, b) | ExprKind::Binary(_, a, b) => has_no_effect(cx, a) && has_no_effect(cx, b),
163+
ExprKind::Index(a, b, _) | ExprKind::Binary(_, a, b) => has_no_effect(cx, a) && has_no_effect(cx, b),
164164
ExprKind::Array(v) | ExprKind::Tup(v) => v.iter().all(|val| has_no_effect(cx, val)),
165165
ExprKind::Repeat(inner, _)
166166
| ExprKind::Cast(inner, _)
@@ -263,7 +263,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<Vec
263263
return None;
264264
}
265265
match expr.kind {
266-
ExprKind::Index(a, b) => Some(vec![a, b]),
266+
ExprKind::Index(a, b, _) => Some(vec![a, b]),
267267
ExprKind::Binary(ref binop, a, b) if binop.node != BinOpKind::And && binop.node != BinOpKind::Or => {
268268
Some(vec![a, b])
269269
},

clippy_lints/src/non_copy_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ declare_lint_pass!(NonCopyConst => [DECLARE_INTERIOR_MUTABLE_CONST, BORROW_INTER
297297

298298
impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
299299
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx Item<'_>) {
300-
if let ItemKind::Const(hir_ty, body_id) = it.kind {
300+
if let ItemKind::Const(hir_ty, _generics, body_id) = it.kind {
301301
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
302302
if !ignored_macro(cx, it) && is_unfrozen(cx, ty) && is_value_unfrozen_poly(cx, body_id, ty) {
303303
lint(cx, Source::Item { item: it.span });
@@ -438,7 +438,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
438438

439439
dereferenced_expr = parent_expr;
440440
},
441-
ExprKind::Index(e, _) if ptr::eq(&**e, cur_expr) => {
441+
ExprKind::Index(e, _, _) if ptr::eq(&**e, cur_expr) => {
442442
// `e[i]` => desugared to `*Index::index(&e, i)`,
443443
// meaning `e` must be referenced.
444444
// no need to go further up since a method call is involved now.

clippy_lints/src/operators/bit_mask.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ fn check_compare(cx: &LateContext<'_>, bit_op: &Expr<'_>, cmp_op: BinOpKind, cmp
4040
if op.node != BinOpKind::BitAnd && op.node != BinOpKind::BitOr {
4141
return;
4242
}
43-
fetch_int_literal(cx, right)
44-
.or_else(|| fetch_int_literal(cx, left))
45-
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span));
43+
if let Some(mask) = fetch_int_literal(cx, right).or_else(|| fetch_int_literal(cx, left)) {
44+
check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span);
45+
}
4646
}
4747
}
4848

clippy_lints/src/ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args:
695695
}
696696
},
697697
// Indexing is fine for currently supported types.
698-
ExprKind::Index(e, _) if e.hir_id == child_id => (),
698+
ExprKind::Index(e, _, _) if e.hir_id == child_id => (),
699699
_ => set_skip_flag(),
700700
},
701701
_ => set_skip_flag(),

0 commit comments

Comments
 (0)