Skip to content

Commit 611e5c4

Browse files
committed
Address review comments
1 parent 87bf9e2 commit 611e5c4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/librustc_typeck/check/demand.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
384384
}
385385

386386
/// 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`).
388388
fn is_range_literal(&self, expr: &hir::Expr) -> bool {
389389
use hir::{Path, QPath, ExprKind, TyKind};
390390

@@ -404,10 +404,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
404404
}
405405
};
406406

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.
411410
let source_map = self.tcx.sess.source_map();
412411
let end_point = source_map.end_point(*span);
413412

@@ -423,7 +422,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
423422
ExprKind::Struct(QPath::Resolved(None, ref path), _, _) |
424423
// `..` desugars to its struct path
425424
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);
427426
}
428427

429428
// `..=` desugars into `::std::ops::RangeInclusive::new(...)`
@@ -432,7 +431,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
432431
if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node {
433432
let call_to_new = segment.ident.as_str() == "new";
434433

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;
436436
}
437437
}
438438
}

0 commit comments

Comments
 (0)