@@ -24,9 +24,10 @@ use syntax::ast::{AttrVec, Attribute, Label, LitKind, StrStyle, FloatTy, IntTy,
2424pub use syntax:: ast:: { Mutability , Constness , Unsafety , Movability , CaptureBy } ;
2525pub use syntax:: ast:: { IsAuto , ImplPolarity , BorrowKind } ;
2626use syntax:: attr:: { InlineAttr , OptimizeAttr } ;
27- use syntax:: symbol:: { Symbol , kw} ;
2827use syntax:: tokenstream:: TokenStream ;
2928use syntax:: util:: parser:: ExprPrecedence ;
29+ use syntax_pos:: symbol:: { Symbol , kw, sym} ;
30+ use syntax_pos:: source_map:: SourceMap ;
3031use rustc_target:: spec:: abi:: Abi ;
3132use rustc_data_structures:: sync:: { par_for_each_in, Send , Sync } ;
3233use rustc_macros:: HashStable ;
@@ -1597,9 +1598,7 @@ impl fmt::Debug for Expr {
15971598
15981599/// Checks if the specified expression is a built-in range literal.
15991600/// (See: `LoweringContext::lower_expr()`).
1600- pub fn is_range_literal ( sess : & Session , expr : & hir:: Expr ) -> bool {
1601- use hir:: { Path , QPath , ExprKind , TyKind } ;
1602-
1601+ pub fn is_range_literal ( sm : & SourceMap , expr : & Expr ) -> bool {
16031602 // Returns whether the given path represents a (desugared) range,
16041603 // either in std or core, i.e. has either a `::std::ops::Range` or
16051604 // `::core::ops::Range` prefix.
@@ -1617,11 +1616,10 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
16171616
16181617 // Check whether a span corresponding to a range expression is a
16191618 // range literal, rather than an explicit struct or `new()` call.
1620- fn is_lit ( sess : & Session , span : & Span ) -> bool {
1621- let source_map = sess. source_map ( ) ;
1622- let end_point = source_map. end_point ( * span) ;
1619+ fn is_lit ( sm : & SourceMap , span : & Span ) -> bool {
1620+ let end_point = sm. end_point ( * span) ;
16231621
1624- if let Ok ( end_string) = source_map . span_to_snippet ( end_point) {
1622+ if let Ok ( end_string) = sm . span_to_snippet ( end_point) {
16251623 !( end_string. ends_with ( "}" ) || end_string. ends_with ( ")" ) )
16261624 } else {
16271625 false
@@ -1632,21 +1630,21 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
16321630 // All built-in range literals but `..=` and `..` desugar to `Struct`s.
16331631 ExprKind :: Struct ( ref qpath, _, _) => {
16341632 if let QPath :: Resolved ( None , ref path) = * * qpath {
1635- return is_range_path ( & path) && is_lit ( sess , & expr. span ) ;
1633+ return is_range_path ( & path) && is_lit ( sm , & expr. span ) ;
16361634 }
16371635 }
16381636
16391637 // `..` desugars to its struct path.
16401638 ExprKind :: Path ( QPath :: Resolved ( None , ref path) ) => {
1641- return is_range_path ( & path) && is_lit ( sess , & expr. span ) ;
1639+ return is_range_path ( & path) && is_lit ( sm , & expr. span ) ;
16421640 }
16431641
16441642 // `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
16451643 ExprKind :: Call ( ref func, _) => {
16461644 if let ExprKind :: Path ( QPath :: TypeRelative ( ref ty, ref segment) ) = func. kind {
16471645 if let TyKind :: Path ( QPath :: Resolved ( None , ref path) ) = ty. kind {
16481646 let new_call = segment. ident . name == sym:: new;
1649- return is_range_path ( & path) && is_lit ( sess , & expr. span ) && new_call;
1647+ return is_range_path ( & path) && is_lit ( sm , & expr. span ) && new_call;
16501648 }
16511649 }
16521650 }
0 commit comments