// Return all non-empty prefixes of a path.
// For each prefix, we return the span for the last segment in the prefix and
// a str representation of the entire prefix.
Return all non-empty prefixes of a path.
For each prefix, we return the span for the last segment in the prefix and
a str representation of the entire prefix.
Return all non - empty prefixes of a path . For each prefix we return the span for the last segment in the prefix and a str representation of the entire prefix .
fn process_path_prefixes(&self, path: &ast::Path) -> Vec<(Span, String)> {
        let spans = self.span.spans_for_path_segments(path);
        // Paths to enums seem to not match their spans - the span includes all the
        // variants too. But they seem to always be at the end, so I hope we can cope with
        // always using the first ones. So, only error out if we don't have enough spans.
        // What could go wrong...?
        if spans.len() < path.segments.len() {
            error!("Mis-calculated spans for path '{}'. \
                    Found {} spans, expected {}. Found spans:",
                   path_to_string(path), spans.len(), path.segments.len());
            for s in &spans {
                let loc = self.sess.codemap().lookup_char_pos(s.lo);
                error!("    '{}' in {}, line {}",
                       self.span.snippet(*s), loc.file.name, loc.line);
            }
            return vec!();
        }
        let mut result: Vec<(Span, String)> = vec!();
        let mut segs = vec!();
        for (i, (seg, span)) in path.segments.iter().zip(&spans).enumerate() {
            segs.push(seg.clone());
            let sub_path = ast::Path {
                span: *span, // span for the last segment
                global: path.global,
                segments: segs,
            };
            let qualname = if i == 0 && path.global {
                format!("::{}", path_to_string(&sub_path))
            } else {
                path_to_string(&sub_path)
            };
            result.push((*span, qualname));
            segs = sub_path.segments;
        }
        result
    }
fn process_path_prefixes ( & self , path : & ast :: Path ) -> Vec < ( Span , String ) > { let spans = self . span . spans_for_path_segments ( path ) ; // Paths to enums seem to not match their spans - the span includes all the // variants too. But they seem to always be at the end, so I hope we can cope with // always using the first ones. So, only error out if we don't have enough spans. // What could go wrong...? if spans . len ( ) < path . segments . len ( ) { error ! ( " \
 " path_to_string ( path ) spans len ( ) path segments len ( ) ) ; for s in & spans { let loc = self . sess . codemap ( ) . lookup_char_pos ( s . lo ) ; error ! ( " " self span snippet ( s ) loc file name loc line ) ; } return vec ! ( ) ; } let mut result : Vec < ( Span , String ) > = vec ! ( ) ; let mut segs = vec ! ( ) ; for ( i , ( seg , span ) ) in path . segments . iter ( ) . zip ( & spans ) . enumerate ( ) { segs . push ( seg . clone ( ) ) ; let sub_path = ast :: Path { span : * span , // span for the last segment global : path . global , segments : segs , } ; let qualname = if i == 0 && path . global { format ! ( " " path_to_string ( sub_path ) ) } else { path_to_string ( & sub_path ) } ; result . push ( ( * span , qualname ) ) ; segs = sub_path . segments ; } result }
Return all non-empty prefixes of a path.
Return all non - empty prefixes of a path .
&self
path
&ast::Path