is_closure_like
This commit is contained in:
parent
8f00ffc901
commit
4fbd5cc31f
@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals {
|
|||||||
fn is_by_value_closure_capture(cx: &LateContext<'_>, redefinition: HirId, root_variable: HirId) -> bool {
|
fn is_by_value_closure_capture(cx: &LateContext<'_>, redefinition: HirId, root_variable: HirId) -> bool {
|
||||||
let closure_def_id = cx.tcx.hir().enclosing_body_owner(redefinition);
|
let closure_def_id = cx.tcx.hir().enclosing_body_owner(redefinition);
|
||||||
|
|
||||||
cx.tcx.is_closure_or_coroutine(closure_def_id.to_def_id())
|
cx.tcx.is_closure_like(closure_def_id.to_def_id())
|
||||||
&& cx.tcx.closure_captures(closure_def_id).iter().any(|c| {
|
&& cx.tcx.closure_captures(closure_def_id).iter().any(|c| {
|
||||||
matches!(c.info.capture_kind, UpvarCapture::ByValue)
|
matches!(c.info.capture_kind, UpvarCapture::ByValue)
|
||||||
&& matches!(c.place.base, PlaceBase::Upvar(upvar) if upvar.var_path.hir_id == root_variable)
|
&& matches!(c.place.base, PlaceBase::Upvar(upvar) if upvar.var_path.hir_id == root_variable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user