@@ -102,11 +102,6 @@ enum restriction {
102
102
RESTRICT_NO_BAR_OR_DOUBLEBAR_OP ,
103
103
}
104
104
105
- // So that we can distinguish a class dtor from other class members
106
-
107
- enum class_contents { dtor_decl( blk , ~[ attribute ] , codemap:: span ) ,
108
- members( ~[ @struct_field ] ) }
109
-
110
105
type arg_or_capture_item = Either < arg , ( ) > ;
111
106
type item_info = ( ident , item_ , Option < ~[ attribute ] > ) ;
112
107
@@ -3299,34 +3294,15 @@ pub impl Parser {
3299
3294
}
3300
3295
3301
3296
let mut fields: ~[ @struct_field ] ;
3302
- let mut the_dtor: Option < ( blk , ~[ attribute ] , codemap:: span ) > = None ;
3303
3297
let is_tuple_like;
3304
3298
3305
3299
if self . eat ( & token:: LBRACE ) {
3306
3300
// It's a record-like struct.
3307
3301
is_tuple_like = false ;
3308
3302
fields = ~[ ] ;
3309
3303
while * self . token != token:: RBRACE {
3310
- match self . parse_struct_decl_field ( ) {
3311
- dtor_decl( ref blk, ref attrs, s) => {
3312
- match the_dtor {
3313
- Some ( ( _, _, s_first) ) => {
3314
- self . span_note ( s, fmt ! ( "Duplicate destructor \
3315
- declaration for class %s",
3316
- * self . interner. get( class_name) ) ) ;
3317
- self . span_fatal ( copy s_first, ~"First destructor \
3318
- declared here") ;
3319
- }
3320
- None => {
3321
- the_dtor = Some ( ( copy * blk, copy * attrs, s) ) ;
3322
- }
3323
- }
3324
- }
3325
- members( mms) => {
3326
- for mms. each |struct_field| {
3327
- fields. push ( * struct_field)
3328
- }
3329
- }
3304
+ for self . parse_struct_decl_field( ) . each |struct_field| {
3305
+ fields. push( * struct_field)
3330
3306
}
3331
3307
}
3332
3308
if fields. len( ) == 0 {
@@ -3365,19 +3341,12 @@ pub impl Parser {
3365
3341
) ;
3366
3342
}
3367
3343
3368
- let actual_dtor = do the_dtor. map |dtor| {
3369
- let ( d_body, d_attrs, d_s) = copy * dtor;
3370
- codemap:: spanned { node : ast:: struct_dtor_ { id : self . get_id ( ) ,
3371
- attrs : d_attrs,
3372
- self_id : self . get_id ( ) ,
3373
- body : d_body} ,
3374
- span : d_s} } ;
3375
3344
let _ = self . get_id( ) ; // XXX: Workaround for crazy bug.
3376
3345
let new_id = self . get_id( ) ;
3377
3346
( class_name,
3378
3347
item_struct( @ast:: struct_def {
3379
3348
fields : fields,
3380
- dtor : actual_dtor ,
3349
+ dtor : None ,
3381
3350
ctor_id : if is_tuple_like { Some ( new_id) } else { None }
3382
3351
} , generics) ,
3383
3352
None )
@@ -3420,34 +3389,28 @@ pub impl Parser {
3420
3389
}
3421
3390
3422
3391
// parse an element of a struct definition
3423
- fn parse_struct_decl_field ( & self ) -> class_contents {
3392
+ fn parse_struct_decl_field ( & self ) -> ~ [ @ struct_field ] {
3424
3393
3425
3394
if self . try_parse_obsolete_priv_section ( ) {
3426
- return members ( ~[ ] ) ;
3395
+ return ~[ ] ;
3427
3396
}
3428
3397
3429
- let attrs = self . parse_outer_attributes ( ) ;
3398
+ // Need this to parse comments on fields.
3399
+ let _attrs = self . parse_outer_attributes ( ) ;
3430
3400
3431
3401
if self . eat_keyword ( & ~"priv") {
3432
- return members ( ~[ self . parse_single_struct_field ( private) ] )
3402
+ return ~[ self . parse_single_struct_field ( private) ]
3433
3403
}
3434
3404
3435
3405
if self . eat_keyword ( & ~"pub ") {
3436
- return members ( ~[ self . parse_single_struct_field ( public) ] ) ;
3406
+ return ~[ self . parse_single_struct_field ( public) ] ;
3437
3407
}
3438
3408
3439
3409
if self . try_parse_obsolete_struct_ctor ( ) {
3440
- return members ( ~[ ] ) ;
3410
+ return ~[ ] ;
3441
3411
}
3442
3412
3443
- if self . eat_keyword ( & ~"drop") {
3444
- let lo = self . last_span . lo ;
3445
- let body = self . parse_block ( ) ;
3446
- return dtor_decl ( body, attrs, mk_sp ( lo, self . last_span . hi ) )
3447
- }
3448
- else {
3449
- return members ( ~[ self . parse_single_struct_field ( inherited) ] ) ;
3450
- }
3413
+ return ~[ self . parse_single_struct_field ( inherited) ] ;
3451
3414
}
3452
3415
3453
3416
// parse visiility: PUB, PRIV, or nothing
@@ -3830,44 +3793,17 @@ pub impl Parser {
3830
3793
// parse a structure-like enum variant definition
3831
3794
// this should probably be renamed or refactored...
3832
3795
fn parse_struct_def ( & self ) -> @struct_def {
3833
- let mut the_dtor: Option < ( blk , ~[ attribute ] , codemap:: span ) > = None ;
3834
3796
let mut fields: ~[ @struct_field ] = ~[ ] ;
3835
3797
while * self . token != token:: RBRACE {
3836
- match self . parse_struct_decl_field ( ) {
3837
- dtor_decl( ref blk, ref attrs, s) => {
3838
- match the_dtor {
3839
- Some ( ( _, _, s_first) ) => {
3840
- self . span_note ( s, ~"duplicate destructor \
3841
- declaration") ;
3842
- self . span_fatal ( copy s_first,
3843
- ~"first destructor \
3844
- declared here") ;
3845
- }
3846
- None => {
3847
- the_dtor = Some ( ( copy * blk, copy * attrs, s) ) ;
3848
- }
3849
- }
3850
- }
3851
- members( mms) => {
3852
- for mms. each |struct_field| {
3853
- fields. push ( * struct_field) ;
3854
- }
3855
- }
3798
+ for self . parse_struct_decl_field( ) . each |struct_field| {
3799
+ fields. push( * struct_field) ;
3856
3800
}
3857
3801
}
3858
3802
self . bump( ) ;
3859
- let actual_dtor = do the_dtor. map |dtor| {
3860
- let ( d_body, d_attrs, d_s) = copy * dtor;
3861
- codemap:: spanned { node : ast:: struct_dtor_ { id : self . get_id ( ) ,
3862
- attrs : d_attrs,
3863
- self_id : self . get_id ( ) ,
3864
- body : d_body } ,
3865
- span : d_s }
3866
- } ;
3867
3803
3868
3804
return @ast:: struct_def {
3869
3805
fields : fields,
3870
- dtor : actual_dtor ,
3806
+ dtor : None ,
3871
3807
ctor_id : None
3872
3808
} ;
3873
3809
}
0 commit comments