about summary refs log tree commit diff
path: root/clippy_lints/src/map_clone.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-08 15:00:30 +0000
committerbors <bors@rust-lang.org>2022-05-08 15:00:30 +0000
commit4667198d4f6a0fd4c2cccd0ddec4e5afbe291401 (patch)
treee0deb4a19ca2bee054e23f3dc52fb922b5acc62b /clippy_lints/src/map_clone.rs
parent9c78883fdf5ccdeef833bc99095a18dcf6312d0b (diff)
parent597f61bbe3a861c3d77b784cc701e6a975fbe842 (diff)
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`
Diffstat (limited to 'clippy_lints/src/map_clone.rs')
-rw-r--r--clippy_lints/src/map_clone.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs
index ceb66947d02..a13d191375b 100644
--- a/clippy_lints/src/map_clone.rs
+++ b/clippy_lints/src/map_clone.rs
@@ -144,7 +144,7 @@ impl MapClone {
     fn lint_explicit_closure(&self, cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) {
         let mut applicability = Applicability::MachineApplicable;
 
-        let (message, sugg_method) = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
+        let (message, sugg_method) = if is_copy && meets_msrv(self.msrv, msrvs::ITERATOR_COPIED) {
             ("you are using an explicit closure for copying elements", "copied")
         } else {
             ("you are using an explicit closure for cloning elements", "cloned")