@@ -211,70 +211,54 @@ impl BlockLike {
211
211
const VISIBILITY_FIRST : TokenSet = TokenSet :: new ( & [ T ! [ pub ] , T ! [ crate ] ] ) ;
212
212
213
213
fn opt_visibility ( p : & mut Parser < ' _ > , in_tuple_field : bool ) -> bool {
214
- match p. current ( ) {
215
- T ! [ pub ] => {
216
- let m = p. start ( ) ;
217
- p. bump ( T ! [ pub ] ) ;
218
- if p. at ( T ! [ '(' ] ) {
219
- match p. nth ( 1 ) {
220
- // test crate_visibility
221
- // pub(crate) struct S;
222
- // pub(self) struct S;
223
- // pub(super) struct S;
224
-
225
- // test_err crate_visibility_empty_recover
226
- // pub() struct S;
227
-
228
- // test pub_parens_typepath
229
- // struct B(pub (super::A));
230
- // struct B(pub (crate::A,));
231
- T ! [ crate ] | T ! [ self ] | T ! [ super ] | T ! [ ident] | T ! [ ')' ] if p. nth ( 2 ) != T ! [ : ] => {
232
- // If we are in a tuple struct, then the parens following `pub`
233
- // might be an tuple field, not part of the visibility. So in that
234
- // case we don't want to consume an identifier.
235
-
236
- // test pub_tuple_field
237
- // struct MyStruct(pub (u32, u32));
238
- // struct MyStruct(pub (u32));
239
- // struct MyStruct(pub ());
240
- if !( in_tuple_field && matches ! ( p. nth( 1 ) , T ![ ident] | T ![ ')' ] ) ) {
241
- p. bump ( T ! [ '(' ] ) ;
242
- paths:: use_path ( p) ;
243
- p. expect ( T ! [ ')' ] ) ;
244
- }
245
- }
246
- // test crate_visibility_in
247
- // pub(in super::A) struct S;
248
- // pub(in crate) struct S;
249
- T ! [ in] => {
250
- p. bump ( T ! [ '(' ] ) ;
251
- p. bump ( T ! [ in] ) ;
252
- paths:: use_path ( p) ;
253
- p. expect ( T ! [ ')' ] ) ;
254
- }
255
- _ => { }
214
+ if !p. at ( T ! [ pub ] ) {
215
+ return false ;
216
+ }
217
+
218
+ let m = p. start ( ) ;
219
+ p. bump ( T ! [ pub ] ) ;
220
+ if p. at ( T ! [ '(' ] ) {
221
+ match p. nth ( 1 ) {
222
+ // test crate_visibility
223
+ // pub(crate) struct S;
224
+ // pub(self) struct S;
225
+ // pub(super) struct S;
226
+
227
+ // test_err crate_visibility_empty_recover
228
+ // pub() struct S;
229
+
230
+ // test pub_parens_typepath
231
+ // struct B(pub (super::A));
232
+ // struct B(pub (crate::A,));
233
+ T ! [ crate ] | T ! [ self ] | T ! [ super ] | T ! [ ident] | T ! [ ')' ] if p. nth ( 2 ) != T ! [ : ] => {
234
+ // If we are in a tuple struct, then the parens following `pub`
235
+ // might be an tuple field, not part of the visibility. So in that
236
+ // case we don't want to consume an identifier.
237
+
238
+ // test pub_tuple_field
239
+ // struct MyStruct(pub (u32, u32));
240
+ // struct MyStruct(pub (u32));
241
+ // struct MyStruct(pub ());
242
+ if !( in_tuple_field && matches ! ( p. nth( 1 ) , T ![ ident] | T ![ ')' ] ) ) {
243
+ p. bump ( T ! [ '(' ] ) ;
244
+ paths:: use_path ( p) ;
245
+ p. expect ( T ! [ ')' ] ) ;
256
246
}
257
247
}
258
- m. complete ( p, VISIBILITY ) ;
259
- true
260
- }
261
- // test crate_keyword_vis
262
- // crate fn main() { }
263
- // struct S { crate field: u32 }
264
- // struct T(crate u32);
265
- T ! [ crate ] => {
266
- if p. nth_at ( 1 , T ! [ :: ] ) {
267
- // test crate_keyword_path
268
- // fn foo() { crate::foo(); }
269
- return false ;
248
+ // test crate_visibility_in
249
+ // pub(in super::A) struct S;
250
+ // pub(in crate) struct S;
251
+ T ! [ in] => {
252
+ p. bump ( T ! [ '(' ] ) ;
253
+ p. bump ( T ! [ in] ) ;
254
+ paths:: use_path ( p) ;
255
+ p. expect ( T ! [ ')' ] ) ;
270
256
}
271
- let m = p. start ( ) ;
272
- p. bump ( T ! [ crate ] ) ;
273
- m. complete ( p, VISIBILITY ) ;
274
- true
257
+ _ => { }
275
258
}
276
- _ => false ,
277
259
}
260
+ m. complete ( p, VISIBILITY ) ;
261
+ true
278
262
}
279
263
280
264
fn opt_rename ( p : & mut Parser < ' _ > ) {
0 commit comments