@@ -266,12 +266,12 @@ pub type McResult<T> = Result<T, ()>;
266
266
*/
267
267
pub trait Typer {
268
268
fn tcx < ' a > ( & ' a self ) -> & ' a ty:: ctxt ;
269
- fn node_ty ( & mut self , id : ast:: NodeId ) -> McResult < ty:: t > ;
269
+ fn node_ty ( & self , id : ast:: NodeId ) -> McResult < ty:: t > ;
270
270
fn node_method_ty ( & self , method_call : typeck:: MethodCall ) -> Option < ty:: t > ;
271
- fn is_method_call ( & mut self , id : ast:: NodeId ) -> bool ;
272
- fn temporary_scope ( & mut self , rvalue_id : ast:: NodeId ) -> Option < ast:: NodeId > ;
273
- fn upvar_borrow ( & mut self , upvar_id : ty:: UpvarId ) -> ty:: UpvarBorrow ;
274
271
fn adjustments < ' a > ( & ' a self ) -> & ' a RefCell < NodeMap < ty:: AutoAdjustment > > ;
272
+ fn is_method_call ( & self , id : ast:: NodeId ) -> bool ;
273
+ fn temporary_scope ( & self , rvalue_id : ast:: NodeId ) -> Option < ast:: NodeId > ;
274
+ fn upvar_borrow ( & self , upvar_id : ty:: UpvarId ) -> ty:: UpvarBorrow ;
275
275
}
276
276
277
277
impl MutabilityCategory {
@@ -353,30 +353,26 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
353
353
self . typer . tcx ( )
354
354
}
355
355
356
- fn adjustment ( & mut self , id : ast:: NodeId ) -> Option < @ty:: AutoAdjustment > {
357
- self . typer . adjustment ( id)
358
- }
359
-
360
- fn expr_ty ( & mut self , expr : & ast:: Expr ) -> McResult < ty:: t > {
356
+ fn expr_ty ( & self , expr : & ast:: Expr ) -> McResult < ty:: t > {
361
357
self . typer . node_ty ( expr. id )
362
358
}
363
359
364
- fn expr_ty_adjusted ( & mut self , expr : & ast:: Expr ) -> McResult < ty:: t > {
360
+ fn expr_ty_adjusted ( & self , expr : & ast:: Expr ) -> McResult < ty:: t > {
365
361
let unadjusted_ty = if_ok ! ( self . expr_ty( expr) ) ;
366
362
Ok ( ty:: adjust_ty ( self . tcx ( ) , expr. span , expr. id , unadjusted_ty,
367
363
self . typer . adjustments ( ) . borrow ( ) . find ( & expr. id ) ,
368
364
|method_call| self . typer . node_method_ty ( method_call) ) )
369
365
}
370
366
371
- fn node_ty ( & mut self , id : ast:: NodeId ) -> McResult < ty:: t > {
367
+ fn node_ty ( & self , id : ast:: NodeId ) -> McResult < ty:: t > {
372
368
self . typer . node_ty ( id)
373
369
}
374
370
375
- fn pat_ty ( & mut self , pat : @ast:: Pat ) -> McResult < ty:: t > {
371
+ fn pat_ty ( & self , pat : @ast:: Pat ) -> McResult < ty:: t > {
376
372
self . typer . node_ty ( pat. id )
377
373
}
378
374
379
- pub fn cat_expr ( & mut self , expr : & ast:: Expr ) -> McResult < cmt > {
375
+ pub fn cat_expr ( & self , expr : & ast:: Expr ) -> McResult < cmt > {
380
376
match self . typer . adjustments ( ) . borrow ( ) . find ( & expr. id ) {
381
377
None => {
382
378
// No adjustments.
@@ -420,7 +416,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
420
416
}
421
417
}
422
418
423
- pub fn cat_expr_autoderefd ( & mut self , expr : & ast:: Expr , autoderefs : uint )
419
+ pub fn cat_expr_autoderefd ( & self , expr : & ast:: Expr , autoderefs : uint )
424
420
-> McResult < cmt > {
425
421
let mut cmt = if_ok ! ( self . cat_expr_unadjusted( expr) ) ;
426
422
for deref in range ( 1 u, autoderefs + 1 ) {
@@ -429,7 +425,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
429
425
return Ok ( cmt) ;
430
426
}
431
427
432
- pub fn cat_expr_unadjusted ( & mut self , expr : & ast:: Expr ) -> McResult < cmt > {
428
+ pub fn cat_expr_unadjusted ( & self , expr : & ast:: Expr ) -> McResult < cmt > {
433
429
debug ! ( "cat_expr: id={} expr={}" , expr. id, expr. repr( self . tcx( ) ) ) ;
434
430
435
431
let expr_ty = if_ok ! ( self . expr_ty( expr) ) ;
@@ -478,7 +474,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
478
474
}
479
475
}
480
476
481
- pub fn cat_def ( & mut self ,
477
+ pub fn cat_def ( & self ,
482
478
id : ast:: NodeId ,
483
479
span : Span ,
484
480
expr_ty : ty:: t ,
@@ -593,7 +589,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
593
589
}
594
590
}
595
591
596
- fn cat_upvar ( & mut self ,
592
+ fn cat_upvar ( & self ,
597
593
id : ast:: NodeId ,
598
594
span : Span ,
599
595
var_id : ast:: NodeId ,
@@ -643,7 +639,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
643
639
Ok ( deref_cmt)
644
640
}
645
641
646
- pub fn cat_rvalue_node ( & mut self ,
642
+ pub fn cat_rvalue_node ( & self ,
647
643
id : ast:: NodeId ,
648
644
span : Span ,
649
645
expr_ty : ty:: t )
@@ -658,7 +654,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
658
654
}
659
655
}
660
656
661
- pub fn cat_rvalue ( & mut self ,
657
+ pub fn cat_rvalue ( & self ,
662
658
cmt_id : ast:: NodeId ,
663
659
span : Span ,
664
660
temp_scope : ty:: Region ,
@@ -672,7 +668,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
672
668
}
673
669
}
674
670
675
- pub fn cat_field < N : ast_node > ( & mut self ,
671
+ pub fn cat_field < N : ast_node > ( & self ,
676
672
node : & N ,
677
673
base_cmt : cmt ,
678
674
f_name : ast:: Ident ,
@@ -687,11 +683,11 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
687
683
}
688
684
}
689
685
690
- pub fn cat_deref_obj < N : ast_node > ( & mut self , node : & N , base_cmt : cmt ) -> cmt {
686
+ pub fn cat_deref_obj < N : ast_node > ( & self , node : & N , base_cmt : cmt ) -> cmt {
691
687
self . cat_deref_common ( node, base_cmt, 0 , ty:: mk_nil ( ) )
692
688
}
693
689
694
- fn cat_deref < N : ast_node > ( & mut self ,
690
+ fn cat_deref < N : ast_node > ( & self ,
695
691
node : & N ,
696
692
base_cmt : cmt ,
697
693
deref_cnt : uint )
@@ -723,7 +719,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
723
719
}
724
720
}
725
721
726
- fn cat_deref_common < N : ast_node > ( & mut self ,
722
+ fn cat_deref_common < N : ast_node > ( & self ,
727
723
node : & N ,
728
724
base_cmt : cmt ,
729
725
deref_cnt : uint ,
@@ -749,7 +745,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
749
745
}
750
746
}
751
747
752
- pub fn cat_index < N : ast_node > ( & mut self ,
748
+ pub fn cat_index < N : ast_node > ( & self ,
753
749
elt : & N ,
754
750
base_cmt : cmt ,
755
751
derefs : uint )
@@ -836,7 +832,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
836
832
}
837
833
}
838
834
839
- pub fn cat_slice_pattern ( & mut self ,
835
+ pub fn cat_slice_pattern ( & self ,
840
836
vec_cmt : cmt ,
841
837
slice_pat : @ast:: Pat )
842
838
-> McResult < ( cmt , ast:: Mutability , ty:: Region ) > {
@@ -883,7 +879,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
883
879
}
884
880
}
885
881
886
- pub fn cat_imm_interior < N : ast_node > ( & mut self ,
882
+ pub fn cat_imm_interior < N : ast_node > ( & self ,
887
883
node : & N ,
888
884
base_cmt : cmt ,
889
885
interior_ty : ty:: t ,
@@ -898,7 +894,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
898
894
}
899
895
}
900
896
901
- pub fn cat_downcast < N : ast_node > ( & mut self ,
897
+ pub fn cat_downcast < N : ast_node > ( & self ,
902
898
node : & N ,
903
899
base_cmt : cmt ,
904
900
downcast_ty : ty:: t )
@@ -912,12 +908,12 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
912
908
}
913
909
}
914
910
915
- pub fn cat_pattern ( & mut self ,
911
+ pub fn cat_pattern ( & self ,
916
912
cmt : cmt ,
917
- pat : @ ast:: Pat ,
918
- op : |& mut MemCategorizationContext < TYPER > ,
913
+ pat : & ast:: Pat ,
914
+ op : |& MemCategorizationContext < TYPER > ,
919
915
cmt ,
920
- @ ast:: Pat |)
916
+ & ast:: Pat |)
921
917
-> McResult < ( ) > {
922
918
// Here, `cmt` is the categorization for the value being
923
919
// matched and pat is the pattern it is being matched against.
0 commit comments