Skip to content

Commit 4667198

Browse files
committed
Auto merge of #8802 - smoelius:allow-expect-unwrap-in-tests, r=llogiq
Optionally allow `expect` and `unwrap` in tests This addresses #1015, except it makes the new behavior optional. The reason for the msrv-related changes is as follows. Rather than expand `check_methods` list of arguments, it seemed easier to make `check_methods` a method of `Methods`, so that `check_methods` could access `Methods`' fields. `check_methods` had an `msrv` parameter, which I consequently made a field of `Methods`. But, to avoid adding a lifetime parameter to `Methods`, I made the field type `Option<RustcVersion>` instead of the parameter's existing type, `Option<&RustcVersion>`. This seemed sensible since `RustcVersion` implements `Copy`. But this broke a lot of code that expected an `Option<&RustcVersion>` or `&Option<RustcVersion>`. I changed all of those occurrences to `Option<RustcVersion>`. IMHO, the code is better as a result of these changes, though. The msrv-related changes are in their own commit to (hopefully) ease review. Closes #1015 changelog: optionally allow `expect` and `unwrap` in tests r? `@llogiq`
2 parents 9c78883 + 597f61b commit 4667198

Some content is hidden

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

47 files changed

+610
-250
lines changed

clippy_lints/src/approx_const.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ impl ApproxConstant {
8787
let s = s.as_str();
8888
if s.parse::<f64>().is_ok() {
8989
for &(constant, name, min_digits, msrv) in &KNOWN_CONSTS {
90-
if is_approx_const(constant, s, min_digits)
91-
&& msrv.as_ref().map_or(true, |msrv| meets_msrv(self.msrv.as_ref(), msrv))
92-
{
90+
if is_approx_const(constant, s, min_digits) && msrv.map_or(true, |msrv| meets_msrv(self.msrv, msrv)) {
9391
span_lint_and_help(
9492
cx,
9593
APPROX_CONSTANT,

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It
613613

614614
fn check_deprecated_cfg_attr(cx: &EarlyContext<'_>, attr: &Attribute, msrv: Option<RustcVersion>) {
615615
if_chain! {
616-
if meets_msrv(msrv.as_ref(), &msrvs::TOOL_ATTRIBUTES);
616+
if meets_msrv(msrv, msrvs::TOOL_ATTRIBUTES);
617617
// check cfg_attr
618618
if attr.has_name(sym::cfg_attr);
619619
if let Some(items) = attr.meta_item_list();

clippy_lints/src/borrow_as_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl BorrowAsPtr {
5757

5858
impl<'tcx> LateLintPass<'tcx> for BorrowAsPtr {
5959
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
60-
if !meets_msrv(self.msrv.as_ref(), &msrvs::BORROW_AS_PTR) {
60+
if !meets_msrv(self.msrv, msrvs::BORROW_AS_PTR) {
6161
return;
6262
}
6363

clippy_lints/src/casts/cast_abs_to_unsigned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ pub(super) fn check(
1616
cast_expr: &Expr<'_>,
1717
cast_from: Ty<'_>,
1818
cast_to: Ty<'_>,
19-
msrv: &Option<RustcVersion>,
19+
msrv: Option<RustcVersion>,
2020
) {
2121
if_chain! {
22-
if meets_msrv(msrv.as_ref(), &msrvs::UNSIGNED_ABS);
22+
if meets_msrv(msrv, msrvs::UNSIGNED_ABS);
2323
if cast_from.is_integral();
2424
if cast_to.is_integral();
2525
if cast_from.is_signed();

clippy_lints/src/casts/cast_lossless.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(super) fn check(
1616
cast_op: &Expr<'_>,
1717
cast_from: Ty<'_>,
1818
cast_to: Ty<'_>,
19-
msrv: &Option<RustcVersion>,
19+
msrv: Option<RustcVersion>,
2020
) {
2121
if !should_lint(cx, expr, cast_from, cast_to, msrv) {
2222
return;
@@ -68,7 +68,7 @@ fn should_lint(
6868
expr: &Expr<'_>,
6969
cast_from: Ty<'_>,
7070
cast_to: Ty<'_>,
71-
msrv: &Option<RustcVersion>,
71+
msrv: Option<RustcVersion>,
7272
) -> bool {
7373
// Do not suggest using From in consts/statics until it is valid to do so (see #2267).
7474
if in_constant(cx, expr.hir_id) {
@@ -95,7 +95,7 @@ fn should_lint(
9595
};
9696
!is_isize_or_usize(cast_from) && from_nbits < to_nbits
9797
},
98-
(false, true) if matches!(cast_from.kind(), ty::Bool) && meets_msrv(msrv.as_ref(), &msrvs::FROM_BOOL) => true,
98+
(false, true) if matches!(cast_from.kind(), ty::Bool) && meets_msrv(msrv, msrvs::FROM_BOOL) => true,
9999
(_, _) => {
100100
matches!(cast_from.kind(), ty::Float(FloatTy::F32)) && matches!(cast_to.kind(), ty::Float(FloatTy::F64))
101101
},

clippy_lints/src/casts/cast_slice_different_sizes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use rustc_semver::RustcVersion;
88

99
use super::CAST_SLICE_DIFFERENT_SIZES;
1010

11-
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Option<RustcVersion>) {
11+
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: Option<RustcVersion>) {
1212
// suggestion is invalid if `ptr::slice_from_raw_parts` does not exist
13-
if !meets_msrv(msrv.as_ref(), &msrvs::PTR_SLICE_RAW_PARTS) {
13+
if !meets_msrv(msrv, msrvs::PTR_SLICE_RAW_PARTS) {
1414
return;
1515
}
1616

clippy_lints/src/casts/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ impl_lint_pass!(Casts => [
532532
impl<'tcx> LateLintPass<'tcx> for Casts {
533533
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
534534
if !in_external_macro(cx.sess(), expr.span) {
535-
ptr_as_ptr::check(cx, expr, &self.msrv);
535+
ptr_as_ptr::check(cx, expr, self.msrv);
536536
}
537537

538538
if expr.span.from_expansion() {
@@ -562,18 +562,18 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
562562
cast_possible_wrap::check(cx, expr, cast_from, cast_to);
563563
cast_precision_loss::check(cx, expr, cast_from, cast_to);
564564
cast_sign_loss::check(cx, expr, cast_expr, cast_from, cast_to);
565-
cast_abs_to_unsigned::check(cx, expr, cast_expr, cast_from, cast_to, &self.msrv);
565+
cast_abs_to_unsigned::check(cx, expr, cast_expr, cast_from, cast_to, self.msrv);
566566
}
567-
cast_lossless::check(cx, expr, cast_expr, cast_from, cast_to, &self.msrv);
567+
cast_lossless::check(cx, expr, cast_expr, cast_from, cast_to, self.msrv);
568568
cast_enum_constructor::check(cx, expr, cast_expr, cast_from);
569569
}
570570
}
571571

572572
cast_ref_to_mut::check(cx, expr);
573573
cast_ptr_alignment::check(cx, expr);
574574
char_lit_as_u8::check(cx, expr);
575-
ptr_as_ptr::check(cx, expr, &self.msrv);
576-
cast_slice_different_sizes::check(cx, expr, &self.msrv);
575+
ptr_as_ptr::check(cx, expr, self.msrv);
576+
cast_slice_different_sizes::check(cx, expr, self.msrv);
577577
}
578578

579579
extract_msrv_attr!(LateContext);

clippy_lints/src/casts/ptr_as_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use rustc_semver::RustcVersion;
1212

1313
use super::PTR_AS_PTR;
1414

15-
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: &Option<RustcVersion>) {
16-
if !meets_msrv(msrv.as_ref(), &msrvs::POINTER_CAST) {
15+
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: Option<RustcVersion>) {
16+
if !meets_msrv(msrv, msrvs::POINTER_CAST) {
1717
return;
1818
}
1919

clippy_lints/src/checked_conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl_lint_pass!(CheckedConversions => [CHECKED_CONVERSIONS]);
5757

5858
impl<'tcx> LateLintPass<'tcx> for CheckedConversions {
5959
fn check_expr(&mut self, cx: &LateContext<'_>, item: &Expr<'_>) {
60-
if !meets_msrv(self.msrv.as_ref(), &msrvs::TRY_FROM) {
60+
if !meets_msrv(self.msrv, msrvs::TRY_FROM) {
6161
return;
6262
}
6363

clippy_lints/src/from_over_into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl_lint_pass!(FromOverInto => [FROM_OVER_INTO]);
5555

5656
impl<'tcx> LateLintPass<'tcx> for FromOverInto {
5757
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
58-
if !meets_msrv(self.msrv.as_ref(), &msrvs::RE_REBALANCING_COHERENCE) {
58+
if !meets_msrv(self.msrv, msrvs::RE_REBALANCING_COHERENCE) {
5959
return;
6060
}
6161

clippy_lints/src/if_then_some_else_none.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl_lint_pass!(IfThenSomeElseNone => [IF_THEN_SOME_ELSE_NONE]);
5757

5858
impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone {
5959
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'tcx Expr<'_>) {
60-
if !meets_msrv(self.msrv.as_ref(), &msrvs::BOOL_THEN) {
60+
if !meets_msrv(self.msrv, msrvs::BOOL_THEN) {
6161
return;
6262
}
6363

clippy_lints/src/index_refutable_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexRefutableSlice {
7575
if !expr.span.from_expansion() || is_expn_of(expr.span, "if_chain").is_some();
7676
if let Some(IfLet {let_pat, if_then, ..}) = IfLet::hir(cx, expr);
7777
if !is_lint_allowed(cx, INDEX_REFUTABLE_SLICE, expr.hir_id);
78-
if meets_msrv(self.msrv.as_ref(), &msrvs::SLICE_PATTERNS);
78+
if meets_msrv(self.msrv, msrvs::SLICE_PATTERNS);
7979

8080
let found_slices = find_slice_values(cx, let_pat);
8181
if !found_slices.is_empty();

clippy_lints/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,17 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
582582
});
583583

584584
let avoid_breaking_exported_api = conf.avoid_breaking_exported_api;
585+
let allow_expect_in_tests = conf.allow_expect_in_tests;
586+
let allow_unwrap_in_tests = conf.allow_unwrap_in_tests;
585587
store.register_late_pass(move || Box::new(approx_const::ApproxConstant::new(msrv)));
586-
store.register_late_pass(move || Box::new(methods::Methods::new(avoid_breaking_exported_api, msrv)));
588+
store.register_late_pass(move || {
589+
Box::new(methods::Methods::new(
590+
avoid_breaking_exported_api,
591+
msrv,
592+
allow_expect_in_tests,
593+
allow_unwrap_in_tests,
594+
))
595+
});
587596
store.register_late_pass(move || Box::new(matches::Matches::new(msrv)));
588597
store.register_early_pass(move || Box::new(manual_non_exhaustive::ManualNonExhaustiveStruct::new(msrv)));
589598
store.register_late_pass(move || Box::new(manual_non_exhaustive::ManualNonExhaustiveEnum::new(msrv)));

clippy_lints/src/manual_bits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl_lint_pass!(ManualBits => [MANUAL_BITS]);
4848

4949
impl<'tcx> LateLintPass<'tcx> for ManualBits {
5050
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
51-
if !meets_msrv(self.msrv.as_ref(), &msrvs::MANUAL_BITS) {
51+
if !meets_msrv(self.msrv, msrvs::MANUAL_BITS) {
5252
return;
5353
}
5454

clippy_lints/src/manual_non_exhaustive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl_lint_pass!(ManualNonExhaustiveEnum => [MANUAL_NON_EXHAUSTIVE]);
9898

9999
impl EarlyLintPass for ManualNonExhaustiveStruct {
100100
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
101-
if !meets_msrv(self.msrv.as_ref(), &msrvs::NON_EXHAUSTIVE) {
101+
if !meets_msrv(self.msrv, msrvs::NON_EXHAUSTIVE) {
102102
return;
103103
}
104104

@@ -150,7 +150,7 @@ impl EarlyLintPass for ManualNonExhaustiveStruct {
150150

151151
impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustiveEnum {
152152
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
153-
if !meets_msrv(self.msrv.as_ref(), &msrvs::NON_EXHAUSTIVE) {
153+
if !meets_msrv(self.msrv, msrvs::NON_EXHAUSTIVE) {
154154
return;
155155
}
156156

clippy_lints/src/manual_strip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ enum StripKind {
6868

6969
impl<'tcx> LateLintPass<'tcx> for ManualStrip {
7070
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
71-
if !meets_msrv(self.msrv.as_ref(), &msrvs::STR_STRIP_PREFIX) {
71+
if !meets_msrv(self.msrv, msrvs::STR_STRIP_PREFIX) {
7272
return;
7373
}
7474

clippy_lints/src/map_clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl MapClone {
144144
fn lint_explicit_closure(&self, cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) {
145145
let mut applicability = Applicability::MachineApplicable;
146146

147-
let (message, sugg_method) = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
147+
let (message, sugg_method) = if is_copy && meets_msrv(self.msrv, msrvs::ITERATOR_COPIED) {
148148
("you are using an explicit closure for copying elements", "copied")
149149
} else {
150150
("you are using an explicit closure for cloning elements", "cloned")

clippy_lints/src/matches/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
658658
}
659659
if !contains_cfg_arm(cx, expr, ex, arms) {
660660
if source == MatchSource::Normal {
661-
if !(meets_msrv(self.msrv.as_ref(), &msrvs::MATCHES_MACRO)
661+
if !(meets_msrv(self.msrv, msrvs::MATCHES_MACRO)
662662
&& match_like_matches::check_match(cx, expr, ex, arms))
663663
{
664664
match_same_arms::check(cx, arms);
@@ -685,7 +685,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
685685
match_wild_err_arm::check(cx, ex, arms);
686686
wild_in_or_pats::check(cx, arms);
687687
} else {
688-
if meets_msrv(self.msrv.as_ref(), &msrvs::MATCHES_MACRO) {
688+
if meets_msrv(self.msrv, msrvs::MATCHES_MACRO) {
689689
match_like_matches::check(cx, expr);
690690
}
691691
redundant_pattern_match::check(cx, expr);

clippy_lints/src/mem_replace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<'tcx> LateLintPass<'tcx> for MemReplace {
254254
then {
255255
check_replace_option_with_none(cx, src, dest, expr.span);
256256
check_replace_with_uninit(cx, src, dest, expr.span);
257-
if meets_msrv(self.msrv.as_ref(), &msrvs::MEM_TAKE) {
257+
if meets_msrv(self.msrv, msrvs::MEM_TAKE) {
258258
check_replace_with_default(cx, src, dest, expr.span);
259259
}
260260
}

clippy_lints/src/methods/cloned_instead_of_copied.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ use rustc_span::{sym, Span};
1010

1111
use super::CLONED_INSTEAD_OF_COPIED;
1212

13-
pub fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span: Span, msrv: Option<&RustcVersion>) {
13+
pub fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span: Span, msrv: Option<RustcVersion>) {
1414
let recv_ty = cx.typeck_results().expr_ty_adjusted(recv);
1515
let inner_ty = match recv_ty.kind() {
1616
// `Option<T>` -> `T`
1717
ty::Adt(adt, subst)
18-
if cx.tcx.is_diagnostic_item(sym::Option, adt.did()) && meets_msrv(msrv, &msrvs::OPTION_COPIED) =>
18+
if cx.tcx.is_diagnostic_item(sym::Option, adt.did()) && meets_msrv(msrv, msrvs::OPTION_COPIED) =>
1919
{
2020
subst.type_at(0)
2121
},
22-
_ if is_trait_method(cx, expr, sym::Iterator) && meets_msrv(msrv, &msrvs::ITERATOR_COPIED) => {
22+
_ if is_trait_method(cx, expr, sym::Iterator) && meets_msrv(msrv, msrvs::ITERATOR_COPIED) => {
2323
match get_iterator_item_ty(cx, recv_ty) {
2424
// <T as Iterator>::Item
2525
Some(ty) => ty,

clippy_lints/src/methods/err_expect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ pub(super) fn check(
1313
cx: &LateContext<'_>,
1414
_expr: &rustc_hir::Expr<'_>,
1515
recv: &rustc_hir::Expr<'_>,
16-
msrv: Option<&RustcVersion>,
16+
msrv: Option<RustcVersion>,
1717
expect_span: Span,
1818
err_span: Span,
1919
) {
2020
if_chain! {
2121
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(recv), sym::Result);
2222
// Test the version to make sure the lint can be showed (expect_err has been
2323
// introduced in rust 1.17.0 : https://github.com/rust-lang/rust/pull/38982)
24-
if meets_msrv(msrv, &msrvs::EXPECT_ERR);
24+
if meets_msrv(msrv, msrvs::EXPECT_ERR);
2525

2626
// Grabs the `Result<T, E>` type
2727
let result_type = cx.typeck_results().expr_ty(recv);

clippy_lints/src/methods/expect_used.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
2+
use clippy_utils::is_in_test_function;
23
use clippy_utils::ty::is_type_diagnostic_item;
34
use rustc_hir as hir;
45
use rustc_lint::LateContext;
@@ -7,7 +8,7 @@ use rustc_span::sym;
78
use super::EXPECT_USED;
89

910
/// lint use of `expect()` for `Option`s and `Result`s
10-
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>) {
11+
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>, allow_expect_in_tests: bool) {
1112
let obj_ty = cx.typeck_results().expr_ty(recv).peel_refs();
1213

1314
let mess = if is_type_diagnostic_item(cx, obj_ty, sym::Option) {
@@ -18,6 +19,10 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr
1819
None
1920
};
2021

22+
if allow_expect_in_tests && is_in_test_function(cx.tcx, expr.hir_id) {
23+
return;
24+
}
25+
2126
if let Some((lint, kind, none_value)) = mess {
2227
span_lint_and_help(
2328
cx,

clippy_lints/src/methods/filter_map_next.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ pub(super) fn check<'tcx>(
1414
expr: &'tcx hir::Expr<'_>,
1515
recv: &'tcx hir::Expr<'_>,
1616
arg: &'tcx hir::Expr<'_>,
17-
msrv: Option<&RustcVersion>,
17+
msrv: Option<RustcVersion>,
1818
) {
1919
if is_trait_method(cx, expr, sym::Iterator) {
20-
if !meets_msrv(msrv, &msrvs::ITERATOR_FIND_MAP) {
20+
if !meets_msrv(msrv, msrvs::ITERATOR_FIND_MAP) {
2121
return;
2222
}
2323

clippy_lints/src/methods/is_digit_ascii_radix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ pub(super) fn check<'tcx>(
1515
expr: &'tcx Expr<'_>,
1616
self_arg: &'tcx Expr<'_>,
1717
radix: &'tcx Expr<'_>,
18-
msrv: Option<&RustcVersion>,
18+
msrv: Option<RustcVersion>,
1919
) {
20-
if !meets_msrv(msrv, &msrvs::IS_ASCII_DIGIT) {
20+
if !meets_msrv(msrv, msrvs::IS_ASCII_DIGIT) {
2121
return;
2222
}
2323

clippy_lints/src/methods/map_unwrap_or.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ pub(super) fn check<'tcx>(
1919
recv: &'tcx hir::Expr<'_>,
2020
map_arg: &'tcx hir::Expr<'_>,
2121
unwrap_arg: &'tcx hir::Expr<'_>,
22-
msrv: Option<&RustcVersion>,
22+
msrv: Option<RustcVersion>,
2323
) -> bool {
2424
// lint if the caller of `map()` is an `Option`
2525
let is_option = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(recv), sym::Option);
2626
let is_result = is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(recv), sym::Result);
2727

28-
if is_result && !meets_msrv(msrv, &msrvs::RESULT_MAP_OR_ELSE) {
28+
if is_result && !meets_msrv(msrv, msrvs::RESULT_MAP_OR_ELSE) {
2929
return false;
3030
}
3131

0 commit comments

Comments
 (0)