@@ -42,7 +42,7 @@ use rustc_lint::{LateContext, LateLintPass};
42
42
use rustc_middle:: mir:: FakeReadCause ;
43
43
use rustc_middle:: ty;
44
44
use rustc_middle:: ty:: UpvarCapture ;
45
- use rustc_session:: { declare_lint_pass, declare_tool_lint } ;
45
+ use rustc_session:: declare_lint_pass;
46
46
47
47
declare_clippy_lint ! {
48
48
/// ### What it does
@@ -55,24 +55,25 @@ declare_clippy_lint! {
55
55
/// the programmer adds the `move` keyword to move the variables into the closure, but
56
56
/// then later decides that he no longer needs the variables in question, so he removes them
57
57
/// from the body of the closure, but forgets to also remove the `move` keyword.
58
- ///
58
+ ///
59
59
/// This is really just a strict coding style issue.
60
- ///
60
+ ///
61
61
/// ### Caveats
62
62
/// There are some cases where this lint will suggest removing the `move` keyword,
63
63
/// but it would be considered idiomatic to keep it.
64
- ///
64
+ ///
65
65
/// For example, the closure passed to `std::thread::spawn` is usually always written
66
66
/// with the `move` keyword, even if it's not necessary:
67
- ///
67
+ ///
68
68
/// ```no_run
69
+ /// # fn function_that_does_something_with(_: String) {}
69
70
/// let a = String::new();
70
71
/// std::thread::spawn(move || {
71
72
/// // ...
72
73
/// function_that_does_something_with(a); // a is moved into the closure
73
74
/// });
74
75
/// ```
75
- ///
76
+ ///
76
77
/// ### Example
77
78
/// ```no_run
78
79
/// let a = String::new();
@@ -139,9 +140,7 @@ impl NeedlessMove {
139
140
}
140
141
141
142
let note_msg = match lint_result {
142
- LintResult :: NothingCaptured => {
143
- "there were no captured variables, so the `move` is unnecessary"
144
- } ,
143
+ LintResult :: NothingCaptured => "there were no captured variables, so the `move` is unnecessary" ,
145
144
LintResult :: Consumed => {
146
145
"there were consumed variables, but no borrowed variables, so the `move` is unnecessary"
147
146
} ,
0 commit comments