@@ -262,8 +262,8 @@ fn parse_substs<'a, 'tcx>(st: &mut PState<'a, 'tcx>,
262
262
let types =
263
263
parse_vec_per_param_space ( st, |st| parse_ty ( st, |x, y| conv ( x, y) ) ) ;
264
264
265
- return subst:: Substs { types : types,
266
- regions : regions } ;
265
+ subst:: Substs { types : types,
266
+ regions : regions }
267
267
}
268
268
269
269
fn parse_region_substs ( st : & mut PState , conv : conv_did ) -> subst:: RegionSubsts {
@@ -281,7 +281,7 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> subst::RegionSubsts {
281
281
fn parse_bound_region ( st : & mut PState , conv : conv_did ) -> ty:: BoundRegion {
282
282
match next ( st) {
283
283
'a' => {
284
- let id = parse_uint ( st) ;
284
+ let id = parse_u32 ( st) ;
285
285
assert_eq ! ( next( st) , '|' ) ;
286
286
ty:: BrAnon ( id)
287
287
}
@@ -291,7 +291,7 @@ fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion {
291
291
ty:: BrNamed ( def, ident. name )
292
292
}
293
293
'f' => {
294
- let id = parse_uint ( st) ;
294
+ let id = parse_u32 ( st) ;
295
295
assert_eq ! ( next( st) , '|' ) ;
296
296
ty:: BrFresh ( id)
297
297
}
@@ -304,7 +304,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
304
304
match next ( st) {
305
305
'b' => {
306
306
assert_eq ! ( next( st) , '[' ) ;
307
- let id = ty:: DebruijnIndex :: new ( parse_uint ( st) ) ;
307
+ let id = ty:: DebruijnIndex :: new ( parse_u32 ( st) ) ;
308
308
assert_eq ! ( next( st) , '|' ) ;
309
309
let br = parse_bound_region ( st, |x, y| conv ( x, y) ) ;
310
310
assert_eq ! ( next( st) , ']' ) ;
@@ -316,7 +316,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
316
316
assert_eq ! ( next( st) , '|' ) ;
317
317
let space = parse_param_space ( st) ;
318
318
assert_eq ! ( next( st) , '|' ) ;
319
- let index = parse_uint ( st) ;
319
+ let index = parse_u32 ( st) ;
320
320
assert_eq ! ( next( st) , '|' ) ;
321
321
let nm = token:: str_to_ident ( parse_str ( st, ']' ) [ ] ) ;
322
322
ty:: ReEarlyBound ( node_id, space, index, nm. name )
@@ -380,7 +380,7 @@ fn parse_trait_ref<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
380
380
-> ty:: TraitRef < ' tcx > {
381
381
let def = parse_def ( st, NominalType , |x, y| conv ( x, y) ) ;
382
382
let substs = parse_substs ( st, |x, y| conv ( x, y) ) ;
383
- ty:: TraitRef { def_id : def, substs : substs}
383
+ ty:: TraitRef { def_id : def, substs : st . tcx . mk_substs ( substs) }
384
384
}
385
385
386
386
fn parse_ty < ' a , ' tcx > ( st : & mut PState < ' a , ' tcx > , conv : conv_did ) -> Ty < ' tcx > {
@@ -409,7 +409,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
409
409
let def = parse_def ( st, NominalType , |x, y| conv ( x, y) ) ;
410
410
let substs = parse_substs ( st, |x, y| conv ( x, y) ) ;
411
411
assert_eq ! ( next( st) , ']' ) ;
412
- return ty:: mk_enum ( st. tcx , def, substs) ;
412
+ return ty:: mk_enum ( st. tcx , def, st . tcx . mk_substs ( substs) ) ;
413
413
}
414
414
'x' => {
415
415
assert_eq ! ( next( st) , '[' ) ;
@@ -421,7 +421,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
421
421
'p' => {
422
422
let did = parse_def ( st, TypeParameter , |x, y| conv ( x, y) ) ;
423
423
debug ! ( "parsed ty_param: did={}" , did) ;
424
- let index = parse_uint ( st) ;
424
+ let index = parse_u32 ( st) ;
425
425
assert_eq ! ( next( st) , '|' ) ;
426
426
let space = parse_param_space ( st) ;
427
427
assert_eq ! ( next( st) , '|' ) ;
@@ -432,7 +432,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
432
432
'&' => {
433
433
let r = parse_region ( st, |x, y| conv ( x, y) ) ;
434
434
let mt = parse_mt ( st, |x, y| conv ( x, y) ) ;
435
- return ty:: mk_rptr ( st. tcx , r , mt) ;
435
+ return ty:: mk_rptr ( st. tcx , st . tcx . mk_region ( r ) , mt) ;
436
436
}
437
437
'V' => {
438
438
let t = parse_ty ( st, |x, y| conv ( x, y) ) ;
@@ -454,10 +454,12 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
454
454
}
455
455
'F' => {
456
456
let def_id = parse_def ( st, NominalType , |x, y| conv ( x, y) ) ;
457
- return ty:: mk_bare_fn ( st. tcx , Some ( def_id) , parse_bare_fn_ty ( st, |x, y| conv ( x, y) ) ) ;
457
+ return ty:: mk_bare_fn ( st. tcx , Some ( def_id) ,
458
+ st. tcx . mk_bare_fn ( parse_bare_fn_ty ( st, |x, y| conv ( x, y) ) ) ) ;
458
459
}
459
460
'G' => {
460
- return ty:: mk_bare_fn ( st. tcx , None , parse_bare_fn_ty ( st, |x, y| conv ( x, y) ) ) ;
461
+ return ty:: mk_bare_fn ( st. tcx , None ,
462
+ st. tcx . mk_bare_fn ( parse_bare_fn_ty ( st, |x, y| conv ( x, y) ) ) ) ;
461
463
}
462
464
'#' => {
463
465
let pos = parse_hex ( st) ;
@@ -490,15 +492,16 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
490
492
let did = parse_def ( st, NominalType , |x, y| conv ( x, y) ) ;
491
493
let substs = parse_substs ( st, |x, y| conv ( x, y) ) ;
492
494
assert_eq ! ( next( st) , ']' ) ;
493
- return ty:: mk_struct ( st. tcx , did, substs) ;
495
+ return ty:: mk_struct ( st. tcx , did, st . tcx . mk_substs ( substs) ) ;
494
496
}
495
497
'k' => {
496
498
assert_eq ! ( next( st) , '[' ) ;
497
499
let did = parse_def ( st, UnboxedClosureSource , |x, y| conv ( x, y) ) ;
498
500
let region = parse_region ( st, |x, y| conv ( x, y) ) ;
499
501
let substs = parse_substs ( st, |x, y| conv ( x, y) ) ;
500
502
assert_eq ! ( next( st) , ']' ) ;
501
- return ty:: mk_unboxed_closure ( st. tcx , did, region, substs) ;
503
+ return ty:: mk_unboxed_closure ( st. tcx , did,
504
+ st. tcx . mk_region ( region) , st. tcx . mk_substs ( substs) ) ;
502
505
}
503
506
'e' => {
504
507
return ty:: mk_err ( ) ;
@@ -535,6 +538,13 @@ fn parse_uint(st: &mut PState) -> uint {
535
538
} ;
536
539
}
537
540
541
+ fn parse_u32 ( st : & mut PState ) -> u32 {
542
+ let n = parse_uint ( st) ;
543
+ let m = n as u32 ;
544
+ assert_eq ! ( m as uint, n) ;
545
+ m
546
+ }
547
+
538
548
fn parse_param_space ( st : & mut PState ) -> subst:: ParamSpace {
539
549
subst:: ParamSpace :: from_uint ( parse_uint ( st) )
540
550
}
@@ -697,7 +707,7 @@ fn parse_type_param_def<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
697
707
let def_id = parse_def ( st, NominalType , |x, y| conv ( x, y) ) ;
698
708
let space = parse_param_space ( st) ;
699
709
assert_eq ! ( next( st) , '|' ) ;
700
- let index = parse_uint ( st) ;
710
+ let index = parse_u32 ( st) ;
701
711
assert_eq ! ( next( st) , '|' ) ;
702
712
let associated_with = parse_opt ( st, |st| {
703
713
parse_def ( st, NominalType , |x, y| conv ( x, y) )
0 commit comments