diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 2e8e4a6d51e..bd35bf50cef 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -165,49 +165,49 @@ pub struct Session_ { pub type Session = @Session_; pub impl Session { - fn span_fatal(sp: span, msg: ~str) -> ! { + fn span_fatal(&self, sp: span, msg: ~str) -> ! { self.span_diagnostic.span_fatal(sp, msg) } - fn fatal(msg: ~str) -> ! { + fn fatal(&self, msg: ~str) -> ! { self.span_diagnostic.handler().fatal(msg) } - fn span_err(sp: span, msg: ~str) { + fn span_err(&self, sp: span, msg: ~str) { self.span_diagnostic.span_err(sp, msg) } - fn err(msg: ~str) { + fn err(&self, msg: ~str) { self.span_diagnostic.handler().err(msg) } - fn has_errors() -> bool { + fn has_errors(&self) -> bool { self.span_diagnostic.handler().has_errors() } - fn abort_if_errors() { + fn abort_if_errors(&self) { self.span_diagnostic.handler().abort_if_errors() } - fn span_warn(sp: span, msg: ~str) { + fn span_warn(&self, sp: span, msg: ~str) { self.span_diagnostic.span_warn(sp, msg) } - fn warn(msg: ~str) { + fn warn(&self, msg: ~str) { self.span_diagnostic.handler().warn(msg) } - fn span_note(sp: span, msg: ~str) { + fn span_note(&self, sp: span, msg: ~str) { self.span_diagnostic.span_note(sp, msg) } - fn note(msg: ~str) { + fn note(&self, msg: ~str) { self.span_diagnostic.handler().note(msg) } - fn span_bug(sp: span, msg: ~str) -> ! { + fn span_bug(&self, sp: span, msg: ~str) -> ! { self.span_diagnostic.span_bug(sp, msg) } - fn bug(msg: ~str) -> ! { + fn bug(&self, msg: ~str) -> ! { self.span_diagnostic.handler().bug(msg) } - fn span_unimpl(sp: span, msg: ~str) -> ! { + fn span_unimpl(&self, sp: span, msg: ~str) -> ! { self.span_diagnostic.span_unimpl(sp, msg) } - fn unimpl(msg: ~str) -> ! { + fn unimpl(&self, msg: ~str) -> ! { self.span_diagnostic.handler().unimpl(msg) } - fn span_lint_level(level: lint::level, sp: span, +msg: ~str) { + fn span_lint_level(&self, level: lint::level, sp: span, +msg: ~str) { match level { lint::allow => { }, lint::warn => self.span_warn(sp, msg), @@ -216,7 +216,7 @@ pub impl Session { } } } - fn span_lint(lint_mode: lint::lint, + fn span_lint(&self, lint_mode: lint::lint, expr_id: ast::node_id, item_id: ast::node_id, span: span, @@ -225,45 +225,55 @@ pub impl Session { self.lint_settings, lint_mode, expr_id, item_id); self.span_lint_level(level, span, msg); } - fn next_node_id() -> ast::node_id { + fn next_node_id(&self) -> ast::node_id { return syntax::parse::next_node_id(self.parse_sess); } - fn diagnostic() -> diagnostic::span_handler { + fn diagnostic(&self) -> diagnostic::span_handler { self.span_diagnostic } - fn debugging_opt(opt: uint) -> bool { + fn debugging_opt(&self, opt: uint) -> bool { (self.opts.debugging_opts & opt) != 0u } // This exists to help with refactoring to eliminate impossible // cases later on - fn impossible_case(sp: span, msg: &str) -> ! { + fn impossible_case(&self, sp: span, msg: &str) -> ! { self.span_bug(sp, fmt!("Impossible case reached: %s", msg)); } - fn verbose() -> bool { self.debugging_opt(verbose) } - fn time_passes() -> bool { self.debugging_opt(time_passes) } - fn count_llvm_insns() -> bool { self.debugging_opt(count_llvm_insns) } - fn count_type_sizes() -> bool { self.debugging_opt(count_type_sizes) } - fn time_llvm_passes() -> bool { self.debugging_opt(time_llvm_passes) } - fn trans_stats() -> bool { self.debugging_opt(trans_stats) } - fn meta_stats() -> bool { self.debugging_opt(meta_stats) } - fn no_asm_comments() -> bool { self.debugging_opt(no_asm_comments) } - fn no_verify() -> bool { self.debugging_opt(no_verify) } - fn trace() -> bool { self.debugging_opt(trace) } - fn coherence() -> bool { self.debugging_opt(coherence) } - fn borrowck_stats() -> bool { self.debugging_opt(borrowck_stats) } - fn borrowck_note_pure() -> bool { self.debugging_opt(borrowck_note_pure) } - fn borrowck_note_loan() -> bool { self.debugging_opt(borrowck_note_loan) } - fn no_monomorphic_collapse() -> bool { + fn verbose(&self) -> bool { self.debugging_opt(verbose) } + fn time_passes(&self) -> bool { self.debugging_opt(time_passes) } + fn count_llvm_insns(&self) -> bool { + self.debugging_opt(count_llvm_insns) + } + fn count_type_sizes(&self) -> bool { + self.debugging_opt(count_type_sizes) + } + fn time_llvm_passes(&self) -> bool { + self.debugging_opt(time_llvm_passes) + } + fn trans_stats(&self) -> bool { self.debugging_opt(trans_stats) } + fn meta_stats(&self) -> bool { self.debugging_opt(meta_stats) } + fn no_asm_comments(&self) -> bool { self.debugging_opt(no_asm_comments) } + fn no_verify(&self) -> bool { self.debugging_opt(no_verify) } + fn trace(&self) -> bool { self.debugging_opt(trace) } + fn coherence(&self) -> bool { self.debugging_opt(coherence) } + fn borrowck_stats(&self) -> bool { self.debugging_opt(borrowck_stats) } + fn borrowck_note_pure(&self) -> bool { + self.debugging_opt(borrowck_note_pure) + } + fn borrowck_note_loan(&self) -> bool { + self.debugging_opt(borrowck_note_loan) + } + fn no_monomorphic_collapse(&self) -> bool { self.debugging_opt(no_monomorphic_collapse) } - fn str_of(id: ast::ident) -> @~str { + fn str_of(&self, id: ast::ident) -> @~str { self.parse_sess.interner.get(id) } - fn ident_of(+st: ~str) -> ast::ident { + fn ident_of(&self, +st: ~str) -> ast::ident { self.parse_sess.interner.intern(@st) } - fn intr() -> @syntax::parse::token::ident_interner { + fn intr(&self) -> @syntax::parse::token::ident_interner { self.parse_sess.interner } } diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 2175d0f074c..82ea0b6d6f1 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -29,10 +29,10 @@ pub fn pick_file(file: Path, path: &Path) -> Option { } pub trait FileSearch { - fn sysroot() -> Path; - fn lib_search_paths() -> ~[Path]; - fn get_target_lib_path() -> Path; - fn get_target_lib_file_path(file: &Path) -> Path; + fn sysroot(&self) -> Path; + fn lib_search_paths(&self) -> ~[Path]; + fn get_target_lib_path(&self) -> Path; + fn get_target_lib_file_path(&self, file: &Path) -> Path; } pub fn mk_filesearch(maybe_sysroot: Option, @@ -44,8 +44,8 @@ pub fn mk_filesearch(maybe_sysroot: Option, target_triple: ~str } impl FileSearch for FileSearchImpl { - fn sysroot() -> Path { /*bad*/copy self.sysroot } - fn lib_search_paths() -> ~[Path] { + fn sysroot(&self) -> Path { /*bad*/copy self.sysroot } + fn lib_search_paths(&self) -> ~[Path] { let mut paths = /*bad*/copy self.addl_lib_search_paths; paths.push( @@ -61,10 +61,10 @@ pub fn mk_filesearch(maybe_sysroot: Option, } paths } - fn get_target_lib_path() -> Path { + fn get_target_lib_path(&self) -> Path { make_target_lib_path(&self.sysroot, self.target_triple) } - fn get_target_lib_file_path(file: &Path) -> Path { + fn get_target_lib_file_path(&self, file: &Path) -> Path { self.get_target_lib_path().push_rel(file) } } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 4152a32fc33..0b1abd683b1 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -75,11 +75,11 @@ struct ExtendedDecodeContext { } trait tr { - fn tr(xcx: @ExtendedDecodeContext) -> Self; + fn tr(&self, xcx: @ExtendedDecodeContext) -> Self; } trait tr_intern { - fn tr_intern(xcx: @ExtendedDecodeContext) -> ast::def_id; + fn tr_intern(&self, xcx: @ExtendedDecodeContext) -> ast::def_id; } // ______________________________________________________________________ @@ -227,41 +227,41 @@ impl ExtendedDecodeContext { } impl tr_intern for ast::def_id { - fn tr_intern(xcx: @ExtendedDecodeContext) -> ast::def_id { - xcx.tr_intern_def_id(self) + fn tr_intern(&self, xcx: @ExtendedDecodeContext) -> ast::def_id { + xcx.tr_intern_def_id(*self) } } impl tr for ast::def_id { - fn tr(xcx: @ExtendedDecodeContext) -> ast::def_id { - xcx.tr_def_id(self) + fn tr(&self, xcx: @ExtendedDecodeContext) -> ast::def_id { + xcx.tr_def_id(*self) } } impl tr for span { - fn tr(xcx: @ExtendedDecodeContext) -> span { - xcx.tr_span(self) + fn tr(&self, xcx: @ExtendedDecodeContext) -> span { + xcx.tr_span(*self) } } trait def_id_encoder_helpers { - fn emit_def_id(did: ast::def_id); + fn emit_def_id(&self, did: ast::def_id); } impl def_id_encoder_helpers for S { - fn emit_def_id(did: ast::def_id) { - did.encode(&self) + fn emit_def_id(&self, did: ast::def_id) { + did.encode(self) } } trait def_id_decoder_helpers { - fn read_def_id(xcx: @ExtendedDecodeContext) -> ast::def_id; + fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id; } impl def_id_decoder_helpers for D { - fn read_def_id(xcx: @ExtendedDecodeContext) -> ast::def_id { - let did: ast::def_id = Decodable::decode(&self); + fn read_def_id(&self, xcx: @ExtendedDecodeContext) -> ast::def_id { + let did: ast::def_id = Decodable::decode(self); did.tr(xcx) } } @@ -405,8 +405,8 @@ fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def { } impl tr for ast::def { - fn tr(xcx: @ExtendedDecodeContext) -> ast::def { - match self { + fn tr(&self, xcx: @ExtendedDecodeContext) -> ast::def { + match *self { ast::def_fn(did, p) => { ast::def_fn(did.tr(xcx), p) } ast::def_static_method(did, did2_opt, p) => { ast::def_static_method(did.tr(xcx), @@ -450,7 +450,7 @@ impl tr for ast::def { // Encoding and decoding of adjustment information impl tr for ty::AutoAdjustment { - fn tr(xcx: @ExtendedDecodeContext) -> ty::AutoAdjustment { + fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::AutoAdjustment { ty::AutoAdjustment { autoderefs: self.autoderefs, autoref: self.autoref.map(|ar| ar.tr(xcx)), @@ -459,7 +459,7 @@ impl tr for ty::AutoAdjustment { } impl tr for ty::AutoRef { - fn tr(xcx: @ExtendedDecodeContext) -> ty::AutoRef { + fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::AutoRef { ty::AutoRef { kind: self.kind, region: self.region.tr(xcx), @@ -469,21 +469,21 @@ impl tr for ty::AutoRef { } impl tr for ty::Region { - fn tr(xcx: @ExtendedDecodeContext) -> ty::Region { - match self { + fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::Region { + match *self { ty::re_bound(br) => ty::re_bound(br.tr(xcx)), ty::re_free(id, br) => ty::re_free(xcx.tr_id(id), br.tr(xcx)), ty::re_scope(id) => ty::re_scope(xcx.tr_id(id)), - ty::re_static | ty::re_infer(*) => self, + ty::re_static | ty::re_infer(*) => *self, } } } impl tr for ty::bound_region { - fn tr(xcx: @ExtendedDecodeContext) -> ty::bound_region { - match self { + fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::bound_region { + match *self { ty::br_anon(_) | ty::br_named(_) | ty::br_self | - ty::br_fresh(_) => self, + ty::br_fresh(_) => *self, ty::br_cap_avoid(id, br) => ty::br_cap_avoid(xcx.tr_id(id), @br.tr(xcx)) } @@ -498,18 +498,20 @@ fn encode_freevar_entry(ebml_w: writer::Encoder, fv: @freevar_entry) { } trait ebml_decoder_helper { - fn read_freevar_entry(xcx: @ExtendedDecodeContext) -> freevar_entry; + fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext) + -> freevar_entry; } impl ebml_decoder_helper for reader::Decoder { - fn read_freevar_entry(xcx: @ExtendedDecodeContext) -> freevar_entry { - let fv: freevar_entry = Decodable::decode(&self); + fn read_freevar_entry(&self, xcx: @ExtendedDecodeContext) + -> freevar_entry { + let fv: freevar_entry = Decodable::decode(self); fv.tr(xcx) } } impl tr for freevar_entry { - fn tr(xcx: @ExtendedDecodeContext) -> freevar_entry { + fn tr(&self, xcx: @ExtendedDecodeContext) -> freevar_entry { freevar_entry { def: self.def.tr(xcx), span: self.span.tr(xcx), @@ -521,18 +523,20 @@ impl tr for freevar_entry { // Encoding and decoding of CaptureVar information trait capture_var_helper { - fn read_capture_var(xcx: @ExtendedDecodeContext) -> moves::CaptureVar; + fn read_capture_var(&self, xcx: @ExtendedDecodeContext) + -> moves::CaptureVar; } impl capture_var_helper for reader::Decoder { - fn read_capture_var(xcx: @ExtendedDecodeContext) -> moves::CaptureVar { - let cvar: moves::CaptureVar = Decodable::decode(&self); + fn read_capture_var(&self, xcx: @ExtendedDecodeContext) + -> moves::CaptureVar { + let cvar: moves::CaptureVar = Decodable::decode(self); cvar.tr(xcx) } } impl tr for moves::CaptureVar { - fn tr(xcx: @ExtendedDecodeContext) -> moves::CaptureVar { + fn tr(&self, xcx: @ExtendedDecodeContext) -> moves::CaptureVar { moves::CaptureVar { def: self.def.tr(xcx), span: self.span.tr(xcx), @@ -545,7 +549,8 @@ impl tr for moves::CaptureVar { // Encoding and decoding of method_map_entry trait read_method_map_entry_helper { - fn read_method_map_entry(xcx: @ExtendedDecodeContext) -> method_map_entry; + fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) + -> method_map_entry; } fn encode_method_map_entry(ecx: @e::EncodeContext, @@ -565,7 +570,7 @@ fn encode_method_map_entry(ecx: @e::EncodeContext, } impl read_method_map_entry_helper for reader::Decoder { - fn read_method_map_entry(xcx: @ExtendedDecodeContext) + fn read_method_map_entry(&self, xcx: @ExtendedDecodeContext) -> method_map_entry { do self.read_rec { method_map_entry { @@ -573,12 +578,12 @@ impl read_method_map_entry_helper for reader::Decoder { self.read_arg(xcx) }), explicit_self: self.read_field(~"explicit_self", 2u, || { - let self_type: ast::self_ty_ = Decodable::decode(&self); + let self_type: ast::self_ty_ = Decodable::decode(self); self_type }), origin: self.read_field(~"origin", 1u, || { let method_origin: method_origin = - Decodable::decode(&self); + Decodable::decode(self); method_origin.tr(xcx) }), } @@ -587,8 +592,8 @@ impl read_method_map_entry_helper for reader::Decoder { } impl tr for method_origin { - fn tr(xcx: @ExtendedDecodeContext) -> method_origin { - match self { + fn tr(&self, xcx: @ExtendedDecodeContext) -> method_origin { + match *self { typeck::method_static(did) => { typeck::method_static(did.tr(xcx)) } @@ -672,17 +677,19 @@ fn encode_vtable_origin(ecx: @e::EncodeContext, } trait vtable_decoder_helpers { - fn read_vtable_res(xcx: @ExtendedDecodeContext) -> typeck::vtable_res; - fn read_vtable_origin(xcx: @ExtendedDecodeContext) + fn read_vtable_res(&self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_res; + fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext) -> typeck::vtable_origin; } impl vtable_decoder_helpers for reader::Decoder { - fn read_vtable_res(xcx: @ExtendedDecodeContext) -> typeck::vtable_res { + fn read_vtable_res(&self, xcx: @ExtendedDecodeContext) + -> typeck::vtable_res { @self.read_to_vec(|| self.read_vtable_origin(xcx) ) } - fn read_vtable_origin(xcx: @ExtendedDecodeContext) + fn read_vtable_origin(&self, xcx: @ExtendedDecodeContext) -> typeck::vtable_origin { do self.read_enum(~"vtable_origin") { do self.read_enum_variant |i| { @@ -736,6 +743,7 @@ trait get_ty_str_ctxt { } impl get_ty_str_ctxt for @e::EncodeContext { + // IMPLICIT SELF WARNING: fix this! fn ty_str_ctxt() -> @tyencode::ctxt { @tyencode::ctxt {diag: self.tcx.sess.diagnostic(), ds: e::def_to_str, @@ -746,46 +754,48 @@ impl get_ty_str_ctxt for @e::EncodeContext { } trait ebml_writer_helpers { - fn emit_arg(ecx: @e::EncodeContext, arg: ty::arg); - fn emit_ty(ecx: @e::EncodeContext, ty: ty::t); - fn emit_vstore(ecx: @e::EncodeContext, vstore: ty::vstore); - fn emit_tys(ecx: @e::EncodeContext, tys: ~[ty::t]); - fn emit_bounds(ecx: @e::EncodeContext, bs: ty::param_bounds); - fn emit_tpbt(ecx: @e::EncodeContext, tpbt: ty::ty_param_bounds_and_ty); + fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg); + fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t); + fn emit_vstore(&self, ecx: @e::EncodeContext, vstore: ty::vstore); + fn emit_tys(&self, ecx: @e::EncodeContext, tys: ~[ty::t]); + fn emit_bounds(&self, ecx: @e::EncodeContext, bs: ty::param_bounds); + fn emit_tpbt(&self, ecx: @e::EncodeContext, + tpbt: ty::ty_param_bounds_and_ty); } impl ebml_writer_helpers for writer::Encoder { - fn emit_ty(ecx: @e::EncodeContext, ty: ty::t) { + fn emit_ty(&self, ecx: @e::EncodeContext, ty: ty::t) { do self.emit_opaque { - e::write_type(ecx, self, ty) + e::write_type(ecx, *self, ty) } } - fn emit_vstore(ecx: @e::EncodeContext, vstore: ty::vstore) { + fn emit_vstore(&self, ecx: @e::EncodeContext, vstore: ty::vstore) { do self.emit_opaque { - e::write_vstore(ecx, self, vstore) + e::write_vstore(ecx, *self, vstore) } } - fn emit_arg(ecx: @e::EncodeContext, arg: ty::arg) { + fn emit_arg(&self, ecx: @e::EncodeContext, arg: ty::arg) { do self.emit_opaque { tyencode::enc_arg(self.writer, ecx.ty_str_ctxt(), arg); } } - fn emit_tys(ecx: @e::EncodeContext, tys: ~[ty::t]) { + fn emit_tys(&self, ecx: @e::EncodeContext, tys: ~[ty::t]) { do self.emit_from_vec(tys) |ty| { self.emit_ty(ecx, *ty) } } - fn emit_bounds(ecx: @e::EncodeContext, bs: ty::param_bounds) { + fn emit_bounds(&self, ecx: @e::EncodeContext, bs: ty::param_bounds) { do self.emit_opaque { tyencode::enc_bounds(self.writer, ecx.ty_str_ctxt(), bs) } } - fn emit_tpbt(ecx: @e::EncodeContext, tpbt: ty::ty_param_bounds_and_ty) { + fn emit_tpbt(&self, ecx: @e::EncodeContext, + tpbt: ty::ty_param_bounds_and_ty) { do self.emit_rec { do self.emit_field(~"bounds", 0) { do self.emit_from_vec(*tpbt.bounds) |bs| { @@ -793,7 +803,7 @@ impl ebml_writer_helpers for writer::Encoder { } } do self.emit_field(~"region_param", 1u) { - tpbt.region_param.encode(&self); + tpbt.region_param.encode(self); } do self.emit_field(~"ty", 2u) { self.emit_ty(ecx, tpbt.ty); @@ -803,16 +813,16 @@ impl ebml_writer_helpers for writer::Encoder { } trait write_tag_and_id { - fn tag(tag_id: c::astencode_tag, f: fn()); - fn id(id: ast::node_id); + fn tag(&self, tag_id: c::astencode_tag, f: fn()); + fn id(&self, id: ast::node_id); } impl write_tag_and_id for writer::Encoder { - fn tag(tag_id: c::astencode_tag, f: fn()) { + fn tag(&self, tag_id: c::astencode_tag, f: fn()) { do self.wr_tag(tag_id as uint) { f() } } - fn id(id: ast::node_id) { + fn id(&self, id: ast::node_id) { self.wr_tagged_u64(c::tag_table_id as uint, id as u64) } } @@ -981,31 +991,31 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext, } trait doc_decoder_helpers { - fn as_int() -> int; - fn opt_child(tag: c::astencode_tag) -> Option; + fn as_int(&self) -> int; + fn opt_child(&self, tag: c::astencode_tag) -> Option; } impl doc_decoder_helpers for ebml::Doc { - fn as_int() -> int { reader::doc_as_u64(self) as int } - fn opt_child(tag: c::astencode_tag) -> Option { - reader::maybe_get_doc(self, tag as uint) + fn as_int(&self) -> int { reader::doc_as_u64(*self) as int } + fn opt_child(&self, tag: c::astencode_tag) -> Option { + reader::maybe_get_doc(*self, tag as uint) } } trait ebml_decoder_decoder_helpers { - fn read_arg(xcx: @ExtendedDecodeContext) -> ty::arg; - fn read_ty(xcx: @ExtendedDecodeContext) -> ty::t; - fn read_tys(xcx: @ExtendedDecodeContext) -> ~[ty::t]; - fn read_bounds(xcx: @ExtendedDecodeContext) -> @~[ty::param_bound]; - fn read_ty_param_bounds_and_ty(xcx: @ExtendedDecodeContext) + fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg; + fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t; + fn read_tys(&self, xcx: @ExtendedDecodeContext) -> ~[ty::t]; + fn read_bounds(&self, xcx: @ExtendedDecodeContext) -> @~[ty::param_bound]; + fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext) -> ty::ty_param_bounds_and_ty; - fn convert_def_id(xcx: @ExtendedDecodeContext, + fn convert_def_id(&self, xcx: @ExtendedDecodeContext, source: DefIdSource, did: ast::def_id) -> ast::def_id; } impl ebml_decoder_decoder_helpers for reader::Decoder { - fn read_arg(xcx: @ExtendedDecodeContext) -> ty::arg { + fn read_arg(&self, xcx: @ExtendedDecodeContext) -> ty::arg { do self.read_opaque |doc| { tydecode::parse_arg_data( doc.data, xcx.dcx.cdata.cnum, doc.start, xcx.dcx.tcx, @@ -1013,7 +1023,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - fn read_ty(xcx: @ExtendedDecodeContext) -> ty::t { + fn read_ty(&self, xcx: @ExtendedDecodeContext) -> ty::t { // Note: regions types embed local node ids. In principle, we // should translate these node ids into the new decode // context. However, we do not bother, because region types @@ -1040,11 +1050,12 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - fn read_tys(xcx: @ExtendedDecodeContext) -> ~[ty::t] { + fn read_tys(&self, xcx: @ExtendedDecodeContext) -> ~[ty::t] { self.read_to_vec(|| self.read_ty(xcx) ) } - fn read_bounds(xcx: @ExtendedDecodeContext) -> @~[ty::param_bound] { + fn read_bounds(&self, xcx: @ExtendedDecodeContext) + -> @~[ty::param_bound] { do self.read_opaque |doc| { tydecode::parse_bounds_data( doc.data, doc.start, xcx.dcx.cdata.cnum, xcx.dcx.tcx, @@ -1052,7 +1063,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - fn read_ty_param_bounds_and_ty(xcx: @ExtendedDecodeContext) + fn read_ty_param_bounds_and_ty(&self, xcx: @ExtendedDecodeContext) -> ty::ty_param_bounds_and_ty { do self.read_rec { @@ -1061,7 +1072,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { @self.read_to_vec(|| self.read_bounds(xcx) ) }), region_param: self.read_field(~"region_param", 1u, || { - Decodable::decode(&self) + Decodable::decode(self) }), ty: self.read_field(~"ty", 2u, || { self.read_ty(xcx) @@ -1070,7 +1081,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder { } } - fn convert_def_id(xcx: @ExtendedDecodeContext, + fn convert_def_id(&self, xcx: @ExtendedDecodeContext, source: tydecode::DefIdSource, did: ast::def_id) -> ast::def_id { /*! @@ -1192,10 +1203,10 @@ fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item { #[cfg(test)] trait fake_ext_ctxt { - fn cfg() -> ast::crate_cfg; - fn parse_sess() -> @mut parse::ParseSess; - fn call_site() -> span; - fn ident_of(+st: ~str) -> ast::ident; + fn cfg(&self) -> ast::crate_cfg; + fn parse_sess(&self) -> @mut parse::ParseSess; + fn call_site(&self) -> span; + fn ident_of(&self, +st: ~str) -> ast::ident; } #[cfg(test)] @@ -1203,16 +1214,16 @@ type fake_session = @mut parse::ParseSess; #[cfg(test)] impl fake_ext_ctxt for fake_session { - fn cfg() -> ast::crate_cfg { ~[] } - fn parse_sess() -> @mut parse::ParseSess { self } - fn call_site() -> span { + fn cfg(&self) -> ast::crate_cfg { ~[] } + fn parse_sess(&self) -> @mut parse::ParseSess { *self } + fn call_site(&self) -> span { codemap::span { lo: codemap::BytePos(0), hi: codemap::BytePos(0), expn_info: None } } - fn ident_of(+st: ~str) -> ast::ident { + fn ident_of(&self, +st: ~str) -> ast::ident { self.interner.intern(@st) } } diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 8519439ee93..afefec00c50 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -90,16 +90,16 @@ enum assignment_type { } impl assignment_type { - fn checked_by_liveness() -> bool { + fn checked_by_liveness(&self) -> bool { // the liveness pass guarantees that immutable local variables // are only assigned once; but it doesn't consider &mut - match self { + match *self { at_straight_up => true, at_swap => true } } - fn ing_form(desc: ~str) -> ~str { - match self { + fn ing_form(&self, desc: ~str) -> ~str { + match *self { at_straight_up => ~"assigning to " + desc, at_swap => ~"swapping to and from " + desc } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 983ee2ca141..b997c94a71b 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -82,7 +82,7 @@ pub struct LanguageItems { } pub impl LanguageItems { - static pub fn new() -> LanguageItems { + static pub fn new(&self) -> LanguageItems { LanguageItems { items: [ None, ..34 ] } @@ -96,7 +96,7 @@ pub impl LanguageItems { } } - static pub fn item_name(index: uint) -> &static/str { + static pub fn item_name(&self, index: uint) -> &static/str { match index { 0 => "const", 1 => "copy", @@ -315,7 +315,7 @@ struct LanguageItemCollector { } impl LanguageItemCollector { - fn match_and_collect_meta_item(item_def_id: def_id, + fn match_and_collect_meta_item(&self, item_def_id: def_id, meta_item: meta_item) { match meta_item.node { meta_name_value(key, literal) => { @@ -330,7 +330,7 @@ impl LanguageItemCollector { } } - fn collect_item(item_index: uint, item_def_id: def_id) { + fn collect_item(&self, item_index: uint, item_def_id: def_id) { // Check for duplicates. match self.items.items[item_index] { Some(original_def_id) if original_def_id != item_def_id => { @@ -346,7 +346,8 @@ impl LanguageItemCollector { self.items.items[item_index] = Some(item_def_id); } - fn match_and_collect_item(item_def_id: def_id, key: @~str, value: @~str) { + fn match_and_collect_item(&self, + item_def_id: def_id, key: @~str, value: @~str) { if *key != ~"lang" { return; // Didn't match. } @@ -361,7 +362,7 @@ impl LanguageItemCollector { } } - fn collect_local_language_items() { + fn collect_local_language_items(&self) { let this = unsafe { ptr::addr_of(&self) }; visit_crate(*self.crate, (), mk_simple_visitor(@SimpleVisitor { visit_item: |item| { @@ -378,7 +379,7 @@ impl LanguageItemCollector { })); } - fn collect_external_language_items() { + fn collect_external_language_items(&self) { let crate_store = self.session.cstore; do iter_crate_data(crate_store) |crate_number, _crate_metadata| { for each_lang_item(crate_store, crate_number) @@ -389,7 +390,7 @@ impl LanguageItemCollector { } } - fn check_completeness() { + fn check_completeness(&self) { for self.item_refs.each |&key, &item_ref| { match self.items.items[item_ref] { None => { @@ -402,7 +403,7 @@ impl LanguageItemCollector { } } - fn collect() { + fn collect(&self) { self.collect_local_language_items(); self.collect_external_language_items(); self.check_completeness(); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index a7cfde0e70f..75bf7cf2609 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -255,7 +255,7 @@ impl to_str::ToStr for Variable { // assignment. And so forth. impl LiveNode { - pure fn is_valid() -> bool { *self != uint::max_value } + pure fn is_valid(&self) -> bool { **self != uint::max_value } } fn invalid_node() -> LiveNode { LiveNode(uint::max_value) } @@ -699,7 +699,7 @@ fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness { } impl Liveness { - fn live_node(node_id: node_id, span: span) -> LiveNode { + fn live_node(&self, node_id: node_id, span: span) -> LiveNode { match self.ir.live_node_map.find(&node_id) { Some(ln) => ln, None => { @@ -714,7 +714,7 @@ impl Liveness { } } - fn variable_from_path(expr: @expr) -> Option { + fn variable_from_path(&self, expr: @expr) -> Option { match expr.node { expr_path(_) => { let def = self.tcx.def_map.get(&expr.id); @@ -726,11 +726,11 @@ impl Liveness { } } - fn variable(node_id: node_id, span: span) -> Variable { + fn variable(&self, node_id: node_id, span: span) -> Variable { self.ir.variable(node_id, span) } - fn variable_from_def_map(node_id: node_id, + fn variable_from_def_map(&self, node_id: node_id, span: span) -> Option { match self.tcx.def_map.find(&node_id) { Some(def) => { @@ -745,7 +745,7 @@ impl Liveness { } } - fn pat_bindings(pat: @pat, f: fn(LiveNode, Variable, span)) { + fn pat_bindings(&self, pat: @pat, f: fn(LiveNode, Variable, span)) { let def_map = self.tcx.def_map; do pat_util::pat_bindings(def_map, pat) |_bm, p_id, sp, _n| { let ln = self.live_node(p_id, sp); @@ -754,7 +754,8 @@ impl Liveness { } } - fn arm_pats_bindings(pats: &[@pat], f: fn(LiveNode, Variable, span)) { + fn arm_pats_bindings(&self, + pats: &[@pat], f: fn(LiveNode, Variable, span)) { // only consider the first pattern; any later patterns must have // the same bindings, and we also consider the first pattern to be // the "authoratative" set of ids @@ -763,11 +764,11 @@ impl Liveness { } } - fn define_bindings_in_pat(pat: @pat, succ: LiveNode) -> LiveNode { + fn define_bindings_in_pat(&self, pat: @pat, succ: LiveNode) -> LiveNode { self.define_bindings_in_arm_pats([pat], succ) } - fn define_bindings_in_arm_pats(pats: &[@pat], + fn define_bindings_in_arm_pats(&self, pats: &[@pat], succ: LiveNode) -> LiveNode { let mut succ = succ; do self.arm_pats_bindings(pats) |ln, var, _sp| { @@ -778,11 +779,11 @@ impl Liveness { succ } - fn idx(ln: LiveNode, var: Variable) -> uint { + fn idx(&self, ln: LiveNode, var: Variable) -> uint { *ln * self.ir.num_vars + *var } - fn live_on_entry(ln: LiveNode, var: Variable) + fn live_on_entry(&self, ln: LiveNode, var: Variable) -> Option { assert ln.is_valid(); @@ -793,18 +794,18 @@ impl Liveness { /* Is this variable live on entry to any of its successor nodes? */ - fn live_on_exit(ln: LiveNode, var: Variable) + fn live_on_exit(&self, ln: LiveNode, var: Variable) -> Option { self.live_on_entry(copy self.successors[*ln], var) } - fn used_on_entry(ln: LiveNode, var: Variable) -> bool { + fn used_on_entry(&self, ln: LiveNode, var: Variable) -> bool { assert ln.is_valid(); self.users[self.idx(ln, var)].used } - fn assigned_on_entry(ln: LiveNode, var: Variable) + fn assigned_on_entry(&self, ln: LiveNode, var: Variable) -> Option { assert ln.is_valid(); @@ -812,13 +813,13 @@ impl Liveness { if writer.is_valid() {Some(self.ir.lnk(writer))} else {None} } - fn assigned_on_exit(ln: LiveNode, var: Variable) + fn assigned_on_exit(&self, ln: LiveNode, var: Variable) -> Option { self.assigned_on_entry(copy self.successors[*ln], var) } - fn indices(ln: LiveNode, op: fn(uint)) { + fn indices(&self, ln: LiveNode, op: fn(uint)) { let node_base_idx = self.idx(ln, Variable(0)); for uint::range(0, self.ir.num_vars) |var_idx| { op(node_base_idx + var_idx) @@ -834,7 +835,7 @@ impl Liveness { } } - fn write_vars(wr: io::Writer, + fn write_vars(&self, wr: io::Writer, ln: LiveNode, test: fn(uint) -> LiveNode) { let node_base_idx = self.idx(ln, Variable(0)); @@ -847,7 +848,7 @@ impl Liveness { } } - fn find_loop_scope(opt_label: Option, id: node_id, sp: span) + fn find_loop_scope(&self, opt_label: Option, id: node_id, sp: span) -> node_id { match opt_label { Some(_) => // Refers to a labeled loop. Use the results of resolve @@ -869,7 +870,7 @@ impl Liveness { } } - fn ln_str(ln: LiveNode) -> ~str { + fn ln_str(&self, ln: LiveNode) -> ~str { do io::with_str_writer |wr| { wr.write_str(~"[ln("); wr.write_uint(*ln); @@ -886,7 +887,7 @@ impl Liveness { } } - fn init_empty(ln: LiveNode, succ_ln: LiveNode) { + fn init_empty(&self, ln: LiveNode, succ_ln: LiveNode) { self.successors[*ln] = succ_ln; // It is not necessary to initialize the @@ -899,7 +900,7 @@ impl Liveness { // } } - fn init_from_succ(ln: LiveNode, succ_ln: LiveNode) { + fn init_from_succ(&self, ln: LiveNode, succ_ln: LiveNode) { // more efficient version of init_empty() / merge_from_succ() self.successors[*ln] = succ_ln; self.indices2(ln, succ_ln, |idx, succ_idx| { @@ -909,7 +910,7 @@ impl Liveness { self.ln_str(ln), self.ln_str(succ_ln)); } - fn merge_from_succ(ln: LiveNode, succ_ln: LiveNode, + fn merge_from_succ(&self, ln: LiveNode, succ_ln: LiveNode, first_merge: bool) -> bool { if ln == succ_ln { return false; } @@ -943,7 +944,7 @@ impl Liveness { // Indicates that a local variable was *defined*; we know that no // uses of the variable can precede the definition (resolve checks // this) so we just clear out all the data. - fn define(writer: LiveNode, var: Variable) { + fn define(&self, writer: LiveNode, var: Variable) { let idx = self.idx(writer, var); self.users[idx].reader = invalid_node(); self.users[idx].writer = invalid_node(); @@ -953,7 +954,7 @@ impl Liveness { } // Either read, write, or both depending on the acc bitset - fn acc(ln: LiveNode, var: Variable, acc: uint) { + fn acc(&self, ln: LiveNode, var: Variable, acc: uint) { let idx = self.idx(ln, var); let user = &mut self.users[idx]; @@ -978,7 +979,7 @@ impl Liveness { // _______________________________________________________________________ - fn compute(decl: fn_decl, body: blk) -> LiveNode { + fn compute(&self, decl: fn_decl, body: blk) -> LiveNode { // if there is a `break` or `again` at the top level, then it's // effectively a return---this only occurs in `for` loops, // where the body is really a closure. @@ -1003,7 +1004,8 @@ impl Liveness { entry_ln } - fn propagate_through_fn_block(decl: fn_decl, blk: blk) -> LiveNode { + fn propagate_through_fn_block(&self, decl: fn_decl, blk: blk) + -> LiveNode { // inputs passed by & mode should be considered live on exit: for decl.inputs.each |arg| { match ty::resolved_mode(self.tcx, arg.mode) { @@ -1036,14 +1038,15 @@ impl Liveness { self.propagate_through_block(blk, self.s.fallthrough_ln) } - fn propagate_through_block(blk: blk, succ: LiveNode) -> LiveNode { + fn propagate_through_block(&self, blk: blk, succ: LiveNode) -> LiveNode { let succ = self.propagate_through_opt_expr(blk.node.expr, succ); do blk.node.stmts.foldr(succ) |stmt, succ| { self.propagate_through_stmt(*stmt, succ) } } - fn propagate_through_stmt(stmt: @stmt, succ: LiveNode) -> LiveNode { + fn propagate_through_stmt(&self, stmt: @stmt, succ: LiveNode) + -> LiveNode { match stmt.node { stmt_decl(decl, _) => { return self.propagate_through_decl(decl, succ); @@ -1059,7 +1062,8 @@ impl Liveness { } } - fn propagate_through_decl(decl: @decl, succ: LiveNode) -> LiveNode { + fn propagate_through_decl(&self, decl: @decl, succ: LiveNode) + -> LiveNode { match /*bad*/copy decl.node { decl_local(locals) => { do locals.foldr(succ) |local, succ| { @@ -1072,7 +1076,8 @@ impl Liveness { } } - fn propagate_through_local(local: @local, succ: LiveNode) -> LiveNode { + fn propagate_through_local(&self, local: @local, succ: LiveNode) + -> LiveNode { // Note: we mark the variable as defined regardless of whether // there is an initializer. Initially I had thought to only mark // the live variable as defined if it was initialized, and then we @@ -1091,21 +1096,22 @@ impl Liveness { self.define_bindings_in_pat(local.node.pat, succ) } - fn propagate_through_exprs(exprs: ~[@expr], + fn propagate_through_exprs(&self, exprs: ~[@expr], succ: LiveNode) -> LiveNode { do exprs.foldr(succ) |expr, succ| { self.propagate_through_expr(*expr, succ) } } - fn propagate_through_opt_expr(opt_expr: Option<@expr>, + fn propagate_through_opt_expr(&self, opt_expr: Option<@expr>, succ: LiveNode) -> LiveNode { do opt_expr.foldl(succ) |succ, expr| { self.propagate_through_expr(*expr, *succ) } } - fn propagate_through_expr(expr: @expr, succ: LiveNode) -> LiveNode { + fn propagate_through_expr(&self, expr: @expr, succ: LiveNode) + -> LiveNode { debug!("propagate_through_expr: %s", expr_to_str(expr, self.tcx.sess.intr())); @@ -1365,7 +1371,7 @@ impl Liveness { } } - fn propagate_through_lvalue_components(expr: @expr, + fn propagate_through_lvalue_components(&self, expr: @expr, succ: LiveNode) -> LiveNode { // # Lvalues // @@ -1424,7 +1430,7 @@ impl Liveness { } // see comment on propagate_through_lvalue() - fn write_lvalue(expr: @expr, + fn write_lvalue(&self, expr: @expr, succ: LiveNode, acc: uint) -> LiveNode { match expr.node { @@ -1438,7 +1444,8 @@ impl Liveness { } } - fn access_path(expr: @expr, succ: LiveNode, acc: uint) -> LiveNode { + fn access_path(&self, expr: @expr, succ: LiveNode, acc: uint) + -> LiveNode { let def = self.tcx.def_map.get(&expr.id); match relevant_def(def) { Some(nid) => { @@ -1454,7 +1461,7 @@ impl Liveness { } } - fn propagate_through_loop(expr: @expr, + fn propagate_through_loop(&self, expr: @expr, cond: Option<@expr>, body: blk, succ: LiveNode) -> LiveNode { @@ -1510,7 +1517,7 @@ impl Liveness { cond_ln } - fn with_loop_nodes(loop_node_id: node_id, + fn with_loop_nodes(&self, loop_node_id: node_id, break_ln: LiveNode, cont_ln: LiveNode, f: fn() -> R) -> R { @@ -1646,7 +1653,7 @@ enum ReadKind { } impl @Liveness { - fn check_ret(id: node_id, sp: span, _fk: visit::fn_kind, + fn check_ret(&self, id: node_id, sp: span, _fk: visit::fn_kind, entry_ln: LiveNode) { if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() { // if no_ret_var is live, then we fall off the end of the @@ -1666,7 +1673,7 @@ impl @Liveness { } } - fn check_move_from_var(ln: LiveNode, + fn check_move_from_var(&self, ln: LiveNode, var: Variable, move_expr: @expr) { @@ -1691,7 +1698,7 @@ impl @Liveness { } } - fn consider_last_use(expr: @expr, ln: LiveNode, var: Variable) { + fn consider_last_use(&self, expr: @expr, ln: LiveNode, var: Variable) { debug!("consider_last_use(expr.id=%?, ln=%s, var=%s)", expr.id, ln.to_str(), var.to_str()); @@ -1701,7 +1708,7 @@ impl @Liveness { } } - fn check_lvalue(expr: @expr, vt: vt<@Liveness>) { + fn check_lvalue(&self, expr: @expr, vt: vt<@Liveness>) { match expr.node { expr_path(_) => { match self.tcx.def_map.get(&expr.id) { @@ -1729,18 +1736,18 @@ impl @Liveness { _ => { // For other kinds of lvalues, no checks are required, // and any embedded expressions are actually rvalues - visit::visit_expr(expr, self, vt); + visit::visit_expr(expr, *self, vt); } } } - fn check_for_reassignments_in_pat(pat: @pat) { + fn check_for_reassignments_in_pat(&self, pat: @pat) { do self.pat_bindings(pat) |ln, var, sp| { self.check_for_reassignment(ln, var, sp); } } - fn check_for_reassignment(ln: LiveNode, var: Variable, + fn check_for_reassignment(&self, ln: LiveNode, var: Variable, orig_span: span) { match self.assigned_on_exit(ln, var) { Some(ExprNode(span)) => { @@ -1761,7 +1768,7 @@ impl @Liveness { } } - fn report_illegal_move(lnk: LiveNodeKind, + fn report_illegal_move(&self, lnk: LiveNodeKind, var: Variable, move_expr: @expr) { @@ -1827,7 +1834,7 @@ impl @Liveness { }; } - fn report_move_location(move_expr: @expr, + fn report_move_location(&self, move_expr: @expr, var: Variable, expr_descr: &str, pronoun: &str) @@ -1842,7 +1849,7 @@ impl @Liveness { ty_to_str(self.tcx, move_expr_ty))); } - fn report_illegal_read(chk_span: span, + fn report_illegal_read(&self, chk_span: span, lnk: LiveNodeKind, var: Variable, rk: ReadKind) { @@ -1873,12 +1880,12 @@ impl @Liveness { } } - fn should_warn(var: Variable) -> Option<@~str> { + fn should_warn(&self, var: Variable) -> Option<@~str> { let name = self.ir.variable_name(var); if name[0] == ('_' as u8) { None } else { Some(name) } } - fn warn_about_unused_args(decl: fn_decl, entry_ln: LiveNode) { + fn warn_about_unused_args(&self, decl: fn_decl, entry_ln: LiveNode) { for decl.inputs.each |arg| { do pat_util::pat_bindings(self.tcx.def_map, arg.pat) |_bm, p_id, sp, _n| { @@ -1888,7 +1895,7 @@ impl @Liveness { } } - fn warn_about_unused_or_dead_vars_in_pat(pat: @pat) { + fn warn_about_unused_or_dead_vars_in_pat(&self, pat: @pat) { do self.pat_bindings(pat) |ln, var, sp| { if !self.warn_about_unused(sp, ln, var) { self.warn_about_dead_assign(sp, ln, var); @@ -1896,7 +1903,8 @@ impl @Liveness { } } - fn warn_about_unused(sp: span, ln: LiveNode, var: Variable) -> bool { + fn warn_about_unused(&self, sp: span, ln: LiveNode, var: Variable) + -> bool { if !self.used_on_entry(ln, var) { for self.should_warn(var).each |name| { @@ -1925,7 +1933,7 @@ impl @Liveness { return false; } - fn warn_about_dead_assign(sp: span, ln: LiveNode, var: Variable) { + fn warn_about_dead_assign(&self, sp: span, ln: LiveNode, var: Variable) { if self.live_on_exit(ln, var).is_none() { for self.should_warn(var).each |name| { // FIXME(#3266)--make liveness warnings lintable diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 0621beb43a3..f027ca99d51 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -277,27 +277,27 @@ pub fn cat_variant( } pub trait ast_node { - fn id() -> ast::node_id; - fn span() -> span; + fn id(&self) -> ast::node_id; + fn span(&self) -> span; } pub impl ast_node for @ast::expr { - fn id() -> ast::node_id { self.id } - fn span() -> span { self.span } + fn id(&self) -> ast::node_id { self.id } + fn span(&self) -> span { self.span } } pub impl ast_node for @ast::pat { - fn id() -> ast::node_id { self.id } - fn span() -> span { self.span } + fn id(&self) -> ast::node_id { self.id } + fn span(&self) -> span { self.span } } pub trait get_type_for_node { - fn ty(node: N) -> ty::t; + fn ty(&self, node: N) -> ty::t; } pub impl get_type_for_node for ty::ctxt { - fn ty(node: N) -> ty::t { - ty::node_id_to_type(self, node.id()) + fn ty(&self, node: N) -> ty::t { + ty::node_id_to_type(*self, node.id()) } } @@ -313,7 +313,7 @@ impl ToStr for MutabilityCategory { } impl MutabilityCategory { - static fn from_mutbl(m: ast::mutability) -> MutabilityCategory { + static fn from_mutbl(&self, m: ast::mutability) -> MutabilityCategory { match m { m_imm => McImmutable, m_const => McReadOnly, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 9c5e4b9f0e0..689d6ca40ee 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -154,8 +154,8 @@ pub enum NamespaceResult { } pub impl NamespaceResult { - pure fn is_unknown() -> bool { - match self { + pure fn is_unknown(&self) -> bool { + match *self { UnknownResult => true, _ => false } @@ -206,11 +206,11 @@ pub enum ResolveResult { } pub impl ResolveResult { - fn failed() -> bool { - match self { Failed => true, _ => false } + fn failed(&self) -> bool { + match *self { Failed => true, _ => false } } - fn indeterminate() -> bool { - match self { Indeterminate => true, _ => false } + fn indeterminate(&self) -> bool { + match *self { Indeterminate => true, _ => false } } } @@ -417,7 +417,7 @@ pub fn ImportResolution(privacy: Privacy, } pub impl ImportResolution { - fn target_for_namespace(namespace: Namespace) -> Option { + fn target_for_namespace(&self, namespace: Namespace) -> Option { match namespace { TypeNS => return copy self.type_target, ValueNS => return copy self.value_target @@ -503,7 +503,7 @@ pub fn Module(parent_link: ParentLink, } pub impl Module { - fn all_imports_resolved() -> bool { + fn all_imports_resolved(&self) -> bool { return self.imports.len() == self.resolved_import_count; } } @@ -706,7 +706,7 @@ pub struct PrimitiveTypeTable { } pub impl PrimitiveTypeTable { - fn intern(intr: @ident_interner, string: @~str, + fn intern(&self, intr: @ident_interner, string: @~str, primitive_type: prim_ty) { let ident = intr.intern(string); self.primitive_types.insert(ident, primitive_type); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 9e3be94294a..f5fa83e3fff 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -105,27 +105,27 @@ pub fn icx_popper(ccx: @CrateContext) -> icx_popper { } pub trait get_insn_ctxt { - fn insn_ctxt(s: &str) -> icx_popper; + fn insn_ctxt(&self, s: &str) -> icx_popper; } pub impl get_insn_ctxt for @CrateContext { - fn insn_ctxt(s: &str) -> icx_popper { + fn insn_ctxt(&self, s: &str) -> icx_popper { debug!("new insn_ctxt: %s", s); if self.sess.count_llvm_insns() { self.stats.llvm_insn_ctxt.push(str::from_slice(s)); } - icx_popper(self) + icx_popper(*self) } } pub impl get_insn_ctxt for block { - fn insn_ctxt(s: &str) -> icx_popper { + fn insn_ctxt(&self, s: &str) -> icx_popper { self.ccx().insn_ctxt(s) } } pub impl get_insn_ctxt for fn_ctxt { - fn insn_ctxt(s: &str) -> icx_popper { + fn insn_ctxt(&self, s: &str) -> icx_popper { self.ccx.insn_ctxt(s) } } diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index dc68eff9c7f..1409199a0d2 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -131,7 +131,7 @@ pub impl EnvAction { } pub impl EnvValue { - fn to_str(ccx: @CrateContext) -> ~str { + fn to_str(&self, ccx: @CrateContext) -> ~str { fmt!("%s(%s)", self.action.to_str(), self.datum.to_str(ccx)) } } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index b58e374320a..969119f0aaf 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -535,17 +535,17 @@ pub struct scope_info { } pub trait get_node_info { - fn info() -> Option; + fn info(&self) -> Option; } pub impl get_node_info for @ast::expr { - fn info() -> Option { + fn info(&self) -> Option { Some(NodeInfo { id: self.id, span: self.span }) } } pub impl get_node_info for ast::blk { - fn info() -> Option { + fn info(&self) -> Option { Some(NodeInfo { id: self.node.id, span: self.span }) } } @@ -554,7 +554,7 @@ pub impl get_node_info for ast::blk { pub type optional_boxed_ast_expr = Option<@ast::expr>; pub impl get_node_info for optional_boxed_ast_expr { - fn info() -> Option { + fn info(&self) -> Option { self.chain_ref(|s| s.info()) } } @@ -627,7 +627,7 @@ pub fn rslt(bcx: block, val: ValueRef) -> Result { } pub impl Result { - fn unpack(bcx: &mut block) -> ValueRef { + fn unpack(&self, bcx: &mut block) -> ValueRef { *bcx = self.bcx; return self.val; } @@ -691,27 +691,27 @@ pub fn block_parent(cx: block) -> block { // Accessors pub impl block { - pure fn ccx() -> @CrateContext { *self.fcx.ccx } - pure fn tcx() -> ty::ctxt { self.fcx.ccx.tcx } - pure fn sess() -> Session { self.fcx.ccx.sess } + pure fn ccx(&self) -> @CrateContext { *self.fcx.ccx } + pure fn tcx(&self) -> ty::ctxt { self.fcx.ccx.tcx } + pure fn sess(&self) -> Session { self.fcx.ccx.sess } - fn node_id_to_str(id: ast::node_id) -> ~str { + fn node_id_to_str(&self, id: ast::node_id) -> ~str { ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr()) } - fn expr_to_str(e: @ast::expr) -> ~str { + fn expr_to_str(&self, e: @ast::expr) -> ~str { expr_repr(self.tcx(), e) } - fn expr_is_lval(e: @ast::expr) -> bool { + fn expr_is_lval(&self, e: @ast::expr) -> bool { ty::expr_is_lval(self.tcx(), self.ccx().maps.method_map, e) } - fn expr_kind(e: @ast::expr) -> ty::ExprKind { + fn expr_kind(&self, e: @ast::expr) -> ty::ExprKind { ty::expr_kind(self.tcx(), self.ccx().maps.method_map, e) } - fn def(nid: ast::node_id) -> ast::def { + fn def(&self, nid: ast::node_id) -> ast::def { match self.tcx().def_map.find(&nid) { Some(v) => v, None => { @@ -721,15 +721,15 @@ pub impl block { } } - fn val_str(val: ValueRef) -> @str { + fn val_str(&self, val: ValueRef) -> @str { val_str(self.ccx().tn, val) } - fn llty_str(llty: TypeRef) -> @str { + fn llty_str(&self, llty: TypeRef) -> @str { ty_str(self.ccx().tn, llty) } - fn ty_to_str(t: ty::t) -> ~str { + fn ty_to_str(&self, t: ty::t) -> ~str { ty_to_str(self.tcx(), t) } fn to_str(&self) -> ~str { diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index ffeffa5775e..ba56eb56c0a 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -142,12 +142,12 @@ pub enum DatumMode { } pub impl DatumMode { - fn is_by_ref() -> bool { - match self { ByRef => true, ByValue => false } + fn is_by_ref(&self) -> bool { + match *self { ByRef => true, ByValue => false } } - fn is_by_value() -> bool { - match self { ByRef => false, ByValue => true } + fn is_by_value(&self) -> bool { + match *self { ByRef => false, ByValue => true } } } @@ -216,7 +216,7 @@ pub fn appropriate_mode(ty: ty::t) -> DatumMode { } pub impl Datum { - fn store_to(bcx: block, id: ast::node_id, + fn store_to(&self, bcx: block, id: ast::node_id, action: CopyAction, dst: ValueRef) -> block { /*! * @@ -231,7 +231,7 @@ pub impl Datum { } } - fn store_to_dest(bcx: block, id: ast::node_id, + fn store_to_dest(&self, bcx: block, id: ast::node_id, dest: expr::Dest) -> block { match dest { expr::Ignore => { @@ -243,7 +243,7 @@ pub impl Datum { } } - fn store_to_datum(bcx: block, id: ast::node_id, + fn store_to_datum(&self, bcx: block, id: ast::node_id, action: CopyAction, datum: Datum) -> block { debug!("store_to_datum(self=%s, action=%?, datum=%s)", self.to_str(bcx.ccx()), action, datum.to_str(bcx.ccx())); @@ -251,17 +251,20 @@ pub impl Datum { self.store_to(bcx, id, action, datum.val) } - fn move_to_datum(bcx: block, action: CopyAction, datum: Datum) -> block { + fn move_to_datum(&self, bcx: block, action: CopyAction, datum: Datum) + -> block { assert datum.mode.is_by_ref(); self.move_to(bcx, action, datum.val) } - fn copy_to_datum(bcx: block, action: CopyAction, datum: Datum) -> block { + fn copy_to_datum(&self, bcx: block, action: CopyAction, datum: Datum) + -> block { assert datum.mode.is_by_ref(); self.copy_to(bcx, action, datum.val) } - fn copy_to(bcx: block, action: CopyAction, dst: ValueRef) -> block { + fn copy_to(&self, bcx: block, action: CopyAction, dst: ValueRef) + -> block { /*! * * Copies the value into `dst`, which should be a pointer to a @@ -303,7 +306,7 @@ pub impl Datum { } } - fn copy_to_no_check(bcx: block, action: CopyAction, + fn copy_to_no_check(&self, bcx: block, action: CopyAction, dst: ValueRef) -> block { /*! @@ -333,7 +336,8 @@ pub impl Datum { // This works like copy_val, except that it deinitializes the source. // Since it needs to zero out the source, src also needs to be an lval. // - fn move_to(bcx: block, action: CopyAction, dst: ValueRef) -> block { + fn move_to(&self, bcx: block, action: CopyAction, dst: ValueRef) + -> block { let _icx = bcx.insn_ctxt("move_to"); let mut bcx = bcx; @@ -362,7 +366,7 @@ pub impl Datum { return bcx; } - fn add_clean(bcx: block) { + fn add_clean(&self, bcx: block) { /*! * * Schedules this datum for cleanup in `bcx`. The datum @@ -379,7 +383,7 @@ pub impl Datum { } } - fn cancel_clean(bcx: block) { + fn cancel_clean(&self, bcx: block) { if ty::type_needs_drop(bcx.tcx(), self.ty) { match self.source { RevokeClean => { @@ -396,7 +400,7 @@ pub impl Datum { } } - fn to_str(ccx: &CrateContext) -> ~str { + fn to_str(&self, ccx: &CrateContext) -> ~str { fmt!("Datum { val=%s, ty=%s, mode=%?, source=%? }", val_str(ccx.tn, self.val), ty_to_str(ccx.tcx, self.ty), @@ -404,7 +408,7 @@ pub impl Datum { self.source) } - fn to_value_datum(bcx: block) -> Datum { + fn to_value_datum(&self, bcx: block) -> Datum { /*! * * Yields a by-ref form of this datum. This may involve @@ -413,7 +417,7 @@ pub impl Datum { * it will not live longer than the current datum. */ match self.mode { - ByValue => self, + ByValue => *self, ByRef => { Datum {val: self.to_value_llval(bcx), mode: ByValue, ty: self.ty, source: RevokeClean} @@ -421,7 +425,7 @@ pub impl Datum { } } - fn to_value_llval(bcx: block) -> ValueRef { + fn to_value_llval(&self, bcx: block) -> ValueRef { /*! * * Yields the value itself. */ @@ -442,7 +446,7 @@ pub impl Datum { } } - fn to_ref_datum(bcx: block) -> Datum { + fn to_ref_datum(&self, bcx: block) -> Datum { /*! * * Yields a by-ref form of this datum. This may involve @@ -451,7 +455,7 @@ pub impl Datum { * it will not live longer than the current datum. */ match self.mode { - ByRef => self, + ByRef => *self, ByValue => { Datum {val: self.to_ref_llval(bcx), mode: ByRef, ty: self.ty, source: RevokeClean} @@ -459,7 +463,7 @@ pub impl Datum { } } - fn to_ref_llval(bcx: block) -> ValueRef { + fn to_ref_llval(&self, bcx: block) -> ValueRef { match self.mode { ByRef => self.val, ByValue => { @@ -474,13 +478,13 @@ pub impl Datum { } } - fn appropriate_mode() -> DatumMode { + fn appropriate_mode(&self) -> DatumMode { /*! See the `appropriate_mode()` function */ appropriate_mode(self.ty) } - fn to_appropriate_llval(bcx: block) -> ValueRef { + fn to_appropriate_llval(&self, bcx: block) -> ValueRef { /*! * * Yields an llvalue with the `appropriate_mode()`. */ @@ -491,7 +495,7 @@ pub impl Datum { } } - fn to_appropriate_datum(bcx: block) -> Datum { + fn to_appropriate_datum(&self, bcx: block) -> Datum { /*! * * Yields a datum with the `appropriate_mode()`. */ @@ -502,7 +506,7 @@ pub impl Datum { } } - fn GEPi(bcx: block, + fn GEPi(&self, bcx: block, ixs: &[uint], ty: ty::t, source: DatumCleanup) @@ -516,7 +520,7 @@ pub impl Datum { } } - fn root(bcx: block, root_info: RootInfo) -> block { + fn root(&self, bcx: block, root_info: RootInfo) -> block { /*! * * In some cases, borrowck will decide that an @T/@[]/@str @@ -555,7 +559,7 @@ pub impl Datum { } } - fn perform_write_guard(bcx: block) -> block { + fn perform_write_guard(&self, bcx: block) -> block { // Create scratch space, but do not root it. let llval = match self.mode { ByValue => self.val, @@ -569,7 +573,7 @@ pub impl Datum { expr::Ignore) } - fn drop_val(bcx: block) -> block { + fn drop_val(&self, bcx: block) -> block { if !ty::type_needs_drop(bcx.tcx(), self.ty) { return bcx; } @@ -580,7 +584,7 @@ pub impl Datum { }; } - fn box_body(bcx: block) -> Datum { + fn box_body(&self, bcx: block) -> Datum { /*! * * This datum must represent an @T or ~T box. Returns a new @@ -600,7 +604,7 @@ pub impl Datum { Datum {val: body, ty: content_ty, mode: ByRef, source: ZeroMem} } - fn to_rptr(bcx: block) -> Datum { + fn to_rptr(&self, bcx: block) -> Datum { //! // // Returns a new datum of region-pointer type containing the @@ -618,7 +622,7 @@ pub impl Datum { mode: ByValue, source: RevokeClean} } - fn try_deref( + fn try_deref(&self, bcx: block, // block wherein to generate insn's expr_id: ast::node_id, // id of expr being deref'd derefs: uint, // number of times deref'd already @@ -656,11 +660,11 @@ pub impl Datum { if is_auto { // unsafe ptrs are not AUTO-derefable return (None, bcx); } else { - return (Some(deref_ptr(bcx, &self, mt.ty)), bcx); + return (Some(deref_ptr(bcx, self, mt.ty)), bcx); } } ty::ty_rptr(_, mt) => { - return (Some(deref_ptr(bcx, &self, mt.ty)), bcx); + return (Some(deref_ptr(bcx, self, mt.ty)), bcx); } ty::ty_enum(did, ref substs) => { // Check whether this enum is a newtype enum: @@ -695,7 +699,7 @@ pub impl Datum { // code in place here to do the right // thing if this change ever goes through. assert ty::type_is_immediate(ty); - (Some(Datum {ty: ty, ..self}), bcx) + (Some(Datum {ty: ty, ..*self}), bcx) } }; } @@ -733,7 +737,7 @@ pub impl Datum { // code in place here to do the right thing if this // change ever goes through. assert ty::type_is_immediate(ty); - (Some(Datum {ty: ty, ..self}), bcx) + (Some(Datum {ty: ty, ..*self}), bcx) } } } @@ -752,7 +756,7 @@ pub impl Datum { } } - fn deref(bcx: block, + fn deref(&self, bcx: block, expr: @ast::expr, // the expression whose value is being deref'd derefs: uint) -> DatumBlock { @@ -765,7 +769,7 @@ pub impl Datum { } } - fn autoderef(bcx: block, + fn autoderef(&self, bcx: block, expr_id: ast::node_id, max: uint) -> DatumBlock { @@ -775,7 +779,7 @@ pub impl Datum { expr_id, max, self.to_str(bcx.ccx())); let _indenter = indenter(); - let mut datum = self; + let mut datum = *self; let mut derefs = 0u; let mut bcx = bcx; while derefs < max { @@ -796,56 +800,56 @@ pub impl Datum { DatumBlock { bcx: bcx, datum: datum } } - fn get_base_and_len(bcx: block) -> (ValueRef, ValueRef) { + fn get_base_and_len(&self, bcx: block) -> (ValueRef, ValueRef) { tvec::get_base_and_len(bcx, self.to_appropriate_llval(bcx), self.ty) } - fn to_result(bcx: block) -> common::Result { + fn to_result(&self, bcx: block) -> common::Result { rslt(bcx, self.to_appropriate_llval(bcx)) } } pub impl DatumBlock { - fn unpack(bcx: &mut block) -> Datum { + fn unpack(&self, bcx: &mut block) -> Datum { *bcx = self.bcx; return self.datum; } - fn assert_by_ref() -> DatumBlock { + fn assert_by_ref(&self) -> DatumBlock { assert self.datum.mode.is_by_ref(); - self + *self } - fn drop_val() -> block { + fn drop_val(&self) -> block { self.datum.drop_val(self.bcx) } - fn store_to(id: ast::node_id, action: CopyAction, + fn store_to(&self, id: ast::node_id, action: CopyAction, dst: ValueRef) -> block { self.datum.store_to(self.bcx, id, action, dst) } - fn copy_to(action: CopyAction, dst: ValueRef) -> block { + fn copy_to(&self, action: CopyAction, dst: ValueRef) -> block { self.datum.copy_to(self.bcx, action, dst) } - fn move_to(action: CopyAction, dst: ValueRef) -> block { + fn move_to(&self, action: CopyAction, dst: ValueRef) -> block { self.datum.move_to(self.bcx, action, dst) } - fn to_value_llval() -> ValueRef { + fn to_value_llval(&self) -> ValueRef { self.datum.to_value_llval(self.bcx) } - fn to_result() -> common::Result { + fn to_result(&self) -> common::Result { rslt(self.bcx, self.datum.to_appropriate_llval(self.bcx)) } - fn ccx() -> @CrateContext { + fn ccx(&self) -> @CrateContext { self.bcx.ccx() } - fn tcx() -> ty::ctxt { + fn tcx(&self) -> ty::ctxt { self.bcx.tcx() } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 83265975b50..a7b12d13d4e 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -157,8 +157,8 @@ pub enum Dest { } impl Dest { - fn to_str(ccx: @CrateContext) -> ~str { - match self { + fn to_str(&self, ccx: @CrateContext) -> ~str { + match *self { SaveIn(v) => fmt!("SaveIn(%s)", val_str(ccx.tn, v)), Ignore => ~"Ignore" } diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 345a20aa5fc..df89647321a 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -146,7 +146,7 @@ pub struct VecTypes { } pub impl VecTypes { - fn to_str(ccx: @CrateContext) -> ~str { + fn to_str(&self, ccx: @CrateContext) -> ~str { fmt!("VecTypes {vec_ty=%s, unit_ty=%s, llunit_ty=%s, llunit_size=%s}", ty_to_str(ccx.tcx, self.vec_ty), ty_to_str(ccx.tcx, self.unit_ty), diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index fdcbf2d9957..239e86623ca 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -657,11 +657,11 @@ impl to_bytes::IterBytes for param_bound { } pub trait Vid { - pure fn to_uint() -> uint; + pure fn to_uint(&self) -> uint; } pub impl Vid for TyVid { - pure fn to_uint() -> uint { *self } + pure fn to_uint(&self) -> uint { **self } } pub impl ToStr for TyVid { @@ -669,7 +669,7 @@ pub impl ToStr for TyVid { } pub impl Vid for IntVid { - pure fn to_uint() -> uint { *self } + pure fn to_uint(&self) -> uint { **self } } pub impl ToStr for IntVid { @@ -677,7 +677,7 @@ pub impl ToStr for IntVid { } pub impl Vid for FloatVid { - pure fn to_uint() -> uint { *self } + pure fn to_uint(&self) -> uint { **self } } pub impl ToStr for FloatVid { @@ -685,7 +685,7 @@ pub impl ToStr for FloatVid { } pub impl Vid for RegionVid { - pure fn to_uint() -> uint { *self } + pure fn to_uint(&self) -> uint { **self } } pub impl ToStr for RegionVid { diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 3553caf5c33..e63e46ace3d 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -660,19 +660,19 @@ pub impl FnCtxt { } pub impl region_scope for @mut FnCtxt { - pure fn anon_region(span: span) -> Result { + pure fn anon_region(&self, span: span) -> Result { // XXX: Unsafe to work around purity unsafe { result::Ok(self.infcx().next_region_var_nb(span)) } } - pure fn self_region(_span: span) -> Result { + pure fn self_region(&self, _span: span) -> Result { // XXX: Unsafe to work around purity unsafe { self.search_in_scope_regions(ty::br_self) } } - pure fn named_region(_span: span, id: ast::ident) + pure fn named_region(&self, _span: span, id: ast::ident) -> Result { // XXX: Unsafe to work around purity unsafe { diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 649f4c79878..29738f28266 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -197,6 +197,7 @@ pub struct CoherenceChecker { } pub impl CoherenceChecker { + // IMPLICIT SELF WARNING: fix this! fn check_coherence(crate: @crate) { // Check implementations and traits. This populates the tables // containing the inherent methods and extension methods. It also @@ -235,7 +236,8 @@ pub impl CoherenceChecker { self.populate_destructor_table(); } - fn check_implementation(item: @item, associated_traits: ~[@trait_ref]) { + fn check_implementation(&self, + item: @item, associated_traits: ~[@trait_ref]) { let self_type = self.crate_context.tcx.tcache.get( &local_def(item.id)); @@ -302,7 +304,8 @@ pub impl CoherenceChecker { let implementation; match implementation_opt { None => { - implementation = self.create_impl_from_item(item); + implementation = + self.create_impl_from_item(item); } Some(copy existing_implementation) => { implementation = existing_implementation; @@ -321,7 +324,7 @@ pub impl CoherenceChecker { // Creates default method IDs and performs type substitutions for an impl // and trait pair. Then, for each provided method in the trait, inserts a // `ProvidedMethodInfo` instance into the `provided_method_sources` map. - fn instantiate_default_methods(impl_id: ast::node_id, + fn instantiate_default_methods(&self, impl_id: ast::node_id, trait_did: ast::def_id) { for self.each_provided_trait_method(trait_did) |trait_method| { // Synthesize an ID. @@ -330,7 +333,8 @@ pub impl CoherenceChecker { let new_did = local_def(new_id); // XXX: Perform substitutions. - let new_polytype = ty::lookup_item_type(tcx, trait_method.def_id); + let new_polytype = ty::lookup_item_type(tcx, + trait_method.def_id); tcx.tcache.insert(new_did, new_polytype); // Pair the new synthesized ID up with the @@ -380,7 +384,8 @@ pub impl CoherenceChecker { } } - fn add_inherent_method(base_def_id: def_id, implementation: @Impl) { + fn add_inherent_method(&self, + base_def_id: def_id, implementation: @Impl) { let implementation_list; match self.crate_context.coherence_info.inherent_methods .find(&base_def_id) { @@ -397,7 +402,7 @@ pub impl CoherenceChecker { implementation_list.push(implementation); } - fn add_trait_method(trait_id: def_id, implementation: @Impl) { + fn add_trait_method(&self, trait_id: def_id, implementation: @Impl) { let implementation_list; match self.crate_context.coherence_info.extension_methods .find(&trait_id) { @@ -414,7 +419,7 @@ pub impl CoherenceChecker { implementation_list.push(implementation); } - fn check_implementation_coherence() { + fn check_implementation_coherence(&self) { let coherence_info = &mut self.crate_context.coherence_info; let extension_methods = &coherence_info.extension_methods; @@ -423,7 +428,7 @@ pub impl CoherenceChecker { } } - fn check_implementation_coherence_of(trait_def_id: def_id) { + fn check_implementation_coherence_of(&self, trait_def_id: def_id) { // Unify pairs of polytypes. do self.iter_impls_of_trait(trait_def_id) |a| { @@ -459,7 +464,8 @@ pub impl CoherenceChecker { // Adds an impl of trait trait_t for self type self_t; that impl // is the_impl - fn add_impl_for_trait(trait_t: def_id, self_t: t, the_impl: @Impl) { + fn add_impl_for_trait(&self, + trait_t: def_id, self_t: t, the_impl: @Impl) { debug!("Adding impl %? of %? for %s", the_impl.did, trait_t, ty_to_str(self.crate_context.tcx, self_t)); @@ -475,7 +481,7 @@ pub impl CoherenceChecker { } } - fn iter_impls_of_trait(trait_def_id: def_id, + fn iter_impls_of_trait(&self, trait_def_id: def_id, f: &fn(@Impl)) { let coherence_info = &mut self.crate_context.coherence_info; @@ -491,7 +497,7 @@ pub impl CoherenceChecker { } } - fn each_provided_trait_method( + fn each_provided_trait_method(&self, trait_did: ast::def_id, f: &fn(x: &ty::method) -> bool) { // Make a list of all the names of the provided methods. @@ -511,7 +517,7 @@ pub impl CoherenceChecker { } } - fn polytypes_unify(polytype_a: ty_param_bounds_and_ty, + fn polytypes_unify(&self, polytype_a: ty_param_bounds_and_ty, polytype_b: ty_param_bounds_and_ty) -> bool { let universally_quantified_a = @@ -527,7 +533,7 @@ pub impl CoherenceChecker { // Converts a polytype to a monotype by replacing all parameters with // type variables. Returns the monotype and the type variables created. - fn universally_quantify_polytype(polytype: ty_param_bounds_and_ty) + fn universally_quantify_polytype(&self, polytype: ty_param_bounds_and_ty) -> UniversalQuantificationResult { // NDM--this span is bogus. let self_region = @@ -558,7 +564,8 @@ pub impl CoherenceChecker { } } - fn can_unify_universally_quantified(a: &a/UniversalQuantificationResult, + fn can_unify_universally_quantified(&self, + a: &a/UniversalQuantificationResult, b: &a/UniversalQuantificationResult) -> bool { let mut might_unify = true; @@ -610,12 +617,13 @@ pub impl CoherenceChecker { might_unify } - fn get_self_type_for_implementation(implementation: @Impl) + fn get_self_type_for_implementation(&self, implementation: @Impl) -> ty_param_bounds_and_ty { return self.crate_context.tcx.tcache.get(&implementation.did); } // Privileged scope checking + // IMPLICIT SELF WARNING: fix this! fn check_privileged_scopes(crate: @crate) { visit_crate(*crate, (), mk_vt(@Visitor { visit_item: |item, _context, visitor| { @@ -699,7 +707,7 @@ pub impl CoherenceChecker { })); } - fn trait_ref_to_trait_def_id(trait_ref: @trait_ref) -> def_id { + fn trait_ref_to_trait_def_id(&self, trait_ref: @trait_ref) -> def_id { let def_map = self.crate_context.tcx.def_map; let trait_def = def_map.get(&trait_ref.ref_id); let trait_id = def_id_of_def(trait_def); @@ -708,7 +716,7 @@ pub impl CoherenceChecker { // This check doesn't really have anything to do with coherence. It's // here for historical reasons - fn please_check_that_trait_methods_are_implemented( + fn please_check_that_trait_methods_are_implemented(&self, all_methods: &mut ~[@MethodInfo], trait_did: def_id, trait_ref_span: span) { @@ -735,7 +743,7 @@ pub impl CoherenceChecker { } // Converts an implementation in the AST to an Impl structure. - fn create_impl_from_item(item: @item) -> @Impl { + fn create_impl_from_item(&self, item: @item) -> @Impl { fn add_provided_methods(all_methods: &mut ~[@MethodInfo], all_provided_methods: ~[@ProvidedMethodInfo], sess: driver::session::Session) { @@ -806,7 +814,7 @@ pub impl CoherenceChecker { } } - fn span_of_impl(implementation: @Impl) -> span { + fn span_of_impl(&self, implementation: @Impl) -> span { assert implementation.did.crate == local_crate; match self.crate_context.tcx.items.find(&implementation.did.node) { Some(node_item(item, _)) => { @@ -822,7 +830,7 @@ pub impl CoherenceChecker { // External crate handling - fn add_impls_for_module(impls_seen: HashMap, + fn add_impls_for_module(&self, impls_seen: HashMap, crate_store: @mut CStore, module_def_id: def_id) { let implementations = get_impls_for_mod(crate_store, @@ -907,7 +915,8 @@ pub impl CoherenceChecker { } } - fn add_default_methods_for_external_trait(trait_def_id: ast::def_id) { + fn add_default_methods_for_external_trait(&self, + trait_def_id: ast::def_id) { let tcx = self.crate_context.tcx; let pmm = tcx.provided_methods; @@ -942,7 +951,7 @@ pub impl CoherenceChecker { // Adds implementations and traits from external crates to the coherence // info. - fn add_external_crates() { + fn add_external_crates(&self) { let impls_seen = HashMap(); let crate_store = self.crate_context.tcx.sess.cstore; @@ -983,7 +992,7 @@ pub impl CoherenceChecker { // Destructors // - fn populate_destructor_table() { + fn populate_destructor_table(&self) { let coherence_info = &mut self.crate_context.coherence_info; let tcx = self.crate_context.tcx; let drop_trait = tcx.lang_items.drop_trait(); diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index 34068a5eb0d..1c6b1507629 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -78,37 +78,38 @@ pub fn macros() { } pub trait Combine { - fn infcx() -> @mut InferCtxt; - fn tag() -> ~str; - fn a_is_expected() -> bool; - fn span() -> span; + fn infcx(&self) -> @mut InferCtxt; + fn tag(&self) -> ~str; + fn a_is_expected(&self) -> bool; + fn span(&self) -> span; - fn sub() -> Sub; - fn lub() -> Lub; - fn glb() -> Glb; + fn sub(&self) -> Sub; + fn lub(&self) -> Lub; + fn glb(&self) -> Glb; - fn mts(a: ty::mt, b: ty::mt) -> cres; - fn contratys(a: ty::t, b: ty::t) -> cres; - fn tys(a: ty::t, b: ty::t) -> cres; - fn tps(as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]>; - fn self_tys(a: Option, b: Option) -> cres>; - fn substs(did: ast::def_id, as_: &ty::substs, + fn mts(&self, a: ty::mt, b: ty::mt) -> cres; + fn contratys(&self, a: ty::t, b: ty::t) -> cres; + fn tys(&self, a: ty::t, b: ty::t) -> cres; + fn tps(&self, as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]>; + fn self_tys(&self, a: Option, b: Option) + -> cres>; + fn substs(&self, did: ast::def_id, as_: &ty::substs, bs: &ty::substs) -> cres; - fn bare_fn_tys(a: &ty::BareFnTy, + fn bare_fn_tys(&self, a: &ty::BareFnTy, b: &ty::BareFnTy) -> cres; - fn closure_tys(a: &ty::ClosureTy, + fn closure_tys(&self, a: &ty::ClosureTy, b: &ty::ClosureTy) -> cres; - fn fn_sigs(a: &ty::FnSig, b: &ty::FnSig) -> cres; - fn flds(a: ty::field, b: ty::field) -> cres; - fn modes(a: ast::mode, b: ast::mode) -> cres; - fn args(a: ty::arg, b: ty::arg) -> cres; - fn sigils(p1: ast::Sigil, p2: ast::Sigil) -> cres; - fn purities(a: purity, b: purity) -> cres; - fn abis(a: ast::Abi, b: ast::Abi) -> cres; - fn oncenesses(a: Onceness, b: Onceness) -> cres; - fn contraregions(a: ty::Region, b: ty::Region) -> cres; - fn regions(a: ty::Region, b: ty::Region) -> cres; - fn vstores(vk: ty::terr_vstore_kind, + fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres; + fn flds(&self, a: ty::field, b: ty::field) -> cres; + fn modes(&self, a: ast::mode, b: ast::mode) -> cres; + fn args(&self, a: ty::arg, b: ty::arg) -> cres; + fn sigils(&self, p1: ast::Sigil, p2: ast::Sigil) -> cres; + fn purities(&self, a: purity, b: purity) -> cres; + fn abis(&self, a: ast::Abi, b: ast::Abi) -> cres; + fn oncenesses(&self, a: Onceness, b: Onceness) -> cres; + fn contraregions(&self, a: ty::Region, b: ty::Region) -> cres; + fn regions(&self, a: ty::Region, b: ty::Region) -> cres; + fn vstores(&self, vk: ty::terr_vstore_kind, a: ty::vstore, b: ty::vstore) -> cres; } diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 464a149a488..5008791723e 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -28,16 +28,16 @@ use std::list; pub enum Glb = CombineFields; // "greatest lower bound" (common subtype) pub impl Combine for Glb { - fn infcx() -> @mut InferCtxt { self.infcx } - fn tag() -> ~str { ~"glb" } - fn a_is_expected() -> bool { self.a_is_expected } - fn span() -> span { self.span } + fn infcx(&self) -> @mut InferCtxt { self.infcx } + fn tag(&self) -> ~str { ~"glb" } + fn a_is_expected(&self) -> bool { self.a_is_expected } + fn span(&self) -> span { self.span } - fn sub() -> Sub { Sub(*self) } - fn lub() -> Lub { Lub(*self) } - fn glb() -> Glb { Glb(*self) } + fn sub(&self) -> Sub { Sub(**self) } + fn lub(&self) -> Lub { Lub(**self) } + fn glb(&self) -> Glb { Glb(**self) } - fn mts(a: ty::mt, b: ty::mt) -> cres { + fn mts(&self, a: ty::mt, b: ty::mt) -> cres { let tcx = self.infcx.tcx; debug!("%s.mts(%s, %s)", @@ -49,17 +49,17 @@ pub impl Combine for Glb { // If one side or both is mut, then the GLB must use // the precise type from the mut side. (m_mutbl, m_const) => { - Sub(*self).tys(a.ty, b.ty).chain(|_t| { + Sub(**self).tys(a.ty, b.ty).chain(|_t| { Ok(ty::mt {ty: a.ty, mutbl: m_mutbl}) }) } (m_const, m_mutbl) => { - Sub(*self).tys(b.ty, a.ty).chain(|_t| { + Sub(**self).tys(b.ty, a.ty).chain(|_t| { Ok(ty::mt {ty: b.ty, mutbl: m_mutbl}) }) } (m_mutbl, m_mutbl) => { - eq_tys(&self, a.ty, b.ty).then(|| { + eq_tys(self, a.ty, b.ty).then(|| { Ok(ty::mt {ty: a.ty, mutbl: m_mutbl}) }) } @@ -90,11 +90,11 @@ pub impl Combine for Glb { } } - fn contratys(a: ty::t, b: ty::t) -> cres { - Lub(*self).tys(a, b) + fn contratys(&self, a: ty::t, b: ty::t) -> cres { + Lub(**self).tys(a, b) } - fn purities(a: purity, b: purity) -> cres { + fn purities(&self, a: purity, b: purity) -> cres { match (a, b) { (pure_fn, _) | (_, pure_fn) => Ok(pure_fn), (extern_fn, _) | (_, extern_fn) => Ok(extern_fn), @@ -103,14 +103,14 @@ pub impl Combine for Glb { } } - fn oncenesses(a: Onceness, b: Onceness) -> cres { + fn oncenesses(&self, a: Onceness, b: Onceness) -> cres { match (a, b) { (Many, _) | (_, Many) => Ok(Many), (Once, Once) => Ok(Once) } } - fn regions(a: ty::Region, b: ty::Region) -> cres { + fn regions(&self, a: ty::Region, b: ty::Region) -> cres { debug!("%s.regions(%?, %?)", self.tag(), a.inf_str(self.infcx), @@ -121,34 +121,35 @@ pub impl Combine for Glb { } } - fn contraregions(a: ty::Region, b: ty::Region) -> cres { - Lub(*self).regions(a, b) + fn contraregions(&self, a: ty::Region, b: ty::Region) + -> cres { + Lub(**self).regions(a, b) } - fn tys(a: ty::t, b: ty::t) -> cres { - super_lattice_tys(&self, a, b) + fn tys(&self, a: ty::t, b: ty::t) -> cres { + super_lattice_tys(self, a, b) } // Traits please (FIXME: #2794): - fn flds(a: ty::field, b: ty::field) -> cres { - super_flds(&self, a, b) + fn flds(&self, a: ty::field, b: ty::field) -> cres { + super_flds(self, a, b) } - fn vstores(vk: ty::terr_vstore_kind, + fn vstores(&self, vk: ty::terr_vstore_kind, a: ty::vstore, b: ty::vstore) -> cres { - super_vstores(&self, vk, a, b) + super_vstores(self, vk, a, b) } - fn modes(a: ast::mode, b: ast::mode) -> cres { - super_modes(&self, a, b) + fn modes(&self, a: ast::mode, b: ast::mode) -> cres { + super_modes(self, a, b) } - fn args(a: ty::arg, b: ty::arg) -> cres { - super_args(&self, a, b) + fn args(&self, a: ty::arg, b: ty::arg) -> cres { + super_args(self, a, b) } - fn fn_sigs(a: &ty::FnSig, b: &ty::FnSig) -> cres { + fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres { // Note: this is a subtle algorithm. For a full explanation, // please see the large comment in `region_inference.rs`. @@ -166,14 +167,14 @@ pub impl Combine for Glb { let (a_with_fresh, a_isr) = self.infcx.replace_bound_regions_with_fresh_regions( self.span, a); - let a_vars = var_ids(&self, a_isr); + let a_vars = var_ids(self, a_isr); let (b_with_fresh, b_isr) = self.infcx.replace_bound_regions_with_fresh_regions( self.span, b); - let b_vars = var_ids(&self, b_isr); + let b_vars = var_ids(self, b_isr); // Collect constraints. - let sig0 = if_ok!(super_fn_sigs(&self, &a_with_fresh, &b_with_fresh)); + let sig0 = if_ok!(super_fn_sigs(self, &a_with_fresh, &b_with_fresh)); debug!("sig0 = %s", sig0.inf_str(self.infcx)); // Generalize the regions appearing in fn_ty0 if possible @@ -182,7 +183,7 @@ pub impl Combine for Glb { let sig1 = self.infcx.fold_regions_in_sig( &sig0, - |r, _in_fn| generalize_region(&self, snapshot, + |r, _in_fn| generalize_region(self, snapshot, new_vars, a_isr, a_vars, b_vars, r)); debug!("sig1 = %s", sig1.inf_str(self.infcx)); @@ -267,36 +268,37 @@ pub impl Combine for Glb { } } - fn sigils(p1: ast::Sigil, p2: ast::Sigil) -> cres { - super_sigils(&self, p1, p2) + fn sigils(&self, p1: ast::Sigil, p2: ast::Sigil) -> cres { + super_sigils(self, p1, p2) } - fn abis(p1: ast::Abi, p2: ast::Abi) -> cres { - super_abis(&self, p1, p2) + fn abis(&self, p1: ast::Abi, p2: ast::Abi) -> cres { + super_abis(self, p1, p2) } - fn bare_fn_tys(a: &ty::BareFnTy, + fn bare_fn_tys(&self, a: &ty::BareFnTy, b: &ty::BareFnTy) -> cres { - super_bare_fn_tys(&self, a, b) + super_bare_fn_tys(self, a, b) } - fn closure_tys(a: &ty::ClosureTy, + fn closure_tys(&self, a: &ty::ClosureTy, b: &ty::ClosureTy) -> cres { - super_closure_tys(&self, a, b) + super_closure_tys(self, a, b) } - fn substs(did: ast::def_id, + fn substs(&self, did: ast::def_id, as_: &ty::substs, bs: &ty::substs) -> cres { - super_substs(&self, did, as_, bs) + super_substs(self, did, as_, bs) } - fn tps(as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]> { - super_tps(&self, as_, bs) + fn tps(&self, as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]> { + super_tps(self, as_, bs) } - fn self_tys(a: Option, b: Option) -> cres> { - super_self_tys(&self, a, b) + fn self_tys(&self, a: Option, b: Option) + -> cres> { + super_self_tys(self, a, b) } } diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index c7ee1b871a8..1a919ac0f3b 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -50,23 +50,27 @@ use middle::typeck::infer::to_str::InferStr; use std::list; pub trait LatticeValue { - static fn sub(cf: &CombineFields, a: &Self, b: &Self) -> ures; - static fn lub(cf: &CombineFields, a: &Self, b: &Self) -> cres; - static fn glb(cf: &CombineFields, a: &Self, b: &Self) -> cres; + static fn sub(&self, cf: &CombineFields, a: &Self, b: &Self) -> ures; + static fn lub(&self, cf: &CombineFields, a: &Self, b: &Self) + -> cres; + static fn glb(&self, cf: &CombineFields, a: &Self, b: &Self) + -> cres; } pub type LatticeOp = &fn(cf: &CombineFields, a: &T, b: &T) -> cres; pub impl LatticeValue for ty::t { - static fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures { + static fn sub(&self, cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures { Sub(*cf).tys(*a, *b).to_ures() } - static fn lub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> cres { + static fn lub(&self, cf: &CombineFields, a: &ty::t, b: &ty::t) + -> cres { Lub(*cf).tys(*a, *b) } - static fn glb(cf: &CombineFields, a: &ty::t, b: &ty::t) -> cres { + static fn glb(&self, cf: &CombineFields, a: &ty::t, b: &ty::t) + -> cres { Glb(*cf).tys(*a, *b) } } @@ -292,39 +296,39 @@ pub impl CombineFields { // for pairs of variables or for variables and values. pub trait LatticeDir { - fn combine_fields() -> CombineFields; - fn bnd(b: &Bounds) -> Option; - fn with_bnd(b: &Bounds, +t: T) -> Bounds; + fn combine_fields(&self) -> CombineFields; + fn bnd(&self, b: &Bounds) -> Option; + fn with_bnd(&self, b: &Bounds, +t: T) -> Bounds; } pub trait TyLatticeDir { - fn ty_bot(t: ty::t) -> cres; + fn ty_bot(&self, t: ty::t) -> cres; } pub impl LatticeDir for Lub { - fn combine_fields() -> CombineFields { *self } - fn bnd(b: &Bounds) -> Option { b.ub } - fn with_bnd(b: &Bounds, +t: T) -> Bounds { + fn combine_fields(&self) -> CombineFields { **self } + fn bnd(&self, b: &Bounds) -> Option { b.ub } + fn with_bnd(&self, b: &Bounds, +t: T) -> Bounds { Bounds { ub: Some(t), ..*b } } } pub impl TyLatticeDir for Lub { - fn ty_bot(t: ty::t) -> cres { + fn ty_bot(&self, t: ty::t) -> cres { Ok(t) } } pub impl LatticeDir for Glb { - fn combine_fields() -> CombineFields { *self } - fn bnd(b: &Bounds) -> Option { b.lb } - fn with_bnd(b: &Bounds, +t: T) -> Bounds { + fn combine_fields(&self) -> CombineFields { **self } + fn bnd(&self, b: &Bounds) -> Option { b.lb } + fn with_bnd(&self, b: &Bounds, +t: T) -> Bounds { Bounds { lb: Some(t), ..*b } } } pub impl TyLatticeDir for Glb { - fn ty_bot(_t: ty::t) -> cres { + fn ty_bot(&self, _t: ty::t) -> cres { Ok(ty::mk_bot(self.infcx.tcx)) } } diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 60f6cd40e04..df4b8c0be09 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -32,21 +32,22 @@ pub fn macros() { pub enum Lub = CombineFields; // least-upper-bound: common supertype pub impl Lub { - fn bot_ty(b: ty::t) -> cres { Ok(b) } - fn ty_bot(b: ty::t) -> cres { self.bot_ty(b) } // commutative + fn bot_ty(&self, b: ty::t) -> cres { Ok(b) } + fn ty_bot(&self, b: ty::t) + -> cres { self.bot_ty(b) } // commutative } pub impl Combine for Lub { - fn infcx() -> @mut InferCtxt { self.infcx } - fn tag() -> ~str { ~"lub" } - fn a_is_expected() -> bool { self.a_is_expected } - fn span() -> span { self.span } + fn infcx(&self) -> @mut InferCtxt { self.infcx } + fn tag(&self) -> ~str { ~"lub" } + fn a_is_expected(&self) -> bool { self.a_is_expected } + fn span(&self) -> span { self.span } - fn sub() -> Sub { Sub(*self) } - fn lub() -> Lub { Lub(*self) } - fn glb() -> Glb { Glb(*self) } + fn sub(&self) -> Sub { Sub(**self) } + fn lub(&self) -> Lub { Lub(**self) } + fn glb(&self) -> Glb { Glb(**self) } - fn mts(a: ty::mt, b: ty::mt) -> cres { + fn mts(&self, a: ty::mt, b: ty::mt) -> cres { let tcx = self.infcx.tcx; debug!("%s.mts(%s, %s)", @@ -67,7 +68,7 @@ pub impl Combine for Lub { m_mutbl => { self.infcx.try(|| { - eq_tys(&self, a.ty, b.ty).then(|| { + eq_tys(self, a.ty, b.ty).then(|| { Ok(ty::mt {ty: a.ty, mutbl: m}) }) }).chain_err(|_e| { @@ -79,11 +80,11 @@ pub impl Combine for Lub { } } - fn contratys(a: ty::t, b: ty::t) -> cres { - Glb(*self).tys(a, b) + fn contratys(&self, a: ty::t, b: ty::t) -> cres { + Glb(**self).tys(a, b) } - fn purities(a: purity, b: purity) -> cres { + fn purities(&self, a: purity, b: purity) -> cres { match (a, b) { (unsafe_fn, _) | (_, unsafe_fn) => Ok(unsafe_fn), (impure_fn, _) | (_, impure_fn) => Ok(impure_fn), @@ -92,18 +93,19 @@ pub impl Combine for Lub { } } - fn oncenesses(a: Onceness, b: Onceness) -> cres { + fn oncenesses(&self, a: Onceness, b: Onceness) -> cres { match (a, b) { (Once, _) | (_, Once) => Ok(Once), (Many, Many) => Ok(Many) } } - fn contraregions(a: ty::Region, b: ty::Region) -> cres { - return Glb(*self).regions(a, b); + fn contraregions(&self, a: ty::Region, b: ty::Region) + -> cres { + return Glb(**self).regions(a, b); } - fn regions(a: ty::Region, b: ty::Region) -> cres { + fn regions(&self, a: ty::Region, b: ty::Region) -> cres { debug!("%s.regions(%?, %?)", self.tag(), a.inf_str(self.infcx), @@ -114,7 +116,7 @@ pub impl Combine for Lub { } } - fn fn_sigs(a: &ty::FnSig, b: &ty::FnSig) -> cres { + fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres { // Note: this is a subtle algorithm. For a full explanation, // please see the large comment in `region_inference.rs`. @@ -133,7 +135,7 @@ pub impl Combine for Lub { self.span, b); // Collect constraints. - let sig0 = if_ok!(super_fn_sigs(&self, &a_with_fresh, &b_with_fresh)); + let sig0 = if_ok!(super_fn_sigs(self, &a_with_fresh, &b_with_fresh)); debug!("sig0 = %s", sig0.inf_str(self.infcx)); // Generalize the regions appearing in sig0 if possible @@ -142,7 +144,7 @@ pub impl Combine for Lub { let sig1 = self.infcx.fold_regions_in_sig( &sig0, - |r, _in_fn| generalize_region(&self, snapshot, new_vars, + |r, _in_fn| generalize_region(self, snapshot, new_vars, a_isr, r)); return Ok(sig1); @@ -191,58 +193,60 @@ pub impl Combine for Lub { } } - fn bare_fn_tys(a: &ty::BareFnTy, + fn bare_fn_tys(&self, a: &ty::BareFnTy, b: &ty::BareFnTy) -> cres { - super_bare_fn_tys(&self, a, b) + super_bare_fn_tys(self, a, b) } - fn closure_tys(a: &ty::ClosureTy, + fn closure_tys(&self, a: &ty::ClosureTy, b: &ty::ClosureTy) -> cres { - super_closure_tys(&self, a, b) + super_closure_tys(self, a, b) } // Traits please (FIXME: #2794): - fn sigils(p1: ast::Sigil, p2: ast::Sigil) -> cres { - super_sigils(&self, p1, p2) + fn sigils(&self, p1: ast::Sigil, p2: ast::Sigil) + -> cres { + super_sigils(self, p1, p2) } - fn abis(p1: ast::Abi, p2: ast::Abi) -> cres { - super_abis(&self, p1, p2) + fn abis(&self, p1: ast::Abi, p2: ast::Abi) -> cres { + super_abis(self, p1, p2) } - fn tys(a: ty::t, b: ty::t) -> cres { - super_lattice_tys(&self, a, b) + fn tys(&self, a: ty::t, b: ty::t) -> cres { + super_lattice_tys(self, a, b) } - fn flds(a: ty::field, b: ty::field) -> cres { - super_flds(&self, a, b) + fn flds(&self, a: ty::field, b: ty::field) -> cres { + super_flds(self, a, b) } - fn vstores(vk: ty::terr_vstore_kind, + fn vstores(&self, vk: ty::terr_vstore_kind, a: ty::vstore, b: ty::vstore) -> cres { - super_vstores(&self, vk, a, b) + super_vstores(self, vk, a, b) } - fn modes(a: ast::mode, b: ast::mode) -> cres { - super_modes(&self, a, b) + fn modes(&self, a: ast::mode, b: ast::mode) -> cres { + super_modes(self, a, b) } - fn args(a: ty::arg, b: ty::arg) -> cres { - super_args(&self, a, b) + fn args(&self, a: ty::arg, b: ty::arg) -> cres { + super_args(self, a, b) } - fn substs(did: ast::def_id, + fn substs(&self, did: ast::def_id, as_: &ty::substs, bs: &ty::substs) -> cres { - super_substs(&self, did, as_, bs) + super_substs(self, did, as_, bs) } - fn tps(as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]> { - super_tps(&self, as_, bs) + fn tps(&self, as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]> { + super_tps(self, as_, bs) } - fn self_tys(a: Option, b: Option) -> cres> { - super_self_tys(&self, a, b) + fn self_tys(&self, a: Option, b: Option) + -> cres> { + super_self_tys(self, a, b) } } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 7d799b7ea2f..f0137125952 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -489,24 +489,24 @@ fn resolve_borrowings(cx: @mut InferCtxt) { */ trait then { - fn then(f: fn() -> Result) + fn then(&self, f: fn() -> Result) -> Result; } impl then for ures { - fn then(f: fn() -> Result) + fn then(&self, f: fn() -> Result) -> Result { self.chain(|_i| f()) } } trait ToUres { - fn to_ures() -> ures; + fn to_ures(&self) -> ures; } impl ToUres for cres { - fn to_ures() -> ures { - match self { + fn to_ures(&self) -> ures { + match *self { Ok(ref _v) => Ok(()), Err(ref e) => Err((*e)) } @@ -514,14 +514,14 @@ impl ToUres for cres { } trait CresCompare { - fn compare(t: T, f: fn() -> ty::type_err) -> cres; + fn compare(&self, t: T, f: fn() -> ty::type_err) -> cres; } impl CresCompare for cres { - fn compare(t: T, f: fn() -> ty::type_err) -> cres { + fn compare(&self, t: T, f: fn() -> ty::type_err) -> cres { do self.chain |s| { if s == t { - self + *self } else { Err(f()) } @@ -551,22 +551,22 @@ struct Snapshot { } impl @mut InferCtxt { - fn combine_fields(a_is_expected: bool, + fn combine_fields(&self, a_is_expected: bool, span: span) -> CombineFields { - CombineFields {infcx: self, + CombineFields {infcx: *self, a_is_expected: a_is_expected, span: span} } - fn sub(a_is_expected: bool, span: span) -> Sub { + fn sub(&self, a_is_expected: bool, span: span) -> Sub { Sub(self.combine_fields(a_is_expected, span)) } - fn in_snapshot() -> bool { + fn in_snapshot(&self) -> bool { self.region_vars.in_snapshot() } - fn start_snapshot() -> Snapshot { + fn start_snapshot(&self) -> Snapshot { Snapshot { ty_var_bindings_len: self.ty_var_bindings.bindings.len(), @@ -579,7 +579,7 @@ impl @mut InferCtxt { } } - fn rollback_to(snapshot: &Snapshot) { + fn rollback_to(&self, snapshot: &Snapshot) { debug!("rollback!"); rollback_to(&mut self.ty_var_bindings, snapshot.ty_var_bindings_len); @@ -643,7 +643,7 @@ fn next_simple_var( } impl @mut InferCtxt { - fn next_ty_var_id() -> TyVid { + fn next_ty_var_id(&self) -> TyVid { let id = self.ty_var_counter; self.ty_var_counter += 1; let vals = self.ty_var_bindings.vals; @@ -651,37 +651,37 @@ impl @mut InferCtxt { return TyVid(id); } - fn next_ty_var() -> ty::t { + fn next_ty_var(&self) -> ty::t { ty::mk_var(self.tcx, self.next_ty_var_id()) } - fn next_ty_vars(n: uint) -> ~[ty::t] { + fn next_ty_vars(&self, n: uint) -> ~[ty::t] { vec::from_fn(n, |_i| self.next_ty_var()) } - fn next_int_var_id() -> IntVid { + fn next_int_var_id(&self) -> IntVid { IntVid(next_simple_var(&mut self.int_var_counter, &mut self.int_var_bindings)) } - fn next_int_var() -> ty::t { + fn next_int_var(&self) -> ty::t { ty::mk_int_var(self.tcx, self.next_int_var_id()) } - fn next_float_var_id() -> FloatVid { + fn next_float_var_id(&self) -> FloatVid { FloatVid(next_simple_var(&mut self.float_var_counter, &mut self.float_var_bindings)) } - fn next_float_var() -> ty::t { + fn next_float_var(&self) -> ty::t { ty::mk_float_var(self.tcx, self.next_float_var_id()) } - fn next_region_var_nb(span: span) -> ty::Region { + fn next_region_var_nb(&self, span: span) -> ty::Region { ty::re_infer(ty::ReVar(self.region_vars.new_region_var(span))) } - fn next_region_var_with_lb(span: span, + fn next_region_var_with_lb(&self, span: span, lb_region: ty::Region) -> ty::Region { let region_var = self.next_region_var_nb(span); @@ -693,27 +693,28 @@ impl @mut InferCtxt { return region_var; } - fn next_region_var(span: span, scope_id: ast::node_id) -> ty::Region { + fn next_region_var(&self, span: span, scope_id: ast::node_id) + -> ty::Region { self.next_region_var_with_lb(span, ty::re_scope(scope_id)) } - fn resolve_regions() { + fn resolve_regions(&self) { self.region_vars.resolve_regions(); } - fn ty_to_str(t: ty::t) -> ~str { + fn ty_to_str(&self, t: ty::t) -> ~str { ty_to_str(self.tcx, self.resolve_type_vars_if_possible(t)) } - fn resolve_type_vars_if_possible(typ: ty::t) -> ty::t { - match resolve_type(self, typ, resolve_nested_tvar | resolve_ivar) { + fn resolve_type_vars_if_possible(&self, typ: ty::t) -> ty::t { + match resolve_type(*self, typ, resolve_nested_tvar | resolve_ivar) { result::Ok(new_type) => new_type, result::Err(_) => typ } } - fn type_error_message(sp: span, mk_msg: fn(~str) -> ~str, + fn type_error_message(&self, sp: span, mk_msg: fn(~str) -> ~str, actual_ty: ty::t, err: Option<&ty::type_err>) { let actual_ty = self.resolve_type_vars_if_possible(actual_ty); @@ -731,7 +732,7 @@ impl @mut InferCtxt { ty::note_and_explain_type_err(self.tcx, *err)); } - fn report_mismatched_types(sp: span, e: ty::t, a: ty::t, + fn report_mismatched_types(&self, sp: span, e: ty::t, a: ty::t, err: &ty::type_err) { // Don't report an error if expected is ty_err let resolved_expected = @@ -749,7 +750,7 @@ impl @mut InferCtxt { self.type_error_message(sp, mk_msg, a, Some(err)); } - fn replace_bound_regions_with_fresh_regions( + fn replace_bound_regions_with_fresh_regions(&self, span: span, fsig: &ty::FnSig) -> (ty::FnSig, isr_alist) { diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 2c8c60a84fb..661c67dbefc 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -33,30 +33,31 @@ pub fn macros() { pub enum Sub = CombineFields; // "subtype", "subregion" etc pub impl Combine for Sub { - fn infcx() -> @mut InferCtxt { self.infcx } - fn tag() -> ~str { ~"sub" } - fn a_is_expected() -> bool { self.a_is_expected } - fn span() -> span { self.span } + fn infcx(&self) -> @mut InferCtxt { self.infcx } + fn tag(&self) -> ~str { ~"sub" } + fn a_is_expected(&self) -> bool { self.a_is_expected } + fn span(&self) -> span { self.span } - fn sub() -> Sub { Sub(*self) } - fn lub() -> Lub { Lub(*self) } - fn glb() -> Glb { Glb(*self) } + fn sub(&self) -> Sub { Sub(**self) } + fn lub(&self) -> Lub { Lub(**self) } + fn glb(&self) -> Glb { Glb(**self) } - fn contratys(a: ty::t, b: ty::t) -> cres { + fn contratys(&self, a: ty::t, b: ty::t) -> cres { let opp = CombineFields { - a_is_expected: !self.a_is_expected,.. *self + a_is_expected: !self.a_is_expected,.. **self }; Sub(opp).tys(b, a) } - fn contraregions(a: ty::Region, b: ty::Region) -> cres { + fn contraregions(&self, a: ty::Region, b: ty::Region) + -> cres { let opp = CombineFields { - a_is_expected: !self.a_is_expected,.. *self + a_is_expected: !self.a_is_expected,.. **self }; Sub(opp).regions(b, a) } - fn regions(a: ty::Region, b: ty::Region) -> cres { + fn regions(&self, a: ty::Region, b: ty::Region) -> cres { debug!("%s.regions(%s, %s)", self.tag(), a.inf_str(self.infcx), @@ -69,7 +70,7 @@ pub impl Combine for Sub { } } - fn mts(a: ty::mt, b: ty::mt) -> cres { + fn mts(&self, a: ty::mt, b: ty::mt) -> cres { debug!("mts(%s <: %s)", a.inf_str(self.infcx), b.inf_str(self.infcx)); if a.mutbl != b.mutbl && b.mutbl != m_const { @@ -80,7 +81,7 @@ pub impl Combine for Sub { m_mutbl => { // If supertype is mut, subtype must match exactly // (i.e., invariant if mut): - eq_tys(&self, a.ty, b.ty).then(|| Ok(a) ) + eq_tys(self, a.ty, b.ty).then(|| Ok(a) ) } m_imm | m_const => { // Otherwise we can be covariant: @@ -89,19 +90,19 @@ pub impl Combine for Sub { } } - fn purities(a: purity, b: purity) -> cres { + fn purities(&self, a: purity, b: purity) -> cres { self.lub().purities(a, b).compare(b, || { - ty::terr_purity_mismatch(expected_found(&self, a, b)) + ty::terr_purity_mismatch(expected_found(self, a, b)) }) } - fn oncenesses(a: Onceness, b: Onceness) -> cres { + fn oncenesses(&self, a: Onceness, b: Onceness) -> cres { self.lub().oncenesses(a, b).compare(b, || { - ty::terr_onceness_mismatch(expected_found(&self, a, b)) + ty::terr_onceness_mismatch(expected_found(self, a, b)) }) } - fn tys(a: ty::t, b: ty::t) -> cres { + fn tys(&self, a: ty::t, b: ty::t) -> cres { debug!("%s.tys(%s, %s)", self.tag(), a.inf_str(self.infcx), b.inf_str(self.infcx)); if a == b { return Ok(a); } @@ -125,16 +126,16 @@ pub impl Combine for Sub { } (_, &ty::ty_bot) => { - Err(ty::terr_sorts(expected_found(&self, a, b))) + Err(ty::terr_sorts(expected_found(self, a, b))) } _ => { - super_tys(&self, a, b) + super_tys(self, a, b) } } } - fn fn_sigs(a: &ty::FnSig, b: &ty::FnSig) -> cres { + fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres { debug!("fn_sigs(a=%s, b=%s)", a.inf_str(self.infcx), b.inf_str(self.infcx)); let _indenter = indenter(); @@ -175,7 +176,7 @@ pub impl Combine for Sub { debug!("b_sig=%s", b_sig.inf_str(self.infcx)); // Compare types now that bound regions have been replaced. - let sig = if_ok!(super_fn_sigs(&self, &a_sig, &b_sig)); + let sig = if_ok!(super_fn_sigs(self, &a_sig, &b_sig)); // Presuming type comparison succeeds, we need to check // that the skolemized regions do not "leak". @@ -212,53 +213,54 @@ pub impl Combine for Sub { // Traits please (FIXME: #2794): - fn sigils(p1: ast::Sigil, p2: ast::Sigil) -> cres { - super_sigils(&self, p1, p2) + fn sigils(&self, p1: ast::Sigil, p2: ast::Sigil) -> cres { + super_sigils(self, p1, p2) } - fn abis(p1: ast::Abi, p2: ast::Abi) -> cres { - super_abis(&self, p1, p2) + fn abis(&self, p1: ast::Abi, p2: ast::Abi) -> cres { + super_abis(self, p1, p2) } - fn flds(a: ty::field, b: ty::field) -> cres { - super_flds(&self, a, b) + fn flds(&self, a: ty::field, b: ty::field) -> cres { + super_flds(self, a, b) } - fn bare_fn_tys(a: &ty::BareFnTy, + fn bare_fn_tys(&self, a: &ty::BareFnTy, b: &ty::BareFnTy) -> cres { - super_bare_fn_tys(&self, a, b) + super_bare_fn_tys(self, a, b) } - fn closure_tys(a: &ty::ClosureTy, + fn closure_tys(&self, a: &ty::ClosureTy, b: &ty::ClosureTy) -> cres { - super_closure_tys(&self, a, b) + super_closure_tys(self, a, b) } - fn vstores(vk: ty::terr_vstore_kind, + fn vstores(&self, vk: ty::terr_vstore_kind, a: ty::vstore, b: ty::vstore) -> cres { - super_vstores(&self, vk, a, b) + super_vstores(self, vk, a, b) } - fn modes(a: ast::mode, b: ast::mode) -> cres { - super_modes(&self, a, b) + fn modes(&self, a: ast::mode, b: ast::mode) -> cres { + super_modes(self, a, b) } - fn args(a: ty::arg, b: ty::arg) -> cres { - super_args(&self, a, b) + fn args(&self, a: ty::arg, b: ty::arg) -> cres { + super_args(self, a, b) } - fn substs(did: ast::def_id, + fn substs(&self, did: ast::def_id, as_: &ty::substs, bs: &ty::substs) -> cres { - super_substs(&self, did, as_, bs) + super_substs(self, did, as_, bs) } - fn tps(as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]> { - super_tps(&self, as_, bs) + fn tps(&self, as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]> { + super_tps(self, as_, bs) } - fn self_tys(a: Option, b: Option) -> cres> { - super_self_tys(&self, a, b) + fn self_tys(&self, a: Option, b: Option) + -> cres> { + super_self_tys(self, a, b) } } diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 4f85718ad1e..d9b2b73890d 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -38,7 +38,7 @@ pub struct Node { } pub trait UnifyVid { - static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt) + static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) -> &v/mut ValsAndBindings; } @@ -147,7 +147,7 @@ pub impl InferCtxt { // doesn't have a subtyping relationship we need to worry about. pub trait SimplyUnifiable { - static fn to_type_err(expected_found) -> ty::type_err; + static fn to_type_err(&self, expected_found) -> ty::type_err; } pub fn mk_err(+a_is_expected: bool, @@ -238,35 +238,35 @@ pub impl InferCtxt { // ______________________________________________________________________ pub impl UnifyVid> for ty::TyVid { - static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt) + static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) -> &v/mut ValsAndBindings> { return &mut infcx.ty_var_bindings; } } pub impl UnifyVid> for ty::IntVid { - static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt) + static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) -> &v/mut ValsAndBindings> { return &mut infcx.int_var_bindings; } } pub impl SimplyUnifiable for IntVarValue { - static fn to_type_err(err: expected_found) + static fn to_type_err(&self, err: expected_found) -> ty::type_err { return ty::terr_int_mismatch(err); } } pub impl UnifyVid> for ty::FloatVid { - static fn appropriate_vals_and_bindings(infcx: &v/mut InferCtxt) + static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) -> &v/mut ValsAndBindings> { return &mut infcx.float_var_bindings; } } pub impl SimplyUnifiable for ast::float_ty { - static fn to_type_err(err: expected_found) + static fn to_type_err(&self, err: expected_found) -> ty::type_err { return ty::terr_float_mismatch(err); } diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 05820bed0d0..49b818328be 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -172,8 +172,8 @@ pub enum vtable_origin { } pub impl vtable_origin { - fn to_str(tcx: ty::ctxt) -> ~str { - match self { + fn to_str(&self, tcx: ty::ctxt) -> ~str { + match *self { vtable_static(def_id, ref tys, ref vtable_res) => { fmt!("vtable_static(%?:%s, %?, %?)", def_id, ty::item_path_str(tcx, def_id), @@ -279,17 +279,17 @@ pub fn require_same_types( pub type isr_alist = @List<(ty::bound_region, ty::Region)>; trait get_and_find_region { - fn get(br: ty::bound_region) -> ty::Region; - fn find(br: ty::bound_region) -> Option; + fn get(&self, br: ty::bound_region) -> ty::Region; + fn find(&self, br: ty::bound_region) -> Option; } impl get_and_find_region for isr_alist { - fn get(br: ty::bound_region) -> ty::Region { + fn get(&self, br: ty::bound_region) -> ty::Region { self.find(br).get() } - fn find(br: ty::bound_region) -> Option { - for list::each(self) |isr| { + fn find(&self, br: ty::bound_region) -> Option { + for list::each(*self) |isr| { let (isr_br, isr_r) = *isr; if isr_br == br { return Some(isr_r); } } diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index d5834af3a57..141a730ca8d 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -19,21 +19,21 @@ use syntax::codemap::span; use syntax::parse::token::special_idents; pub trait region_scope { - pure fn anon_region(span: span) -> Result; - pure fn self_region(span: span) -> Result; - pure fn named_region(span: span, id: ast::ident) + pure fn anon_region(&self, span: span) -> Result; + pure fn self_region(&self, span: span) -> Result; + pure fn named_region(&self, span: span, id: ast::ident) -> Result; } pub enum empty_rscope { empty_rscope } pub impl region_scope for empty_rscope { - pure fn anon_region(_span: span) -> Result { + pure fn anon_region(&self, _span: span) -> Result { result::Ok(ty::re_static) } - pure fn self_region(_span: span) -> Result { + pure fn self_region(&self, _span: span) -> Result { result::Err(~"only the static region is allowed here") } - pure fn named_region(_span: span, _id: ast::ident) + pure fn named_region(&self, _span: span, _id: ast::ident) -> Result { result::Err(~"only the static region is allowed here") } @@ -41,17 +41,17 @@ pub impl region_scope for empty_rscope { pub enum type_rscope = Option; pub impl region_scope for type_rscope { - pure fn anon_region(_span: span) -> Result { - match *self { + pure fn anon_region(&self, _span: span) -> Result { + match **self { Some(_) => result::Ok(ty::re_bound(ty::br_self)), None => result::Err(~"to use region types here, the containing \ type must be declared with a region bound") } } - pure fn self_region(span: span) -> Result { + pure fn self_region(&self, span: span) -> Result { self.anon_region(span) } - pure fn named_region(span: span, id: ast::ident) + pure fn named_region(&self, span: span, id: ast::ident) -> Result { do empty_rscope.named_region(span, id).chain_err |_e| { result::Err(~"named regions other than `self` are not \ @@ -75,13 +75,13 @@ pub fn in_anon_rscope(self: RS, @anon_rscope {anon: r, base: self as region_scope} } pub impl region_scope for @anon_rscope { - pure fn anon_region(_span: span) -> Result { + pure fn anon_region(&self, _span: span) -> Result { result::Ok(self.anon) } - pure fn self_region(span: span) -> Result { + pure fn self_region(&self, span: span) -> Result { self.base.self_region(span) } - pure fn named_region(span: span, id: ast::ident) + pure fn named_region(&self, span: span, id: ast::ident) -> Result { self.base.named_region(span, id) } @@ -98,7 +98,7 @@ pub fn in_binding_rscope(self: RS) @mut binding_rscope { base: base, anon_bindings: 0 } } pub impl region_scope for @mut binding_rscope { - pure fn anon_region(_span: span) -> Result { + pure fn anon_region(&self, _span: span) -> Result { // XXX: Unsafe to work around purity unsafe { let idx = self.anon_bindings; @@ -106,10 +106,10 @@ pub impl region_scope for @mut binding_rscope { result::Ok(ty::re_bound(ty::br_anon(idx))) } } - pure fn self_region(span: span) -> Result { + pure fn self_region(&self, span: span) -> Result { self.base.self_region(span) } - pure fn named_region(span: span, id: ast::ident) + pure fn named_region(&self, span: span, id: ast::ident) -> Result { do self.base.named_region(span, id).chain_err |_e| { result::Ok(ty::re_bound(ty::br_named(id)))