pub fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span> {
        use std::cmp;

        // make sure we're at the same expansion id
        if sp_lhs.expn_id != sp_rhs.expn_id {
            return None;
        }

        let lhs_end = match self.lookup_line(sp_lhs.hi) {
            Ok(x) => x,
            Err(_) => return None
        };
        let rhs_begin = match self.lookup_line(sp_rhs.lo) {
            Ok(x) => x,
            Err(_) => return None
        };

        // if we must cross lines to merge, don't merge
        if lhs_end.line != rhs_begin.line {
            return None;
        }

        // ensure these follow the expected order and we don't overlap
        if (sp_lhs.lo <= sp_rhs.lo) && (sp_lhs.hi <= sp_rhs.lo) {
            Some(Span {
                lo: cmp::min(sp_lhs.lo, sp_rhs.lo),
                hi: cmp::max(sp_lhs.hi, sp_rhs.hi),
                expn_id: sp_lhs.expn_id,
            })
        } else {
            None
        }
    }
/// Returns `Some(span)`, a union of the lhs and rhs span.  The lhs must precede the rhs. If
/// there are gaps between lhs and rhs, the resulting union will cross these gaps.
/// For this to work, the spans have to be:
///    * the expn_id of both spans much match
///    * the lhs span needs to end on the same line the rhs span begins
///    * the lhs span must start at or before the rhs span
Returns `Some(span)`, a union of the lhs and rhs span.  The lhs must precede the rhs. If
there are gaps between lhs and rhs, the resulting union will cross these gaps.
For this to work, the spans have to be:
the expn_id of both spans much match
the lhs span needs to end on the same line the rhs span begins
the lhs span must start at or before the rhs span
Returns ` Some ( span ) ` a union of the lhs and rhs span . The lhs must precede the rhs . If there are gaps between lhs and rhs the resulting union will cross these gaps . For this to work the spans have to be : the expn_id of both spans much match the lhs span needs to end on the same line the rhs span begins the lhs span must start at or before the rhs span
pub fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span> {
        use std::cmp;
        // make sure we're at the same expansion id
        if sp_lhs.expn_id != sp_rhs.expn_id {
            return None;
        }
        let lhs_end = match self.lookup_line(sp_lhs.hi) {
            Ok(x) => x,
            Err(_) => return None
        };
        let rhs_begin = match self.lookup_line(sp_rhs.lo) {
            Ok(x) => x,
            Err(_) => return None
        };
        // if we must cross lines to merge, don't merge
        if lhs_end.line != rhs_begin.line {
            return None;
        }
        // ensure these follow the expected order and we don't overlap
        if (sp_lhs.lo <= sp_rhs.lo) && (sp_lhs.hi <= sp_rhs.lo) {
            Some(Span {
                lo: cmp::min(sp_lhs.lo, sp_rhs.lo),
                hi: cmp::max(sp_lhs.hi, sp_rhs.hi),
                expn_id: sp_lhs.expn_id,
            })
        } else {
            None
        }
    }
pub fn merge_spans ( & self , sp_lhs : Span , sp_rhs : Span ) -> Option < Span > { use std :: cmp ; // make sure we're at the same expansion id if sp_lhs . expn_id != sp_rhs . expn_id { return None ; } let lhs_end = match self . lookup_line ( sp_lhs . hi ) { Ok ( x ) => x , Err ( _ ) => return None } ; let rhs_begin = match self . lookup_line ( sp_rhs . lo ) { Ok ( x ) => x , Err ( _ ) => return None } ; // if we must cross lines to merge, don't merge if lhs_end . line != rhs_begin . line { return None ; } // ensure these follow the expected order and we don't overlap if ( sp_lhs . lo <= sp_rhs . lo ) && ( sp_lhs . hi <= sp_rhs . lo ) { Some ( Span { lo : cmp :: min ( sp_lhs . lo , sp_rhs . lo ) , hi : cmp :: max ( sp_lhs . hi , sp_rhs . hi ) , expn_id : sp_lhs . expn_id , } ) } else { None } }
Returns `Some(span)`, a union of the lhs and rhs span.
Returns ` Some ( span ) ` a union of the lhs and rhs span .
&self
sp_lhs
Span
sp_rhs
Span
&self
sp_lhs
Span
sp_rhs
Span