pub fn tr_span(&self, span: Span) -> Span {
        let imported_filemaps = &self.cdata.codemap_import_info[..];

        let span = if span.lo > span.hi {
            // Currently macro expansion sometimes produces invalid Span values
            // where lo > hi. In order not to crash the compiler when trying to
            // translate these values, let's transform them into something we
            // can handle (and which will produce useful debug locations at
            // least some of the time).
            // This workaround is only necessary as long as macro expansion is
            // not fixed. FIXME(#23480)
            codemap::mk_sp(span.lo, span.lo)
        } else {
            span
        };

        let filemap_index = {
            // Optimize for the case that most spans within a translated item
            // originate from the same filemap.
            let last_filemap_index = self.last_filemap_index.get();

            if span.lo >= imported_filemaps[last_filemap_index].original_start_pos &&
               span.lo <= imported_filemaps[last_filemap_index].original_end_pos &&
               span.hi >= imported_filemaps[last_filemap_index].original_start_pos &&
               span.hi <= imported_filemaps[last_filemap_index].original_end_pos {
                last_filemap_index
            } else {
                let mut a = 0;
                let mut b = imported_filemaps.len();

                while b - a > 1 {
                    let m = (a + b) / 2;
                    if imported_filemaps[m].original_start_pos > span.lo {
                        b = m;
                    } else {
                        a = m;
                    }
                }

                self.last_filemap_index.set(a);
                a
            }
        };

        let lo = (span.lo - imported_filemaps[filemap_index].original_start_pos) +
                  imported_filemaps[filemap_index].translated_filemap.start_pos;
        let hi = (span.hi - imported_filemaps[filemap_index].original_start_pos) +
                  imported_filemaps[filemap_index].translated_filemap.start_pos;

        codemap::mk_sp(lo, hi)
    }
/// Translates a `Span` from an extern crate to the corresponding `Span`
/// within the local crate's codemap. `creader::import_codemap()` will
/// already have allocated any additionally needed FileMaps in the local
/// codemap as a side-effect of creating the crate_metadata's
/// `codemap_import_info`.
Translates a `Span` from an extern crate to the corresponding `Span`
within the local crate's codemap. `creader::import_codemap()` will
already have allocated any additionally needed FileMaps in the local
codemap as a side-effect of creating the crate_metadata's
`codemap_import_info`.
Translates a ` Span ` from an extern crate to the corresponding ` Span ` within the local crate ' s codemap . ` creader :: import_codemap () ` will already have allocated any additionally needed FileMaps in the local codemap as a side - effect of creating the crate_metadata ' s ` codemap_import_info ` .
pub fn tr_span(&self, span: Span) -> Span {
        let imported_filemaps = &self.cdata.codemap_import_info[..];
        let span = if span.lo > span.hi {
            // Currently macro expansion sometimes produces invalid Span values
            // where lo > hi. In order not to crash the compiler when trying to
            // translate these values, let's transform them into something we
            // can handle (and which will produce useful debug locations at
            // least some of the time).
            // This workaround is only necessary as long as macro expansion is
            // not fixed. FIXME(#23480)
            codemap::mk_sp(span.lo, span.lo)
        } else {
            span
        };
        let filemap_index = {
            // Optimize for the case that most spans within a translated item
            // originate from the same filemap.
            let last_filemap_index = self.last_filemap_index.get();
            if span.lo >= imported_filemaps[last_filemap_index].original_start_pos &&
               span.lo <= imported_filemaps[last_filemap_index].original_end_pos &&
               span.hi >= imported_filemaps[last_filemap_index].original_start_pos &&
               span.hi <= imported_filemaps[last_filemap_index].original_end_pos {
                last_filemap_index
            } else {
                let mut a = 0;
                let mut b = imported_filemaps.len();
                while b - a > 1 {
                    let m = (a + b) / 2;
                    if imported_filemaps[m].original_start_pos > span.lo {
                        b = m;
                    } else {
                        a = m;
                    }
                }
                self.last_filemap_index.set(a);
                a
            }
        };
        let lo = (span.lo - imported_filemaps[filemap_index].original_start_pos) +
                  imported_filemaps[filemap_index].translated_filemap.start_pos;
        let hi = (span.hi - imported_filemaps[filemap_index].original_start_pos) +
                  imported_filemaps[filemap_index].translated_filemap.start_pos;
        codemap::mk_sp(lo, hi)
    }
pub fn tr_span ( & self , span : Span ) -> Span { let imported_filemaps = & self . cdata . codemap_import_info [ .. ] ; let span = if span . lo > span . hi { // Currently macro expansion sometimes produces invalid Span values // where lo > hi. In order not to crash the compiler when trying to // translate these values, let's transform them into something we // can handle (and which will produce useful debug locations at // least some of the time). // This workaround is only necessary as long as macro expansion is // not fixed. FIXME(#23480) codemap :: mk_sp ( span . lo , span . lo ) } else { span } ; let filemap_index = { // Optimize for the case that most spans within a translated item // originate from the same filemap. let last_filemap_index = self . last_filemap_index . get ( ) ; if span . lo >= imported_filemaps [ last_filemap_index ] . original_start_pos && span . lo <= imported_filemaps [ last_filemap_index ] . original_end_pos && span . hi >= imported_filemaps [ last_filemap_index ] . original_start_pos && span . hi <= imported_filemaps [ last_filemap_index ] . original_end_pos { last_filemap_index } else { let mut a = 0 ; let mut b = imported_filemaps . len ( ) ; while b - a > 1 { let m = ( a + b ) / 2 ; if imported_filemaps [ m ] . original_start_pos > span . lo { b = m ; } else { a = m ; } } self . last_filemap_index . set ( a ) ; a } } ; let lo = ( span . lo - imported_filemaps [ filemap_index ] . original_start_pos ) + imported_filemaps [ filemap_index ] . translated_filemap . start_pos ; let hi = ( span . hi - imported_filemaps [ filemap_index ] . original_start_pos ) + imported_filemaps [ filemap_index ] . translated_filemap . start_pos ; codemap :: mk_sp ( lo , hi ) }
Translates a `Span` from an extern crate to the corresponding `Span`
within the local crate's codemap.
Translates a ` Span ` from an extern crate to the corresponding ` Span ` within the local crate ' s codemap .
&self
span
Span