@@ -384,7 +384,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
384
384
}
385
385
386
386
/// This function checks if the specified expression is a built-in range literal.
387
- /// (See: ``librustc::hir::lowering:: LoweringContext::lower_expr()``).
387
+ /// (See: `LoweringContext::lower_expr()` in `src/librustc/hir/lowering.rs `).
388
388
fn is_range_literal ( & self , expr : & hir:: Expr ) -> bool {
389
389
use hir:: { Path , QPath , ExprKind , TyKind } ;
390
390
@@ -404,10 +404,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
404
404
}
405
405
} ;
406
406
407
- let is_range_literal = |span : & Span | {
408
- // Tell if expression span snippet doesn't look like an explicit
409
- // Range struct or `new()` call. This is to allow inferring
410
- // that this is a range literal.
407
+ let span_is_range_literal = |span : & Span | {
408
+ // Check whether a span corresponding to a range expression
409
+ // is a range literal, rather than an explicit struct or `new()` call.
411
410
let source_map = self . tcx . sess . source_map ( ) ;
412
411
let end_point = source_map. end_point ( * span) ;
413
412
@@ -423,7 +422,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
423
422
ExprKind :: Struct ( QPath :: Resolved ( None , ref path) , _, _) |
424
423
// `..` desugars to its struct path
425
424
ExprKind :: Path ( QPath :: Resolved ( None , ref path) ) => {
426
- return is_range_path ( & path) && is_range_literal ( & expr. span ) ;
425
+ return is_range_path ( & path) && span_is_range_literal ( & expr. span ) ;
427
426
}
428
427
429
428
// `..=` desugars into `::std::ops::RangeInclusive::new(...)`
@@ -432,7 +431,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
432
431
if let TyKind :: Path ( QPath :: Resolved ( None , ref path) ) = ty. node {
433
432
let call_to_new = segment. ident . as_str ( ) == "new" ;
434
433
435
- return is_range_path ( & path) && is_range_literal ( & expr. span ) && call_to_new;
434
+ return is_range_path ( & path) && span_is_range_literal ( & expr. span )
435
+ && call_to_new;
436
436
}
437
437
}
438
438
}
0 commit comments