Skip to content

Commit ee1be93

Browse files
committed
submodules: update clippy from 69f99e7 to cfb3320
Changes: ```` rustup "Merge `ast::Mutability` and `mir::Mutability`" rustup rust-lang/rust#67130 rustup rust-lang/rust#67455 There are no per-file copyright headers anymore Update lints for `iterator_step_by_zero` changes Fix 'redudant' spelling in redundant_clone docs Fix documentation example for unnecessary_filter_map. Fix `expect_fun_call` false negative on references Fix `iterator_step_by_zero` description in declaration Fix `iterator_step_by_zero` definition Correct `iterator_step_by_zero` documentation Update iterator_step_by_zero Prevent `cmp_nan` when inside constants Detect comparisons with NAN constants Fix clippy build failure ````
1 parent df5a1ee commit ee1be93

34 files changed

+333
-193
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,5 @@ Copyright 2014-2019 The Rust Project Developers
182182
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
183183
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)> or the MIT license
184184
<LICENSE-MIT or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)>, at your
185-
option. All files in the project carrying such notice may not be
185+
option. Files in the project may not be
186186
copied, modified, or distributed except according to those terms.

clippy_lints/src/functions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ fn is_mutable_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, span: Span,
553553
Tuple(ref substs) => substs.types().any(|ty| is_mutable_ty(cx, ty, span, tys)),
554554
Array(ty, _) | Slice(ty) => is_mutable_ty(cx, ty, span, tys),
555555
RawPtr(ty::TypeAndMut { ty, mutbl }) | Ref(_, ty, mutbl) => {
556-
mutbl == hir::Mutability::Mutable || is_mutable_ty(cx, ty, span, tys)
556+
mutbl == hir::Mutability::Mut || is_mutable_ty(cx, ty, span, tys)
557557
},
558558
// calling something constitutes a side effect, so return true on all callables
559559
// also never calls need not be used, so return true for them, too
@@ -658,7 +658,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
658658
tys.clear();
659659
}
660660
},
661-
Assign(ref target, _) | AssignOp(_, ref target, _) | AddrOf(_, hir::Mutability::Mutable, ref target) => {
661+
Assign(ref target, _) | AssignOp(_, ref target, _) | AddrOf(_, hir::Mutability::Mut, ref target) => {
662662
self.mutates_static |= is_mutated_static(self.cx, target)
663663
},
664664
_ => {},

clippy_lints/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
1313
#![feature(crate_visibility_modifier)]
1414
#![feature(concat_idents)]
15-
#![feature(result_map_or)]
1615

1716
// FIXME: switch to something more ergonomic here, once available.
1817
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
@@ -607,6 +606,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
607606
&methods::GET_UNWRAP,
608607
&methods::INEFFICIENT_TO_STRING,
609608
&methods::INTO_ITER_ON_REF,
609+
&methods::ITERATOR_STEP_BY_ZERO,
610610
&methods::ITER_CLONED_COLLECT,
611611
&methods::ITER_NTH,
612612
&methods::ITER_SKIP_NEXT,
@@ -700,7 +700,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
700700
&ptr::PTR_ARG,
701701
&ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
702702
&question_mark::QUESTION_MARK,
703-
&ranges::ITERATOR_STEP_BY_ZERO,
704703
&ranges::RANGE_MINUS_ONE,
705704
&ranges::RANGE_PLUS_ONE,
706705
&ranges::RANGE_ZIP_WITH_LEN,
@@ -1180,6 +1179,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
11801179
LintId::of(&methods::FLAT_MAP_IDENTITY),
11811180
LintId::of(&methods::INEFFICIENT_TO_STRING),
11821181
LintId::of(&methods::INTO_ITER_ON_REF),
1182+
LintId::of(&methods::ITERATOR_STEP_BY_ZERO),
11831183
LintId::of(&methods::ITER_CLONED_COLLECT),
11841184
LintId::of(&methods::ITER_NTH),
11851185
LintId::of(&methods::ITER_SKIP_NEXT),
@@ -1245,7 +1245,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
12451245
LintId::of(&ptr::PTR_ARG),
12461246
LintId::of(&ptr_offset_with_cast::PTR_OFFSET_WITH_CAST),
12471247
LintId::of(&question_mark::QUESTION_MARK),
1248-
LintId::of(&ranges::ITERATOR_STEP_BY_ZERO),
12491248
LintId::of(&ranges::RANGE_MINUS_ONE),
12501249
LintId::of(&ranges::RANGE_PLUS_ONE),
12511250
LintId::of(&ranges::RANGE_ZIP_WITH_LEN),
@@ -1522,6 +1521,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
15221521
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
15231522
LintId::of(&mem_replace::MEM_REPLACE_WITH_UNINIT),
15241523
LintId::of(&methods::CLONE_DOUBLE_REF),
1524+
LintId::of(&methods::ITERATOR_STEP_BY_ZERO),
15251525
LintId::of(&methods::TEMPORARY_CSTRING_AS_PTR),
15261526
LintId::of(&methods::UNINIT_ASSUMED_INIT),
15271527
LintId::of(&methods::ZST_OFFSET),
@@ -1534,7 +1534,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
15341534
LintId::of(&non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST),
15351535
LintId::of(&open_options::NONSENSICAL_OPEN_OPTIONS),
15361536
LintId::of(&ptr::MUT_FROM_REF),
1537-
LintId::of(&ranges::ITERATOR_STEP_BY_ZERO),
15381537
LintId::of(&regex::INVALID_REGEX),
15391538
LintId::of(&serde_api::SERDE_API_MISUSE),
15401539
LintId::of(&suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL),

clippy_lints/src/loops.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,8 +1507,8 @@ fn make_iterator_snippet(cx: &LateContext<'_, '_>, arg: &Expr, applic_ref: &mut
15071507
if has_iter_method(cx, cx.tables.expr_ty(&arg_inner)).is_some() =>
15081508
{
15091509
let meth_name = match mutability {
1510-
Mutability::Mutable => "iter_mut",
1511-
Mutability::Immutable => "iter",
1510+
Mutability::Mut => "iter_mut",
1511+
Mutability::Not => "iter",
15121512
};
15131513
format!(
15141514
"{}.{}()",
@@ -1540,14 +1540,14 @@ fn check_for_loop_over_map_kv<'a, 'tcx>(
15401540
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).kind {
15411541
ty::Ref(_, ty, mutbl) => match (&pat[0].kind, &pat[1].kind) {
15421542
(key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl),
1543-
(_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, Mutability::Immutable),
1543+
(_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, Mutability::Not),
15441544
_ => return,
15451545
},
15461546
_ => return,
15471547
};
15481548
let mutbl = match mutbl {
1549-
Mutability::Immutable => "",
1550-
Mutability::Mutable => "_mut",
1549+
Mutability::Not => "",
1550+
Mutability::Mut => "_mut",
15511551
};
15521552
let arg = match arg.kind {
15531553
ExprKind::AddrOf(BorrowKind::Ref, _, ref expr) => &**expr,
@@ -1868,7 +1868,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
18681868
self.visit_expr(rhs);
18691869
},
18701870
ExprKind::AddrOf(BorrowKind::Ref, mutbl, ref expr) => {
1871-
if mutbl == Mutability::Mutable {
1871+
if mutbl == Mutability::Mut {
18721872
self.prefer_mutable = true;
18731873
}
18741874
self.visit_expr(expr);
@@ -1879,7 +1879,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
18791879
let ty = self.cx.tables.expr_ty_adjusted(expr);
18801880
self.prefer_mutable = false;
18811881
if let ty::Ref(_, _, mutbl) = ty.kind {
1882-
if mutbl == Mutability::Mutable {
1882+
if mutbl == Mutability::Mut {
18831883
self.prefer_mutable = true;
18841884
}
18851885
}
@@ -1891,7 +1891,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
18911891
for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) {
18921892
self.prefer_mutable = false;
18931893
if let ty::Ref(_, _, mutbl) = ty.kind {
1894-
if mutbl == Mutability::Mutable {
1894+
if mutbl == Mutability::Mut {
18951895
self.prefer_mutable = true;
18961896
}
18971897
}
@@ -2084,7 +2084,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> {
20842084
}
20852085
},
20862086
ExprKind::Assign(ref lhs, _) if lhs.hir_id == expr.hir_id => *state = VarState::DontWarn,
2087-
ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mutable => {
2087+
ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mut => {
20882088
*state = VarState::DontWarn
20892089
},
20902090
_ => (),
@@ -2168,7 +2168,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
21682168
VarState::DontWarn
21692169
}
21702170
},
2171-
ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mutable => {
2171+
ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mut => {
21722172
self.state = VarState::DontWarn
21732173
},
21742174
_ => (),

clippy_lints/src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ fn is_panic_block(block: &Block) -> bool {
571571
fn check_match_ref_pats(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Expr) {
572572
if has_only_ref_pats(arms) {
573573
let mut suggs = Vec::new();
574-
let (title, msg) = if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Immutable, ref inner) = ex.kind {
574+
let (title, msg) = if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, ref inner) = ex.kind {
575575
let span = ex.span.source_callsite();
576576
suggs.push((span, Sugg::hir_with_macro_callsite(cx, inner, "..").to_string()));
577577
(

clippy_lints/src/mem_replace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemReplace {
9191
// argument's type. All that's left is to get
9292
// replacee's path.
9393
let replaced_path = match func_args[0].kind {
94-
ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mutable, ref replaced) => {
94+
ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mut, ref replaced) => {
9595
if let ExprKind::Path(QPath::Resolved(None, ref replaced_path)) = replaced.kind {
9696
replaced_path
9797
} else {

clippy_lints/src/methods/mod.rs

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,25 @@ declare_clippy_lint! {
737737
"getting the inner pointer of a temporary `CString`"
738738
}
739739

740+
declare_clippy_lint! {
741+
/// **What it does:** Checks for calling `.step_by(0)` on iterators which panics.
742+
///
743+
/// **Why is this bad?** This very much looks like an oversight. Use `panic!()` instead if you
744+
/// actually intend to panic.
745+
///
746+
/// **Known problems:** None.
747+
///
748+
/// **Example:**
749+
/// ```should_panic
750+
/// for x in (0..100).step_by(0) {
751+
/// //..
752+
/// }
753+
/// ```
754+
pub ITERATOR_STEP_BY_ZERO,
755+
correctness,
756+
"using `Iterator::step_by(0)`, which will panic at runtime"
757+
}
758+
740759
declare_clippy_lint! {
741760
/// **What it does:** Checks for use of `.iter().nth()` (and the related
742761
/// `.iter_mut().nth()`) on standard library types with O(1) element access.
@@ -958,11 +977,11 @@ declare_clippy_lint! {
958977
/// ```
959978
///
960979
/// ```rust
961-
/// let _ = (0..4).filter_map(i32::checked_abs);
980+
/// let _ = (0..4).filter_map(|x| Some(x + 1));
962981
/// ```
963982
/// As there is no conditional check on the argument this could be written as:
964983
/// ```rust
965-
/// let _ = (0..4).map(i32::checked_abs);
984+
/// let _ = (0..4).map(|x| x + 1);
966985
/// ```
967986
pub UNNECESSARY_FILTER_MAP,
968987
complexity,
@@ -1115,6 +1134,7 @@ declare_lint_pass!(Methods => [
11151134
FLAT_MAP_IDENTITY,
11161135
FIND_MAP,
11171136
MAP_FLATTEN,
1137+
ITERATOR_STEP_BY_ZERO,
11181138
ITER_NTH,
11191139
ITER_SKIP_NEXT,
11201140
GET_UNWRAP,
@@ -1173,6 +1193,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
11731193
},
11741194
["nth", "iter"] => lint_iter_nth(cx, expr, arg_lists[1], false),
11751195
["nth", "iter_mut"] => lint_iter_nth(cx, expr, arg_lists[1], true),
1196+
["step_by", ..] => lint_step_by(cx, expr, arg_lists[0]),
11761197
["next", "skip"] => lint_iter_skip_next(cx, expr),
11771198
["collect", "cloned"] => lint_iter_cloned_collect(cx, expr, arg_lists[1]),
11781199
["as_ref"] => lint_asref(cx, expr, "as_ref", arg_lists[0]),
@@ -1595,7 +1616,7 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span:
15951616
return;
15961617
}
15971618

1598-
let receiver_type = cx.tables.expr_ty(&args[0]);
1619+
let receiver_type = cx.tables.expr_ty_adjusted(&args[0]);
15991620
let closure_args = if match_type(cx, receiver_type, &paths::OPTION) {
16001621
"||"
16011622
} else if match_type(cx, receiver_type, &paths::RESULT) {
@@ -1950,6 +1971,20 @@ fn lint_unnecessary_fold(cx: &LateContext<'_, '_>, expr: &hir::Expr, fold_args:
19501971
}
19511972
}
19521973

1974+
fn lint_step_by<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &hir::Expr, args: &'tcx [hir::Expr]) {
1975+
if match_trait_method(cx, expr, &paths::ITERATOR) {
1976+
use crate::consts::{constant, Constant};
1977+
if let Some((Constant::Int(0), _)) = constant(cx, cx.tables, &args[1]) {
1978+
span_lint(
1979+
cx,
1980+
ITERATOR_STEP_BY_ZERO,
1981+
expr.span,
1982+
"Iterator::step_by(0) will panic at runtime",
1983+
);
1984+
}
1985+
}
1986+
}
1987+
19531988
fn lint_iter_nth<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &hir::Expr, iter_args: &'tcx [hir::Expr], is_mut: bool) {
19541989
let mut_str = if is_mut { "_mut" } else { "" };
19551990
let caller_type = if derefs_to_slice(cx, &iter_args[0], cx.tables.expr_ty(&iter_args[0])).is_some() {
@@ -2789,8 +2824,8 @@ fn ty_has_iter_method(cx: &LateContext<'_, '_>, self_ref_ty: Ty<'_>) -> Option<(
27892824
_ => unreachable!(),
27902825
};
27912826
let method_name = match mutbl {
2792-
hir::Mutability::Immutable => "iter",
2793-
hir::Mutability::Mutable => "iter_mut",
2827+
hir::Mutability::Not => "iter",
2828+
hir::Mutability::Mut => "iter_mut",
27942829
};
27952830
(ty_name, method_name)
27962831
})
@@ -2980,8 +3015,8 @@ impl SelfKind {
29803015
}
29813016

29823017
let trait_path = match mutability {
2983-
hir::Mutability::Immutable => &paths::ASREF_TRAIT,
2984-
hir::Mutability::Mutable => &paths::ASMUT_TRAIT,
3018+
hir::Mutability::Not => &paths::ASREF_TRAIT,
3019+
hir::Mutability::Mut => &paths::ASMUT_TRAIT,
29853020
};
29863021

29873022
let trait_def_id = match get_trait_def_id(cx, trait_path) {
@@ -2993,10 +3028,8 @@ impl SelfKind {
29933028

29943029
match self {
29953030
Self::Value => matches_value(parent_ty, ty),
2996-
Self::Ref => {
2997-
matches_ref(cx, hir::Mutability::Immutable, parent_ty, ty) || ty == parent_ty && is_copy(cx, ty)
2998-
},
2999-
Self::RefMut => matches_ref(cx, hir::Mutability::Mutable, parent_ty, ty),
3031+
Self::Ref => matches_ref(cx, hir::Mutability::Not, parent_ty, ty) || ty == parent_ty && is_copy(cx, ty),
3032+
Self::RefMut => matches_ref(cx, hir::Mutability::Mut, parent_ty, ty),
30003033
Self::No => ty != parent_ty,
30013034
}
30023035
}

clippy_lints/src/misc.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints {
343343
ExprKind::Binary(ref cmp, ref left, ref right) => {
344344
let op = cmp.node;
345345
if op.is_comparison() {
346-
if let ExprKind::Path(QPath::Resolved(_, ref path)) = left.kind {
347-
check_nan(cx, path, expr);
348-
}
349-
if let ExprKind::Path(QPath::Resolved(_, ref path)) = right.kind {
350-
check_nan(cx, path, expr);
351-
}
346+
check_nan(cx, left, expr);
347+
check_nan(cx, right, expr);
352348
check_to_owned(cx, left, right);
353349
check_to_owned(cx, right, left);
354350
}
@@ -444,14 +440,22 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MiscLints {
444440
}
445441
}
446442

447-
fn check_nan(cx: &LateContext<'_, '_>, path: &Path, expr: &Expr) {
448-
if !in_constant(cx, expr.hir_id) {
449-
if let Some(seg) = path.segments.last() {
450-
if seg.ident.name == sym!(NAN) {
443+
fn check_nan(cx: &LateContext<'_, '_>, expr: &Expr, cmp_expr: &Expr) {
444+
if_chain! {
445+
if !in_constant(cx, cmp_expr.hir_id);
446+
if let Some((value, _)) = constant(cx, cx.tables, expr);
447+
then {
448+
let needs_lint = match value {
449+
Constant::F32(num) => num.is_nan(),
450+
Constant::F64(num) => num.is_nan(),
451+
_ => false,
452+
};
453+
454+
if needs_lint {
451455
span_lint(
452456
cx,
453457
CMP_NAN,
454-
expr.span,
458+
cmp_expr.span,
455459
"doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead",
456460
);
457461
}
@@ -628,8 +632,8 @@ fn check_cast(cx: &LateContext<'_, '_>, span: Span, e: &Expr, ty: &Ty) {
628632
if !in_constant(cx, e.hir_id);
629633
then {
630634
let (msg, sugg_fn) = match mut_ty.mutbl {
631-
Mutability::Mutable => ("`0 as *mut _` detected", "std::ptr::null_mut"),
632-
Mutability::Immutable => ("`0 as *const _` detected", "std::ptr::null"),
635+
Mutability::Mut => ("`0 as *mut _` detected", "std::ptr::null_mut"),
636+
Mutability::Not => ("`0 as *const _` detected", "std::ptr::null"),
633637
};
634638

635639
let (sugg, appl) = if let TyKind::Infer = mut_ty.ty.kind {

clippy_lints/src/mut_mut.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
5858
// Let's ignore the generated code.
5959
intravisit::walk_expr(self, arg);
6060
intravisit::walk_expr(self, body);
61-
} else if let hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Mutable, ref e) = expr.kind {
62-
if let hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Mutable, _) = e.kind {
61+
} else if let hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Mut, ref e) = expr.kind {
62+
if let hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Mut, _) = e.kind {
6363
span_lint(
6464
self.cx,
6565
MUT_MUT,
6666
expr.span,
6767
"generally you want to avoid `&mut &mut _` if possible",
6868
);
69-
} else if let ty::Ref(_, _, hir::Mutability::Mutable) = self.cx.tables.expr_ty(e).kind {
69+
} else if let ty::Ref(_, _, hir::Mutability::Mut) = self.cx.tables.expr_ty(e).kind {
7070
span_lint(
7171
self.cx,
7272
MUT_MUT,
@@ -82,14 +82,14 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
8282
_,
8383
hir::MutTy {
8484
ty: ref pty,
85-
mutbl: hir::Mutability::Mutable,
85+
mutbl: hir::Mutability::Mut,
8686
},
8787
) = ty.kind
8888
{
8989
if let hir::TyKind::Rptr(
9090
_,
9191
hir::MutTy {
92-
mutbl: hir::Mutability::Mutable,
92+
mutbl: hir::Mutability::Mut,
9393
..
9494
},
9595
) = pty.kind

clippy_lints/src/mut_reference.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ fn check_arguments<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arguments: &[Expr], typ
5656
let parameters = type_definition.fn_sig(cx.tcx).skip_binder().inputs();
5757
for (argument, parameter) in arguments.iter().zip(parameters.iter()) {
5858
match parameter.kind {
59-
ty::Ref(_, _, Mutability::Immutable)
59+
ty::Ref(_, _, Mutability::Not)
6060
| ty::RawPtr(ty::TypeAndMut {
61-
mutbl: Mutability::Immutable,
62-
..
61+
mutbl: Mutability::Not, ..
6362
}) => {
64-
if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mutable, _) = argument.kind {
63+
if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mut, _) = argument.kind {
6564
span_lint(
6665
cx,
6766
UNNECESSARY_MUT_PASSED,

0 commit comments

Comments
 (0)