@@ -316,11 +316,7 @@ impl Span {
316
316
317
317
/// Returns `self` if `self` is not the dummy span, and `other` otherwise.
318
318
pub fn substitute_dummy ( self , other : Span ) -> Span {
319
- if self . is_dummy ( ) {
320
- other
321
- } else {
322
- self
323
- }
319
+ if self . is_dummy ( ) { other } else { self }
324
320
}
325
321
326
322
/// Returns `true` if `self` fully encloses `other`.
@@ -351,33 +347,21 @@ impl Span {
351
347
pub fn trim_start ( self , other : Span ) -> Option < Span > {
352
348
let span = self . data ( ) ;
353
349
let other = other. data ( ) ;
354
- if span. hi > other. hi {
355
- Some ( span. with_lo ( cmp:: max ( span. lo , other. hi ) ) )
356
- } else {
357
- None
358
- }
350
+ if span. hi > other. hi { Some ( span. with_lo ( cmp:: max ( span. lo , other. hi ) ) ) } else { None }
359
351
}
360
352
361
353
/// Returns the source span -- this is either the supplied span, or the span for
362
354
/// the macro callsite that expanded to it.
363
355
pub fn source_callsite ( self ) -> Span {
364
356
let expn_data = self . ctxt ( ) . outer_expn_data ( ) ;
365
- if !expn_data. is_root ( ) {
366
- expn_data. call_site . source_callsite ( )
367
- } else {
368
- self
369
- }
357
+ if !expn_data. is_root ( ) { expn_data. call_site . source_callsite ( ) } else { self }
370
358
}
371
359
372
360
/// The `Span` for the tokens in the previous macro expansion from which `self` was generated,
373
361
/// if any.
374
362
pub fn parent ( self ) -> Option < Span > {
375
363
let expn_data = self . ctxt ( ) . outer_expn_data ( ) ;
376
- if !expn_data. is_root ( ) {
377
- Some ( expn_data. call_site )
378
- } else {
379
- None
380
- }
364
+ if !expn_data. is_root ( ) { Some ( expn_data. call_site ) } else { None }
381
365
}
382
366
383
367
/// Edition of the crate from which this span came.
@@ -403,18 +387,10 @@ impl Span {
403
387
pub fn source_callee ( self ) -> Option < ExpnData > {
404
388
fn source_callee ( expn_data : ExpnData ) -> ExpnData {
405
389
let next_expn_data = expn_data. call_site . ctxt ( ) . outer_expn_data ( ) ;
406
- if !next_expn_data. is_root ( ) {
407
- source_callee ( next_expn_data)
408
- } else {
409
- expn_data
410
- }
390
+ if !next_expn_data. is_root ( ) { source_callee ( next_expn_data) } else { expn_data }
411
391
}
412
392
let expn_data = self . ctxt ( ) . outer_expn_data ( ) ;
413
- if !expn_data. is_root ( ) {
414
- Some ( source_callee ( expn_data) )
415
- } else {
416
- None
417
- }
393
+ if !expn_data. is_root ( ) { Some ( source_callee ( expn_data) ) } else { None }
418
394
}
419
395
420
396
/// Checks if a span is "internal" to a macro in which `#[unstable]`
@@ -1234,11 +1210,7 @@ impl SourceFile {
1234
1210
1235
1211
let line_index = lookup_line ( & self . lines [ ..] , pos) ;
1236
1212
assert ! ( line_index < self . lines. len( ) as isize ) ;
1237
- if line_index >= 0 {
1238
- Some ( line_index as usize )
1239
- } else {
1240
- None
1241
- }
1213
+ if line_index >= 0 { Some ( line_index as usize ) } else { None }
1242
1214
}
1243
1215
1244
1216
pub fn line_bounds ( & self , line_index : usize ) -> ( BytePos , BytePos ) {
0 commit comments