]> git.lizzy.rs Git - rust.git/commitdiff
adding condition for map_clone message
authorkyoto7250 <50972773+kyoto7250@users.noreply.github.com>
Mon, 11 Apr 2022 19:03:48 +0000 (04:03 +0900)
committerkyoto7250 <50972773+kyoto7250@users.noreply.github.com>
Mon, 11 Apr 2022 19:03:48 +0000 (04:03 +0900)
if msrv < 1.36, the message tells , but the suggestion is

clippy_lints/src/map_clone.rs
tests/ui-toml/min_rust_version/min_rust_version.stderr

index e233300e26ab898e94efcdbd13b5bee37b6dbcf7..a03d5d540653dc616da5e317d1316bd40d5b0d0d 100644 (file)
@@ -143,7 +143,7 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) {
 impl MapClone {
     fn lint_explicit_closure(&self, cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) {
         let mut applicability = Applicability::MachineApplicable;
-        let message = if is_copy {
+        let message = if is_copy && meets_msrv(self.msrv.as_ref(), &msrvs::ITERATOR_COPIED) {
             "you are using an explicit closure for copying elements"
         } else {
             "you are using an explicit closure for cloning elements"
index a1e7361c0cb32fe4bbe9e9c5a09320691b3b123a..5dae5af7eb5a9cc9413582d37256b2869abd32c8 100644 (file)
@@ -1,4 +1,4 @@
-error: you are using an explicit closure for copying elements
+error: you are using an explicit closure for cloning elements
   --> $DIR/min_rust_version.rs:74:26
    |
 LL |     let _: Option<u64> = Some(&16).map(|b| *b);