mirror of https://github.com/rust-lang/rust
4aba2c55e6
Start pointing to where bindings were declared when they are captured in closures: ``` error[E0597]: `x` does not live long enough --> $DIR/suggest-return-closure.rs:23:9 | LL | let x = String::new(); | - binding `x` declared here ... LL | |c| { | --- value captured here LL | x.push(c); | ^ borrowed value does not live long enough ... LL | } | -- borrow later used here | | | `x` dropped here while still borrowed ``` Suggest cloning in more cases involving closures: ``` error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/issue-27282-move-ref-mut-into-guard.rs:11:19 | LL | if { (|| { let mut bar = foo; bar.take() })(); false } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard help: consider cloning the value if the performance cost is acceptable | LL | if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {}, | ++++++++ ``` |
||
---|---|---|
.. | ||
escape-argument-callee.rs | ||
escape-argument-callee.stderr | ||
escape-argument.rs | ||
escape-argument.stderr | ||
escape-upvar-nested.rs | ||
escape-upvar-nested.stderr | ||
escape-upvar-ref.rs | ||
escape-upvar-ref.stderr | ||
issue-58127-mutliple-requirements.rs | ||
propagate-approximated-fail-no-postdom.rs | ||
propagate-approximated-fail-no-postdom.stderr | ||
propagate-approximated-ref.rs | ||
propagate-approximated-ref.stderr | ||
propagate-approximated-shorter-to-static-comparing-against-free.rs | ||
propagate-approximated-shorter-to-static-comparing-against-free.stderr | ||
propagate-approximated-shorter-to-static-no-bound.rs | ||
propagate-approximated-shorter-to-static-no-bound.stderr | ||
propagate-approximated-shorter-to-static-wrong-bound.rs | ||
propagate-approximated-shorter-to-static-wrong-bound.stderr | ||
propagate-approximated-val.rs | ||
propagate-approximated-val.stderr | ||
propagate-despite-same-free-region.rs | ||
propagate-despite-same-free-region.stderr | ||
propagate-fail-to-approximate-longer-no-bounds.rs | ||
propagate-fail-to-approximate-longer-no-bounds.stderr | ||
propagate-fail-to-approximate-longer-wrong-bounds.rs | ||
propagate-fail-to-approximate-longer-wrong-bounds.stderr | ||
propagate-from-trait-match.rs | ||
propagate-from-trait-match.stderr | ||
propagate-multiple-requirements.rs | ||
propagate-multiple-requirements.stderr | ||
region-lbr-anon-does-not-outlive-static.rs | ||
region-lbr-anon-does-not-outlive-static.stderr | ||
region-lbr-named-does-not-outlive-static.rs | ||
region-lbr-named-does-not-outlive-static.stderr | ||
region-lbr1-does-not-outlive-ebr2.rs | ||
region-lbr1-does-not-outlive-ebr2.stderr | ||
region-lbr1-does-outlive-lbr2-because-implied-bound.rs | ||
return-wrong-bound-region.rs | ||
return-wrong-bound-region.stderr | ||
type-test-subject-non-trivial-region.rs | ||
type-test-subject-opaque-1.rs | ||
type-test-subject-opaque-2.rs | ||
type-test-subject-unnamed-region.rs |