From 7a3337ae0ae4bbaeb691b40fdb12f777b6688b68 Mon Sep 17 00:00:00 2001 From: Dinu Blanovschi Date: Mon, 1 Apr 2024 12:43:24 +0200 Subject: [PATCH] fix: minor fixes --- clippy_lints/src/needless_move.rs | 43 +++--- tests/ui/needless_move.fixed | 58 ++++----- tests/ui/needless_move.stderr | 208 +++++++++++++++--------------- 3 files changed, 155 insertions(+), 154 deletions(-) diff --git a/clippy_lints/src/needless_move.rs b/clippy_lints/src/needless_move.rs index bcbdd210295b..77cb51084134 100644 --- a/clippy_lints/src/needless_move.rs +++ b/clippy_lints/src/needless_move.rs @@ -33,9 +33,9 @@ //! try to infer the actual min capture kind needed. use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::sugg::DiagnosticExt; +use clippy_utils::sugg::DiagExt; use rustc_errors::Applicability; -use rustc_hir::{CaptureBy, Closure, Expr, ExprKind, HirId}; +use rustc_hir::{CaptureBy, Expr, ExprKind, HirId}; use rustc_hir_typeck::expr_use_visitor as euv; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LateLintPass}; @@ -46,7 +46,7 @@ use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does - /// Checks for closures and `async` blocks where the `move` is not necessary. + /// Checks for closures and `async` blocks where capturing by value (the `move` keyword) is unnecessary. /// E.g. all the values are captured by value into the closure / `async` block. /// /// ### Why is this bad? @@ -96,8 +96,16 @@ declare_clippy_lint! { declare_lint_pass!(NeedlessMove => [NEEDLESS_MOVE]); -impl NeedlessMove { - fn check_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, closure: &'tcx Closure<'tcx>) { +impl<'tcx> LateLintPass<'tcx> for NeedlessMove { + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { + if expr.span.from_expansion() { + return; + } + + let ExprKind::Closure(closure) = &expr.kind else { + return; + }; + let CaptureBy::Value { move_kw } = closure.capture_clause else { return; }; @@ -140,9 +148,9 @@ impl NeedlessMove { } let note_msg = match lint_result { - LintResult::NothingCaptured => "there were no captured variables, so the `move` is unnecessary", + LintResult::NothingCaptured => "there are no captured variables, so the `move` keyword is unnecessary", LintResult::Consumed => { - "there were consumed variables, but no borrowed variables, so the `move` is unnecessary" + "there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary" }, LintResult::NeedMove => { // there was a value which would be borrowed if it weren't for the move keyword, @@ -155,27 +163,20 @@ impl NeedlessMove { cx, NEEDLESS_MOVE, expr.span, - "you seem to use `move`, but the `move` is unnecessary", + "this closure does not need to capture by value", |diag| { - diag.suggest_remove_item(cx, move_kw, "remove the `move`", Applicability::MachineApplicable); + diag.suggest_remove_item( + cx, + move_kw, + "remove the `move` keyword", + Applicability::MachineApplicable, + ); diag.note(note_msg); }, ); } } -impl<'tcx> LateLintPass<'tcx> for NeedlessMove { - fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { - if expr.span.from_expansion() { - return; - } - - if let ExprKind::Closure(closure) = &expr.kind { - Self::check_closure(cx, expr, closure); - } - } -} - enum LintResult { /// do not remove the `move` keyword. NeedMove, diff --git a/tests/ui/needless_move.fixed b/tests/ui/needless_move.fixed index cc0533d3adba..f0685ac19a86 100644 --- a/tests/ui/needless_move.fixed +++ b/tests/ui/needless_move.fixed @@ -396,7 +396,7 @@ fn main() { // below are a few tests from rustc's testsuite that use move closures, // which might uncover edge cases - // rust/$DIR/closures/2229_closure_analysis/migrations/no_migrations.rs + // rust/tests/ui/closures/2229_closure_analysis/migrations/no_migrations.rs fn _no_migrations() { // Set of test cases that don't need migrations @@ -480,7 +480,7 @@ fn main() { } } - // rust/$DIR/closures/2229_closure_analysis/run_pass/issue-88476.rs + // rust/tests/ui/closures/2229_closure_analysis/run_pass/issue-88476.rs fn _issue_88476() { use std::rc::Rc; @@ -529,7 +529,7 @@ fn main() { fn main() {} } - // rust/$DIR/closures/2229_closure_analysis/preserve_field_drop_order2.rs + // rust/tests/ui/closures/2229_closure_analysis/preserve_field_drop_order2.rs fn _preserve_field_drop_order2() { #[derive(Debug)] @@ -601,7 +601,7 @@ fn main() { } } - // rust/$DIR/closures/issue-72408-nested-closures-exponential.rs + // rust/tests/ui/closures/issue-72408-nested-closures-exponential.rs fn _issue_72408_nested_closures_exponential() { @@ -669,7 +669,7 @@ fn main() { */ } - // rust/$DIR/closures/issue-97607.rs + // rust/tests/ui/closures/issue-97607.rs fn _issue_97607() { #[allow(unused)] @@ -685,7 +685,7 @@ fn main() { fn main() {} } - // rust/$DIR/closures/once-move-out-on-heap.rs + // rust/tests/ui/closures/once-move-out-on-heap.rs fn _once_move_out_on_heap() { // Testing guarantees provided by once functions. @@ -705,7 +705,7 @@ fn main() { } } - // rust/$DIR/closures/supertrait-hint-references-assoc-ty.rs + // rust/tests/ui/closures/supertrait-hint-references-assoc-ty.rs fn _supertrait_hint_references_assoc_ty() { pub trait Fn0: Fn(i32) -> Self::Out { @@ -725,7 +725,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/issue-18652.rs + // rust/tests/ui/unboxed-closures/issue-18652.rs fn _issue_18652() { // Tests multiple free variables being passed by value into an unboxed @@ -739,7 +739,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-all-traits.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-all-traits.rs fn _unboxed_closures_all_traits() { fn a isize>(f: F) -> isize { @@ -762,7 +762,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-boxed.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-boxed.rs fn _unboxed_closures_boxed() { use std::ops::FnMut; @@ -779,7 +779,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs fn _unboxed_closures_call_sugar_object_autoderef() { // Test that the call operator autoderefs when calling to an object type. @@ -798,7 +798,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-call-sugar-object.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-call-sugar-object.rs fn _unboxed_closures_call_sugar_object() { use std::ops::FnMut; @@ -815,7 +815,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-counter-not-moved.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-counter-not-moved.rs fn _unboxed_closures_counter_not_moved() { // Test that we mutate a counter on the stack only when we expect to. @@ -849,7 +849,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-drop.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-drop.rs fn _unboxed_closures_drop() { #![allow(path_statements)] @@ -985,7 +985,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-infer-fnmut-move.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-infer-fnmut-move.rs fn _unboxed_closures_infer_fnmut_move() { // Test that we are able to infer a suitable kind for this `move` @@ -1008,7 +1008,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-infer-fnonce-move.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-infer-fnonce-move.rs fn _unboxed_closures_infer_fnonce_move() { // Test that we are able to infer a suitable kind for this `move` @@ -1037,7 +1037,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-monomorphization.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-monomorphization.rs fn _unboxed_closures_monomorphization() { // Test that unboxed closures in contexts with free type parameters @@ -1067,7 +1067,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-move-mutable.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-move-mutable.rs fn _unboxed_closures_move_mutable() { // pretty-expanded FIXME #23616 @@ -1104,7 +1104,7 @@ fn main() { } } - // rust/$DIR/unboxed-closures/unboxed-closures-single-word-env.rs + // rust/tests/ui/unboxed-closures/unboxed-closures-single-word-env.rs fn _unboxed_closures_single_word_env() { // Ensures that single-word environments work right in unboxed closures. @@ -1130,7 +1130,7 @@ fn main() { } } - // rust/$DIR/functions-closures/clone-closure.rs + // rust/tests/ui/functions-closures/clone-closure.rs fn _clone_closure() { // Check that closures implement `Clone`. @@ -1152,7 +1152,7 @@ fn main() { } } - // rust/$DIR/functions-closures/closure-bounds-can-capture-chan.rs + // rust/tests/ui/functions-closures/closure-bounds-can-capture-chan.rs fn _closure_bounds_can_capture_chan() { // pretty-expanded FIXME #23616 @@ -1172,7 +1172,7 @@ fn main() { } } - // rust/$DIR/functions-closures/nullable-pointer-opt-closures.rs + // rust/tests/ui/functions-closures/nullable-pointer-opt-closures.rs fn _nullable_pointer_opt_closures() { use std::mem; @@ -1209,7 +1209,7 @@ fn main() { } } - // rust/$DIR/moves/moves-based-on-type-capture-clause.rs + // rust/tests/ui/moves/moves-based-on-type-capture-clause.rs fn _moves_based_on_type_capture_clause() { #![allow(unused_must_use)] @@ -1226,7 +1226,7 @@ fn main() { } } - // rust/$DIR/borrowck/borrow-raw-address-of-mutability-ok.rs + // rust/tests/ui/borrowck/borrow-raw-address-of-mutability-ok.rs fn _borrow_raw_address_of_mutability_ok() { fn mutable_address_of() { @@ -1273,7 +1273,7 @@ fn main() { fn main() {} } - // rust/$DIR/borrowck/kindck-implicit-close-over-mut-var.rs + // rust/tests/ui/borrowck/kindck-implicit-close-over-mut-var.rs fn _kindck_implicit_close_over_mut_var() { #![allow(unused_must_use)] @@ -1325,7 +1325,7 @@ fn main() { pub fn main() {} } - // rust/$DIR/async-await/track-caller/panic-track-caller.rs + // rust/tests/ui/async-await/track-caller/panic-track-caller.rs fn _panic_track_caller() { // needs-unwind @@ -1457,7 +1457,7 @@ fn main() { } } - // rust/$DIR/async-await/deep-futures-are-freeze.rs + // rust/tests/ui/async-await/deep-futures-are-freeze.rs fn _deep_futures_are_freeze() { // no-prefer-dynamic @@ -1638,7 +1638,7 @@ fn main() { async fn boom(f: &mut ()) {} } - // rust/$DIR/async-await/generics-and-bounds.rs + // rust/tests/ui/async-await/generics-and-bounds.rs fn _generics_and_bounds() { use std::future::Future; @@ -1727,7 +1727,7 @@ fn main() { } } - // rust/$DIR/async-await/issue-105501.rs + // rust/tests/ui/async-await/issue-105501.rs fn _issue_105501() { // This is a regression test for https://github.com/rust-lang/rust/issues/105501. diff --git a/tests/ui/needless_move.stderr b/tests/ui/needless_move.stderr index 2b7944c16371..a3cbf9d8da1f 100644 --- a/tests/ui/needless_move.stderr +++ b/tests/ui/needless_move.stderr @@ -1,89 +1,89 @@ -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:72:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:72:33 | LL | let closure = assert_static(move || {}); | -----^^^^^ | | - | help: remove the `move` + | help: remove the `move` keyword | - = note: there were no captured variables, so the `move` is unnecessary + = note: there are no captured variables, so the `move` keyword is unnecessary = note: `-D clippy::needless-move` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_move)]` -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:73:29 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:73:29 | LL | let fut = assert_static(async move {}); | ^^^^^^-----^^ | | - | help: remove the `move` + | help: remove the `move` keyword | - = note: there were no captured variables, so the `move` is unnecessary + = note: there are no captured variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:77:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:77:33 | LL | let closure = assert_static(move || { | ^---- | | - | _________________________________help: remove the `move` + | _________________________________help: remove the `move` keyword | | LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:123:29 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:123:29 | LL | let fut = assert_static(async move { - | ^ ----- help: remove the `move` + | ^ ----- help: remove the `move` keyword | _____________________________| | | LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:160:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:160:33 | LL | let closure = assert_static(move || { | ^---- | | - | _________________________________help: remove the `move` + | _________________________________help: remove the `move` keyword | | LL | | with_ref(&a); LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:174:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:174:33 | LL | let closure = assert_static(move || { | ^---- | | - | _________________________________help: remove the `move` + | _________________________________help: remove the `move` keyword | | LL | | with_ref_mut(&mut a); LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:189:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:189:33 | LL | let closure = assert_static(move || { | ^---- | | - | _________________________________help: remove the `move` + | _________________________________help: remove the `move` keyword | | LL | | with_ref(&a); LL | | with_owned(b); @@ -91,86 +91,86 @@ LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:208:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:208:33 | LL | let closure = assert_static(move || { | ^---- | | - | _________________________________help: remove the `move` + | _________________________________help: remove the `move` keyword | | LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:246:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:246:33 | LL | let closure = assert_static(move || { | ^---- | | - | _________________________________help: remove the `move` + | _________________________________help: remove the `move` keyword | | LL | | with_owned(a.non_copy); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:318:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:318:33 | LL | let closure = assert_static(move || { | ^---- | | - | _________________________________help: remove the `move` + | _________________________________help: remove the `move` keyword | | LL | | a = NonCopy; LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:325:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:325:33 | LL | let closure = assert_static(move || { | ^---- | | - | _________________________________help: remove the `move` + | _________________________________help: remove the `move` keyword | | LL | | a.copy = Copy; LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:332:33 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:332:33 | LL | let closure = assert_static(move || { | ^---- | | - | _________________________________help: remove the `move` + | _________________________________help: remove the `move` keyword | | LL | | a.non_copy = NonCopy; LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:371:29 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:371:29 | LL | let fut = assert_static(async move { - | ^ ----- help: remove the `move` + | ^ ----- help: remove the `move` keyword | _____________________________| | | LL | | a = NonCopy; @@ -178,13 +178,13 @@ LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:378:29 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:378:29 | LL | let fut = assert_static(async move { - | ^ ----- help: remove the `move` + | ^ ----- help: remove the `move` keyword | _____________________________| | | LL | | a.copy = Copy; @@ -192,13 +192,13 @@ LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:385:29 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:385:29 | LL | let fut = assert_static(async move { - | ^ ----- help: remove the `move` + | ^ ----- help: remove the `move` keyword | _____________________________| | | LL | | a.non_copy = NonCopy; @@ -206,89 +206,89 @@ LL | | with_owned(a); LL | | }); | |_____^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:701:17 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:701:17 | LL | foo(move || { | ^---- | | - | _________________help: remove the `move` + | _________________help: remove the `move` keyword | | LL | | assert!(*x); LL | | drop(x); LL | | }); | |_____________^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:722:27 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:722:27 | LL | closure_typer(move |x| { | ^---- | | - | ___________________________help: remove the `move` + | ___________________________help: remove the `move` keyword | | LL | | let _: i64 = x.into(); LL | | }); | |_____________^ | - = note: there were no captured variables, so the `move` is unnecessary + = note: there are no captured variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:896:19 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:896:19 | LL | a(move |a: isize, b| a + b); | -----^^^^^^^^^^^^^^^^^^^ | | - | help: remove the `move` + | help: remove the `move` keyword | - = note: there were no captured variables, so the `move` is unnecessary + = note: there are no captured variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:925:19 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:925:19 | LL | b(move |a: isize, b| a + b); | -----^^^^^^^^^^^^^^^^^^^ | | - | help: remove the `move` + | help: remove the `move` keyword | - = note: there were no captured variables, so the `move` is unnecessary + = note: there are no captured variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:954:19 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:954:19 | LL | c(move |a: isize, b| a + b); | -----^^^^^^^^^^^^^^^^^^^ | | - | help: remove the `move` + | help: remove the `move` keyword | - = note: there were no captured variables, so the `move` is unnecessary + = note: there are no captured variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:960:19 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:960:19 | LL | c(move |a: isize, b| { | ^---- | | - | ___________________help: remove the `move` + | ___________________help: remove the `move` keyword | | LL | | z; LL | | a + b LL | | }); | |_________________^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:971:19 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:971:19 | LL | c(move |a: isize, b| { | ^---- | | - | ___________________help: remove the `move` + | ___________________help: remove the `move` keyword | | LL | | z; LL | | zz; @@ -296,50 +296,50 @@ LL | | a + b LL | | }); | |_________________^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:1032:28 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:1032:28 | LL | let tick = move || mem::drop(drop_me); | -----^^^^^^^^^^^^^^^^^^^^^ | | - | help: remove the `move` + | help: remove the `move` keyword | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:1468:19 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:1468:19 | LL | spawn(move || main0()) | -----^^^^^^^^^^ | | - | help: remove the `move` + | help: remove the `move` keyword | - = note: there were no captured variables, so the `move` is unnecessary + = note: there are no captured variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:1691:13 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:1691:13 | LL | async move {} | ^^^^^^-----^^ | | - | help: remove the `move` + | help: remove the `move` keyword | - = note: there were no captured variables, so the `move` is unnecessary + = note: there are no captured variables, so the `move` keyword is unnecessary -error: you seem to use `move`, but the `move` is unnecessary - --> $DIR/needless_move.rs:1754:21 +error: this closure does not need to capture by value + --> tests/ui/needless_move.rs:1754:21 | LL | is_send(async move { - | ^ ----- help: remove the `move` + | ^ ----- help: remove the `move` keyword | _____________________| | | LL | | let _: Option<()> = fut.await; LL | | }); | |_____________^ | - = note: there were consumed variables, but no borrowed variables, so the `move` is unnecessary + = note: there are consumed variables, but no borrowed variables, so the `move` keyword is unnecessary error: aborting due to 26 previous errors