Skip to content

Commit 824b9e7

Browse files
committed
convert FnCtxt methods from @mut self to &self
1 parent 4077d7b commit 824b9e7

File tree

1 file changed

+35
-33
lines changed
  • src/librustc/middle/typeck/check

1 file changed

+35
-33
lines changed

src/librustc/middle/typeck/check/mod.rs

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,10 @@ impl AstConv for FnCtxt {
649649

650650
pub impl FnCtxt {
651651
fn infcx(&self) -> @mut infer::InferCtxt { self.inh.infcx }
652-
fn search_in_scope_regions(&self,
653-
br: ty::bound_region)
654-
-> Result<ty::Region, ~str> {
652+
fn search_in_scope_regions(
653+
&self,
654+
br: ty::bound_region) -> Result<ty::Region, ~str>
655+
{
655656
let in_scope_regions = self.in_scope_regions;
656657
match in_scope_regions.find(br) {
657658
Some(r) => result::Ok(r),
@@ -683,9 +684,9 @@ impl region_scope for FnCtxt {
683684
}
684685

685686
pub impl FnCtxt {
686-
fn tag(@mut self) -> ~str { fmt!("%x", ptr::addr_of(&(*self)) as uint) }
687+
fn tag(&self) -> ~str { fmt!("%x", ptr::addr_of(&(*self)) as uint) }
687688

688-
fn local_ty(@mut self, span: span, nid: ast::node_id) -> ty::t {
689+
fn local_ty(&self, span: span, nid: ast::node_id) -> ty::t {
689690
match self.inh.locals.find(&nid) {
690691
Some(t) => t,
691692
None => {
@@ -696,7 +697,7 @@ pub impl FnCtxt {
696697
}
697698
}
698699

699-
fn expr_to_str(@mut self, expr: @ast::expr) -> ~str {
700+
fn expr_to_str(&self, expr: @ast::expr) -> ~str {
700701
fmt!("expr(%?:%s)", expr.id,
701702
pprust::expr_to_str(expr, self.tcx().sess.intr()))
702703
}
@@ -706,13 +707,13 @@ pub impl FnCtxt {
706707
}
707708

708709
#[inline(always)]
709-
fn write_ty(@mut self, node_id: ast::node_id, ty: ty::t) {
710+
fn write_ty(&self, node_id: ast::node_id, ty: ty::t) {
710711
debug!("write_ty(%d, %s) in fcx %s",
711712
node_id, ppaux::ty_to_str(self.tcx(), ty), self.tag());
712713
self.inh.node_types.insert(node_id, ty);
713714
}
714715

715-
fn write_substs(@mut self, node_id: ast::node_id, +substs: ty::substs) {
716+
fn write_substs(&self, node_id: ast::node_id, +substs: ty::substs) {
716717
if !ty::substs_is_noop(&substs) {
717718
debug!("write_substs(%d, %s) in fcx %s",
718719
node_id,
@@ -722,7 +723,7 @@ pub impl FnCtxt {
722723
}
723724
}
724725

725-
fn write_ty_substs(@mut self,
726+
fn write_ty_substs(&self,
726727
node_id: ast::node_id,
727728
ty: ty::t,
728729
+substs: ty::substs) {
@@ -731,7 +732,7 @@ pub impl FnCtxt {
731732
self.write_substs(node_id, substs);
732733
}
733734

734-
fn write_autoderef_adjustment(@mut self,
735+
fn write_autoderef_adjustment(&self,
735736
node_id: ast::node_id,
736737
derefs: uint) {
737738
if derefs == 0 { return; }
@@ -743,33 +744,33 @@ pub impl FnCtxt {
743744
);
744745
}
745746

746-
fn write_adjustment(@mut self,
747+
fn write_adjustment(&self,
747748
node_id: ast::node_id,
748749
adj: @ty::AutoAdjustment) {
749750
debug!("write_adjustment(node_id=%?, adj=%?)", node_id, adj);
750751
self.inh.adjustments.insert(node_id, adj);
751752
}
752753

753-
fn write_nil(@mut self, node_id: ast::node_id) {
754+
fn write_nil(&self, node_id: ast::node_id) {
754755
self.write_ty(node_id, ty::mk_nil(self.tcx()));
755756
}
756-
fn write_bot(@mut self, node_id: ast::node_id) {
757+
fn write_bot(&self, node_id: ast::node_id) {
757758
self.write_ty(node_id, ty::mk_bot(self.tcx()));
758759
}
759760

760-
fn to_ty(@mut self, ast_t: @ast::Ty) -> ty::t {
761+
fn to_ty(&self, ast_t: @ast::Ty) -> ty::t {
761762
ast_ty_to_ty(self, self, ast_t)
762763
}
763764

764-
fn expr_to_str(@mut self, expr: @ast::expr) -> ~str {
765+
fn expr_to_str(&self, expr: @ast::expr) -> ~str {
765766
expr_repr(self.tcx(), expr)
766767
}
767768

768-
fn pat_to_str(@mut self, pat: @ast::pat) -> ~str {
769+
fn pat_to_str(&self, pat: @ast::pat) -> ~str {
769770
pat_repr(self.tcx(), pat)
770771
}
771772

772-
fn expr_ty(@mut self, ex: @ast::expr) -> ty::t {
773+
fn expr_ty(&self, ex: @ast::expr) -> ty::t {
773774
match self.inh.node_types.find(&ex.id) {
774775
Some(t) => t,
775776
None => {
@@ -779,7 +780,7 @@ pub impl FnCtxt {
779780
}
780781
}
781782
}
782-
fn node_ty(@mut self, id: ast::node_id) -> ty::t {
783+
fn node_ty(&self, id: ast::node_id) -> ty::t {
783784
match self.inh.node_types.find(&id) {
784785
Some(t) => t,
785786
None => {
@@ -792,7 +793,7 @@ pub impl FnCtxt {
792793
}
793794
}
794795
}
795-
fn node_ty_substs(@mut self, id: ast::node_id) -> ty::substs {
796+
fn node_ty_substs(&self, id: ast::node_id) -> ty::substs {
796797
match self.inh.node_type_substs.find(&id) {
797798
Some(ref ts) => (/*bad*/copy *ts),
798799
None => {
@@ -805,12 +806,12 @@ pub impl FnCtxt {
805806
}
806807
}
807808
}
808-
fn opt_node_ty_substs(@mut self, id: ast::node_id) -> Option<ty::substs> {
809+
fn opt_node_ty_substs(&self, id: ast::node_id) -> Option<ty::substs> {
809810
self.inh.node_type_substs.find(&id)
810811
}
811812

812813

813-
fn mk_subty(@mut self,
814+
fn mk_subty(&self,
814815
a_is_expected: bool,
815816
span: span,
816817
sub: ty::t,
@@ -819,14 +820,14 @@ pub impl FnCtxt {
819820
infer::mk_subty(self.infcx(), a_is_expected, span, sub, sup)
820821
}
821822

822-
fn can_mk_subty(@mut self,
823+
fn can_mk_subty(&self,
823824
sub: ty::t,
824825
sup: ty::t)
825826
-> Result<(), ty::type_err> {
826827
infer::can_mk_subty(self.infcx(), sub, sup)
827828
}
828829

829-
fn mk_assignty(@mut self, expr: @ast::expr, sub: ty::t, sup: ty::t)
830+
fn mk_assignty(&self, expr: @ast::expr, sub: ty::t, sup: ty::t)
830831
-> Result<(), ty::type_err> {
831832
match infer::mk_coercety(self.infcx(), false, expr.span, sub, sup) {
832833
Ok(None) => result::Ok(()),
@@ -838,14 +839,14 @@ pub impl FnCtxt {
838839
}
839840
}
840841

841-
fn can_mk_assignty(@mut self,
842+
fn can_mk_assignty(&self,
842843
sub: ty::t,
843844
sup: ty::t)
844845
-> Result<(), ty::type_err> {
845846
infer::can_mk_coercety(self.infcx(), sub, sup)
846847
}
847848

848-
fn mk_eqty(@mut self,
849+
fn mk_eqty(&self,
849850
a_is_expected: bool,
850851
span: span,
851852
sub: ty::t,
@@ -854,7 +855,7 @@ pub impl FnCtxt {
854855
infer::mk_eqty(self.infcx(), a_is_expected, span, sub, sup)
855856
}
856857

857-
fn mk_subr(@mut self,
858+
fn mk_subr(&self,
858859
a_is_expected: bool,
859860
span: span,
860861
sub: ty::Region,
@@ -863,7 +864,7 @@ pub impl FnCtxt {
863864
infer::mk_subr(self.infcx(), a_is_expected, span, sub, sup)
864865
}
865866

866-
fn require_unsafe(@mut self, sp: span, op: ~str) {
867+
fn require_unsafe(&self, sp: span, op: ~str) {
867868
match self.purity {
868869
ast::unsafe_fn => {/*ok*/}
869870
_ => {
@@ -873,15 +874,16 @@ pub impl FnCtxt {
873874
}
874875
}
875876
}
876-
fn with_region_lb<R>(@mut self, lb: ast::node_id, f: fn() -> R) -> R {
877+
878+
fn with_region_lb<R>(@mut self, lb: ast::node_id, f: &fn() -> R) -> R {
877879
let old_region_lb = self.region_lb;
878880
self.region_lb = lb;
879881
let v = f();
880882
self.region_lb = old_region_lb;
881883
v
882884
}
883885

884-
fn region_var_if_parameterized(@mut self,
886+
fn region_var_if_parameterized(&self,
885887
rp: Option<ty::region_variance>,
886888
span: span,
887889
lower_bound: ty::Region)
@@ -890,15 +892,15 @@ pub impl FnCtxt {
890892
|_rp| self.infcx().next_region_var_with_lb(span, lower_bound))
891893
}
892894

893-
fn type_error_message(@mut self,
895+
fn type_error_message(&self,
894896
sp: span,
895897
mk_msg: &fn(~str) -> ~str,
896898
actual_ty: ty::t,
897899
err: Option<&ty::type_err>) {
898900
self.infcx().type_error_message(sp, mk_msg, actual_ty, err);
899901
}
900902

901-
fn report_mismatched_return_types(@mut self,
903+
fn report_mismatched_return_types(&self,
902904
sp: span,
903905
e: ty::t,
904906
a: ty::t,
@@ -919,12 +921,12 @@ pub impl FnCtxt {
919921
}
920922
}
921923

922-
fn report_mismatched_types(@mut self,
924+
fn report_mismatched_types(&self,
923925
sp: span,
924926
e: ty::t,
925927
a: ty::t,
926928
err: &ty::type_err) {
927-
self.infcx().report_mismatched_types(sp, e, a, err)
929+
self.infcx().report_mismatched_types(sp, e, a, err)
928930
}
929931
}
930932

0 commit comments

Comments
 (0)