diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 22b4fd36154..75400c5e324 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -163,50 +163,50 @@ pub struct Session_ { pub type Session = @Session_; -pub impl Session { - fn span_fatal(&self, sp: span, msg: ~str) -> ! { +pub impl Session_ { + fn span_fatal(@self, sp: span, msg: ~str) -> ! { self.span_diagnostic.span_fatal(sp, msg) } - fn fatal(&self, msg: ~str) -> ! { + fn fatal(@self, msg: ~str) -> ! { self.span_diagnostic.handler().fatal(msg) } - fn span_err(&self, sp: span, msg: ~str) { + fn span_err(@self, sp: span, msg: ~str) { self.span_diagnostic.span_err(sp, msg) } - fn err(&self, msg: ~str) { + fn err(@self, msg: ~str) { self.span_diagnostic.handler().err(msg) } - fn has_errors(&self) -> bool { + fn has_errors(@self) -> bool { self.span_diagnostic.handler().has_errors() } - fn abort_if_errors(&self) { + fn abort_if_errors(@self) { self.span_diagnostic.handler().abort_if_errors() } - fn span_warn(&self, sp: span, msg: ~str) { + fn span_warn(@self, sp: span, msg: ~str) { self.span_diagnostic.span_warn(sp, msg) } - fn warn(&self, msg: ~str) { + fn warn(@self, msg: ~str) { self.span_diagnostic.handler().warn(msg) } - fn span_note(&self, sp: span, msg: ~str) { + fn span_note(@self, sp: span, msg: ~str) { self.span_diagnostic.span_note(sp, msg) } - fn note(&self, msg: ~str) { + fn note(@self, msg: ~str) { self.span_diagnostic.handler().note(msg) } - fn span_bug(&self, sp: span, msg: ~str) -> ! { + fn span_bug(@self, sp: span, msg: ~str) -> ! { self.span_diagnostic.span_bug(sp, msg) } - fn bug(&self, msg: ~str) -> ! { + fn bug(@self, msg: ~str) -> ! { self.span_diagnostic.handler().bug(msg) } - fn span_unimpl(&self, sp: span, msg: ~str) -> ! { + fn span_unimpl(@self, sp: span, msg: ~str) -> ! { self.span_diagnostic.span_unimpl(sp, msg) } - fn unimpl(&self, msg: ~str) -> ! { + fn unimpl(@self, msg: ~str) -> ! { self.span_diagnostic.handler().unimpl(msg) } - fn span_lint_level(&self, 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), @@ -215,7 +215,7 @@ pub impl Session { } } } - fn span_lint(&self, lint_mode: lint::lint, + fn span_lint(@self, lint_mode: lint::lint, expr_id: ast::node_id, item_id: ast::node_id, span: span, @@ -224,55 +224,55 @@ pub impl Session { self.lint_settings, lint_mode, expr_id, item_id); self.span_lint_level(level, span, msg); } - fn next_node_id(&self) -> ast::node_id { + fn next_node_id(@self) -> ast::node_id { return syntax::parse::next_node_id(self.parse_sess); } - fn diagnostic(&self) -> @diagnostic::span_handler { + fn diagnostic(@self) -> @diagnostic::span_handler { self.span_diagnostic } - fn debugging_opt(&self, 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(&self, sp: span, msg: &str) -> ! { + fn impossible_case(@self, sp: span, msg: &str) -> ! { self.span_bug(sp, fmt!("Impossible case reached: %s", msg)); } - fn verbose(&self) -> bool { self.debugging_opt(verbose) } - fn time_passes(&self) -> bool { self.debugging_opt(time_passes) } - fn count_llvm_insns(&self) -> 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 { + fn count_type_sizes(@self) -> bool { self.debugging_opt(count_type_sizes) } - fn time_llvm_passes(&self) -> bool { + 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 { + 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 { + fn borrowck_note_loan(@self) -> bool { self.debugging_opt(borrowck_note_loan) } - fn no_monomorphic_collapse(&self) -> bool { + fn no_monomorphic_collapse(@self) -> bool { self.debugging_opt(no_monomorphic_collapse) } - fn str_of(&self, id: ast::ident) -> @~str { + fn str_of(@self, id: ast::ident) -> @~str { self.parse_sess.interner.get(id) } - fn ident_of(&self, +st: ~str) -> ast::ident { + fn ident_of(@self, +st: ~str) -> ast::ident { self.parse_sess.interner.intern(@st) } - fn intr(&self) -> @syntax::parse::token::ident_interner { + fn intr(@self) -> @syntax::parse::token::ident_interner { self.parse_sess.interner } } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 27561e619af..1201346ab68 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -1640,8 +1640,8 @@ enum ReadKind { PartiallyMovedValue } -pub impl @Liveness { - fn check_ret(&self, id: node_id, sp: span, _fk: &visit::fn_kind, +pub impl Liveness { + 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 @@ -1661,10 +1661,9 @@ pub impl @Liveness { } } - fn check_move_from_var(&self, ln: LiveNode, + fn check_move_from_var(@self, ln: LiveNode, var: Variable, - move_expr: @expr) - { + move_expr: @expr) { /*! * * Checks whether `var` is live on entry to any of the @@ -1686,7 +1685,7 @@ pub impl @Liveness { } } - fn consider_last_use(&self, 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()); @@ -1696,7 +1695,7 @@ pub impl @Liveness { } } - fn check_lvalue(&self, 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) { @@ -1724,18 +1723,18 @@ pub 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(&self, 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(&self, 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)) => { @@ -1756,10 +1755,9 @@ pub impl @Liveness { } } - fn report_illegal_move(&self, lnk: LiveNodeKind, + fn report_illegal_move(@self, lnk: LiveNodeKind, var: Variable, - move_expr: @expr) - { + move_expr: @expr) { // the only time that it is possible to have a moved variable // used by ExitNode would be arguments or fields in a ctor. // we give a slightly different error message in those cases. @@ -1822,11 +1820,10 @@ pub impl @Liveness { }; } - fn report_move_location(&self, move_expr: @expr, + fn report_move_location(@self, move_expr: @expr, var: Variable, expr_descr: &str, - pronoun: &str) - { + pronoun: &str) { let move_expr_ty = ty::expr_ty(self.tcx, move_expr); let name = self.ir.variable_name(var); self.tcx.sess.span_note( @@ -1837,7 +1834,7 @@ pub impl @Liveness { ty_to_str(self.tcx, move_expr_ty))); } - fn report_illegal_read(&self, chk_span: span, + fn report_illegal_read(@self, chk_span: span, lnk: LiveNodeKind, var: Variable, rk: ReadKind) { @@ -1868,12 +1865,12 @@ pub impl @Liveness { } } - fn should_warn(&self, 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(&self, 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| { @@ -1883,7 +1880,7 @@ pub impl @Liveness { } } - fn warn_about_unused_or_dead_vars_in_pat(&self, 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); @@ -1891,7 +1888,7 @@ pub impl @Liveness { } } - fn warn_about_unused(&self, sp: span, ln: LiveNode, var: Variable) + 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| { @@ -1921,7 +1918,7 @@ pub impl @Liveness { return false; } - fn warn_about_dead_assign(&self, 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/trans/common.rs b/src/librustc/middle/trans/common.rs index 03806e71ac5..04e25bdbf21 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -677,28 +677,28 @@ pub fn block_parent(cx: block) -> block { // Accessors -pub impl block { - 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 } +pub impl block_ { + pure fn ccx(@mut self) -> @CrateContext { *self.fcx.ccx } + pure fn tcx(@mut self) -> ty::ctxt { self.fcx.ccx.tcx } + pure fn sess(@mut self) -> Session { self.fcx.ccx.sess } - fn node_id_to_str(&self, id: ast::node_id) -> ~str { + fn node_id_to_str(@mut self, id: ast::node_id) -> ~str { ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr()) } - fn expr_to_str(&self, e: @ast::expr) -> ~str { + fn expr_to_str(@mut self, e: @ast::expr) -> ~str { expr_repr(self.tcx(), e) } - fn expr_is_lval(&self, e: @ast::expr) -> bool { + fn expr_is_lval(@mut self, e: @ast::expr) -> bool { ty::expr_is_lval(self.tcx(), self.ccx().maps.method_map, e) } - fn expr_kind(&self, e: @ast::expr) -> ty::ExprKind { + fn expr_kind(@mut self, e: @ast::expr) -> ty::ExprKind { ty::expr_kind(self.tcx(), self.ccx().maps.method_map, e) } - fn def(&self, nid: ast::node_id) -> ast::def { + fn def(@mut self, nid: ast::node_id) -> ast::def { match self.tcx().def_map.find(&nid) { Some(v) => v, None => { @@ -708,18 +708,18 @@ pub impl block { } } - fn val_str(&self, val: ValueRef) -> @str { + fn val_str(@mut self, val: ValueRef) -> @str { val_str(self.ccx().tn, val) } - fn llty_str(&self, llty: TypeRef) -> @str { + fn llty_str(@mut self, llty: TypeRef) -> @str { ty_str(self.ccx().tn, llty) } - fn ty_to_str(&self, t: ty::t) -> ~str { + fn ty_to_str(@mut self, t: ty::t) -> ~str { ty_to_str(self.tcx(), t) } - fn to_str(&self) -> ~str { + fn to_str(@mut self) -> ~str { match self.node_info { Some(node_info) => { fmt!("[block %d]", node_info.id) diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 00352ba2958..ed26812f44d 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -72,8 +72,8 @@ pub fn get_base_type(inference_context: @mut InferCtxt, -> Option { let resolved_type; match resolve_type(inference_context, - original_type, - resolve_ivar) { + original_type, + resolve_ivar) { Ok(resulting_type) if !type_is_ty_var(resulting_type) => { resolved_type = resulting_type; } @@ -87,15 +87,6 @@ pub fn get_base_type(inference_context: @mut InferCtxt, } match get(resolved_type).sty { - ty_box(base_mutability_and_type) | - ty_uniq(base_mutability_and_type) | - ty_ptr(base_mutability_and_type) | - ty_rptr(_, base_mutability_and_type) => { - debug!("(getting base type) recurring"); - get_base_type(inference_context, span, - base_mutability_and_type.ty) - } - ty_enum(*) | ty_trait(*) | ty_struct(*) => { debug!("(getting base type) found base type"); Some(resolved_type) @@ -104,7 +95,8 @@ pub fn get_base_type(inference_context: @mut InferCtxt, ty_nil | ty_bot | ty_bool | ty_int(*) | ty_uint(*) | ty_float(*) | ty_estr(*) | ty_evec(*) | ty_bare_fn(*) | ty_closure(*) | ty_tup(*) | ty_infer(*) | ty_param(*) | ty_self | ty_type | ty_opaque_box | - ty_opaque_closure_ptr(*) | ty_unboxed_vec(*) | ty_err => { + ty_opaque_closure_ptr(*) | ty_unboxed_vec(*) | ty_err | ty_box(_) | + ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => { debug!("(getting base type) no base type; found %?", get(original_type).sty); None diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index f68a0db6387..03649faff63 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -542,23 +542,23 @@ struct Snapshot { region_vars_snapshot: uint, } -pub impl @mut InferCtxt { - fn combine_fields(&self, a_is_expected: bool, +pub impl InferCtxt { + fn combine_fields(@mut self, a_is_expected: bool, span: span) -> CombineFields { - CombineFields {infcx: *self, + CombineFields {infcx: self, a_is_expected: a_is_expected, span: span} } - fn sub(&self, a_is_expected: bool, span: span) -> Sub { + fn sub(@mut self, a_is_expected: bool, span: span) -> Sub { Sub(self.combine_fields(a_is_expected, span)) } - fn in_snapshot(&self) -> bool { + fn in_snapshot(@mut self) -> bool { self.region_vars.in_snapshot() } - fn start_snapshot(&self) -> Snapshot { + fn start_snapshot(@mut self) -> Snapshot { Snapshot { ty_var_bindings_len: self.ty_var_bindings.bindings.len(), @@ -571,7 +571,7 @@ pub impl @mut InferCtxt { } } - fn rollback_to(&self, snapshot: &Snapshot) { + fn rollback_to(@mut self, snapshot: &Snapshot) { debug!("rollback!"); rollback_to(&mut self.ty_var_bindings, snapshot.ty_var_bindings_len); @@ -584,7 +584,7 @@ pub impl @mut InferCtxt { } /// Execute `f` and commit the bindings if successful - fn commit(&self, f: &fn() -> Result) -> Result { + fn commit(@mut self, f: &fn() -> Result) -> Result { fail_unless!(!self.in_snapshot()); debug!("commit()"); @@ -599,7 +599,7 @@ pub impl @mut InferCtxt { } /// Execute `f`, unroll bindings on failure - fn try(&self, f: &fn() -> Result) -> Result { + fn try(@mut self, f: &fn() -> Result) -> Result { debug!("try()"); do indent { let snapshot = self.start_snapshot(); @@ -613,7 +613,7 @@ pub impl @mut InferCtxt { } /// Execute `f` then unroll any bindings it creates - fn probe(&self, f: &fn() -> Result) -> Result { + fn probe(@mut self, f: &fn() -> Result) -> Result { debug!("probe()"); do indent { let snapshot = self.start_snapshot(); @@ -634,8 +634,8 @@ fn next_simple_var( return id; } -pub impl @mut InferCtxt { - fn next_ty_var_id(&self) -> TyVid { +pub impl InferCtxt { + fn next_ty_var_id(@mut self) -> TyVid { let id = self.ty_var_counter; self.ty_var_counter += 1; let vals = self.ty_var_bindings.vals; @@ -643,37 +643,37 @@ pub impl @mut InferCtxt { return TyVid(id); } - fn next_ty_var(&self) -> ty::t { + fn next_ty_var(@mut self) -> ty::t { ty::mk_var(self.tcx, self.next_ty_var_id()) } - fn next_ty_vars(&self, n: uint) -> ~[ty::t] { + fn next_ty_vars(@mut self, n: uint) -> ~[ty::t] { vec::from_fn(n, |_i| self.next_ty_var()) } - fn next_int_var_id(&self) -> IntVid { + fn next_int_var_id(@mut self) -> IntVid { IntVid(next_simple_var(&mut self.int_var_counter, &mut self.int_var_bindings)) } - fn next_int_var(&self) -> ty::t { + fn next_int_var(@mut self) -> ty::t { ty::mk_int_var(self.tcx, self.next_int_var_id()) } - fn next_float_var_id(&self) -> FloatVid { + fn next_float_var_id(@mut self) -> FloatVid { FloatVid(next_simple_var(&mut self.float_var_counter, &mut self.float_var_bindings)) } - fn next_float_var(&self) -> ty::t { + fn next_float_var(@mut self) -> ty::t { ty::mk_float_var(self.tcx, self.next_float_var_id()) } - fn next_region_var_nb(&self, span: span) -> ty::Region { + fn next_region_var_nb(@mut self, span: span) -> ty::Region { ty::re_infer(ty::ReVar(self.region_vars.new_region_var(span))) } - fn next_region_var_with_lb(&self, span: span, + fn next_region_var_with_lb(@mut self, span: span, lb_region: ty::Region) -> ty::Region { let region_var = self.next_region_var_nb(span); @@ -685,28 +685,28 @@ pub impl @mut InferCtxt { return region_var; } - fn next_region_var(&self, span: span, scope_id: ast::node_id) + fn next_region_var(@mut 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(&self) { + fn resolve_regions(@mut self) { self.region_vars.resolve_regions(); } - fn ty_to_str(&self, t: ty::t) -> ~str { + fn ty_to_str(@mut self, t: ty::t) -> ~str { ty_to_str(self.tcx, self.resolve_type_vars_if_possible(t)) } - fn resolve_type_vars_if_possible(&self, typ: ty::t) -> ty::t { - match resolve_type(*self, typ, resolve_nested_tvar | resolve_ivar) { + fn resolve_type_vars_if_possible(@mut 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(&self, sp: span, mk_msg: &fn(~str) -> ~str, + fn type_error_message(@mut 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); @@ -725,7 +725,7 @@ pub impl @mut InferCtxt { } } - fn report_mismatched_types(&self, sp: span, e: ty::t, a: ty::t, + fn report_mismatched_types(@mut self, sp: span, e: ty::t, a: ty::t, err: &ty::type_err) { let resolved_expected = self.resolve_type_vars_if_possible(e); @@ -743,7 +743,7 @@ pub impl @mut InferCtxt { self.type_error_message(sp, mk_msg, a, Some(err)); } - fn replace_bound_regions_with_fresh_regions(&self, + fn replace_bound_regions_with_fresh_regions(@mut self, span: span, fsig: &ty::FnSig) -> (ty::FnSig, isr_alist) { @@ -763,7 +763,7 @@ pub impl @mut InferCtxt { } fn fold_regions_in_sig( - &self, + @mut self, fn_sig: &ty::FnSig, fldr: &fn(r: ty::Region, in_fn: bool) -> ty::Region) -> ty::FnSig { diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index 6a234b9dc9b..a4b00e4dd04 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -73,7 +73,7 @@ pub mod chained { FoundAfter(@Entry, @Entry) } - priv impl T { + priv impl HashMap_ { pure fn search_rem(&self, k: &K, h: uint, idx: uint, e_root: @Entry) -> SearchResult { let mut e0 = e_root; @@ -120,7 +120,7 @@ pub mod chained { } } - fn rehash(&self) { + fn rehash(@self) { let n_old_chains = self.chains.len(); let n_new_chains: uint = uint::next_power_of_two(n_old_chains+1u); let mut new_chains = chains(n_new_chains); @@ -133,7 +133,7 @@ pub mod chained { } } - pub impl T { + pub impl HashMap_ { pure fn each_entry(&self, blk: &fn(@Entry) -> bool) { // n.b. we can't use vec::iter() here because self.chains // is stored in a mutable location. @@ -153,22 +153,20 @@ pub mod chained { i += 1u; } } - } - impl Container for T { - pure fn len(&self) -> uint { self.count } - pure fn is_empty(&self) -> bool { self.count == 0 } - } - - impl Mutable for T { - fn clear(&mut self) { + fn clear(@self) { self.count = 0u; self.chains = chains(initial_capacity); } } - pub impl T { - pure fn contains_key(&self, k: &K) -> bool { + impl Container for HashMap_ { + pure fn len(&self) -> uint { self.count } + pure fn is_empty(&self) -> bool { self.count == 0 } + } + + pub impl HashMap_ { + pure fn contains_key(@self, k: &K) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(k, hash) { NotFound => false, @@ -176,7 +174,7 @@ pub mod chained { } } - fn insert(&self, k: K, v: V) -> bool { + fn insert(@self, k: K, v: V) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(&k, hash) { NotFound => { @@ -220,7 +218,7 @@ pub mod chained { } } - fn remove(&self, k: &K) -> bool { + fn remove(@self, k: &K) -> bool { match self.search_tbl(k, k.hash_keyed(0,0) as uint) { NotFound => false, FoundFirst(idx, entry) => { @@ -236,22 +234,22 @@ pub mod chained { } } - pure fn each(&self, blk: &fn(key: &K, value: &V) -> bool) { + pure fn each(@self, blk: &fn(key: &K, value: &V) -> bool) { for self.each_entry |entry| { if !blk(&entry.key, &entry.value) { break; } } } - pure fn each_key(&self, blk: &fn(key: &K) -> bool) { + pure fn each_key(@self, blk: &fn(key: &K) -> bool) { self.each(|k, _v| blk(k)) } - pure fn each_value(&self, blk: &fn(value: &V) -> bool) { + pure fn each_value(@self, blk: &fn(value: &V) -> bool) { self.each(|_k, v| blk(v)) } } - pub impl T { + pub impl HashMap_ { pure fn find(&self, k: &K) -> Option { match self.search_tbl(k, k.hash_keyed(0,0) as uint) { NotFound => None, @@ -260,7 +258,7 @@ pub mod chained { } } - fn update_with_key(&self, key: K, newval: V, ff: &fn(K, V, V) -> V) + fn update_with_key(@self, key: K, newval: V, ff: &fn(K, V, V) -> V) -> bool { /* match self.find(key) { @@ -312,7 +310,7 @@ pub mod chained { } } - fn update(&self, key: K, newval: V, ff: &fn(V, V) -> V) -> bool { + fn update(@self, key: K, newval: V, ff: &fn(V, V) -> V) -> bool { return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)); } @@ -325,7 +323,8 @@ pub mod chained { } } - pub impl T { + pub impl + HashMap_ { fn to_writer(&self, wr: @io::Writer) { if self.count == 0u { wr.write_str(~"{}"); @@ -348,7 +347,7 @@ pub mod chained { } impl ToStr - for T { + for HashMap_ { pure fn to_str(&self) -> ~str { unsafe { // Meh -- this should be safe @@ -357,7 +356,8 @@ pub mod chained { } } - impl ops::Index for T { + impl ops::Index + for HashMap_ { pure fn index(&self, k: K) -> V { self.get(&k) } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 2190475d943..abd8bc74235 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -99,7 +99,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint) } #[doc(hidden)] -pub impl &self/Sem { +pub impl Sem { fn acquire(&self) { let mut waiter_nobe = None; unsafe { @@ -135,26 +135,26 @@ pub impl &self/Sem { } // FIXME(#3154) move both copies of this into Sem, and unify the 2 structs #[doc(hidden)] -pub impl &self/Sem<()> { +pub impl Sem<()> { fn access(&self, blk: &fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { self.acquire(); - release = Some(SemRelease(*self)); + release = Some(SemRelease(self)); } } blk() } } #[doc(hidden)] -pub impl &self/Sem<~[Waitqueue]> { +pub impl Sem<~[Waitqueue]> { fn access(&self, blk: &fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { self.acquire(); - release = Some(SemAndSignalRelease(*self)); + release = Some(SemAndSignalRelease(self)); } } blk() diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 60df7623e40..c9680ac02c9 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -172,9 +172,13 @@ pub impl protocol_ { } } -pub impl protocol { - fn add_state_poly(&self, +name: ~str, ident: ast::ident, dir: direction, - +generics: ast::Generics) -> state { +pub impl protocol_ { + fn add_state_poly(@mut self, + +name: ~str, + ident: ast::ident, + dir: direction, + +generics: ast::Generics) + -> state { let messages = @mut ~[]; let state = @state_ { @@ -185,7 +189,7 @@ pub impl protocol { dir: dir, generics: generics, messages: messages, - proto: *self + proto: self }; self.states.push(state);