@@ -29,10 +29,10 @@ use syntax::ast::{AttrVec, Attribute, FloatTy, IntTy, Label, LitKind, StrStyle,
2929pub use syntax:: ast:: { BorrowKind , ImplPolarity , IsAuto } ;
3030pub use syntax:: ast:: { CaptureBy , Constness , Movability , Mutability , Unsafety } ;
3131use syntax:: attr:: { InlineAttr , OptimizeAttr } ;
32- use syntax:: source_map:: Spanned ;
33- use syntax:: symbol:: { kw, Symbol } ;
3432use syntax:: tokenstream:: TokenStream ;
3533use syntax:: util:: parser:: ExprPrecedence ;
34+ use syntax_pos:: source_map:: { SourceMap , Spanned } ;
35+ use syntax_pos:: symbol:: { kw, sym, Symbol } ;
3636use syntax_pos:: { MultiSpan , Span , DUMMY_SP } ;
3737
3838/// HIR doesn't commit to a concrete storage type and has its own alias for a vector.
@@ -1566,9 +1566,7 @@ impl fmt::Debug for Expr {
15661566
15671567/// Checks if the specified expression is a built-in range literal.
15681568/// (See: `LoweringContext::lower_expr()`).
1569- pub fn is_range_literal ( sess : & Session , expr : & hir:: Expr ) -> bool {
1570- use hir:: { Path , QPath , ExprKind , TyKind } ;
1571-
1569+ pub fn is_range_literal ( sm : & SourceMap , expr : & Expr ) -> bool {
15721570 // Returns whether the given path represents a (desugared) range,
15731571 // either in std or core, i.e. has either a `::std::ops::Range` or
15741572 // `::core::ops::Range` prefix.
@@ -1586,11 +1584,10 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
15861584
15871585 // Check whether a span corresponding to a range expression is a
15881586 // range literal, rather than an explicit struct or `new()` call.
1589- fn is_lit ( sess : & Session , span : & Span ) -> bool {
1590- let source_map = sess. source_map ( ) ;
1591- let end_point = source_map. end_point ( * span) ;
1587+ fn is_lit ( sm : & SourceMap , span : & Span ) -> bool {
1588+ let end_point = sm. end_point ( * span) ;
15921589
1593- if let Ok ( end_string) = source_map . span_to_snippet ( end_point) {
1590+ if let Ok ( end_string) = sm . span_to_snippet ( end_point) {
15941591 !( end_string. ends_with ( "}" ) || end_string. ends_with ( ")" ) )
15951592 } else {
15961593 false
@@ -1601,21 +1598,21 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
16011598 // All built-in range literals but `..=` and `..` desugar to `Struct`s.
16021599 ExprKind :: Struct ( ref qpath, _, _) => {
16031600 if let QPath :: Resolved ( None , ref path) = * * qpath {
1604- return is_range_path ( & path) && is_lit ( sess , & expr. span ) ;
1601+ return is_range_path ( & path) && is_lit ( sm , & expr. span ) ;
16051602 }
16061603 }
16071604
16081605 // `..` desugars to its struct path.
16091606 ExprKind :: Path ( QPath :: Resolved ( None , ref path) ) => {
1610- return is_range_path ( & path) && is_lit ( sess , & expr. span ) ;
1607+ return is_range_path ( & path) && is_lit ( sm , & expr. span ) ;
16111608 }
16121609
16131610 // `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
16141611 ExprKind :: Call ( ref func, _) => {
16151612 if let ExprKind :: Path ( QPath :: TypeRelative ( ref ty, ref segment) ) = func. kind {
16161613 if let TyKind :: Path ( QPath :: Resolved ( None , ref path) ) = ty. kind {
16171614 let new_call = segment. ident . name == sym:: new;
1618- return is_range_path ( & path) && is_lit ( sess , & expr. span ) && new_call;
1615+ return is_range_path ( & path) && is_lit ( sm , & expr. span ) && new_call;
16191616 }
16201617 }
16211618 }
0 commit comments