@@ -285,10 +285,10 @@ struct parser {
285
285
proto = self . parse_fn_ty_proto ( ) ;
286
286
bounds = self . parse_optional_ty_param_bounds ( ) ;
287
287
} ;
288
- ty_fn ( proto, bounds, self . parse_ty_fn_decl ( purity ) )
288
+ ty_fn ( proto, purity , bounds, self . parse_ty_fn_decl ( ) )
289
289
}
290
290
291
- fn parse_ty_fn_decl ( purity : ast :: purity ) -> fn_decl {
291
+ fn parse_ty_fn_decl ( ) -> fn_decl {
292
292
let inputs = do self . parse_unspanned_seq (
293
293
token:: LPAREN , token:: RPAREN ,
294
294
seq_sep_trailing_disallowed ( token:: COMMA ) ) |p| {
@@ -297,7 +297,7 @@ struct parser {
297
297
} ;
298
298
let ( ret_style, ret_ty) = self . parse_ret_ty ( ) ;
299
299
return { inputs: inputs, output: ret_ty,
300
- purity : purity , cf: ret_style} ;
300
+ cf: ret_style} ;
301
301
}
302
302
303
303
fn parse_trait_methods ( ) -> ~[ trait_method ] {
@@ -316,7 +316,7 @@ struct parser {
316
316
317
317
let tps = p. parse_ty_params ( ) ;
318
318
319
- let ( self_ty, d, _) = do self . parse_fn_decl_with_self ( pur ) |p| {
319
+ let ( self_ty, d, _) = do self . parse_fn_decl_with_self ( ) |p| {
320
320
// This is somewhat dubious; We don't want to allow argument
321
321
// names to be left off if there is a definition...
322
322
either:: Left ( p. parse_arg_general ( false ) )
@@ -335,7 +335,7 @@ struct parser {
335
335
// NB: at the moment, visibility annotations on required
336
336
// methods are ignored; this could change.
337
337
required ( { ident: ident, attrs: attrs,
338
- decl : { purity : pur with d } , tps: tps,
338
+ purity: pur, decl : d , tps: tps,
339
339
self_ty: self_ty,
340
340
id: p. get_id ( ) , span: mk_sp ( lo, hi) } )
341
341
}
@@ -348,6 +348,7 @@ struct parser {
348
348
attrs: attrs,
349
349
tps: tps,
350
350
self_ty: self_ty,
351
+ purity: pur,
351
352
decl: d,
352
353
body: body,
353
354
id: p. get_id ( ) ,
@@ -518,7 +519,7 @@ struct parser {
518
519
self . parse_ty_fn ( ast:: impure_fn)
519
520
} else if self . eat_keyword ( ~"extern ") {
520
521
self . expect_keyword ( ~"fn ") ;
521
- ty_fn ( proto_bare, @~[ ] , self . parse_ty_fn_decl ( ast :: impure_fn ) )
522
+ ty_fn ( proto_bare, ast :: impure_fn , @~[ ] , self . parse_ty_fn_decl ( ) )
522
523
} else if self . token == token:: MOD_SEP || is_ident ( self . token ) {
523
524
let path = self . parse_path_with_tps ( colons_before_params) ;
524
525
ty_path ( path, self . get_id ( ) )
@@ -1492,8 +1493,7 @@ struct parser {
1492
1493
// if we want to allow fn expression argument types to be inferred in
1493
1494
// the future, just have to change parse_arg to parse_fn_block_arg.
1494
1495
let ( decl, capture_clause) =
1495
- self . parse_fn_decl ( impure_fn,
1496
- |p| p. parse_arg_or_capture_item ( ) ) ;
1496
+ self . parse_fn_decl ( |p| p. parse_arg_or_capture_item ( ) ) ;
1497
1497
1498
1498
let body = self . parse_block ( ) ;
1499
1499
return self . mk_expr ( lo, body. span . hi ,
@@ -1518,7 +1518,6 @@ struct parser {
1518
1518
node : ty_infer,
1519
1519
span : self . span
1520
1520
} ,
1521
- purity: impure_fn,
1522
1521
cf: return_val
1523
1522
}
1524
1523
} ,
@@ -2281,8 +2280,7 @@ struct parser {
2281
2280
} else { ~[ ] }
2282
2281
}
2283
2282
2284
- fn parse_fn_decl ( purity : purity ,
2285
- parse_arg_fn : fn ( parser ) -> arg_or_capture_item )
2283
+ fn parse_fn_decl ( parse_arg_fn : fn ( parser ) -> arg_or_capture_item )
2286
2284
-> ( fn_decl , capture_clause ) {
2287
2285
2288
2286
let args_or_capture_items: ~[ arg_or_capture_item ] =
@@ -2295,9 +2293,8 @@ struct parser {
2295
2293
2296
2294
let ( ret_style, ret_ty) = self . parse_ret_ty ( ) ;
2297
2295
return ( { inputs: inputs,
2298
- output: ret_ty,
2299
- purity: purity,
2300
- cf: ret_style} , capture_clause) ;
2296
+ output: ret_ty,
2297
+ cf: ret_style} , capture_clause) ;
2301
2298
}
2302
2299
2303
2300
fn is_self_ident ( ) -> bool {
@@ -2316,8 +2313,7 @@ struct parser {
2316
2313
self . bump ( ) ;
2317
2314
}
2318
2315
2319
- fn parse_fn_decl_with_self ( purity : purity ,
2320
- parse_arg_fn :
2316
+ fn parse_fn_decl_with_self ( parse_arg_fn :
2321
2317
fn ( parser ) -> arg_or_capture_item )
2322
2318
-> ( self_ty , fn_decl , capture_clause ) {
2323
2319
@@ -2401,7 +2397,6 @@ struct parser {
2401
2397
let fn_decl = {
2402
2398
inputs: inputs,
2403
2399
output: ret_ty,
2404
- purity: purity,
2405
2400
cf: ret_style
2406
2401
} ;
2407
2402
@@ -2425,10 +2420,9 @@ struct parser {
2425
2420
@{ id: self . get_id ( ) , node: ty_infer, span: self . span }
2426
2421
} ;
2427
2422
return ( { inputs: either:: lefts ( inputs_captures) ,
2428
- output: output,
2429
- purity: impure_fn,
2430
- cf: return_val} ,
2431
- @either:: rights ( inputs_captures) ) ;
2423
+ output: output,
2424
+ cf: return_val} ,
2425
+ @either:: rights ( inputs_captures) ) ;
2432
2426
}
2433
2427
2434
2428
fn parse_fn_header ( ) -> { ident: ident, tps: ~[ ty_param] } {
@@ -2450,9 +2444,9 @@ struct parser {
2450
2444
2451
2445
fn parse_item_fn ( purity : purity ) -> item_info {
2452
2446
let t = self . parse_fn_header ( ) ;
2453
- let ( decl, _) = self . parse_fn_decl ( purity , |p| p. parse_arg ( ) ) ;
2447
+ let ( decl, _) = self . parse_fn_decl ( |p| p. parse_arg ( ) ) ;
2454
2448
let ( inner_attrs, body) = self . parse_inner_attrs_and_block ( true ) ;
2455
- ( t. ident , item_fn ( decl, t. tps , body) , some ( inner_attrs) )
2449
+ ( t. ident , item_fn ( decl, purity , t. tps , body) , some ( inner_attrs) )
2456
2450
}
2457
2451
2458
2452
fn parse_method_name ( ) -> ident {
@@ -2469,7 +2463,7 @@ struct parser {
2469
2463
let pur = self . parse_fn_purity ( ) ;
2470
2464
let ident = self . parse_method_name ( ) ;
2471
2465
let tps = self . parse_ty_params ( ) ;
2472
- let ( self_ty, decl, _) = do self . parse_fn_decl_with_self ( pur ) |p| {
2466
+ let ( self_ty, decl, _) = do self . parse_fn_decl_with_self ( ) |p| {
2473
2467
p. parse_arg ( )
2474
2468
} ;
2475
2469
// XXX: interaction between staticness, self_ty is broken now
@@ -2478,7 +2472,7 @@ struct parser {
2478
2472
let ( inner_attrs, body) = self . parse_inner_attrs_and_block ( true ) ;
2479
2473
let attrs = vec:: append ( attrs, inner_attrs) ;
2480
2474
@{ ident: ident, attrs: attrs,
2481
- tps: tps, self_ty: self_ty, decl: decl,
2475
+ tps: tps, self_ty: self_ty, purity : pur , decl: decl,
2482
2476
body: body, id: self . get_id ( ) , span: mk_sp ( lo, body. span . hi ) ,
2483
2477
self_id: self . get_id ( ) , vis: pr}
2484
2478
}
@@ -2717,7 +2711,7 @@ struct parser {
2717
2711
fn parse_ctor(attrs: ~[attribute],
2718
2712
result_ty: ast::ty_) -> class_contents {
2719
2713
let lo = self.last_span.lo;
2720
- let (decl_, _) = self.parse_fn_decl(impure_fn, |p| p.parse_arg());
2714
+ let (decl_, _) = self.parse_fn_decl(|p| p.parse_arg());
2721
2715
let decl = {output: @{id: self.get_id(),
2722
2716
node: result_ty, span: decl_.output.span}
2723
2717
with decl_};
@@ -2837,18 +2831,18 @@ struct parser {
2837
2831
( id, item_mod ( m) , some ( inner_attrs. inner ) )
2838
2832
}
2839
2833
2840
- fn parse_item_foreign_fn ( +attrs : ~[ attribute ] ,
2841
- purity : purity ) -> @ foreign_item {
2842
- let lo = self . last_span . lo ;
2834
+ fn parse_item_foreign_fn ( +attrs : ~[ attribute ] ) -> @ foreign_item {
2835
+ let lo = self . span . lo ;
2836
+ let purity = self . parse_fn_purity ( ) ;
2843
2837
let t = self . parse_fn_header ( ) ;
2844
- let ( decl, _) = self . parse_fn_decl ( purity , |p| p. parse_arg ( ) ) ;
2838
+ let ( decl, _) = self . parse_fn_decl ( |p| p. parse_arg ( ) ) ;
2845
2839
let mut hi = self . span . hi ;
2846
2840
self . expect ( token:: SEMI ) ;
2847
2841
return @{ ident: t. ident ,
2848
- attrs: attrs,
2849
- node: foreign_item_fn ( decl, t. tps ) ,
2850
- id: self . get_id ( ) ,
2851
- span: mk_sp ( lo, hi) } ;
2842
+ attrs: attrs,
2843
+ node: foreign_item_fn ( decl, purity , t. tps ) ,
2844
+ id: self . get_id ( ) ,
2845
+ span: mk_sp ( lo, hi) } ;
2852
2846
}
2853
2847
2854
2848
fn parse_fn_purity ( ) -> purity {
@@ -2865,7 +2859,7 @@ struct parser {
2865
2859
2866
2860
fn parse_foreign_item ( +attrs : ~[ attribute ] ) ->
2867
2861
@foreign_item {
2868
- self . parse_item_foreign_fn ( attrs, self . parse_fn_purity ( ) )
2862
+ self . parse_item_foreign_fn ( attrs)
2869
2863
}
2870
2864
2871
2865
fn parse_foreign_mod_items ( +first_item_attrs : ~[ attribute ] ) ->
0 commit comments