@@ -62,17 +62,17 @@ pub struct PState {
62
62
tcx : ty:: ctxt
63
63
}
64
64
65
- fn peek ( st : @ mut PState ) -> char {
65
+ fn peek ( st : & PState ) -> char {
66
66
st. data [ st. pos ] as char
67
67
}
68
68
69
- fn next ( st : @ mut PState ) -> char {
69
+ fn next ( st : & mut PState ) -> char {
70
70
let ch = st. data [ st. pos ] as char ;
71
71
st. pos = st. pos + 1 u;
72
72
return ch;
73
73
}
74
74
75
- fn next_byte ( st : @ mut PState ) -> u8 {
75
+ fn next_byte ( st : & mut PState ) -> u8 {
76
76
let b = st. data [ st. pos ] ;
77
77
st. pos = st. pos + 1 u;
78
78
return b;
@@ -92,20 +92,20 @@ fn scan<R>(st: &mut PState, is_last: &fn(char) -> bool,
92
92
return op ( st. data . slice ( start_pos, end_pos) ) ;
93
93
}
94
94
95
- pub fn parse_ident ( st : @ mut PState , last : char ) -> ast:: ident {
95
+ pub fn parse_ident ( st : & mut PState , last : char ) -> ast:: ident {
96
96
fn is_last ( b : char , c : char ) -> bool { return c == b; }
97
97
return parse_ident_ ( st, |a| is_last ( last, a) ) ;
98
98
}
99
99
100
- fn parse_ident_ ( st : @ mut PState , is_last : @fn ( char ) -> bool ) ->
100
+ fn parse_ident_ ( st : & mut PState , is_last : @fn ( char ) -> bool ) ->
101
101
ast:: ident {
102
102
let rslt = scan ( st, is_last, str:: from_bytes) ;
103
103
return st. tcx . sess . ident_of ( rslt) ;
104
104
}
105
105
106
106
pub fn parse_state_from_data ( data : @~[ u8 ] , crate_num : int ,
107
- pos : uint , tcx : ty:: ctxt ) -> @ mut PState {
108
- @ mut PState {
107
+ pos : uint , tcx : ty:: ctxt ) -> PState {
108
+ PState {
109
109
data : data,
110
110
crate : crate_num,
111
111
pos : pos,
@@ -115,23 +115,23 @@ pub fn parse_state_from_data(data: @~[u8], crate_num: int,
115
115
116
116
pub fn parse_ty_data ( data : @~[ u8 ] , crate_num : int , pos : uint , tcx : ty:: ctxt ,
117
117
conv : conv_did ) -> ty:: t {
118
- let st = parse_state_from_data ( data, crate_num, pos, tcx) ;
119
- parse_ty ( st, conv)
118
+ let mut st = parse_state_from_data ( data, crate_num, pos, tcx) ;
119
+ parse_ty ( & mut st, conv)
120
120
}
121
121
122
122
pub fn parse_bare_fn_ty_data ( data : @~[ u8 ] , crate_num : int , pos : uint , tcx : ty:: ctxt ,
123
123
conv : conv_did ) -> ty:: BareFnTy {
124
- let st = parse_state_from_data ( data, crate_num, pos, tcx) ;
125
- parse_bare_fn_ty ( st, conv)
124
+ let mut st = parse_state_from_data ( data, crate_num, pos, tcx) ;
125
+ parse_bare_fn_ty ( & mut st, conv)
126
126
}
127
127
128
128
pub fn parse_trait_ref_data ( data : @~[ u8 ] , crate_num : int , pos : uint , tcx : ty:: ctxt ,
129
129
conv : conv_did ) -> ty:: TraitRef {
130
- let st = parse_state_from_data ( data, crate_num, pos, tcx) ;
131
- parse_trait_ref ( st, conv)
130
+ let mut st = parse_state_from_data ( data, crate_num, pos, tcx) ;
131
+ parse_trait_ref ( & mut st, conv)
132
132
}
133
133
134
- fn parse_path ( st : @ mut PState ) -> @ast:: Path {
134
+ fn parse_path ( st : & mut PState ) -> @ast:: Path {
135
135
let mut idents: ~[ ast:: ident ] = ~[ ] ;
136
136
fn is_last ( c : char ) -> bool { return c == '(' || c == ':' ; }
137
137
idents. push ( parse_ident_ ( st, is_last) ) ;
@@ -151,7 +151,7 @@ fn parse_path(st: @mut PState) -> @ast::Path {
151
151
} ;
152
152
}
153
153
154
- fn parse_sigil ( st : @ mut PState ) -> ast:: Sigil {
154
+ fn parse_sigil ( st : & mut PState ) -> ast:: Sigil {
155
155
match next ( st) {
156
156
'@' => ast:: ManagedSigil ,
157
157
'~' => ast:: OwnedSigil ,
@@ -160,7 +160,7 @@ fn parse_sigil(st: @mut PState) -> ast::Sigil {
160
160
}
161
161
}
162
162
163
- fn parse_vstore ( st : @ mut PState ) -> ty:: vstore {
163
+ fn parse_vstore ( st : & mut PState ) -> ty:: vstore {
164
164
assert_eq ! ( next( st) , '/' ) ;
165
165
166
166
let c = peek ( st) ;
@@ -178,7 +178,7 @@ fn parse_vstore(st: @mut PState) -> ty::vstore {
178
178
}
179
179
}
180
180
181
- fn parse_trait_store ( st : @ mut PState ) -> ty:: TraitStore {
181
+ fn parse_trait_store ( st : & mut PState ) -> ty:: TraitStore {
182
182
match next ( st) {
183
183
'~' => ty:: UniqTraitStore ,
184
184
'@' => ty:: BoxTraitStore ,
@@ -187,10 +187,10 @@ fn parse_trait_store(st: @mut PState) -> ty::TraitStore {
187
187
}
188
188
}
189
189
190
- fn parse_substs ( st : @ mut PState , conv : conv_did ) -> ty:: substs {
191
- let self_r = parse_opt ( st, || parse_region ( st) ) ;
190
+ fn parse_substs ( st : & mut PState , conv : conv_did ) -> ty:: substs {
191
+ let self_r = parse_opt ( st, |st | parse_region ( st) ) ;
192
192
193
- let self_ty = parse_opt ( st, || parse_ty ( st, conv) ) ;
193
+ let self_ty = parse_opt ( st, |st | parse_ty ( st, conv) ) ;
194
194
195
195
assert_eq ! ( next( st) , '[' ) ;
196
196
let mut params: ~[ ty:: t ] = ~[ ] ;
@@ -204,7 +204,7 @@ fn parse_substs(st: @mut PState, conv: conv_did) -> ty::substs {
204
204
} ;
205
205
}
206
206
207
- fn parse_bound_region ( st : @ mut PState ) -> ty:: bound_region {
207
+ fn parse_bound_region ( st : & mut PState ) -> ty:: bound_region {
208
208
match next ( st) {
209
209
's' => ty:: br_self,
210
210
'a' => {
@@ -222,7 +222,7 @@ fn parse_bound_region(st: @mut PState) -> ty::bound_region {
222
222
}
223
223
}
224
224
225
- fn parse_region ( st : @ mut PState ) -> ty:: Region {
225
+ fn parse_region ( st : & mut PState ) -> ty:: Region {
226
226
match next ( st) {
227
227
'b' => {
228
228
ty:: re_bound ( parse_bound_region ( st) )
@@ -251,15 +251,15 @@ fn parse_region(st: @mut PState) -> ty::Region {
251
251
}
252
252
}
253
253
254
- fn parse_opt < T > ( st : @ mut PState , f : & fn ( ) -> T ) -> Option < T > {
254
+ fn parse_opt < T > ( st : & mut PState , f : & fn ( & mut PState ) -> T ) -> Option < T > {
255
255
match next ( st) {
256
256
'n' => None ,
257
- 's' => Some ( f ( ) ) ,
257
+ 's' => Some ( f ( st ) ) ,
258
258
_ => fail ! ( "parse_opt: bad input" )
259
259
}
260
260
}
261
261
262
- fn parse_str ( st : @ mut PState , term : char ) -> ~str {
262
+ fn parse_str ( st : & mut PState , term : char ) -> ~str {
263
263
let mut result = ~"";
264
264
while peek ( st) != term {
265
265
result += str:: from_byte ( next_byte ( st) ) ;
@@ -268,13 +268,13 @@ fn parse_str(st: @mut PState, term: char) -> ~str {
268
268
return result;
269
269
}
270
270
271
- fn parse_trait_ref ( st : @ mut PState , conv : conv_did ) -> ty:: TraitRef {
271
+ fn parse_trait_ref ( st : & mut PState , conv : conv_did ) -> ty:: TraitRef {
272
272
let def = parse_def ( st, NominalType , conv) ;
273
273
let substs = parse_substs ( st, conv) ;
274
274
ty:: TraitRef { def_id : def, substs : substs}
275
275
}
276
276
277
- fn parse_ty ( st : @ mut PState , conv : conv_did ) -> ty:: t {
277
+ fn parse_ty ( st : & mut PState , conv : conv_did ) -> ty:: t {
278
278
match next ( st) {
279
279
'n' => return ty:: mk_nil ( ) ,
280
280
'z' => return ty:: mk_bot ( ) ,
@@ -370,8 +370,8 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t {
370
370
match st. tcx . rcache . find ( & key) {
371
371
Some ( & tt) => return tt,
372
372
None => {
373
- let ps = @ mut PState { pos : pos , .. copy * st} ;
374
- let tt = parse_ty ( ps, conv) ;
373
+ let mut ps = PState { pos : pos , .. copy * st} ;
374
+ let tt = parse_ty ( & mut ps, conv) ;
375
375
st. tcx . rcache . insert ( key, tt) ;
376
376
return tt;
377
377
}
@@ -394,28 +394,25 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t {
394
394
}
395
395
}
396
396
397
- fn parse_mutability ( st : @ mut PState ) -> ast:: mutability {
397
+ fn parse_mutability ( st : & mut PState ) -> ast:: mutability {
398
398
match peek ( st) {
399
399
'm' => { next ( st) ; ast:: m_mutbl }
400
400
'?' => { next ( st) ; ast:: m_const }
401
401
_ => { ast:: m_imm }
402
402
}
403
403
}
404
404
405
- fn parse_mt ( st : @ mut PState , conv : conv_did ) -> ty:: mt {
405
+ fn parse_mt ( st : & mut PState , conv : conv_did ) -> ty:: mt {
406
406
let m = parse_mutability ( st) ;
407
407
ty:: mt { ty : parse_ty ( st, conv) , mutbl : m }
408
408
}
409
409
410
- fn parse_def ( st : @ mut PState , source : DefIdSource ,
410
+ fn parse_def ( st : & mut PState , source : DefIdSource ,
411
411
conv : conv_did ) -> ast:: def_id {
412
- let mut def = ~[ ] ;
413
- while peek ( st) != '|' { def. push ( next_byte ( st) ) ; }
414
- st. pos = st. pos + 1 u;
415
- return conv ( source, parse_def_id ( def) ) ;
412
+ return conv ( source, scan ( st, |c| { c == '|' } , parse_def_id) ) ;
416
413
}
417
414
418
- fn parse_uint ( st : @ mut PState ) -> uint {
415
+ fn parse_uint ( st : & mut PState ) -> uint {
419
416
let mut n = 0 ;
420
417
loop {
421
418
let cur = peek ( st) ;
@@ -426,7 +423,7 @@ fn parse_uint(st: @mut PState) -> uint {
426
423
} ;
427
424
}
428
425
429
- fn parse_hex ( st : @ mut PState ) -> uint {
426
+ fn parse_hex ( st : & mut PState ) -> uint {
430
427
let mut n = 0 u;
431
428
loop {
432
429
let cur = peek ( st) ;
@@ -449,7 +446,7 @@ fn parse_purity(c: char) -> purity {
449
446
}
450
447
}
451
448
452
- fn parse_abi_set ( st : @ mut PState ) -> AbiSet {
449
+ fn parse_abi_set ( st : & mut PState ) -> AbiSet {
453
450
assert_eq ! ( next( st) , '[' ) ;
454
451
let mut abis = AbiSet :: empty ( ) ;
455
452
while peek ( st) != ']' {
@@ -470,7 +467,7 @@ fn parse_onceness(c: char) -> ast::Onceness {
470
467
}
471
468
}
472
469
473
- fn parse_closure_ty ( st : @ mut PState , conv : conv_did ) -> ty:: ClosureTy {
470
+ fn parse_closure_ty ( st : & mut PState , conv : conv_did ) -> ty:: ClosureTy {
474
471
let sigil = parse_sigil ( st) ;
475
472
let purity = parse_purity ( next ( st) ) ;
476
473
let onceness = parse_onceness ( next ( st) ) ;
@@ -487,7 +484,7 @@ fn parse_closure_ty(st: @mut PState, conv: conv_did) -> ty::ClosureTy {
487
484
}
488
485
}
489
486
490
- fn parse_bare_fn_ty ( st : @ mut PState , conv : conv_did ) -> ty:: BareFnTy {
487
+ fn parse_bare_fn_ty ( st : & mut PState , conv : conv_did ) -> ty:: BareFnTy {
491
488
let purity = parse_purity ( next ( st) ) ;
492
489
let abi = parse_abi_set ( st) ;
493
490
let sig = parse_sig ( st, conv) ;
@@ -498,7 +495,7 @@ fn parse_bare_fn_ty(st: @mut PState, conv: conv_did) -> ty::BareFnTy {
498
495
}
499
496
}
500
497
501
- fn parse_sig ( st : @ mut PState , conv : conv_did ) -> ty:: FnSig {
498
+ fn parse_sig ( st : & mut PState , conv : conv_did ) -> ty:: FnSig {
502
499
assert_eq ! ( next( st) , '[' ) ;
503
500
let mut inputs = ~[ ] ;
504
501
while peek ( st) != ']' {
@@ -541,16 +538,16 @@ pub fn parse_type_param_def_data(data: @~[u8], start: uint,
541
538
crate_num : int , tcx : ty:: ctxt ,
542
539
conv : conv_did ) -> ty:: TypeParameterDef
543
540
{
544
- let st = parse_state_from_data ( data, crate_num, start, tcx) ;
545
- parse_type_param_def ( st, conv)
541
+ let mut st = parse_state_from_data ( data, crate_num, start, tcx) ;
542
+ parse_type_param_def ( & mut st, conv)
546
543
}
547
544
548
- fn parse_type_param_def ( st : @ mut PState , conv : conv_did ) -> ty:: TypeParameterDef {
545
+ fn parse_type_param_def ( st : & mut PState , conv : conv_did ) -> ty:: TypeParameterDef {
549
546
ty:: TypeParameterDef { def_id : parse_def ( st, NominalType , conv) ,
550
547
bounds : @parse_bounds ( st, conv) }
551
548
}
552
549
553
- fn parse_bounds ( st : @ mut PState , conv : conv_did ) -> ty:: ParamBounds {
550
+ fn parse_bounds ( st : & mut PState , conv : conv_did ) -> ty:: ParamBounds {
554
551
let mut param_bounds = ty:: ParamBounds {
555
552
builtin_bounds : ty:: EmptyBuiltinBounds ( ) ,
556
553
trait_bounds : ~[ ]
0 commit comments