@@ -19,6 +19,10 @@ pub(super) fn use_path(p: &mut Parser<'_>) {
19
19
path ( p, Mode :: Use ) ;
20
20
}
21
21
22
+ pub ( super ) fn attr_path ( p : & mut Parser < ' _ > ) {
23
+ path ( p, Mode :: Attr ) ;
24
+ }
25
+
22
26
pub ( crate ) fn type_path ( p : & mut Parser < ' _ > ) {
23
27
path ( p, Mode :: Type ) ;
24
28
}
@@ -37,6 +41,7 @@ pub(crate) fn type_path_for_qualifier(
37
41
#[ derive( Clone , Copy , Eq , PartialEq ) ]
38
42
enum Mode {
39
43
Use ,
44
+ Attr ,
40
45
Type ,
41
46
Expr ,
42
47
}
@@ -93,12 +98,7 @@ fn path_segment(p: &mut Parser<'_>, mode: Mode, first: bool) {
93
98
p. error ( "expected `::`" ) ;
94
99
}
95
100
} else {
96
- let empty = if first {
97
- p. eat ( T ! [ :: ] ) ;
98
- false
99
- } else {
100
- true
101
- } ;
101
+ let mut empty = if first { !p. eat ( T ! [ :: ] ) } else { true } ;
102
102
match p. current ( ) {
103
103
IDENT => {
104
104
name_ref ( p) ;
@@ -114,10 +114,13 @@ fn path_segment(p: &mut Parser<'_>, mode: Mode, first: bool) {
114
114
_ => {
115
115
let recover_set = match mode {
116
116
Mode :: Use => items:: ITEM_RECOVERY_SET ,
117
+ Mode :: Attr => {
118
+ items:: ITEM_RECOVERY_SET . union ( TokenSet :: new ( & [ T ! [ ']' ] , T ! [ =] , T ! [ #] ] ) )
119
+ }
117
120
Mode :: Type => TYPE_PATH_SEGMENT_RECOVERY_SET ,
118
121
Mode :: Expr => EXPR_PATH_SEGMENT_RECOVERY_SET ,
119
122
} ;
120
- p. err_recover ( "expected identifier" , recover_set) ;
123
+ empty &= p. err_recover ( "expected identifier" , recover_set) ;
121
124
if empty {
122
125
// test_err empty_segment
123
126
// use crate::;
@@ -132,7 +135,7 @@ fn path_segment(p: &mut Parser<'_>, mode: Mode, first: bool) {
132
135
133
136
fn opt_path_type_args ( p : & mut Parser < ' _ > , mode : Mode ) {
134
137
match mode {
135
- Mode :: Use => { }
138
+ Mode :: Use | Mode :: Attr => { }
136
139
Mode :: Type => {
137
140
// test typepathfn_with_coloncolon
138
141
// type F = Start::(Middle) -> (Middle)::End;
0 commit comments