/// Finds the span of arguments of a closure (within `maybe_closure_span`)
/// and its usage of the local assigned at `location`.
/// This is done by searching in statements succeeding `location`
/// and originating from `maybe_closure_span`.
Finds the span of arguments of a closure (within `maybe_closure_span`)
and its usage of the local assigned at `location`.
This is done by searching in statements succeeding `location`
and originating from `maybe_closure_span`.
Finds the span of arguments of a closure ( within ` maybe_closure_span ` ) and its usage of the local assigned at ` location ` . This is done by searching in statements succeeding ` location ` and originating from ` maybe_closure_span ` .
pub(super) fn borrow_spans(&self, use_span: Span, location: Location) -> UseSpans {
        use self::UseSpans::*;
        use rustc::hir::ExprKind::Closure;
        use rustc::mir::AggregateKind;
        let local = match self.mir[location.block]
            .statements
            .get(location.statement_index)
        {
            Some(&Statement {
                kind: StatementKind::Assign(Place::Local(local), _),
                ..
            }) => local,
            _ => return OtherUse(use_span),
        };
        if self.mir.local_kind(local) != LocalKind::Temp {
            // operands are always temporaries.
            return OtherUse(use_span);
        }
        for stmt in &self.mir[location.block].statements[location.statement_index + 1..] {
            if let StatementKind::Assign(_, Rvalue::Aggregate(ref kind, ref places)) = stmt.kind {
                if let AggregateKind::Closure(def_id, _) = **kind {
                    debug!("find_closure_borrow_span: found closure {:?}", places);
                    return if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
                        let args_span = if let Closure(_, _, _, span, _) =
                            self.tcx.hir.expect_expr(node_id).node
                        {
                            span
                        } else {
                            return OtherUse(use_span);
                        };
                        self.tcx
                            .with_freevars(node_id, |freevars| {
                                for (v, place) in freevars.iter().zip(places) {
                                    match *place {
                                        Operand::Copy(Place::Local(l))
                                        | Operand::Move(Place::Local(l))
                                            if local == l =>
                                        {
                                            debug!(
                                                "find_closure_borrow_span: found captured local \
                                                 {:?}",
                                                l
                                            );
                                            return Some(v.span);
                                        }
                                        _ => {}
                                    }
                                }
                                None
                            }).map(|var_span| ClosureUse {
                                args_span,
                                var_span,
                            }).unwrap_or(OtherUse(use_span))
                    } else {
                        OtherUse(use_span)
                    };
                }
            }
            if use_span != stmt.source_info.span {
                break;
            }
        }
        OtherUse(use_span)
    }
pub ( super ) fn borrow_spans ( & self , use_span : Span , location : Location ) -> UseSpans { use self :: UseSpans :: * ; use rustc :: hir :: ExprKind :: Closure ; use rustc :: mir :: AggregateKind ; let local = match self . mir [ location . block ] . statements . get ( location . statement_index ) { Some ( & Statement { kind : StatementKind :: Assign ( Place :: Local ( local ) , _ ) , .. } ) => local , _ => return OtherUse ( use_span ) , } ; if self . mir . local_kind ( local ) != LocalKind :: Temp { // operands are always temporaries. return OtherUse ( use_span ) ; } for stmt in & self . mir [ location . block ] . statements [ location . statement_index + 1 .. ] { if let StatementKind :: Assign ( _ , Rvalue :: Aggregate ( ref kind , ref places ) ) = stmt . kind { if let AggregateKind :: Closure ( def_id , _ ) = * * kind { debug ! ( " " places ) ; return if let Some ( node_id ) = self . tcx . hir . as_local_node_id ( def_id ) { let args_span = if let Closure ( _ , _ , _ , span , _ ) = self . tcx . hir . expect_expr ( node_id ) . node { span } else { return OtherUse ( use_span ) ; } ; self . tcx . with_freevars ( node_id , | freevars | { for ( v , place ) in freevars . iter ( ) . zip ( places ) { match * place { Operand :: Copy ( Place :: Local ( l ) ) | Operand :: Move ( Place :: Local ( l ) ) if local == l => { debug ! ( " \
 " l ) ; return Some ( v . span ) ; } _ => { } } } None } ) . map ( | var_span | ClosureUse { args_span , var_span , } ) . unwrap_or ( OtherUse ( use_span ) ) } else { OtherUse ( use_span ) } ; } } if use_span != stmt . source_info . span { break ; } } OtherUse ( use_span ) }
Finds the span of arguments of a closure (within `maybe_closure_span`)
and its usage of the local assigned at `location`.
Finds the span of arguments of a closure ( within ` maybe_closure_span ` ) and its usage of the local assigned at ` location ` .
&self
use_span
Span
location
Location