@@ -306,11 +306,7 @@ impl Span {
306
306
307
307
/// Returns `self` if `self` is not the dummy span, and `other` otherwise.
308
308
pub fn substitute_dummy ( self , other : Span ) -> Span {
309
- if self . is_dummy ( ) {
310
- other
311
- } else {
312
- self
313
- }
309
+ if self . is_dummy ( ) { other } else { self }
314
310
}
315
311
316
312
/// Returns `true` if `self` fully encloses `other`.
@@ -341,33 +337,21 @@ impl Span {
341
337
pub fn trim_start ( self , other : Span ) -> Option < Span > {
342
338
let span = self . data ( ) ;
343
339
let other = other. data ( ) ;
344
- if span. hi > other. hi {
345
- Some ( span. with_lo ( cmp:: max ( span. lo , other. hi ) ) )
346
- } else {
347
- None
348
- }
340
+ if span. hi > other. hi { Some ( span. with_lo ( cmp:: max ( span. lo , other. hi ) ) ) } else { None }
349
341
}
350
342
351
343
/// Returns the source span -- this is either the supplied span, or the span for
352
344
/// the macro callsite that expanded to it.
353
345
pub fn source_callsite ( self ) -> Span {
354
346
let expn_data = self . ctxt ( ) . outer_expn_data ( ) ;
355
- if !expn_data. is_root ( ) {
356
- expn_data. call_site . source_callsite ( )
357
- } else {
358
- self
359
- }
347
+ if !expn_data. is_root ( ) { expn_data. call_site . source_callsite ( ) } else { self }
360
348
}
361
349
362
350
/// The `Span` for the tokens in the previous macro expansion from which `self` was generated,
363
351
/// if any.
364
352
pub fn parent ( self ) -> Option < Span > {
365
353
let expn_data = self . ctxt ( ) . outer_expn_data ( ) ;
366
- if !expn_data. is_root ( ) {
367
- Some ( expn_data. call_site )
368
- } else {
369
- None
370
- }
354
+ if !expn_data. is_root ( ) { Some ( expn_data. call_site ) } else { None }
371
355
}
372
356
373
357
/// Edition of the crate from which this span came.
@@ -393,18 +377,10 @@ impl Span {
393
377
pub fn source_callee ( self ) -> Option < ExpnData > {
394
378
fn source_callee ( expn_data : ExpnData ) -> ExpnData {
395
379
let next_expn_data = expn_data. call_site . ctxt ( ) . outer_expn_data ( ) ;
396
- if !next_expn_data. is_root ( ) {
397
- source_callee ( next_expn_data)
398
- } else {
399
- expn_data
400
- }
380
+ if !next_expn_data. is_root ( ) { source_callee ( next_expn_data) } else { expn_data }
401
381
}
402
382
let expn_data = self . ctxt ( ) . outer_expn_data ( ) ;
403
- if !expn_data. is_root ( ) {
404
- Some ( source_callee ( expn_data) )
405
- } else {
406
- None
407
- }
383
+ if !expn_data. is_root ( ) { Some ( source_callee ( expn_data) ) } else { None }
408
384
}
409
385
410
386
/// Checks if a span is "internal" to a macro in which `#[unstable]`
@@ -1224,11 +1200,7 @@ impl SourceFile {
1224
1200
1225
1201
let line_index = lookup_line ( & self . lines [ ..] , pos) ;
1226
1202
assert ! ( line_index < self . lines. len( ) as isize ) ;
1227
- if line_index >= 0 {
1228
- Some ( line_index as usize )
1229
- } else {
1230
- None
1231
- }
1203
+ if line_index >= 0 { Some ( line_index as usize ) } else { None }
1232
1204
}
1233
1205
1234
1206
pub fn line_bounds ( & self , line_index : usize ) -> ( BytePos , BytePos ) {
0 commit comments