@@ -27,7 +27,7 @@ use ast::Local;
27
27
use ast:: MacStmtStyle ;
28
28
use ast:: Mac_ ;
29
29
use ast:: { MutTy , Mutability } ;
30
- use ast:: { Pat , PatKind } ;
30
+ use ast:: { Pat , PatKind , PathSegment } ;
31
31
use ast:: { PolyTraitRef , QSelf } ;
32
32
use ast:: { Stmt , StmtKind } ;
33
33
use ast:: { VariantData , StructField } ;
@@ -1811,7 +1811,7 @@ impl<'a> Parser<'a> {
1811
1811
} ;
1812
1812
1813
1813
if is_global {
1814
- segments. insert ( 0 , ast :: PathSegment :: crate_root ( ) ) ;
1814
+ segments. insert ( 0 , PathSegment :: crate_root ( ) ) ;
1815
1815
}
1816
1816
1817
1817
// Assemble the span.
@@ -1829,11 +1829,12 @@ impl<'a> Parser<'a> {
1829
1829
/// - `a::b<T,U>::c<V,W>`
1830
1830
/// - `a::b<T,U>::c(V) -> W`
1831
1831
/// - `a::b<T,U>::c(V)`
1832
- pub fn parse_path_segments_without_colons ( & mut self ) -> PResult < ' a , Vec < ast :: PathSegment > > {
1832
+ pub fn parse_path_segments_without_colons ( & mut self ) -> PResult < ' a , Vec < PathSegment > > {
1833
1833
let mut segments = Vec :: new ( ) ;
1834
1834
loop {
1835
1835
// First, parse an identifier.
1836
1836
let identifier = self . parse_path_segment_ident ( ) ?;
1837
+ let ident_span = self . prev_span ;
1837
1838
1838
1839
if self . check ( & token:: ModSep ) && self . look_ahead ( 1 , |t| * t == token:: Lt ) {
1839
1840
self . bump ( ) ;
@@ -1881,7 +1882,11 @@ impl<'a> Parser<'a> {
1881
1882
} ;
1882
1883
1883
1884
// Assemble and push the result.
1884
- segments. push ( ast:: PathSegment { identifier : identifier, parameters : parameters } ) ;
1885
+ segments. push ( PathSegment {
1886
+ identifier : identifier,
1887
+ span : ident_span,
1888
+ parameters : parameters
1889
+ } ) ;
1885
1890
1886
1891
// Continue only if we see a `::`
1887
1892
if !self . eat ( & token:: ModSep ) {
@@ -1892,15 +1897,16 @@ impl<'a> Parser<'a> {
1892
1897
1893
1898
/// Examples:
1894
1899
/// - `a::b::<T,U>::c`
1895
- pub fn parse_path_segments_with_colons ( & mut self ) -> PResult < ' a , Vec < ast :: PathSegment > > {
1900
+ pub fn parse_path_segments_with_colons ( & mut self ) -> PResult < ' a , Vec < PathSegment > > {
1896
1901
let mut segments = Vec :: new ( ) ;
1897
1902
loop {
1898
1903
// First, parse an identifier.
1899
1904
let identifier = self . parse_path_segment_ident ( ) ?;
1905
+ let ident_span = self . prev_span ;
1900
1906
1901
1907
// If we do not see a `::`, stop.
1902
1908
if !self . eat ( & token:: ModSep ) {
1903
- segments. push ( identifier . into ( ) ) ;
1909
+ segments. push ( PathSegment :: from_ident ( identifier , ident_span ) ) ;
1904
1910
return Ok ( segments) ;
1905
1911
}
1906
1912
@@ -1909,8 +1915,9 @@ impl<'a> Parser<'a> {
1909
1915
// Consumed `a::b::<`, go look for types
1910
1916
let ( lifetimes, types, bindings) = self . parse_generic_args ( ) ?;
1911
1917
self . expect_gt ( ) ?;
1912
- segments. push ( ast :: PathSegment {
1918
+ segments. push ( PathSegment {
1913
1919
identifier : identifier,
1920
+ span : ident_span,
1914
1921
parameters : ast:: AngleBracketedParameterData {
1915
1922
lifetimes : lifetimes,
1916
1923
types : types,
@@ -1924,22 +1931,22 @@ impl<'a> Parser<'a> {
1924
1931
}
1925
1932
} else {
1926
1933
// Consumed `a::`, go look for `b`
1927
- segments. push ( identifier . into ( ) ) ;
1934
+ segments. push ( PathSegment :: from_ident ( identifier , ident_span ) ) ;
1928
1935
}
1929
1936
}
1930
1937
}
1931
1938
1932
1939
/// Examples:
1933
1940
/// - `a::b::c`
1934
1941
pub fn parse_path_segments_without_types ( & mut self )
1935
- -> PResult < ' a , Vec < ast :: PathSegment > > {
1942
+ -> PResult < ' a , Vec < PathSegment > > {
1936
1943
let mut segments = Vec :: new ( ) ;
1937
1944
loop {
1938
1945
// First, parse an identifier.
1939
1946
let identifier = self . parse_path_segment_ident ( ) ?;
1940
1947
1941
1948
// Assemble and push the result.
1942
- segments. push ( identifier. into ( ) ) ;
1949
+ segments. push ( PathSegment :: from_ident ( identifier, self . prev_span ) ) ;
1943
1950
1944
1951
// If we do not see a `::` or see `::{`/`::*`, stop.
1945
1952
if !self . check ( & token:: ModSep ) || self . is_import_coupler ( ) {
@@ -5902,7 +5909,7 @@ impl<'a> Parser<'a> {
5902
5909
// `{foo, bar}`, `::{foo, bar}`, `*`, or `::*`.
5903
5910
self . eat ( & token:: ModSep ) ;
5904
5911
let prefix = ast:: Path {
5905
- segments : vec ! [ ast :: PathSegment :: crate_root( ) ] ,
5912
+ segments : vec ! [ PathSegment :: crate_root( ) ] ,
5906
5913
span : mk_sp ( lo, self . span . hi ) ,
5907
5914
} ;
5908
5915
let view_path_kind = if self . eat ( & token:: BinOp ( token:: Star ) ) {
0 commit comments