need_dir(&c.bindir);
for sources.each_key_ref |&k| {
- let mut s = sources.get(&k);
+ let mut s = sources.get(k);
load_source_packages(&c, s);
sources.insert(k, s);
}
pub fn install_uuid_specific(c: &mut Cargo, wd: &Path, src: ~str,
uuid: ~str) {
- match c.sources.find(&src) {
+ match c.sources.find(src) {
Some(s) => {
for s.packages.each |p| {
if p.uuid == uuid {
pub fn install_named_specific(c: &mut Cargo, wd: &Path, src: ~str,
name: ~str) {
- match c.sources.find(&src) {
+ match c.sources.find(src) {
Some(s) => {
for s.packages.each |p| {
if p.name == name {
}
pub fn install_query(c: &mut Cargo, wd: &Path, target: ~str) {
- match c.dep_cache.find(&target) {
+ match c.dep_cache.find(target) {
Some(inst) => {
if inst {
return;
pub fn sync(c: &Cargo) {
for c.sources.each_key_ref |&k| {
- let mut s = c.sources.get(&k);
+ let mut s = c.sources.get(k);
sync_one(c, s);
c.sources.insert(k, s);
}
if !valid_pkg_name(*name) {
error(fmt!("'%s' is an invalid source name", *name));
} else {
- match c.sources.find(name) {
+ match c.sources.find(*name) {
Some(source) => {
print_source(source);
}
return;
}
- match c.sources.find(&name) {
+ match c.sources.find(name) {
Some(source) => {
let old = copy source.url;
let method = assume_source_method(url);
return;
}
- match c.sources.find(&name) {
+ match c.sources.find(name) {
Some(source) => {
let old = copy source.method;
return;
}
- match c.sources.find(&name) {
+ match c.sources.find(name) {
Some(source) => {
c.sources.remove(&name);
c.sources.insert(newn, source);
}
pub fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> @str {
- match ccx.type_hashcodes.find(&t) {
+ match ccx.type_hashcodes.find(t) {
Some(h) => h,
None => {
let hash = symbol_hash(ccx.tcx, ccx.symbol_hasher, t, ccx.link_meta);
getopts::opt_strs(matches, level_name));
for flags.each |lint_name| {
let lint_name = str::replace(*lint_name, ~"-", ~"_");
- match lint_dict.find(&lint_name) {
+ match lint_dict.find(/*bad*/ copy lint_name) {
None => {
early_error(demitter, fmt!("unknown %s flag: %s",
level_name, lint_name));
}
pub fn type_has_name(tn: type_names, t: TypeRef) -> Option<@str> {
- return tn.type_names.find(&t);
+ return tn.type_names.find(t);
}
pub fn name_has_type(tn: type_names, s: @str) -> Option<TypeRef> {
- return tn.named_types.find(&s);
+ return tn.named_types.find(s);
}
pub fn mk_type_names() -> type_names {
pub fn get_crate_data(cstore: CStore, cnum: ast::crate_num)
-> crate_metadata {
- return p(cstore).metas.get(&cnum);
+ return p(cstore).metas.get(cnum);
}
pub fn get_crate_hash(cstore: CStore, cnum: ast::crate_num) -> ~str {
pub fn find_use_stmt_cnum(cstore: CStore,
use_id: ast::node_id) -> Option<ast::crate_num> {
- p(cstore).use_crate_map.find(&use_id)
+ p(cstore).use_crate_map.find(use_id)
}
// returns hashes of crates directly used by this crate. Hashes are
return ast::def_id { crate: cdata.cnum, node: did.node };
}
- match cdata.cnum_map.find(&did.crate) {
+ match cdata.cnum_map.find(did.crate) {
option::Some(n) => ast::def_id { crate: n, node: did.node },
option::None => die!(~"didn't find a crate in the cnum_map")
}
fn encode_region_param(ecx: @encode_ctxt, ebml_w: writer::Encoder,
it: @ast::item) {
- let opt_rp = ecx.tcx.region_paramd_items.find(&it.id);
+ let opt_rp = ecx.tcx.region_paramd_items.find(it.id);
for opt_rp.each |rp| {
do ebml_w.wr_tag(tag_region_param) {
(*rp).encode(&ebml_w);
fn encode_type_param_bounds(ebml_w: writer::Encoder, ecx: @encode_ctxt,
params: &[ty_param]) {
let ty_param_bounds =
- @params.map(|param| ecx.tcx.ty_param_bounds.get(¶m.id));
+ @params.map(|param| ecx.tcx.ty_param_bounds.get(param.id));
encode_ty_type_param_bounds(ebml_w, ecx, ty_param_bounds);
}
fn encode_symbol(ecx: @encode_ctxt, ebml_w: writer::Encoder, id: node_id) {
ebml_w.start_tag(tag_items_data_item_symbol);
- let sym = match ecx.item_symbols.find(&id) {
+ let sym = match ecx.item_symbols.find(id) {
Some(ref x) => (/*bad*/copy *x),
None => {
ecx.diag.handler().bug(
fn encode_discriminant(ecx: @encode_ctxt, ebml_w: writer::Encoder,
id: node_id) {
ebml_w.start_tag(tag_items_data_item_symbol);
- ebml_w.writer.write(str::to_bytes(ecx.discrim_symbols.get(&id)));
+ ebml_w.writer.write(str::to_bytes(ecx.discrim_symbols.get(id)));
ebml_w.end_tag();
}
// Encode the reexports of this module.
debug!("(encoding info for module) encoding reexports for %d", id);
- match ecx.reexports2.find(&id) {
+ match ecx.reexports2.find(id) {
Some(ref exports) => {
debug!("(encoding info for module) found reexports for %d", id);
for (*exports).each |exp| {
encode_name(ecx, ebml_w, ty_m.ident);
encode_family(ebml_w,
purity_static_method_family(ty_m.purity));
- let polyty = ecx.tcx.tcache.get(&local_def(ty_m.id));
+ let polyty = ecx.tcx.tcache.get(local_def(ty_m.id));
encode_ty_type_param_bounds(ebml_w, ecx, polyty.bounds);
encode_type(ecx, ebml_w, polyty.ty);
let mut m_path = vec::append(~[], path); // :-(
let ebml_w = copy ebml_w;
|i, cx, v| {
visit::visit_item(i, cx, v);
- match ecx.tcx.items.get(&i.id) {
+ match ecx.tcx.items.get(i.id) {
ast_map::node_item(_, pt) => {
encode_info_for_item(ecx, ebml_w, i,
index, *pt);
let ebml_w = copy ebml_w;
|ni, cx, v| {
visit::visit_foreign_item(ni, cx, v);
- match ecx.tcx.items.get(&ni.id) {
+ match ecx.tcx.items.get(ni.id) {
ast_map::node_foreign_item(_, abi, pt) => {
encode_info_for_foreign_item(ecx, ebml_w, ni,
index, /*bad*/copy *pt,
let len = parse_hex(st);
assert (next(st) == '#');
let key = creader_cache_key { cnum: st.crate, pos: pos, len: len };
- match st.tcx.rcache.find(&key) {
+ match st.tcx.rcache.find(key) {
Some(tt) => return tt,
None => {
let ps = @{pos: pos ,.. copy *st};
pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
match cx.abbrevs {
ac_no_abbrevs => {
- let result_str = match cx.tcx.short_names_cache.find(&t) {
+ let result_str = match cx.tcx.short_names_cache.find(t) {
Some(s) => /*bad*/copy *s,
None => {
let s = do io::with_str_writer |wr| {
w.write_str(result_str);
}
ac_use_abbrevs(abbrevs) => {
- match abbrevs.find(&t) {
+ match abbrevs.find(t) {
Some(a) => { w.write_str(*a.s); return; }
None => {
let pos = w.tell();
debug!("Encoding side tables for id %d", id);
- do option::iter(&tcx.def_map.find(&id)) |def| {
+ do option::iter(&tcx.def_map.find(id)) |def| {
do ebml_w.tag(c::tag_table_def) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
}
}
- do option::iter(&tcx.node_type_substs.find(&id)) |tys| {
+ do option::iter(&tcx.node_type_substs.find(id)) |tys| {
do ebml_w.tag(c::tag_table_node_type_subst) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
}
}
- do option::iter(&tcx.freevars.find(&id)) |fv| {
+ do option::iter(&tcx.freevars.find(id)) |fv| {
do ebml_w.tag(c::tag_table_freevars) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
}
let lid = ast::def_id { crate: ast::local_crate, node: id };
- do option::iter(&tcx.tcache.find(&lid)) |tpbt| {
+ do option::iter(&tcx.tcache.find(lid)) |tpbt| {
do ebml_w.tag(c::tag_table_tcache) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
}
}
- do option::iter(&tcx.ty_param_bounds.find(&id)) |pbs| {
+ do option::iter(&tcx.ty_param_bounds.find(id)) |pbs| {
do ebml_w.tag(c::tag_table_param_bounds) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
// is what we actually use in trans, all modes will have been
// resolved.
//
- //option::iter(tcx.inferred_modes.find(&id)) {|m|
+ //option::iter(tcx.inferred_modes.find(id)) {|m|
// ebml_w.tag(c::tag_table_inferred_modes) {||
// ebml_w.id(id);
// ebml_w.tag(c::tag_table_val) {||
// }
//}
- do option::iter(&maps.mutbl_map.find(&id)) |_m| {
+ do option::iter(&maps.mutbl_map.find(id)) |_m| {
do ebml_w.tag(c::tag_table_mutbl) {
ebml_w.id(id);
}
}
- do option::iter(&maps.last_use_map.find(&id)) |m| {
+ do option::iter(&maps.last_use_map.find(id)) |m| {
do ebml_w.tag(c::tag_table_last_use) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
}
}
- do option::iter(&maps.method_map.find(&id)) |mme| {
+ do option::iter(&maps.method_map.find(id)) |mme| {
do ebml_w.tag(c::tag_table_method_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
}
}
- do option::iter(&maps.vtable_map.find(&id)) |dr| {
+ do option::iter(&maps.vtable_map.find(id)) |dr| {
do ebml_w.tag(c::tag_table_vtable_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
}
}
- do option::iter(&tcx.adjustments.find(&id)) |adj| {
+ do option::iter(&tcx.adjustments.find(id)) |adj| {
do ebml_w.tag(c::tag_table_adjustments) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
}
}
- do option::iter(&tcx.legacy_boxed_traits.find(&id)) |_x| {
+ do option::iter(&tcx.legacy_boxed_traits.find(id)) |_x| {
do ebml_w.tag(c::tag_table_legacy_boxed_trait) {
ebml_w.id(id);
}
}
- for maps.moves_map.find(&id).each |_| {
+ for maps.moves_map.find(id).each |_| {
do ebml_w.tag(c::tag_table_moves_map) {
ebml_w.id(id);
}
}
- for maps.capture_map.find(&id).each |cap_vars| {
+ for maps.capture_map.find(id).each |cap_vars| {
do ebml_w.tag(c::tag_table_capture_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
let region_map = self.tcx().region_map;
let pure_map = self.req_maps.pure_map;
loop {
- match pure_map.find(&scope_id) {
+ match pure_map.find(scope_id) {
None => (),
Some(ref e) => return Some(pc_cmt((*e)))
}
- match region_map.find(&scope_id) {
+ match region_map.find(scope_id) {
None => return default_purity,
Some(next_scope_id) => scope_id = next_scope_id
}
let req_loan_map = self.req_maps.req_loan_map;
loop {
- for req_loan_map.find(&scope_id).each |loans| {
+ for req_loan_map.find(scope_id).each |loans| {
for loans.each |loan| {
if !f(loan) { return; }
}
}
- match region_map.find(&scope_id) {
+ match region_map.find(scope_id) {
None => return,
Some(next_scope_id) => scope_id = next_scope_id,
}
Some(expr) => {
match expr.node {
ast::expr_path(_) if pc == pc_pure_fn => {
- let def = self.tcx().def_map.get(&expr.id);
+ let def = self.tcx().def_map.get(expr.id);
let did = ast_util::def_id_of_def(def);
let is_fn_arg =
did.crate == ast::local_crate &&
fn is_allowed_pure_arg(expr: @ast::expr) -> bool {
return match expr.node {
ast::expr_path(_) => {
- let def = self.tcx().def_map.get(&expr.id);
+ let def = self.tcx().def_map.get(expr.id);
let did = ast_util::def_id_of_def(def);
did.crate == ast::local_crate &&
(*self.fn_args).contains(&(did.node))
fn check_for_conflicting_loans(scope_id: ast::node_id) {
debug!("check_for_conflicting_loans(scope_id=%?)", scope_id);
- let new_loans = match self.req_maps.req_loan_map.find(&scope_id) {
+ let new_loans = match self.req_maps.req_loan_map.find(scope_id) {
None => return,
Some(loans) => loans
};
debug!("new_loans has length %?", new_loans.len());
- let par_scope_id = self.tcx().region_map.get(&scope_id);
+ let par_scope_id = self.tcx().region_map.get(scope_id);
for self.walk_loans(par_scope_id) |old_loan| {
debug!("old_loan=%?", self.bccx.loan_to_repr(old_loan));
fn check_assignment(at: assignment_type, ex: @ast::expr) {
// We don't use cat_expr() here because we don't want to treat
// auto-ref'd parameters in overloaded operators as rvalues.
- let cmt = match self.bccx.tcx.adjustments.find(&ex.id) {
+ let cmt = match self.bccx.tcx.adjustments.find(ex.id) {
None => self.bccx.cat_expr_unadjusted(ex),
Some(adj) => self.bccx.cat_expr_autoderefd(ex, adj)
};
{
match fty_proto {
ast::ProtoBox | ast::ProtoUniq => {
- let cap_vars = self.bccx.capture_map.get(&id);
+ let cap_vars = self.bccx.capture_map.get(id);
for cap_vars.each |cap_var| {
match cap_var.mode {
moves::CapRef | moves::CapCopy => { loop; }
// If this expression is borrowed, have to ensure it remains valid:
if !self.ignore_adjustments.contains(&ex.id) {
- for tcx.adjustments.find(&ex.id).each |adjustments| {
+ for tcx.adjustments.find(ex.id).each |adjustments| {
self.guarantee_adjustments(ex, *adjustments);
}
}
}
}
- match self.bccx.method_map.find(&ex.id) {
+ match self.bccx.method_map.find(ex.id) {
Some(ref method_map_entry) => {
match (*method_map_entry).explicit_self {
ast::sty_by_ref => {
// (if used like `a.b(...)`), the call where it's an argument
// (if used like `x(a.b)`), or the block (if used like `let x
// = a.b`).
- let scope_r = ty::re_scope(self.tcx().region_map.get(&ex.id));
+ let scope_r = ty::re_scope(self.tcx().region_map.get(ex.id));
let rcvr_cmt = self.bccx.cat_expr(rcvr);
self.guarantee_valid(rcvr_cmt, m_imm, scope_r);
visit::visit_expr(ex, self, vt);
fn add_loans_to_scope_id(&self, scope_id: ast::node_id, +loans: ~[Loan]) {
debug!("adding %u loans to scope_id %?", loans.len(), scope_id);
- match self.req_maps.req_loan_map.find(&scope_id) {
+ match self.req_maps.req_loan_map.find(scope_id) {
Some(req_loans) => {
req_loans.push_all(loans);
}
~"rvalue with a non-none lp");
}
cat_local(local_id) | cat_arg(local_id) | cat_self(local_id) => {
- let local_scope_id = self.tcx().region_map.get(&local_id);
+ let local_scope_id = self.tcx().region_map.get(local_id);
self.issue_loan(cmt, ty::re_scope(local_scope_id), req_mutbl,
owns_lent_data)
}
// Maybe if we pass in the parent instead here,
// we can prevent the "scope not found" error
debug!("scope_region thing: %? ", cmt.id);
- ty::re_scope(self.tcx().region_map.get(&cmt.id))
+ ty::re_scope(self.tcx().region_map.get(cmt.id))
};
self.compare_scope(cmt, scope_region)
cmt.span,
~"preserve() called with local and !root_managed_data");
}
- let local_scope_id = self.tcx().region_map.get(&local_id);
+ let local_scope_id = self.tcx().region_map.get(local_id);
self.compare_scope(cmt, ty::re_scope(local_scope_id))
}
cat_binding(local_id) => {
// Bindings are these kind of weird implicit pointers (cc
// #2329). We require (in gather_loans) that they be
// rooted in an immutable location.
- let local_scope_id = self.tcx().region_map.get(&local_id);
+ let local_scope_id = self.tcx().region_map.get(local_id);
self.compare_scope(cmt, ty::re_scope(local_scope_id))
}
cat_arg(local_id) => {
// modes). In that case, the caller guarantees stability
// for at least the scope of the fn. This is basically a
// deref of a region ptr.
- let local_scope_id = self.tcx().region_map.get(&local_id);
+ let local_scope_id = self.tcx().region_map.get(local_id);
self.compare_scope(cmt, ty::re_scope(local_scope_id))
}
cat_self(local_id) => {
- let local_scope_id = self.tcx().region_map.get(&local_id);
+ let local_scope_id = self.tcx().region_map.get(local_id);
self.compare_scope(cmt, ty::re_scope(local_scope_id))
}
cat_comp(cmt_base, comp_field(*)) |
e.span, ~"paths in constants may only refer to \
items without type parameters");
}
- match def_map.find(&e.id) {
+ match def_map.find(e.id) {
Some(def_const(def_id)) |
Some(def_fn(def_id, _)) |
Some(def_variant(_, def_id)) |
}
}
expr_call(callee, _, false) => {
- match def_map.find(&callee.id) {
+ match def_map.find(callee.id) {
Some(def_struct(*)) => {} // OK.
Some(def_variant(*)) => {} // OK.
_ => {
fn visit_expr(e: @expr, &&env: env, v: visit::vt<env>) {
match e.node {
expr_path(*) => {
- match env.def_map.find(&e.id) {
+ match env.def_map.find(e.id) {
Some(def_const(def_id)) => {
- match env.ast_map.get(&def_id.node) {
+ match env.ast_map.get(def_id.node) {
ast_map::node_item(it, _) => {
(v.visit_item)(it, env, v);
}
match /*bad*/copy pat.node {
pat_wild => { None }
pat_ident(_, _, _) | pat_enum(_, _) => {
- match cx.tcx.def_map.find(&pat.id) {
+ match cx.tcx.def_map.find(pat.id) {
Some(def_variant(_, id)) => Some(variant(id)),
Some(def_const(did)) => {
let const_expr = lookup_const_by_id(cx.tcx, did).get();
Some(range(eval_const_expr(cx.tcx, lo), eval_const_expr(cx.tcx, hi)))
}
pat_struct(*) => {
- match cx.tcx.def_map.find(&pat.id) {
+ match cx.tcx.def_map.find(pat.id) {
Some(def_variant(_, id)) => Some(variant(id)),
_ => Some(single)
}
match pat.node {
pat_wild => { true }
pat_ident(_, _, _) => {
- match cx.tcx.def_map.find(&pat.id) {
+ match cx.tcx.def_map.find(pat.id) {
Some(def_variant(_, _)) | Some(def_const(*)) => { false }
_ => { true }
}
pat_wild => Some(vec::append(vec::from_elem(arity, wild()),
vec::tail(r))),
pat_ident(_, _, _) => {
- match cx.tcx.def_map.find(&pat_id) {
+ match cx.tcx.def_map.find(pat_id) {
Some(def_variant(_, id)) => {
if variant(id) == ctor_id { Some(vec::tail(r)) }
else { None }
}
}
pat_enum(_, args) => {
- match cx.tcx.def_map.get(&pat_id) {
+ match cx.tcx.def_map.get(pat_id) {
def_variant(_, id) if variant(id) == ctor_id => {
let args = match args {
Some(args) => args,
}
pat_struct(_, ref flds, _) => {
// Is this a struct or an enum variant?
- match cx.tcx.def_map.get(&pat_id) {
+ match cx.tcx.def_map.get(pat_id) {
def_variant(_, variant_id) => {
if variant(variant_id) == ctor_id {
// FIXME #4731: Is this right? --pcw
}
pub fn is_refutable(cx: @MatchCheckCtxt, pat: &pat) -> bool {
- match cx.tcx.def_map.find(&pat.id) {
+ match cx.tcx.def_map.find(pat.id) {
Some(def_variant(enum_id, _)) => {
if vec::len(*ty::enum_variants(cx.tcx, enum_id)) != 1u {
return true;
tcx: ty::ctxt)
-> constness {
let did = ast_util::local_def(e.id);
- match tcx.ccache.find(&did) {
+ match tcx.ccache.find(did) {
Some(x) => x,
None => {
let cn =
}
pub fn lookup_const(tcx: ty::ctxt, e: @expr) -> Option<@expr> {
- match tcx.def_map.find(&e.id) {
+ match tcx.def_map.find(e.id) {
Some(ast::def_const(def_id)) => lookup_const_by_id(tcx, def_id),
_ => None
}
def_id: ast::def_id)
-> Option<@expr> {
if ast_util::is_local(def_id) {
- match tcx.items.find(&def_id.node) {
+ match tcx.items.find(def_id.node) {
None => None,
Some(ast_map::node_item(it, _)) => match it.node {
item_const(_, const_expr) => Some(const_expr),
}
ast::expr_path(*) => {
let mut i = 0;
- match def_map.find(&expr.id) {
+ match def_map.find(expr.id) {
None => die!(~"path not found"),
Some(df) => {
let mut def = df;
}
pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info {
- match tcx.freevars.find(&fid) {
+ match tcx.freevars.find(fid) {
None => die!(~"get_freevars: " + int::str(fid) + ~" has no freevars"),
Some(d) => return d
}
expr_unary(*)|expr_binary(*)|expr_method_call(*) => e.callee_id,
_ => e.id
};
- do option::iter(&cx.tcx.node_type_substs.find(&type_parameter_id)) |ts| {
+ do option::iter(&cx.tcx.node_type_substs.find(type_parameter_id)) |ts| {
let bounds = match e.node {
expr_path(_) => {
- let did = ast_util::def_id_of_def(cx.tcx.def_map.get(&e.id));
+ let did = ast_util::def_id_of_def(cx.tcx.def_map.get(e.id));
ty::lookup_item_type(cx.tcx, did).bounds
}
_ => {
fn check_ty(aty: @Ty, cx: ctx, v: visit::vt<ctx>) {
match aty.node {
ty_path(_, id) => {
- do option::iter(&cx.tcx.node_type_substs.find(&id)) |ts| {
- let did = ast_util::def_id_of_def(cx.tcx.def_map.get(&id));
+ do option::iter(&cx.tcx.node_type_substs.find(id)) |ts| {
+ let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id));
let bounds = ty::lookup_item_type(cx.tcx, did).bounds;
for vec::each2(*ts, *bounds) |ty, bound| {
check_bounds(cx, aty.id, aty.span, *ty, *bound)
fn is_nullary_variant(cx: ctx, ex: @expr) -> bool {
match ex.node {
expr_path(_) => {
- match cx.tcx.def_map.get(&ex.id) {
+ match cx.tcx.def_map.get(ex.id) {
def_variant(edid, vdid) => {
vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u
}
return; // Didn't match.
}
- match self.item_refs.find(&value) {
+ match self.item_refs.find(/*bad*/copy value) {
None => {
// Didn't match.
}
_expr_id: ast::node_id,
item_id: ast::node_id)
-> level {
- match settings.settings_map.find(&item_id) {
+ match settings.settings_map.find(item_id) {
Some(modes) => get_lint_level(modes, lint_mode),
None => get_lint_level(settings.default_settings, lint_mode)
}
for triples.each |pair| {
let (meta, level, lintname) = /*bad*/copy *pair;
- match self.dict.find(&lintname) {
+ match self.dict.find(/*bad*/ copy lintname) {
None => {
self.span_lint(
new_ctxt.get_level(unrecognized_lint),
for vec::each(vec::append_one(tys, decl.output)) |ty| {
match ty.node {
ast::ty_path(_, id) => {
- match cx.def_map.get(&id) {
+ match cx.def_map.get(id) {
ast::def_prim_ty(ast::ty_int(ast::ty_i)) => {
cx.sess.span_lint(
ctypes, id, fn_id,
}
fn variable(node_id: node_id, span: span) -> Variable {
- match self.variable_map.find(&node_id) {
+ match self.variable_map.find(node_id) {
Some(var) => var,
None => {
self.tcx.sess.span_bug(
}
fn captures(expr: @expr) -> @~[CaptureInfo] {
- match self.capture_info_map.find(&expr.id) {
+ match self.capture_info_map.find(expr.id) {
Some(caps) => caps,
None => {
self.tcx.sess.span_bug(expr.span, ~"no registered caps");
Local(LocalInfo {id: id, kind: FromLetNoInitializer, _}) |
Local(LocalInfo {id: id, kind: FromLetWithInitializer, _}) |
Local(LocalInfo {id: id, kind: FromMatch(_), _}) => {
- let v = match self.last_use_map.find(&expr_id) {
+ let v = match self.last_use_map.find(expr_id) {
Some(v) => v,
None => {
let v = @DVec();
match expr.node {
// live nodes required for uses or definitions of variables:
expr_path(_) => {
- let def = self.tcx.def_map.get(&expr.id);
+ let def = self.tcx.def_map.get(expr.id);
debug!("expr %d: path that leads to %?", expr.id, def);
if relevant_def(def).is_some() {
self.add_live_node_for_node(expr.id, ExprNode(expr.span));
// being the location that the variable is used. This results
// in better error messages than just pointing at the closure
// construction site.
- let cvs = self.capture_map.get(&expr.id);
+ let cvs = self.capture_map.get(expr.id);
let mut call_caps = ~[];
for cvs.each |cv| {
match relevant_def(cv.def) {
impl Liveness {
fn live_node(node_id: node_id, span: span) -> LiveNode {
- match self.ir.live_node_map.find(&node_id) {
+ match self.ir.live_node_map.find(node_id) {
Some(ln) => ln,
None => {
// This must be a mismatch between the ir_map construction
fn variable_from_path(expr: @expr) -> Option<Variable> {
match expr.node {
expr_path(_) => {
- let def = self.tcx.def_map.get(&expr.id);
+ let def = self.tcx.def_map.get(expr.id);
relevant_def(def).map(
|rdef| self.variable(*rdef, expr.span)
)
fn variable_from_def_map(node_id: node_id,
span: span) -> Option<Variable> {
- match self.tcx.def_map.find(&node_id) {
+ match self.tcx.def_map.find(node_id) {
Some(def) => {
relevant_def(def).map(
|rdef| self.variable(*rdef, span)
match opt_label {
Some(_) => // Refers to a labeled loop. Use the results of resolve
// to find with one
- match self.tcx.def_map.find(&id) {
+ match self.tcx.def_map.find(id) {
Some(def_label(loop_id)) => loop_id,
_ => self.tcx.sess.span_bug(sp, ~"Label on break/loop \
doesn't refer to a loop")
// Now that we know the label we're going to,
// look it up in the break loop nodes table
- match self.break_ln.find(&sc) {
+ match self.break_ln.find(sc) {
Some(b) => b,
None => self.tcx.sess.span_bug(expr.span,
~"Break to unknown label")
// Now that we know the label we're going to,
// look it up in the continue loop nodes table
- match self.cont_ln.find(&sc) {
+ match self.cont_ln.find(sc) {
Some(b) => b,
None => self.tcx.sess.span_bug(expr.span,
~"Loop to unknown label")
}
fn access_path(expr: @expr, succ: LiveNode, acc: uint) -> LiveNode {
- let def = self.tcx.def_map.get(&expr.id);
+ let def = self.tcx.def_map.get(expr.id);
match relevant_def(def) {
Some(nid) => {
let ln = self.live_node(expr.id, expr.span);
let ln = self.live_node(expr.id, expr.span);
self.consider_last_use(expr, ln, *var);
- match self.ir.variable_moves_map.find(&expr.id) {
+ match self.ir.variable_moves_map.find(expr.id) {
None => {}
Some(entire_expr) => {
debug!("(checking expr) is a move: `%s`",
fn check_lvalue(expr: @expr, vt: vt<@Liveness>) {
match expr.node {
expr_path(_) => {
- match self.tcx.def_map.get(&expr.id) {
+ match self.tcx.def_map.get(expr.id) {
def_local(nid, false) => {
// Assignment to an immutable variable or argument:
// only legal if there is no later assignment.
pub impl &mem_categorization_ctxt {
fn cat_expr(expr: @ast::expr) -> cmt {
- match self.tcx.adjustments.find(&expr.id) {
+ match self.tcx.adjustments.find(expr.id) {
None => {
// No adjustments.
self.cat_expr_unadjusted(expr)
}
ast::expr_path(_) => {
- let def = self.tcx.def_map.get(&expr.id);
+ let def = self.tcx.def_map.get(expr.id);
self.cat_def(expr.id, expr.span, expr_ty, def)
}
// variant(*)
}
ast::pat_enum(_, Some(ref subpats)) => {
- match self.tcx.def_map.find(&pat.id) {
+ match self.tcx.def_map.find(pat.id) {
Some(ast::def_variant(enum_did, _)) => {
// variant(x, y, z)
for subpats.each |subpat| {
}
}
ty::ty_enum(*) => {
- match tcx.def_map.get(&node_id) {
+ match tcx.def_map.get(node_id) {
ast::def_variant(_, variant_id) => {
for ty::lookup_struct_fields(tcx, variant_id).each |fld| {
if fld.ident == f_name {
// `expr_mode` refers to the post-adjustment value. If one of
// those adjustments is to take a reference, then it's only
// reading the underlying expression, not moving it.
- let comp_mode = match self.tcx.adjustments.find(&expr.id) {
+ let comp_mode = match self.tcx.adjustments.find(expr.id) {
Some(adj) if adj.autoref.is_some() => Read,
_ => expr_mode.component_mode(expr)
};
receiver_expr: @expr,
visitor: vt<VisitContext>)
{
- let callee_mode = match self.method_map.find(&expr_id) {
+ let callee_mode = match self.method_map.find(expr_id) {
Some(ref method_map_entry) => {
match method_map_entry.explicit_self {
sty_by_ref => by_ref,
pub fn pat_is_variant_or_struct(dm: resolve::DefMap, pat: @pat) -> bool {
match pat.node {
pat_enum(_, _) | pat_ident(_, _, None) | pat_struct(*) => {
- match dm.find(&pat.id) {
+ match dm.find(pat.id) {
Some(def_variant(*)) | Some(def_struct(*)) => true,
_ => false
}
pub fn pat_is_const(dm: resolve::DefMap, pat: &pat) -> bool {
match pat.node {
pat_ident(_, _, None) => {
- match dm.find(&pat.id) {
+ match dm.find(pat.id) {
Some(def_const(*)) => true,
_ => false
}
match *origin {
method_static(method_id) => {
if method_id.crate == local_crate {
- match tcx.items.find(&method_id.node) {
+ match tcx.items.find(method_id.node) {
Some(node_method(method, impl_id, _)) => {
if method.vis == private &&
(impl_id.crate != local_crate ||
method_self(trait_id, method_num) |
method_super(trait_id, method_num) => {
if trait_id.crate == local_crate {
- match tcx.items.find(&trait_id.node) {
+ match tcx.items.find(trait_id.node) {
Some(node_item(item, _)) => {
match item.node {
item_trait(_, _, ref methods) => {
ty_struct(id, _)
if id.crate != local_crate ||
!privileged_items.contains(&(id.node)) => {
- match method_map.find(&expr.id) {
+ match method_map.find(expr.id) {
None => {
debug!("(privacy checking) checking \
field access");
ty_struct(id, _)
if id.crate != local_crate ||
!privileged_items.contains(&(id.node)) => {
- match method_map.find(&expr.id) {
+ match method_map.find(expr.id) {
None => {
tcx.sess.span_bug(expr.span,
~"method call not in \
ty_enum(id, _) => {
if id.crate != local_crate ||
!privileged_items.contains(&(id.node)) {
- match tcx.def_map.get(&expr.id) {
+ match tcx.def_map.get(expr.id) {
def_variant(_, variant_id) => {
for (*fields).each |field| {
debug!("(privacy checking) \
if enum_id.crate != local_crate ||
!privileged_items.contains(
&enum_id.node) {
- match tcx.def_map.find(&pattern.id) {
+ match tcx.def_map.find(pattern.id) {
Some(def_variant(_, variant_id)) => {
for fields.each |field| {
debug!("(privacy checking) \
subscope: ast::node_id) -> bool {
let mut subscope = subscope;
while superscope != subscope {
- match region_map.find(&subscope) {
+ match region_map.find(subscope) {
None => return false,
Some(scope) => subscope = scope
}
let mut result = ~[scope];
let mut scope = scope;
loop {
- match region_map.find(&scope) {
+ match region_map.find(scope) {
None => return result,
Some(superscope) => {
result.push(superscope);
pub fn resolve_pat(pat: @ast::pat, cx: ctxt, visitor: visit::vt<ctxt>) {
match pat.node {
ast::pat_ident(*) => {
- let defn_opt = cx.def_map.find(&pat.id);
+ let defn_opt = cx.def_map.find(pat.id);
match defn_opt {
Some(ast::def_variant(_,_)) => {
/* Nothing to do; this names a variant. */
/// the new variance is joined with the old variance.
fn add_rp(id: ast::node_id, variance: region_variance) {
assert id != 0;
- let old_variance = self.region_paramd_items.find(&id);
+ let old_variance = self.region_paramd_items.find(id);
let joined_variance = match old_variance {
None => variance,
Some(v) => join_variance(v, variance)
ast_map::node_id_to_str(self.ast_map, self.item_id,
self.sess.parse_sess.interner),
copy self.ambient_variance);
- let vec = match self.dep_map.find(&from) {
+ let vec = match self.dep_map.find(from) {
Some(vec) => vec,
None => {
let vec = @DVec();
// that as a direct dependency.
match ty.node {
ast::ty_path(path, id) => {
- match cx.def_map.find(&id) {
+ match cx.def_map.find(id) {
Some(ast::def_ty(did)) | Some(ast::def_struct(did)) => {
if did.crate == ast::local_crate {
if cx.opt_region_is_relevant(path.rp) {
// update the region-parameterization of D to reflect the result.
while cx.worklist.len() != 0 {
let c_id = cx.worklist.pop();
- let c_variance = cx.region_paramd_items.get(&c_id);
+ let c_variance = cx.region_paramd_items.get(c_id);
debug!("popped %d from worklist", c_id);
- match cx.dep_map.find(&c_id) {
+ match cx.dep_map.find(c_id) {
None => {}
Some(deps) => {
for deps.each |dep| {
// Add or reuse the child.
let new_parent = ModuleReducedGraphParent(module_);
- match module_.children.find(&name) {
+ match module_.children.find(name) {
None => {
let child = @NameBindings();
module_.children.insert(name, child);
%s", final_ident);
let parent_link = self.get_parent_link(new_parent, ident);
- match modules.find(&def_id) {
+ match modules.find(def_id) {
None => {
child_name_bindings.define_module(Public,
parent_link,
die!(~"can't happen");
}
ModuleParentLink(parent_module, ident) => {
- let name_bindings = parent_module.children.get(
- &ident);
+ let name_bindings = parent_module.children.get(ident);
resolution.type_target =
Some(Target(parent_module, name_bindings));
}
self.idents_to_str(module_path.get()),
self.session.str_of(target));
- match module_.import_resolutions.find(&target) {
+ match module_.import_resolutions.find(target) {
Some(resolution) => {
debug!("(building import directive) bumping \
reference");
let mut type_result = UnknownResult;
// Search for direct children of the containing module.
- match containing_module.children.find(&source) {
+ match containing_module.children.find(source) {
None => {
// Continue.
}
// Now search the exported imports within the containing
// module.
- match containing_module.import_resolutions.find(&source) {
+ match containing_module.import_resolutions.find(source) {
None => {
// The containing module definitely doesn't have an
// exported import with the name in question. We can
// We've successfully resolved the import. Write the results in.
assert module_.import_resolutions.contains_key_ref(&target);
- let import_resolution = module_.import_resolutions.get(&target);
+ let import_resolution = module_.import_resolutions.get(target);
match value_result {
BoundResult(target_module, name_bindings) => {
let mut module_result = UnknownResult;
// Search for direct children of the containing module.
- match containing_module.children.find(&source) {
+ match containing_module.children.find(source) {
None => {
// Continue.
}
// Now search the exported imports within the containing
// module.
- match containing_module.import_resolutions.find(&source) {
+ match containing_module.import_resolutions.find(source) {
None => {
// The containing module definitely doesn't have an
// exported import with the name in question. We can
// We've successfully resolved the import. Write the results in.
assert module_.import_resolutions.contains_key_ref(&target);
- let import_resolution = module_.import_resolutions.get(&target);
+ let import_resolution = module_.import_resolutions.get(target);
match module_result {
BoundResult(target_module, name_bindings) => {
self.module_to_str(module_));
// Here we merge two import resolutions.
- match module_.import_resolutions.find(&ident) {
+ match module_.import_resolutions.find(ident) {
None => {
// Simple: just copy the old import resolution.
let new_import_resolution =
// Add all children from the containing module.
for containing_module.children.each_ref |&ident, &name_bindings| {
let mut dest_import_resolution;
- match module_.import_resolutions.find(&ident) {
+ match module_.import_resolutions.find(ident) {
None => {
// Create a new import resolution from this child.
dest_import_resolution = @ImportResolution(privacy, span);
// The current module node is handled specially. First, check for
// its immediate children.
- match module_.children.find(&name) {
+ match module_.children.find(name) {
Some(name_bindings)
if (*name_bindings).defined_in_namespace(namespace) => {
return Success(Target(module_, name_bindings));
// adjacent import statements are processed as though they mutated the
// current scope.
- match module_.import_resolutions.find(&name) {
+ match module_.import_resolutions.find(name) {
None => {
// Not found; continue.
}
self.module_to_str(module_));
// First, check the direct children of the module.
- match module_.children.find(&name) {
+ match module_.children.find(name) {
Some(name_bindings)
if (*name_bindings).defined_in_namespace(namespace) => {
}
// Otherwise, we check the list of resolved imports.
- match module_.import_resolutions.find(&name) {
+ match module_.import_resolutions.find(name) {
Some(import_resolution) => {
if import_resolution.outstanding_references != 0 {
debug!("(resolving name in module) import unresolved; \
}
// Otherwise, proceed and write in the bindings.
- match module_.import_resolutions.find(&target_name) {
+ match module_.import_resolutions.find(target_name) {
None => {
die!(~"(resolving one-level renaming import) reduced graph \
construction or glob importing should have created the \
// Nothing to do.
}
Some(name) => {
- match orig_module.children.find(&name) {
+ match orig_module.children.find(name) {
None => {
debug!("!!! (with scope) didn't find `%s` in `%s`",
self.session.str_of(name),
// If the def is a ty param, and came from the parent
// item, it's ok
match def {
- def_ty_param(did, _) if self.def_map.find(&did.node)
+ def_ty_param(did, _) if self.def_map.find(copy(did.node))
== Some(def_typaram_binder(item_id)) => {
// ok
}
while i != 0 {
i -= 1;
let rib = (*ribs).get_elt(i);
- match rib.bindings.find(&name) {
+ match rib.bindings.find(name) {
Some(def_like) => {
return self.upvarify(ribs, i, def_like, span,
allow_capturing_self);
let map_i = self.binding_mode_map(*p);
for map_0.each_ref |&key, &binding_0| {
- match map_i.find(&key) {
+ match map_i.find(key) {
None => {
self.session.span_err(
p.span,
// Move down in the graph, if there's an anonymous module rooted here.
let orig_module = self.current_module;
- match self.current_module.anonymous_children.find(&block.node.id) {
+ match self.current_module.anonymous_children.find(block.node.id) {
None => { /* Nothing to do. */ }
Some(anonymous_module) => {
debug!("(resolving block) found anonymous module, moving \
match self.primitive_type_table
.primitive_types
- .find(&name) {
+ .find(name) {
Some(primitive_type) => {
result_def =
bindings_list.insert(ident, pat_id);
}
Some(b) => {
- if b.find(&ident) == Some(pat_id) {
+ if b.find(ident) == Some(pat_id) {
// Then this is a duplicate variable
// in the same disjunct, which is an
// error
-> NameDefinition {
// First, search children.
- match containing_module.children.find(&name) {
+ match containing_module.children.find(name) {
Some(child_name_bindings) => {
match (child_name_bindings.def_for_namespace(namespace),
child_name_bindings.privacy_for_namespace(namespace)) {
}
// Next, search import resolutions.
- match containing_module.import_resolutions.find(&name) {
+ match containing_module.import_resolutions.find(name) {
Some(import_resolution) if import_resolution.privacy == Public ||
xray == Xray => {
match (*import_resolution).target_for_namespace(namespace) {
trait_def_id.node,
self.session.str_of(name));
- match self.trait_info.find(&trait_def_id) {
+ match self.trait_info.find(trait_def_id) {
Some(trait_info) if trait_info.contains_key_ref(&name) => {
debug!("(adding trait info if containing method) found trait \
%d:%d for method '%s'",
}
pub fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> Opt {
- match tcx.def_map.get(&pat_id) {
+ match tcx.def_map.get(pat_id) {
ast::def_variant(enum_id, var_id) => {
let variants = ty::enum_variants(tcx, enum_id);
for vec::each(*variants) |v| {
vec::view(br.pats, col + 1u, br.pats.len())));
let binding_info =
- br.data.bindings_map.get(&path_to_ident(path));
+ br.data.bindings_map.get(path_to_ident(path));
Store(bcx, val, binding_info.llmatch);
@Match {pats: pats, data: br.data}
ast::pat_ident(_, path, None) => {
if pat_is_binding(dm, self) {
let binding_info =
- br.data.bindings_map.get(
- &path_to_ident(path));
+ br.data.bindings_map.get(path_to_ident(path));
Store(bcx, val, binding_info.llmatch);
}
}
}
}
ast::pat_ident(_, _, None) if pat_is_const(tcx.def_map, p) => {
- let const_def = tcx.def_map.get(&p.id);
+ let const_def = tcx.def_map.get(p.id);
let const_def_id = ast_util::def_id_of_def(const_def);
if opt_eq(tcx, &lit(ConstLit(const_def_id)), opt) {
Some(~[])
if opt_eq(tcx, &variant_opt(tcx, p.id), opt) {
// Look up the struct variant ID.
let struct_id;
- match tcx.def_map.get(&p.id) {
+ match tcx.def_map.get(p.id) {
ast::def_variant(_, found_struct_id) => {
struct_id = found_struct_id;
}
ast::pat_ident(*) => {
// This is one of: an enum variant, a unit-like struct, or a
// variable binding.
- match ccx.tcx.def_map.find(&cur.id) {
+ match ccx.tcx.def_map.find(cur.id) {
Some(ast::def_variant(*)) => {
add_to_set(ccx.tcx, &found,
variant_opt(ccx.tcx, cur.id));
ast::pat_enum(*) | ast::pat_struct(*) => {
// This could be one of: a tuple-like enum variant, a
// struct-like enum variant, or a struct.
- match ccx.tcx.def_map.find(&cur.id) {
+ match ccx.tcx.def_map.find(cur.id) {
Some(ast::def_variant(*)) => {
add_to_set(ccx.tcx, &found,
variant_opt(ccx.tcx, cur.id));
let pat_id = br.pats[col].id;
let key = root_map_key {id: pat_id, derefs: 0u };
- match bcx.ccx().maps.root_map.find(&key) {
+ match bcx.ccx().maps.root_map.find(key) {
None => (),
Some(root_info) => {
// Note: the scope_id will always be the id of the match. See
let pat = br.pats[col];
match pat.node {
ast::pat_enum(_, Some(_)) => {
- match bcx.tcx().def_map.find(&pat.id) {
+ match bcx.tcx().def_map.find(pat.id) {
Some(ast::def_struct(*)) => true,
_ => false
}
}
}
ast::pat_enum(_, sub_pats) => {
- match bcx.tcx().def_map.find(&pat.id) {
+ match bcx.tcx().def_map.find(pat.id) {
Some(ast::def_variant(*)) => {
- let pat_def = ccx.tcx.def_map.get(&pat.id);
+ let pat_def = ccx.tcx.def_map.get(pat.id);
let vdefs = ast_util::variant_def_ids(pat_def);
let args = extract_variant_args(bcx, pat.id, vdefs, val);
for sub_pats.each |sub_pat| {
+name: ~str,
cc: lib::llvm::CallConv,
ty: TypeRef) -> ValueRef {
- if externs.contains_key_ref(&name) { return externs.get(&name); }
+ if externs.contains_key_ref(&name) { return externs.get(name); }
// XXX: Bad copy.
let f = decl_fn(llmod, copy name, cc, ty);
externs.insert(name, f);
pub fn get_extern_const(externs: HashMap<~str, ValueRef>, llmod: ModuleRef,
+name: ~str, ty: TypeRef) -> ValueRef {
unsafe {
- if externs.contains_key_ref(&name) { return externs.get(&name); }
+ if externs.contains_key_ref(&name) { return externs.get(name); }
let c = str::as_c_str(name, |buf| {
llvm::LLVMAddGlobal(llmod, ty, buf)
});
}
pub fn get_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
- match ccx.tydescs.find(&t) {
+ match ccx.tydescs.find(t) {
Some(inf) => inf,
_ => {
ccx.stats.n_static_tydescs += 1u;
pub fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef {
unsafe {
let _icx = ccx.insn_ctxt("lookup_discriminant");
- match ccx.discrims.find(&vid) {
+ match ccx.discrims.find(vid) {
None => {
// It's an external discriminant that we haven't seen yet.
assert (vid.crate != ast::local_crate);
}
}
- let llptr = match bcx.fcx.lllocals.find(&local.node.id) {
+ let llptr = match bcx.fcx.lllocals.find(local.node.id) {
Some(local_mem(v)) => v,
_ => { bcx.tcx().sess.span_bug(local.span,
~"init_local: Someone forgot to document why it's\
session::arch_x86 | session::arch_arm => ~"llvm.memcpy.p0i8.p0i8.i32",
session::arch_x86_64 => ~"llvm.memcpy.p0i8.p0i8.i64"
};
- let memcpy = ccx.intrinsics.get(&key);
+ let memcpy = ccx.intrinsics.get(key);
let src_ptr = PointerCast(cx, src, T_ptr(T_i8()));
let dst_ptr = PointerCast(cx, dst, T_ptr(T_i8()));
let size = IntCast(cx, n_bytes, ccx.int_type);
}
}
- let llintrinsicfn = ccx.intrinsics.get(&intrinsic_key);
+ let llintrinsicfn = ccx.intrinsics.get(intrinsic_key);
let llptr = PointerCast(cx, llptr, T_ptr(T_i8()));
let llzeroval = C_u8(0);
let size = IntCast(cx, machine::llsize_of(ccx, llty), ccx.int_type);
// If this argument to this function is a enum, it'll have come in to
// this function as an opaque blob due to the way that type_of()
// works. So we have to cast to the destination's view of the type.
- let llarg = match fcx.llargs.find(&va.id) {
+ let llarg = match fcx.llargs.find(va.id) {
Some(local_mem(x)) => x,
_ => die!(~"trans_enum_variant: how do we know this works?"),
};
for fields.eachi |i, field| {
let lldestptr = GEPi(bcx, fcx.llretptr, [0, 0, i]);
- let llarg = match fcx.llargs.get(&field.node.id) {
+ let llarg = match fcx.llargs.get(field.node.id) {
local_mem(x) => x,
_ => {
ccx.tcx.sess.bug(~"trans_tuple_struct: llarg wasn't \
pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
let _icx = ccx.insn_ctxt("trans_item");
- let path = match ccx.tcx.items.get(&item.id) {
+ let path = match ccx.tcx.items.get(item.id) {
ast_map::node_item(_, p) => p,
// tjc: ?
_ => die!(~"trans_item"),
pub fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path {
vec::append(
- /*bad*/copy *match ccx.tcx.items.get(&i.id) {
+ /*bad*/copy *match ccx.tcx.items.get(i.id) {
ast_map::node_item(_, p) => p,
// separate map for paths?
_ => die!(~"item_path")
+substs: Option<param_substs>)
-> ~str {
let t = ty::node_id_to_type(ccx.tcx, id);
- match ccx.item_symbols.find(&id) {
+ match ccx.item_symbols.find(id) {
Some(ref s) => (/*bad*/copy *s),
None if substs.is_none() => {
let s = mangle_exported_name(
pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
debug!("get_item_val(id=`%?`)", id);
let tcx = ccx.tcx;
- match ccx.item_vals.find(&id) {
+ match ccx.item_vals.find(id) {
Some(v) => v,
None => {
let mut exprt = false;
- let val = match ccx.tcx.items.get(&id) {
+ let val = match ccx.tcx.items.get(id) {
ast_map::node_item(i, pth) => {
let my_path = vec::append(/*bad*/copy *pth,
~[path_name(i.ident)]);
pub fn trap(bcx: block) {
let v: ~[ValueRef] = ~[];
- match bcx.ccx().intrinsics.find(&~"llvm.trap") {
+ match bcx.ccx().intrinsics.find(~"llvm.trap") {
Some(x) => { Call(bcx, x, v); },
_ => bcx.sess().bug(~"unbound llvm.trap in trap")
}
i = 0u;
while i < len {
let e = /*bad*/copy v[i];
- i = mm.get(&e);
+ i = mm.get(/*bad*/ copy e);
s += ~"/";
s += e;
i += 1u;
s += ~"/";
s += category;
- let n = match h.find(&s) {
+ let n = match h.find(/*bad*/ copy s) {
Some(n) => n,
_ => 0u
};
return trans_def(bcx, bcx.def(expr.id), expr);
}
ast::expr_field(base, _, _) => {
- match bcx.ccx().maps.method_map.find(&expr.id) {
+ match bcx.ccx().maps.method_map.find(expr.id) {
Some(ref origin) => { // An impl method
return meth::trans_method_callee(bcx, expr.id,
base, (*origin));
// Modify the def_id if this is a default method; we want to be
// monomorphizing the trait's code.
let (def_id, opt_impl_did) =
- match tcx.provided_method_sources.find(&def_id) {
+ match tcx.provided_method_sources.find(def_id) {
None => (def_id, None),
Some(source) => (source.method_id, Some(source.impl_id))
};
} else if def_id.crate == ast::local_crate {
let map_node = session::expect(
ccx.sess,
- ccx.tcx.items.find(&def_id.node),
+ ccx.tcx.items.find(def_id.node),
|| fmt!("local item should be in ast map"));
match map_node {
node_id_type(in_cx, call_ex.callee_id),
expr_ty(in_cx, call_ex),
|cx| {
- match cx.ccx().maps.method_map.find(&call_ex.id) {
+ match cx.ccx().maps.method_map.find(call_ex.id) {
Some(ref origin) => {
meth::trans_method_callee(cx,
call_ex.callee_id,
let Result {bcx: bcx, val: closure} = match proto {
ast::ProtoBorrowed | ast::ProtoBox | ast::ProtoUniq => {
- let cap_vars = ccx.maps.capture_map.get(&user_id);
+ let cap_vars = ccx.maps.capture_map.get(user_id);
let ret_handle = match is_loop_body {Some(x) => x,
None => None};
let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, proto,
}
fn def(nid: ast::node_id) -> ast::def {
- match self.tcx().def_map.find(&nid) {
+ match self.tcx().def_map.find(nid) {
Some(v) => v,
None => {
self.tcx().sess.bug(fmt!(
// our boxed-and-length-annotated strings.
pub fn C_cstr(cx: @crate_ctxt, +s: ~str) -> ValueRef {
unsafe {
- match cx.const_cstr_cache.find(&s) {
+ match cx.const_cstr_cache.find(/*bad*/copy s) {
Some(llval) => return llval,
None => ()
}
pub fn node_vtables(bcx: block, id: ast::node_id)
-> Option<typeck::vtable_res> {
- let raw_vtables = bcx.ccx().maps.vtable_map.find(&id);
+ let raw_vtables = bcx.ccx().maps.vtable_map.find(id);
raw_vtables.map(
|vts| resolve_vtables_in_fn_ctxt(bcx.fcx, *vts))
}
pub fn const_deref(cx: @crate_ctxt, v: ValueRef) -> ValueRef {
unsafe {
- let v = match cx.const_globals.find(&(v as int)) {
+ let v = match cx.const_globals.find(v as int) {
Some(v) => v,
None => v
};
cx.tcx.sess.bug(~"cross-crate constants");
}
if !cx.const_values.contains_key_ref(&def_id.node) {
- match cx.tcx.items.get(&def_id.node) {
+ match cx.tcx.items.get(def_id.node) {
ast_map::node_item(@ast::item {
node: ast::item_const(_, subexpr), _
}, _) => {
_ => cx.tcx.sess.bug(~"expected a const to be an item")
}
}
- cx.const_values.get(&def_id.node)
+ cx.const_values.get(def_id.node)
}
pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
}
ast::expr_path(pth) => {
assert pth.types.len() == 0;
- match cx.tcx.def_map.find(&e.id) {
+ match cx.tcx.def_map.find(e.id) {
Some(ast::def_fn(def_id, purity)) => {
assert ast_util::is_local(def_id);
let f = base::get_item_val(cx, def_id.node);
}
}
ast::expr_call(callee, args, _) => {
- match cx.tcx.def_map.find(&callee.id) {
+ match cx.tcx.def_map.find(callee.id) {
Some(ast::def_struct(def_id)) => {
let ety = ty::expr_ty(cx.tcx, e);
let llty = type_of::type_of(cx, ety);
let g = base::get_item_val(ccx, id);
// At this point, get_item_val has already translated the
// constant's initializer to determine its LLVM type.
- let v = ccx.const_values.get(&id);
+ let v = ccx.const_values.get(id);
llvm::LLVMSetInitializer(g, v);
llvm::LLVMSetGlobalConstant(g, True);
}
let modname = path_str(ccx.sess, copy modpath);
let global = if ccx.module_data.contains_key_ref(&modname) {
- ccx.module_data.get(&modname)
+ ccx.module_data.get(modname)
} else {
let s = link::mangle_internal_name_by_path_and_seq(
ccx, modpath, ~"loglevel");
//
// (Note: root'd values are always boxes)
let key = root_map_key { id: expr_id, derefs: derefs };
- let bcx = match ccx.maps.root_map.find(&key) {
+ let bcx = match ccx.maps.root_map.find(key) {
None => bcx,
Some(root_info) => self.root(bcx, root_info)
};
// Perform the write guard, if necessary.
//
// (Note: write-guarded values are always boxes)
- let bcx = match ccx.maps.write_guard_map.find(&key) {
+ let bcx = match ccx.maps.write_guard_map.find(key) {
None => bcx,
Some(_) => self.perform_write_guard(bcx)
};
fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) {
let existing = if cache.contains_key_ref(&mdtag) {
- cache.get(&mdtag)
+ cache.get(mdtag)
} else {
~[]
};
-> Option<T> {
unsafe {
if cache.contains_key_ref(&mdtag) {
- let items = cache.get(&mdtag);
+ let items = cache.get(mdtag);
for items.each |item| {
let md: T = md_from_metadata::<T>(*item);
if eq_fn(md) {
Some(bcx) => create_block(bcx).node
};
let file_node = create_file(cx.ccx(), fname);
- let unique_id = match cache.find(&LexicalBlockTag) {
+ let unique_id = match cache.find(LexicalBlockTag) {
option::Some(v) => vec::len(v) as int,
option::None => 0
};
let mdval = @{node: mdnode, data: {id: local.node.id}};
update_cache(cache, AutoVariableTag, local_var_metadata(mdval));
- let llptr = match bcx.fcx.lllocals.find(&local.node.id) {
+ let llptr = match bcx.fcx.lllocals.find(local.node.id) {
option::Some(local_mem(v)) => v,
option::Some(_) => {
bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
something weird");
}
option::None => {
- match bcx.fcx.lllocals.get(&local.node.pat.id) {
+ match bcx.fcx.lllocals.get(local.node.pat.id) {
local_imm(v) => v,
_ => bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
something weird")
}
};
let declargs = ~[llmdnode(~[llptr]), mdnode];
- trans::build::Call(bcx, cx.intrinsics.get(&~"llvm.dbg.declare"),
+ trans::build::Call(bcx, cx.intrinsics.get(~"llvm.dbg.declare"),
declargs);
return mdval;
}
let mdval = @{node: mdnode, data: {id: arg.id}};
update_cache(cache, tg, argument_metadata(mdval));
- let llptr = match fcx.llargs.get(&arg.id) {
+ let llptr = match fcx.llargs.get(arg.id) {
local_mem(v) | local_imm(v) => v,
};
let declargs = ~[llmdnode(~[llptr]), mdnode];
trans::build::Call(bcx,
- cx.intrinsics.get(&~"llvm.dbg.declare"),
+ cx.intrinsics.get(~"llvm.dbg.declare"),
declargs);
return Some(mdval);
}
let sp = fcx.span.get();
log(debug, cx.sess.codemap.span_to_str(sp));
- let (ident, ret_ty, id) = match cx.tcx.items.get(&fcx.id) {
+ let (ident, ret_ty, id) = match cx.tcx.items.get(fcx.id) {
ast_map::node_item(item, _) => {
match /*bad*/copy item.node {
ast::item_fn(decl, _, _, _) => {
pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr));
- return match bcx.tcx().adjustments.find(&expr.id) {
+ return match bcx.tcx().adjustments.find(expr.id) {
None => {
trans_to_datum_unadjusted(bcx, expr)
}
* instead, but sometimes we call trans_lvalue() directly as a
* means of asserting that a particular expression is an lvalue. */
- return match bcx.tcx().adjustments.find(&expr.id) {
+ return match bcx.tcx().adjustments.find(expr.id) {
None => trans_lvalue_unadjusted(bcx, expr),
Some(_) => {
bcx.sess().span_bug(
// the lvalue in there, and then arrange for it to be cleaned up
// at the end of the scope with id `scope_id`:
let root_key = root_map_key { id: expr.id, derefs: 0u };
- for bcx.ccx().maps.root_map.find(&root_key).each |&root_info| {
+ for bcx.ccx().maps.root_map.find(root_key).each |&root_info| {
bcx = unrooted_datum.root(bcx, root_info);
}
ast::def_upvar(nid, _, _, _) => {
// Can't move upvars, so this is never a ZeroMemLastUse.
let local_ty = node_id_type(bcx, nid);
- match bcx.fcx.llupvars.find(&nid) {
+ match bcx.fcx.llupvars.find(nid) {
Some(val) => {
Datum {
val: val,
fn take_local(bcx: block,
table: HashMap<ast::node_id, local_val>,
nid: ast::node_id) -> Datum {
- let (v, mode) = match table.find(&nid) {
+ let (v, mode) = match table.find(nid) {
Some(local_mem(v)) => (v, ByRef),
Some(local_imm(v)) => (v, ByValue),
None => {
ty_to_str(tcx, ty)));
}
Some(node_id) => {
- match tcx.def_map.get(&node_id) {
+ match tcx.def_map.get(node_id) {
ast::def_variant(_, variant_id) => {
op(false, struct_mutable_fields(
tcx, variant_id, substs))
let tcx = bcx.tcx();
let addr = match ty::get(ty).sty {
ty::ty_enum(_, ref substs) => {
- match tcx.def_map.get(&id) {
+ match tcx.def_map.get(id) {
ast::def_variant(enum_id, variant_id) => {
let variant_info = ty::enum_variant_with_id(
tcx, enum_id, variant_id);
dest: Dest,
+autoref_arg: AutorefArg) -> block
{
- let origin = bcx.ccx().maps.method_map.get(&expr.id);
+ let origin = bcx.ccx().maps.method_map.get(expr.id);
let fty = node_id_type(bcx, expr.callee_id);
return callee::trans_call_inner(
bcx, expr.info(), fty,
let dst_datum = unpack_datum!(bcx, trans_lvalue_unadjusted(bcx, dst));
// A user-defined operator method
- if bcx.ccx().maps.method_map.find(&expr.id).is_some() {
+ if bcx.ccx().maps.method_map.find(expr.id).is_some() {
// FIXME(#2528) evaluates the receiver twice!!
let scratch = scratch_datum(bcx, dst_datum.ty, false);
let bcx = trans_overloaded_op(bcx, expr, dst, ~[src],
let tp_sz = machine::llbitsize_of_real(ccx, lltp_ty),
out_sz = machine::llbitsize_of_real(ccx, llout_ty);
if tp_sz != out_sz {
- let sp = match ccx.tcx.items.get(&ref_id.get()) {
+ let sp = match ccx.tcx.items.get(ref_id.get()) {
ast_map::node_expr(e) => e.span,
_ => die!(~"reinterpret_cast or forget has non-expr arg")
};
abi::tydesc_field_visit_glue, None);
}
~"frame_address" => {
- let frameaddress = ccx.intrinsics.get(&~"llvm.frameaddress");
+ let frameaddress = ccx.intrinsics.get(~"llvm.frameaddress");
let frameaddress_val = Call(bcx, frameaddress, ~[C_i32(0i32)]);
let star_u8 = ty::mk_imm_ptr(
bcx.tcx(),
let align = C_i32(1);
let volatile = C_bool(false);
let llfn = bcx.ccx().intrinsics.get(
- &~"llvm.memmove.p0i8.p0i8.i32");
+ ~"llvm.memmove.p0i8.p0i8.i32");
Call(bcx, llfn, ~[dst_ptr, src_ptr, size, align, volatile]);
}
~"memmove64" => {
let align = C_i32(1);
let volatile = C_bool(false);
let llfn = bcx.ccx().intrinsics.get(
- &~"llvm.memmove.p0i8.p0i8.i64");
+ ~"llvm.memmove.p0i8.p0i8.i64");
Call(bcx, llfn, ~[dst_ptr, src_ptr, size, align, volatile]);
}
~"sqrtf32" => {
let x = get_param(decl, first_real_arg);
- let sqrtf = ccx.intrinsics.get(&~"llvm.sqrt.f32");
+ let sqrtf = ccx.intrinsics.get(~"llvm.sqrt.f32");
Store(bcx, Call(bcx, sqrtf, ~[x]), fcx.llretptr);
}
~"sqrtf64" => {
let x = get_param(decl, first_real_arg);
- let sqrtf = ccx.intrinsics.get(&~"llvm.sqrt.f64");
+ let sqrtf = ccx.intrinsics.get(~"llvm.sqrt.f64");
Store(bcx, Call(bcx, sqrtf, ~[x]), fcx.llretptr);
}
~"powif32" => {
let a = get_param(decl, first_real_arg);
let x = get_param(decl, first_real_arg + 1u);
- let powif = ccx.intrinsics.get(&~"llvm.powi.f32");
+ let powif = ccx.intrinsics.get(~"llvm.powi.f32");
Store(bcx, Call(bcx, powif, ~[a, x]), fcx.llretptr);
}
~"powif64" => {
let a = get_param(decl, first_real_arg);
let x = get_param(decl, first_real_arg + 1u);
- let powif = ccx.intrinsics.get(&~"llvm.powi.f64");
+ let powif = ccx.intrinsics.get(~"llvm.powi.f64");
Store(bcx, Call(bcx, powif, ~[a, x]), fcx.llretptr);
}
~"sinf32" => {
let x = get_param(decl, first_real_arg);
- let sinf = ccx.intrinsics.get(&~"llvm.sin.f32");
+ let sinf = ccx.intrinsics.get(~"llvm.sin.f32");
Store(bcx, Call(bcx, sinf, ~[x]), fcx.llretptr);
}
~"sinf64" => {
let x = get_param(decl, first_real_arg);
- let sinf = ccx.intrinsics.get(&~"llvm.sin.f64");
+ let sinf = ccx.intrinsics.get(~"llvm.sin.f64");
Store(bcx, Call(bcx, sinf, ~[x]), fcx.llretptr);
}
~"cosf32" => {
let x = get_param(decl, first_real_arg);
- let cosf = ccx.intrinsics.get(&~"llvm.cos.f32");
+ let cosf = ccx.intrinsics.get(~"llvm.cos.f32");
Store(bcx, Call(bcx, cosf, ~[x]), fcx.llretptr);
}
~"cosf64" => {
let x = get_param(decl, first_real_arg);
- let cosf = ccx.intrinsics.get(&~"llvm.cos.f64");
+ let cosf = ccx.intrinsics.get(~"llvm.cos.f64");
Store(bcx, Call(bcx, cosf, ~[x]), fcx.llretptr);
}
~"powf32" => {
let a = get_param(decl, first_real_arg);
let x = get_param(decl, first_real_arg + 1u);
- let powf = ccx.intrinsics.get(&~"llvm.pow.f32");
+ let powf = ccx.intrinsics.get(~"llvm.pow.f32");
Store(bcx, Call(bcx, powf, ~[a, x]), fcx.llretptr);
}
~"powf64" => {
let a = get_param(decl, first_real_arg);
let x = get_param(decl, first_real_arg + 1u);
- let powf = ccx.intrinsics.get(&~"llvm.pow.f64");
+ let powf = ccx.intrinsics.get(~"llvm.pow.f64");
Store(bcx, Call(bcx, powf, ~[a, x]), fcx.llretptr);
}
~"expf32" => {
let x = get_param(decl, first_real_arg);
- let expf = ccx.intrinsics.get(&~"llvm.exp.f32");
+ let expf = ccx.intrinsics.get(~"llvm.exp.f32");
Store(bcx, Call(bcx, expf, ~[x]), fcx.llretptr);
}
~"expf64" => {
let x = get_param(decl, first_real_arg);
- let expf = ccx.intrinsics.get(&~"llvm.exp.f64");
+ let expf = ccx.intrinsics.get(~"llvm.exp.f64");
Store(bcx, Call(bcx, expf, ~[x]), fcx.llretptr);
}
~"exp2f32" => {
let x = get_param(decl, first_real_arg);
- let exp2f = ccx.intrinsics.get(&~"llvm.exp2.f32");
+ let exp2f = ccx.intrinsics.get(~"llvm.exp2.f32");
Store(bcx, Call(bcx, exp2f, ~[x]), fcx.llretptr);
}
~"exp2f64" => {
let x = get_param(decl, first_real_arg);
- let exp2f = ccx.intrinsics.get(&~"llvm.exp2.f64");
+ let exp2f = ccx.intrinsics.get(~"llvm.exp2.f64");
Store(bcx, Call(bcx, exp2f, ~[x]), fcx.llretptr);
}
~"logf32" => {
let x = get_param(decl, first_real_arg);
- let logf = ccx.intrinsics.get(&~"llvm.log.f32");
+ let logf = ccx.intrinsics.get(~"llvm.log.f32");
Store(bcx, Call(bcx, logf, ~[x]), fcx.llretptr);
}
~"logf64" => {
let x = get_param(decl, first_real_arg);
- let logf = ccx.intrinsics.get(&~"llvm.log.f64");
+ let logf = ccx.intrinsics.get(~"llvm.log.f64");
Store(bcx, Call(bcx, logf, ~[x]), fcx.llretptr);
}
~"log10f32" => {
let x = get_param(decl, first_real_arg);
- let log10f = ccx.intrinsics.get(&~"llvm.log10.f32");
+ let log10f = ccx.intrinsics.get(~"llvm.log10.f32");
Store(bcx, Call(bcx, log10f, ~[x]), fcx.llretptr);
}
~"log10f64" => {
let x = get_param(decl, first_real_arg);
- let log10f = ccx.intrinsics.get(&~"llvm.log10.f64");
+ let log10f = ccx.intrinsics.get(~"llvm.log10.f64");
Store(bcx, Call(bcx, log10f, ~[x]), fcx.llretptr);
}
~"log2f32" => {
let x = get_param(decl, first_real_arg);
- let log2f = ccx.intrinsics.get(&~"llvm.log2.f32");
+ let log2f = ccx.intrinsics.get(~"llvm.log2.f32");
Store(bcx, Call(bcx, log2f, ~[x]), fcx.llretptr);
}
~"log2f64" => {
let x = get_param(decl, first_real_arg);
- let log2f = ccx.intrinsics.get(&~"llvm.log2.f64");
+ let log2f = ccx.intrinsics.get(~"llvm.log2.f64");
Store(bcx, Call(bcx, log2f, ~[x]), fcx.llretptr);
}
~"fmaf32" => {
let a = get_param(decl, first_real_arg);
let b = get_param(decl, first_real_arg + 1u);
let c = get_param(decl, first_real_arg + 2u);
- let fmaf = ccx.intrinsics.get(&~"llvm.fma.f32");
+ let fmaf = ccx.intrinsics.get(~"llvm.fma.f32");
Store(bcx, Call(bcx, fmaf, ~[a, b, c]), fcx.llretptr);
}
~"fmaf64" => {
let a = get_param(decl, first_real_arg);
let b = get_param(decl, first_real_arg + 1u);
let c = get_param(decl, first_real_arg + 2u);
- let fmaf = ccx.intrinsics.get(&~"llvm.fma.f64");
+ let fmaf = ccx.intrinsics.get(~"llvm.fma.f64");
Store(bcx, Call(bcx, fmaf, ~[a, b, c]), fcx.llretptr);
}
~"fabsf32" => {
let x = get_param(decl, first_real_arg);
- let fabsf = ccx.intrinsics.get(&~"llvm.fabs.f32");
+ let fabsf = ccx.intrinsics.get(~"llvm.fabs.f32");
Store(bcx, Call(bcx, fabsf, ~[x]), fcx.llretptr);
}
~"fabsf64" => {
let x = get_param(decl, first_real_arg);
- let fabsf = ccx.intrinsics.get(&~"llvm.fabs.f64");
+ let fabsf = ccx.intrinsics.get(~"llvm.fabs.f64");
Store(bcx, Call(bcx, fabsf, ~[x]), fcx.llretptr);
}
~"floorf32" => {
let x = get_param(decl, first_real_arg);
- let floorf = ccx.intrinsics.get(&~"llvm.floor.f32");
+ let floorf = ccx.intrinsics.get(~"llvm.floor.f32");
Store(bcx, Call(bcx, floorf, ~[x]), fcx.llretptr);
}
~"floorf64" => {
let x = get_param(decl, first_real_arg);
- let floorf = ccx.intrinsics.get(&~"llvm.floor.f64");
+ let floorf = ccx.intrinsics.get(~"llvm.floor.f64");
Store(bcx, Call(bcx, floorf, ~[x]), fcx.llretptr);
}
~"ceilf32" => {
let x = get_param(decl, first_real_arg);
- let ceilf = ccx.intrinsics.get(&~"llvm.ceil.f32");
+ let ceilf = ccx.intrinsics.get(~"llvm.ceil.f32");
Store(bcx, Call(bcx, ceilf, ~[x]), fcx.llretptr);
}
~"ceilf64" => {
let x = get_param(decl, first_real_arg);
- let ceilf = ccx.intrinsics.get(&~"llvm.ceil.f64");
+ let ceilf = ccx.intrinsics.get(~"llvm.ceil.f64");
Store(bcx, Call(bcx, ceilf, ~[x]), fcx.llretptr);
}
~"truncf32" => {
let x = get_param(decl, first_real_arg);
- let truncf = ccx.intrinsics.get(&~"llvm.trunc.f32");
+ let truncf = ccx.intrinsics.get(~"llvm.trunc.f32");
Store(bcx, Call(bcx, truncf, ~[x]), fcx.llretptr);
}
~"truncf64" => {
let x = get_param(decl, first_real_arg);
- let truncf = ccx.intrinsics.get(&~"llvm.trunc.f64");
+ let truncf = ccx.intrinsics.get(~"llvm.trunc.f64");
Store(bcx, Call(bcx, truncf, ~[x]), fcx.llretptr);
}
~"ctpop8" => {
let x = get_param(decl, first_real_arg);
- let ctpop = ccx.intrinsics.get(&~"llvm.ctpop.i8");
+ let ctpop = ccx.intrinsics.get(~"llvm.ctpop.i8");
Store(bcx, Call(bcx, ctpop, ~[x]), fcx.llretptr)
}
~"ctpop16" => {
let x = get_param(decl, first_real_arg);
- let ctpop = ccx.intrinsics.get(&~"llvm.ctpop.i16");
+ let ctpop = ccx.intrinsics.get(~"llvm.ctpop.i16");
Store(bcx, Call(bcx, ctpop, ~[x]), fcx.llretptr)
}
~"ctpop32" => {
let x = get_param(decl, first_real_arg);
- let ctpop = ccx.intrinsics.get(&~"llvm.ctpop.i32");
+ let ctpop = ccx.intrinsics.get(~"llvm.ctpop.i32");
Store(bcx, Call(bcx, ctpop, ~[x]), fcx.llretptr)
}
~"ctpop64" => {
let x = get_param(decl, first_real_arg);
- let ctpop = ccx.intrinsics.get(&~"llvm.ctpop.i64");
+ let ctpop = ccx.intrinsics.get(~"llvm.ctpop.i64");
Store(bcx, Call(bcx, ctpop, ~[x]), fcx.llretptr)
}
~"ctlz8" => {
let x = get_param(decl, first_real_arg);
let y = C_bool(false);
- let ctlz = ccx.intrinsics.get(&~"llvm.ctlz.i8");
+ let ctlz = ccx.intrinsics.get(~"llvm.ctlz.i8");
Store(bcx, Call(bcx, ctlz, ~[x, y]), fcx.llretptr)
}
~"ctlz16" => {
let x = get_param(decl, first_real_arg);
let y = C_bool(false);
- let ctlz = ccx.intrinsics.get(&~"llvm.ctlz.i16");
+ let ctlz = ccx.intrinsics.get(~"llvm.ctlz.i16");
Store(bcx, Call(bcx, ctlz, ~[x, y]), fcx.llretptr)
}
~"ctlz32" => {
let x = get_param(decl, first_real_arg);
let y = C_bool(false);
- let ctlz = ccx.intrinsics.get(&~"llvm.ctlz.i32");
+ let ctlz = ccx.intrinsics.get(~"llvm.ctlz.i32");
Store(bcx, Call(bcx, ctlz, ~[x, y]), fcx.llretptr)
}
~"ctlz64" => {
let x = get_param(decl, first_real_arg);
let y = C_bool(false);
- let ctlz = ccx.intrinsics.get(&~"llvm.ctlz.i64");
+ let ctlz = ccx.intrinsics.get(~"llvm.ctlz.i64");
Store(bcx, Call(bcx, ctlz, ~[x, y]), fcx.llretptr)
}
~"cttz8" => {
let x = get_param(decl, first_real_arg);
let y = C_bool(false);
- let cttz = ccx.intrinsics.get(&~"llvm.cttz.i8");
+ let cttz = ccx.intrinsics.get(~"llvm.cttz.i8");
Store(bcx, Call(bcx, cttz, ~[x, y]), fcx.llretptr)
}
~"cttz16" => {
let x = get_param(decl, first_real_arg);
let y = C_bool(false);
- let cttz = ccx.intrinsics.get(&~"llvm.cttz.i16");
+ let cttz = ccx.intrinsics.get(~"llvm.cttz.i16");
Store(bcx, Call(bcx, cttz, ~[x, y]), fcx.llretptr)
}
~"cttz32" => {
let x = get_param(decl, first_real_arg);
let y = C_bool(false);
- let cttz = ccx.intrinsics.get(&~"llvm.cttz.i32");
+ let cttz = ccx.intrinsics.get(~"llvm.cttz.i32");
Store(bcx, Call(bcx, cttz, ~[x, y]), fcx.llretptr)
}
~"cttz64" => {
let x = get_param(decl, first_real_arg);
let y = C_bool(false);
- let cttz = ccx.intrinsics.get(&~"llvm.cttz.i64");
+ let cttz = ccx.intrinsics.get(~"llvm.cttz.i64");
Store(bcx, Call(bcx, cttz, ~[x, y]), fcx.llretptr)
}
~"bswap16" => {
let x = get_param(decl, first_real_arg);
- let cttz = ccx.intrinsics.get(&~"llvm.bswap.i16");
+ let cttz = ccx.intrinsics.get(~"llvm.bswap.i16");
Store(bcx, Call(bcx, cttz, ~[x]), fcx.llretptr)
}
~"bswap32" => {
let x = get_param(decl, first_real_arg);
- let cttz = ccx.intrinsics.get(&~"llvm.bswap.i32");
+ let cttz = ccx.intrinsics.get(~"llvm.bswap.i32");
Store(bcx, Call(bcx, cttz, ~[x]), fcx.llretptr)
}
~"bswap64" => {
let x = get_param(decl, first_real_arg);
- let cttz = ccx.intrinsics.get(&~"llvm.bswap.i64");
+ let cttz = ccx.intrinsics.get(~"llvm.bswap.i64");
Store(bcx, Call(bcx, cttz, ~[x]), fcx.llretptr)
}
_ => {
fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item)
-> ast::foreign_abi {
match attr::first_attr_value_str_by_name(i.attrs, ~"abi") {
- None => match ccx.tcx.items.get(&i.id) {
+ None => match ccx.tcx.items.get(i.id) {
ast_map::node_foreign_item(_, abi, _) => abi,
// ??
_ => die!(~"abi_of_foreign_fn: not foreign")
let mut bcx = bcx;
let ty_visitor_name = special_idents::ty_visitor;
assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name);
- let (trait_id, ty) = bcx.ccx().tcx.intrinsic_defs.get(&ty_visitor_name);
+ let (trait_id, ty) = bcx.ccx().tcx.intrinsic_defs.get(ty_visitor_name);
let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty)));
bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, trait_id);
build_return(bcx);
translate: bool)
-> ast::def_id {
let _icx = ccx.insn_ctxt("maybe_instantiate_inline");
- match ccx.external.find(&fn_id) {
+ match ccx.external.find(fn_id) {
Some(Some(node_id)) => {
// Already inline
debug!("maybe_instantiate_inline(%s): already inline as node id %d",
// Computes the size of the data part of an enum.
pub fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint {
- if cx.enum_sizes.contains_key_ref(&t) { return cx.enum_sizes.get(&t); }
+ if cx.enum_sizes.contains_key_ref(&t) { return cx.enum_sizes.get(t); }
match ty::get(t).sty {
ty::ty_enum(tid, ref substs) => {
// Compute max(variant sizes).
};
let mname = if method_id.crate == ast::local_crate {
- match bcx.tcx().items.get(&method_id.node) {
+ match bcx.tcx().items.get(method_id.node) {
ast_map::node_trait_method(trait_method, _, _) => {
ast_util::trait_method_to_ty_method(*trait_method).ident
}
name=%s", method_id, callee_id, ccx.sess.str_of(mname));
let vtbls = resolve_vtables_in_fn_ctxt(
- bcx.fcx, ccx.maps.vtable_map.get(&callee_id));
+ bcx.fcx, ccx.maps.vtable_map.get(callee_id));
match /*bad*/copy vtbls[bound_index] {
typeck::vtable_static(impl_did, rcvr_substs, rcvr_origins) => {
pub fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
name: ast::ident) -> ast::def_id {
if impl_id.crate == ast::local_crate {
- match ccx.tcx.items.get(&impl_id.node) {
+ match ccx.tcx.items.get(impl_id.node) {
ast_map::node_item(@ast::item {
node: ast::item_impl(_, _, _, ref ms),
_
pub fn method_with_name_or_default(ccx: @crate_ctxt, impl_id: ast::def_id,
name: ast::ident) -> ast::def_id {
if impl_id.crate == ast::local_crate {
- match ccx.tcx.items.get(&impl_id.node) {
+ match ccx.tcx.items.get(impl_id.node) {
ast_map::node_item(@ast::item {
node: ast::item_impl(_, _, _, ref ms), _
}, _) => {
} else {
// Look for a default method
let pmm = ccx.tcx.provided_methods;
- match pmm.find(&impl_id) {
+ match pmm.find(impl_id) {
Some(pmis) => {
for pmis.each |pmi| {
if pmi.method_info.ident == name {
i_id: ast::def_id) -> uint {
debug!("method_ty_param_count: m_id: %?, i_id: %?", m_id, i_id);
if m_id.crate == ast::local_crate {
- match ccx.tcx.items.find(&m_id.node) {
+ match ccx.tcx.items.find(m_id.node) {
Some(ast_map::node_method(m, _, _)) => m.tps.len(),
None => {
- match ccx.tcx.provided_method_sources.find(&m_id) {
+ match ccx.tcx.provided_method_sources.find(m_id) {
Some(source) => {
method_ty_param_count(
ccx, source.method_id, source.impl_id)
-> ValueRef {
// XXX: Bad copy.
let hash_id = vtable_id(ccx, copy origin);
- match ccx.vtables.find(&hash_id) {
+ match ccx.vtables.find(hash_id) {
Some(val) => val,
None => match origin {
typeck::vtable_static(id, substs, sub_vtables) => {
}
// Store the vtable into the pair or triple.
- let orig = /*bad*/copy ccx.maps.vtable_map.get(&id)[0];
+ let orig = /*bad*/copy ccx.maps.vtable_map.get(id)[0];
let orig = resolve_vtable_in_fn_ctxt(bcx.fcx, orig);
let vtable = get_vtable(bcx.ccx(), orig);
Store(bcx, vtable, PointerCast(bcx,
real_substs.map(|s| ty_to_str(ccx.tcx, *s)),
substs.map(|s| ty_to_str(ccx.tcx, *s)), hash_id);
- match ccx.monomorphized.find(&hash_id) {
+ match ccx.monomorphized.find(hash_id) {
Some(val) => {
debug!("leaving monomorphic fn %s",
ty::item_path_str(ccx.tcx, fn_id));
let tpt = ty::lookup_item_type(ccx.tcx, fn_id);
let mut llitem_ty = tpt.ty;
- let map_node = session::expect(ccx.sess, ccx.tcx.items.find(&fn_id.node),
+ let map_node = session::expect(ccx.sess, ccx.tcx.items.find(fn_id.node),
|| fmt!("While monomorphizing %?, couldn't find it in the item map \
(may have attempted to monomorphize an item defined in a different \
crate?)", fn_id));
ccx.stats.n_monos += 1;
- let depth = option::get_or_default(ccx.monomorphizing.find(&fn_id), 0u);
+ let depth = option::get_or_default(ccx.monomorphizing.find(fn_id), 0u);
// Random cut-off -- code that needs to instantiate the same function
// recursively more than ten times can probably safely be assumed to be
// causing an infinite expansion.
fn traverse_exports(cx: ctx, mod_id: node_id) -> bool {
let mut found_export = false;
- match cx.exp_map2.find(&mod_id) {
+ match cx.exp_map2.find(mod_id) {
Some(ref exp2s) => {
for (*exp2s).each |e2| {
found_export = true;
fn traverse_def_id(cx: ctx, did: def_id) {
if did.crate != local_crate { return; }
- let n = match cx.tcx.items.find(&did.node) {
+ let n = match cx.tcx.items.find(did.node) {
None => return, // This can happen for self, for example
Some(ref n) => (/*bad*/copy *n)
};
match ty.node {
ty_path(p, p_id) => {
- match cx.tcx.def_map.find(&p_id) {
+ match cx.tcx.def_map.find(p_id) {
// Kind of a hack to check this here, but I'm not sure what else
// to do
Some(def_prim_ty(_)) => { /* do nothing */ }
fn traverse_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
match e.node {
expr_path(_) => {
- match cx.tcx.def_map.find(&e.id) {
+ match cx.tcx.def_map.find(e.id) {
Some(d) => {
traverse_def_id(cx, def_id_of_def(d));
}
}
}
expr_field(_, _, _) => {
- match cx.method_map.find(&e.id) {
+ match cx.method_map.find(e.id) {
Some(typeck::method_map_entry {
origin: typeck::method_static(did),
_
}
}
expr_method_call(*) => {
- match cx.method_map.find(&e.id) {
+ match cx.method_map.find(e.id) {
Some(typeck::method_map_entry {
origin: typeck::method_static(did),
_
use syntax::parse::token::special_idents::tydesc;
let final = sub_block(bcx, ~"final");
assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&tydesc);
- let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(&tydesc);
+ let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(tydesc);
let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty);
let r = reflector({
visitor_val: visitor_val,
debug!("type_of %?: %?", t, ty::get(t));
// Check the cache.
- if cx.lltypes.contains_key_ref(&t) { return cx.lltypes.get(&t); }
+ if cx.lltypes.contains_key_ref(&t) { return cx.lltypes.get(t); }
// Replace any typedef'd types with their equivalent non-typedef
// type. This ensures that all LLVM nominal types that contain
pub fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
-> ~[type_uses] {
- match ccx.type_use_cache.find(&fn_id) {
+ match ccx.type_use_cache.find(fn_id) {
Some(uses) => return uses,
None => ()
}
ccx.type_use_cache.insert(fn_id, copy uses);
return uses;
}
- let map_node = match ccx.tcx.items.find(&fn_id_loc.node) {
+ let map_node = match ccx.tcx.items.find(fn_id_loc.node) {
Some(ref x) => (/*bad*/copy *x),
None => ccx.sess.bug(fmt!("type_uses_for: unbound item ID %?",
fn_id_loc))
}
pub fn mark_for_method_call(cx: ctx, e_id: node_id, callee_id: node_id) {
- do option::iter(&cx.ccx.maps.method_map.find(&e_id)) |mth| {
+ do option::iter(&cx.ccx.maps.method_map.find(e_id)) |mth| {
match mth.origin {
typeck::method_static(did) => {
- do cx.ccx.tcx.node_type_substs.find(&callee_id).iter |ts| {
+ do cx.ccx.tcx.node_type_substs.find(callee_id).iter |ts| {
let type_uses = type_uses_for(cx.ccx, did, ts.len());
for vec::each2(type_uses, *ts) |uses, subst| {
type_needs(cx, *uses, *subst)
}
}
expr_path(_) => {
- do cx.ccx.tcx.node_type_substs.find(&e.id).iter |ts| {
- let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get(&e.id));
+ do cx.ccx.tcx.node_type_substs.find(e.id).iter |ts| {
+ let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get(e.id));
let uses_for_ts = type_uses_for(cx.ccx, id, ts.len());
for vec::each2(uses_for_ts, *ts) |uses, subst| {
type_needs(cx, *uses, *subst)
// and returns the box as cast to an unsafe ptr (see comments for t above).
fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
let key = intern_key { sty: to_unsafe_ptr(&st), o_def_id: o_def_id };
- match cx.interner.find(&key) {
+ match cx.interner.find(key) {
Some(t) => unsafe { return cast::reinterpret_cast(&t); },
_ => ()
}
// Returns the narrowest lifetime enclosing the evaluation of the expression
// with id `id`.
pub fn encl_region(cx: ctxt, id: ast::node_id) -> ty::Region {
- match cx.region_map.find(&id) {
+ match cx.region_map.find(id) {
Some(encl_scope) => ty::re_scope(encl_scope),
None => ty::re_static
}
}
pub fn type_needs_drop(cx: ctxt, ty: t) -> bool {
- match cx.needs_drop_cache.find(&ty) {
+ match cx.needs_drop_cache.find(ty) {
Some(result) => return result,
None => {/* fall through */ }
}
// that only contain scalars and shared boxes can avoid unwind
// cleanups.
pub fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool {
- match cx.needs_unwind_cleanup_cache.find(&ty) {
+ match cx.needs_unwind_cleanup_cache.find(ty) {
Some(result) => return result,
None => ()
}
encountered_box: bool) -> bool {
// Prevent infinite recursion
- match tycache.find(&ty) {
+ match tycache.find(ty) {
Some(_) => return false,
None => { tycache.insert(ty, ()); }
}
// If `allow_ty_var` is true, then this is a conservative assumption; we
// assume that type variables *do* have all kinds.
pub fn type_kind_ext(cx: ctxt, ty: t, allow_ty_var: bool) -> Kind {
- match cx.kind_cache.find(&ty) {
+ match cx.kind_cache.find(ty) {
Some(result) => return result,
None => {/* fall through */ }
}
// cross-crate inlining code to translate a def-id.
assert p.def_id.crate == ast::local_crate;
- param_bounds_to_kind(cx.ty_param_bounds.get(&p.def_id.node))
+ param_bounds_to_kind(cx.ty_param_bounds.get(p.def_id.node))
}
// self is a special type parameter that can only appear in traits; it
}
pub fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] {
- match cx.node_type_substs.find(&id) {
+ match cx.node_type_substs.find(id) {
None => return ~[],
Some(ts) => return ts
}
let unadjusted_ty = expr_ty(cx, expr);
- return match cx.adjustments.find(&expr.id) {
+ return match cx.adjustments.find(expr.id) {
None => unadjusted_ty,
Some(adj) => {
pub fn method_call_bounds(tcx: ctxt, method_map: typeck::method_map,
id: ast::node_id)
-> Option<@~[param_bounds]> {
- do method_map.find(&id).map |method| {
+ do method_map.find(id).map |method| {
match method.origin {
typeck::method_static(did) => {
// n.b.: When we encode impl methods, the bounds
}
fn resolve_expr(tcx: ctxt, expr: @ast::expr) -> ast::def {
- match tcx.def_map.find(&expr.id) {
+ match tcx.def_map.find(expr.id) {
Some(def) => def,
None => {
tcx.sess.span_bug(expr.span, fmt!(
fn canon<T:Copy cmp::Eq>(tbl: HashMap<ast::node_id, ast::inferable<T>>,
+m0: ast::inferable<T>) -> ast::inferable<T> {
match m0 {
- ast::infer(id) => match tbl.find(&id) {
+ ast::infer(id) => match tbl.find(id) {
None => m0,
Some(ref m1) => {
let cm1 = canon(tbl, (*m1));
pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[ast::ident] {
if is_local(id) {
- match cx.items.find(&id.node) {
+ match cx.items.find(id.node) {
Some(ast_map::node_item(@ast::item {
node: item_trait(_, _, ref ms),
_
id: ast::def_id)
-> @~[InstantiatedTraitRef] {
// Check the cache.
- match cx.supertraits.find(&id) {
+ match cx.supertraits.find(id) {
Some(instantiated_trait_info) => { return instantiated_trait_info; }
None => {} // Continue.
}
}
pub fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] {
- match cx.trait_method_cache.find(&id) {
+ match cx.trait_method_cache.find(id) {
// Local traits are supposed to have been added explicitly.
Some(ms) => ms,
_ => {
if id.crate == ast::local_crate {
debug!("(impl_traits) searching for trait impl %?", id);
- match cx.items.find(&id.node) {
+ match cx.items.find(id.node) {
Some(ast_map::node_item(@ast::item {
node: ast::item_impl(_, opt_trait, _, _),
_},
cx.sess.unimpl(~"constructor ID of cross-crate tuple structs");
}
- match cx.items.find(&struct_did.node) {
+ match cx.items.find(struct_did.node) {
Some(ast_map::node_item(item, _)) => {
match item.node {
ast::item_struct(struct_def, _) => {
/* If struct_id names a struct with a dtor, return Some(the dtor's id).
Otherwise return none. */
pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind {
- match cx.destructor_for_type.find(&struct_id) {
+ match cx.destructor_for_type.find(struct_id) {
Some(method_def_id) => return TraitDtor(method_def_id),
None => {} // Continue.
}
if is_local(struct_id) {
- match cx.items.find(&struct_id.node) {
+ match cx.items.find(struct_id.node) {
Some(ast_map::node_item(@ast::item {
node: ast::item_struct(@ast::struct_def { dtor: Some(ref dtor),
_ },
if id.crate != ast::local_crate {
csearch::get_item_path(cx, id)
} else {
- let node = cx.items.get(&id.node);
+ let node = cx.items.get(id.node);
match node {
ast_map::node_item(item, path) => {
let item_elt = match item.node {
}
pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] {
- match cx.enum_var_cache.find(&id) {
+ match cx.enum_var_cache.find(id) {
Some(variants) => return variants,
_ => { /* fallthrough */ }
}
call eval_const_expr, it should never get called twice for the same
expr, since check_enum_variants also updates the enum_var_cache
*/
- match cx.items.get(&id.node) {
+ match cx.items.get(id.node) {
ast_map::node_item(@ast::item {
node: ast::item_enum(ref enum_definition, _),
_
pub fn lookup_item_type(cx: ctxt,
did: ast::def_id)
-> ty_param_bounds_and_ty {
- match cx.tcache.find(&did) {
+ match cx.tcache.find(did) {
Some(tpt) => {
// The item is in this crate. The caller should have added it to the
// type cache already
node_id_to_type(tcx, id.node)
}
else {
- match tcx.tcache.find(&id) {
+ match tcx.tcache.find(id) {
Some(tpt) => tpt.ty,
None => {
let tpt = csearch::get_field_type(tcx, struct_id, id);
// Fails if the id is not bound to a struct.
pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
if did.crate == ast::local_crate {
- match cx.items.find(&did.node) {
+ match cx.items.find(did.node) {
Some(ast_map::node_item(i,_)) => {
match i.node {
ast::item_struct(struct_def, _) => {
}
}
- match cx.normalized_cache.find(&t) {
+ match cx.normalized_cache.find(t) {
Some(t) => return t,
None => ()
}
// Given a trait and a type, returns the impl of that type
pub fn get_impl_id(tcx: ctxt, trait_id: def_id, self_ty: t) -> def_id {
- match tcx.trait_impls.find(&trait_id) {
- Some(ty_to_impl) => match ty_to_impl.find(&self_ty) {
+ match tcx.trait_impls.find(trait_id) {
+ Some(ty_to_impl) => match ty_to_impl.find(self_ty) {
Some(the_impl) => the_impl.did,
None => // try autoderef!
match deref(tcx, self_ty, false) {
return ty::mk_evec(tcx, mt, vst);
}
ast::ty_path(path, id) if a_seq_ty.mutbl == ast::m_imm => {
- match tcx.def_map.find(&id) {
+ match tcx.def_map.find(id) {
Some(ast::def_prim_ty(ast::ty_str)) => {
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
return ty::mk_estr(tcx, vst);
let tcx = self.tcx();
- match tcx.ast_ty_to_ty_cache.find(&ast_ty) {
+ match tcx.ast_ty_to_ty_cache.find(ast_ty) {
Some(ty::atttce_resolved(ty)) => return ty,
Some(ty::atttce_unresolved) => {
tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \
ty::mk_fn(tcx, fn_decl)
}
ast::ty_path(path, id) => {
- let a_def = match tcx.def_map.find(&id) {
+ let a_def = match tcx.def_map.find(id) {
None => tcx.sess.span_fatal(
ast_ty.span, fmt!("unbound path %s",
path_to_str(path, tcx.sess.intr()))),
// Typecheck each field.
let found_fields = HashMap();
for fields.each |field| {
- match field_map.find(&field.ident) {
+ match field_map.find(field.ident) {
Some(index) => {
let class_field = class_fields[index];
let field_type = ty::lookup_field_type(tcx,
let class_fields = ty::lookup_struct_fields(tcx, class_id);
// Check to ensure that the struct is the one specified.
- match tcx.def_map.find(&pat_id) {
+ match tcx.def_map.find(pat_id) {
Some(ast::def_struct(supplied_def_id))
if supplied_def_id == class_id => {
// OK.
let tcx = pcx.fcx.ccx.tcx;
// Find the variant that was specified.
- match tcx.def_map.find(&pat_id) {
+ match tcx.def_map.find(pat_id) {
Some(ast::def_variant(found_enum_id, variant_id))
if found_enum_id == enum_id => {
// Get the struct fields from this struct-like enum variant.
fcx.write_ty(pat.id, b_ty);
}
ast::pat_ident(*) if pat_is_const(tcx.def_map, pat) => {
- let const_did = ast_util::def_id_of_def(tcx.def_map.get(&pat.id));
+ let const_did = ast_util::def_id_of_def(tcx.def_map.get(pat.id));
let const_tpt = ty::lookup_item_type(tcx, const_did);
fcx.write_ty(pat.id, const_tpt.ty);
}
}
}
- let canon_id = pcx.map.get(&ast_util::path_to_ident(name));
+ let canon_id = pcx.map.get(ast_util::path_to_ident(name));
if canon_id != pat.id {
let ct = fcx.local_ty(pat.span, canon_id);
demand::eqtype(fcx, pat.span, ct, typ);
// If the method being called is associated with a trait, then
// find all the impls of that trait. Each of those are
// candidates.
- let opt_applicable_traits = self.fcx.ccx.trait_map.find(
- &self.expr.id);
+ let opt_applicable_traits = self.fcx.ccx.trait_map.find(self.expr.id);
for opt_applicable_traits.each |applicable_traits| {
for applicable_traits.each |trait_did| {
let coherence_info = self.fcx.ccx.coherence_info;
// Look for explicit implementations.
let opt_impl_infos =
- coherence_info.extension_methods.find(trait_did);
+ coherence_info.extension_methods.find(*trait_did);
for opt_impl_infos.each |impl_infos| {
for impl_infos.each |impl_info| {
self.push_candidates_from_impl(
}
// Look for default methods.
- match self.tcx().provided_methods.find(trait_did) {
+ match self.tcx().provided_methods.find(*trait_did) {
Some(methods) => {
self.push_candidates_from_provided_methods(
&self.extension_candidates, self_ty, *trait_did,
let tcx = self.tcx();
let mut next_bound_idx = 0; // count only trait bounds
- let bounds = tcx.ty_param_bounds.get(¶m_ty.def_id.node);
+ let bounds = tcx.ty_param_bounds.get(param_ty.def_id.node);
for vec::each(*bounds) |bound| {
let bound_trait_ty = match *bound {
fn push_inherent_impl_candidates_for_type(did: def_id) {
let opt_impl_infos =
- self.fcx.ccx.coherence_info.inherent_methods.find(&did);
+ self.fcx.ccx.coherence_info.inherent_methods.find(did);
for opt_impl_infos.each |impl_infos| {
for impl_infos.each |impl_info| {
self.push_candidates_from_impl(
fn report_static_candidate(&self, idx: uint, did: def_id) {
let span = if did.crate == ast::local_crate {
- match self.tcx().items.find(&did.node) {
+ match self.tcx().items.find(did.node) {
Some(ast_map::node_method(m, _, _)) => m.span,
_ => die!(fmt!("report_static_candidate: bad item %?", did))
}
assign(self_info.self_id, Some(self_info.self_ty));
debug!("self is assigned to %s",
fcx.infcx().ty_to_str(
- fcx.inh.locals.get(&self_info.self_id)));
+ fcx.inh.locals.get(self_info.self_id)));
}
// Add formal parameters.
debug!("Local variable %s is assigned type %s",
fcx.pat_to_str(local.node.pat),
fcx.infcx().ty_to_str(
- fcx.inh.locals.get(&local.node.id)));
+ fcx.inh.locals.get(local.node.id)));
visit::visit_local(local, e, v);
};
debug!("Pattern binding %s is assigned to %s",
tcx.sess.str_of(path.idents[0]),
fcx.infcx().ty_to_str(
- fcx.inh.locals.get(&p.id)));
+ fcx.inh.locals.get(p.id)));
}
_ => {}
}
for fields.each |p| {
let (id, sp) = *p;
- match field_names.find(&id) {
+ match field_names.find(id) {
Some(orig_sp) => {
tcx.sess.span_err(sp, fmt!("Duplicate field \
name %s in record type declaration",
check_bare_fn(ccx, decl, (*body), it.id, None);
}
ast::item_impl(_, _, ty, ms) => {
- let rp = ccx.tcx.region_paramd_items.find(&it.id);
+ let rp = ccx.tcx.region_paramd_items.find(it.id);
debug!("item_impl %s with id %d rp %?",
ccx.tcx.sess.str_of(it.ident), it.id, rp);
let self_ty = ccx.to_ty(rscope::type_rscope(rp), ty);
fn tag() -> ~str { fmt!("%x", ptr::addr_of(&(*self)) as uint) }
fn local_ty(span: span, nid: ast::node_id) -> ty::t {
- match self.inh.locals.find(&nid) {
+ match self.inh.locals.find(nid) {
Some(t) => t,
None => {
self.tcx().sess.span_bug(
}
fn expr_ty(ex: @ast::expr) -> ty::t {
- match self.inh.node_types.find(&ex.id) {
+ match self.inh.node_types.find(ex.id) {
Some(t) => t,
None => {
self.tcx().sess.bug(
}
}
fn node_ty(id: ast::node_id) -> ty::t {
- match self.inh.node_types.find(&id) {
+ match self.inh.node_types.find(id) {
Some(t) => t,
None => {
self.tcx().sess.bug(
}
}
fn node_ty_substs(id: ast::node_id) -> ty::substs {
- match self.inh.node_type_substs.find(&id) {
+ match self.inh.node_type_substs.find(id) {
Some(ref ts) => (/*bad*/copy *ts),
None => {
self.tcx().sess.bug(
}
}
fn opt_node_ty_substs(id: ast::node_id) -> Option<ty::substs> {
- self.inh.node_type_substs.find(&id)
+ self.inh.node_type_substs.find(id)
}
let tcx = vcx.tcx();
let {n_tps, region_param, raw_ty} = if did.crate == ast::local_crate {
- let region_param = tcx.region_paramd_items.find(&did.node);
- match tcx.items.find(&did.node) {
+ let region_param = tcx.region_paramd_items.find(did.node);
+ match tcx.items.find(did.node) {
Some(ast_map::node_item(@ast::item {
node: ast::item_impl(ref ts, _, st, _),
_
// Typecheck each field.
for ast_fields.each |field| {
- match class_field_map.find(&field.node.ident) {
+ match class_field_map.find(field.node.ident) {
None => {
tcx.sess.span_err(
field.span,
let mut missing_fields = ~[];
for field_types.each |class_field| {
let name = class_field.ident;
- let (_, seen) = class_field_map.get(&name);
+ let (_, seen) = class_field_map.get(name);
if !seen {
missing_fields.push(
~"`" + tcx.sess.str_of(name) + ~"`");
let type_parameter_count, region_parameterized, raw_type;
if class_id.crate == ast::local_crate {
region_parameterized =
- tcx.region_paramd_items.find(&class_id.node);
- match tcx.items.find(&class_id.node) {
+ tcx.region_paramd_items.find(class_id.node);
+ match tcx.items.find(class_id.node) {
Some(ast_map::node_item(@ast::item {
node: ast::item_struct(_, ref type_parameters),
_
let type_parameter_count, region_parameterized, raw_type;
if enum_id.crate == ast::local_crate {
region_parameterized =
- tcx.region_paramd_items.find(&enum_id.node);
- match tcx.items.find(&enum_id.node) {
+ tcx.region_paramd_items.find(enum_id.node);
+ match tcx.items.find(enum_id.node) {
Some(ast_map::node_item(@ast::item {
node: ast::item_enum(_, ref type_parameters),
_
}
ast::expr_struct(path, ref fields, base_expr) => {
// Resolve the path.
- match tcx.def_map.find(&id) {
+ match tcx.def_map.find(id) {
Some(ast::def_struct(type_def_id)) => {
check_struct_constructor(fcx, id, expr.span, type_def_id,
(/*bad*/copy *fields), base_expr);
}
let region =
- ty::re_scope(tcx.region_map.get(&local.node.id));
+ ty::re_scope(tcx.region_map.get(local.node.id));
let pcx = pat_ctxt {
fcx: fcx,
map: pat_id_map(tcx.def_map, local.node.pat),
id: ast::node_id) {
let rty = ty::node_id_to_type(ccx.tcx, id);
let fcx = blank_fn_ctxt(ccx, rty, e.id);
- let declty = fcx.ccx.tcx.tcache.get(&local_def(id)).ty;
+ let declty = fcx.ccx.tcx.tcache.get(local_def(id)).ty;
check_const_with_ty(fcx, _sp, e, declty);
}
(block_query(b, |e| {
match e.node {
ast::expr_break(Some(_)) =>
- match cx.def_map.find(&e.id) {
+ match cx.def_map.find(e.id) {
Some(ast::def_label(loop_id)) if id == loop_id => true,
_ => false,
},
let ty_visitor_name = tcx.sess.ident_of(~"TyVisitor");
assert tcx.intrinsic_defs.contains_key_ref(&tydesc_name);
assert ccx.tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name);
- let (_, tydesc_ty) = tcx.intrinsic_defs.get(&tydesc_name);
- let (_, visitor_trait) = tcx.intrinsic_defs.get(&ty_visitor_name);
+ let (_, tydesc_ty) = tcx.intrinsic_defs.get(tydesc_name);
+ let (_, visitor_trait) = tcx.intrinsic_defs.get(ty_visitor_name);
let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty,
mutbl: ast::m_imm});
(0u, ~[arg(ast::by_val, td_ptr),
pub fn visit_expr(expr: @ast::expr, &&rcx: @rcx, v: rvt) {
debug!("visit_expr(e=%s)", rcx.fcx.expr_to_str(expr));
- for rcx.fcx.inh.adjustments.find(&expr.id).each |adjustment| {
+ for rcx.fcx.inh.adjustments.find(expr.id).each |adjustment| {
for adjustment.autoref.each |autoref| {
guarantor::for_autoref(rcx, expr, *adjustment, autoref);
}
debug!("constrain_auto_ref(expr=%s)", rcx.fcx.expr_to_str(expr));
- let adjustment = rcx.fcx.inh.adjustments.find(&expr.id);
+ let adjustment = rcx.fcx.inh.adjustments.find(expr.id);
let region = match adjustment {
Some(@ty::AutoAdjustment { autoref: Some(ref auto_ref), _ }) => {
auto_ref.region
let mut expr_ct = categorize_unadjusted(rcx, expr);
debug!("before adjustments, cat=%?", expr_ct.cat);
- for rcx.fcx.inh.adjustments.find(&expr.id).each |adjustment| {
+ for rcx.fcx.inh.adjustments.find(expr.id).each |adjustment| {
debug!("adjustment=%?", adjustment);
expr_ct = apply_autoderefs(
match ty::get(ty).sty {
ty::ty_param(param_ty {idx: n, def_id: did}) => {
let mut n_bound = 0;
- let bounds = tcx.ty_param_bounds.get(&did.node);
+ let bounds = tcx.ty_param_bounds.get(did.node);
for ty::iter_bound_traits_and_supertraits(
tcx, bounds) |ity| {
debug!("checking bounds trait %?",
let mut impls_seen = HashMap();
- match vcx.ccx.coherence_info.extension_methods.find(&trait_id) {
+ match vcx.ccx.coherence_info.extension_methods.find(trait_id) {
None => {
// Nothing found. Continue.
}
ast::expr_path(*) => {
match fcx.opt_node_ty_substs(ex.id) {
Some(ref substs) => {
- let def = cx.tcx.def_map.get(&ex.id);
+ let def = cx.tcx.def_map.get(ex.id);
let did = ast_util::def_id_of_def(def);
let item_ty = ty::lookup_item_type(cx.tcx, did);
debug!("early resolve expr: def %? %?, %?, %?", ex.id, did, def,
fn resolve_method_map_entry(fcx: @fn_ctxt, sp: span, id: ast::node_id)
{
// Resolve any method map entry
- match fcx.ccx.method_map.find(&id) {
+ match fcx.ccx.method_map.find(id) {
None => {}
Some(ref mme) => {
for resolve_type_vars_in_type(fcx, sp, mme.self_arg.ty).each |t| {
let fcx = wbcx.fcx, tcx = fcx.ccx.tcx;
// Resolve any borrowings for the node with id `id`
- match fcx.inh.adjustments.find(&id) {
+ match fcx.inh.adjustments.find(id) {
None => (),
Some(adj) => {
let resolved_autoref = match adj.autoref {
}
fn check_implementation(item: @item, associated_traits: ~[@trait_ref]) {
- let self_type = self.crate_context.tcx.tcache.get(
- &local_def(item.id));
+ let self_type = self.crate_context.tcx.tcache.get(local_def(item.id));
// If there are no traits, then this implementation must have a
// base type.
};
let pmm = self.crate_context.tcx.provided_methods;
- match pmm.find(&local_def(impl_id)) {
+ match pmm.find(local_def(impl_id)) {
Some(mis) => {
// If the trait already has an entry in the
// provided_methods_map, we just need to add this
fn add_inherent_method(base_def_id: def_id, implementation: @Impl) {
let implementation_list;
match self.crate_context.coherence_info.inherent_methods
- .find(&base_def_id) {
+ .find(base_def_id) {
None => {
implementation_list = @DVec();
self.crate_context.coherence_info.inherent_methods
fn add_trait_method(trait_id: def_id, implementation: @Impl) {
let implementation_list;
match self.crate_context.coherence_info.extension_methods
- .find(&trait_id) {
+ .find(trait_id) {
None => {
implementation_list = @DVec();
self.crate_context.coherence_info.extension_methods
debug!("Adding impl %? of %? for %s",
the_impl.did, trait_t,
ty_to_str(self.crate_context.tcx, self_t));
- match self.crate_context.tcx.trait_impls.find(&trait_t) {
+ match self.crate_context.tcx.trait_impls.find(trait_t) {
None => {
let m = HashMap();
m.insert(self_t, the_impl);
let coherence_info = &self.crate_context.coherence_info;
let extension_methods = &coherence_info.extension_methods;
- match extension_methods.find(&trait_def_id) {
+ match extension_methods.find(trait_def_id) {
Some(impls) => {
for uint::range(0, impls.len()) |i| {
f(impls[i]);
fn get_self_type_for_implementation(implementation: @Impl)
-> ty_param_bounds_and_ty {
- return self.crate_context.tcx.tcache.get(&implementation.did);
+ return self.crate_context.tcx.tcache.get(implementation.did);
}
// Privileged scope checking
item_impl(_, opt_trait, _, _) => {
let mut ok = false;
match self.base_type_def_ids.find(
- &local_def(item.id)) {
+ local_def(item.id)) {
None => {
// Nothing to do.
fn trait_ref_to_trait_def_id(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_def = def_map.get(trait_ref.ref_id);
let trait_id = def_id_of_def(trait_def);
return trait_id;
}
match self.crate_context.tcx
.provided_methods
- .find(&local_def(item.id)) {
+ .find(local_def(item.id)) {
None => {
debug!("(creating impl) trait with node_id `%d` \
has no provided methods", trait_did.node);
fn span_of_impl(implementation: @Impl) -> span {
assert implementation.did.crate == local_crate;
- match self.crate_context.tcx.items.find(&implementation.did.node) {
+ match self.crate_context.tcx.items.find(implementation.did.node) {
Some(node_item(item, _)) => {
return item.span;
}
// Make sure we don't visit the same implementation
// multiple times.
- match impls_seen.find(&implementation.did) {
+ match impls_seen.find(implementation.did) {
None => {
// Good. Continue.
impls_seen.insert(implementation.did, ());
let coherence_info = &self.crate_context.coherence_info;
let tcx = self.crate_context.tcx;
let drop_trait = tcx.lang_items.drop_trait();
- let impls_opt = coherence_info.extension_methods.find(&drop_trait);
+ let impls_opt = coherence_info.extension_methods.find(drop_trait);
let impls;
match impls_opt {
_ => {
// Destructors only work on nominal types.
if impl_info.did.crate == ast::local_crate {
- match tcx.items.find(&impl_info.did.node) {
+ match tcx.items.find(impl_info.did.node) {
Some(ast_map::node_item(@ref item, _)) => {
tcx.sess.span_err((*item).span,
~"the Drop trait may only \
if id.crate != ast::local_crate {
csearch::get_type(self.tcx, id)
} else {
- match self.tcx.items.find(&id.node) {
+ match self.tcx.items.find(id.node) {
Some(ast_map::node_item(item, _)) => {
ty_of_item(self, item)
}
let tcx = ccx.tcx;
- let region_paramd = tcx.region_paramd_items.find(&id);
- match tcx.items.get(&id) {
+ let region_paramd = tcx.region_paramd_items.find(id);
+ match tcx.items.get(id) {
ast_map::node_item(@ast::item {
node: ast::item_trait(ref params, _, ref ms),
_
// trait ref. Otherwise, we will potentially overwrite the types of
// the methods within the trait with bogus results. (See issue #3903.)
- match tcx.items.find(&did.node) {
+ match tcx.items.find(did.node) {
Some(ast_map::node_item(item, _)) => {
let tpt = ty_of_item(ccx, item);
ensure_trait_methods(ccx, did.node, tpt.ty);
pub fn convert(ccx: @crate_ctxt, it: @ast::item) {
let tcx = ccx.tcx;
- let rp = tcx.region_paramd_items.find(&it.id);
+ let rp = tcx.region_paramd_items.find(it.id);
debug!("convert: item %s with id %d rp %?",
tcx.sess.str_of(it.ident), it.id, rp);
match /*bad*/copy it.node {
arg {
mode: ast::expl(ast::by_copy),
ty: ccx.tcx.tcache.get
- (&local_def(field.node.id)).ty
+ (local_def(field.node.id)).ty
}
},
output: selfty
let def_id = local_def(it.id);
let tcx = ccx.tcx;
- match tcx.tcache.find(&def_id) {
+ match tcx.tcache.find(def_id) {
Some(tpt) => return tpt,
_ => {}
}
- let rp = tcx.region_paramd_items.find(&it.id);
+ let rp = tcx.region_paramd_items.find(it.id);
match /*bad*/copy it.node {
ast::item_const(t, _) => {
let typ = ccx.to_ty(empty_rscope, t);
return tpt;
}
ast::item_ty(t, tps) => {
- match tcx.tcache.find(&local_def(it.id)) {
+ match tcx.tcache.find(local_def(it.id)) {
Some(tpt) => return tpt,
None => { }
}
- let rp = tcx.region_paramd_items.find(&it.id);
+ let rp = tcx.region_paramd_items.find(it.id);
let tpt = {
let ty = {
let t0 = ccx.to_ty(type_rscope(rp), t);
pub fn ty_param_bounds(ccx: @crate_ctxt,
params: ~[ast::ty_param]) -> @~[ty::param_bounds] {
@do params.map |param| {
- match ccx.tcx.ty_param_bounds.find(¶m.id) {
+ match ccx.tcx.ty_param_bounds.find(param.id) {
Some(bs) => bs,
None => {
let bounds = compute_bounds(ccx, param.bounds);
-> cres<Region> {
let vars = TwoRegions { a: a, b: b };
- match combines.find(&vars) {
+ match combines.find(vars) {
Some(c) => Ok(re_infer(ReVar(c))),
None => {
let c = self.new_region_var(span);
}
pub fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::node_id) -> ast::def {
- match tcx.def_map.find(&id) {
+ match tcx.def_map.find(id) {
Some(x) => x,
_ => {
tcx.sess.span_fatal(sp, ~"internal error looking up a definition")
let main_t = ty::node_id_to_type(tcx, main_id);
match ty::get(main_t).sty {
ty::ty_fn(ref fn_ty) => {
- match tcx.items.find(&main_id) {
+ match tcx.items.find(main_id) {
Some(ast_map::node_item(it,_)) => {
match it.node {
ast::item_fn(_, _, ref ps, _)
-> (~str, Option<span>) {
return match region {
re_scope(node_id) => {
- match cx.items.find(&node_id) {
+ match cx.items.find(node_id) {
Some(ast_map::node_block(ref blk)) => {
explain_span(cx, "block", (*blk).span)
}
bound_region_to_str(cx, br))
};
- match cx.items.find(&id) {
+ match cx.items.find(id) {
Some(ast_map::node_block(ref blk)) => {
let (msg, opt_span) = explain_span(cx, "block", (*blk).span);
(fmt!("%s %s", prefix, msg), opt_span)
}
pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str {
- match cx.items.find(&node_id) {
+ match cx.items.find(node_id) {
Some(ast_map::node_block(ref blk)) => {
fmt!("<block at %s>",
cx.sess.codemap.span_to_str((*blk).span))
id: doc::AstId,
parse_attrs: fn~(a: ~[ast::attribute]) -> T) -> T {
do astsrv::exec(srv) |move parse_attrs, ctxt| {
- let attrs = match ctxt.ast_map.get(&id) {
+ let attrs = match ctxt.ast_map.get(id) {
ast_map::node_item(item, _) => copy item.attrs,
ast_map::node_foreign_item(item, _, _) => copy item.attrs,
_ => die!(~"parse_item_attrs: not an item")
let desc = {
let variant = copy variant;
do astsrv::exec(srv.clone()) |ctxt| {
- match ctxt.ast_map.get(&doc_id) {
+ match ctxt.ast_map.get(doc_id) {
ast_map::node_item(@ast::item {
node: ast::item_enum(ref enum_definition, _), _
}, _) => {
// Create an assoc list from method name to attributes
let attrs: ~[(~str, Option<~str>)] = do astsrv::exec(srv) |ctxt| {
- match ctxt.ast_map.get(&item_id) {
+ match ctxt.ast_map.get(item_id) {
ast_map::node_item(@ast::item {
node: ast::item_trait(_, _, ref methods), _
}, _) => {
let id = doc.id;
do astsrv::exec(srv) |ctxt| {
- let attrs = match ctxt.ast_map.get(&id) {
+ let attrs = match ctxt.ast_map.get(id) {
ast_map::node_item(item, _) => copy item.attrs,
_ => ~[]
};
let id = doc.id;
do astsrv::exec(srv) |ctxt| {
- match ctxt.ast_map.get(&id) {
+ match ctxt.ast_map.get(id) {
ast_map::node_item(item, _) => {
item.vis == ast::public
}
fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
do astsrv::exec(srv) |ctxt| {
- match ctxt.ast_map.get(&fn_id) {
+ match ctxt.ast_map.get(fn_id) {
ast_map::node_item(@ast::item {
ident: ident,
node: ast::item_fn(ref decl, _, ref tys, _), _
sig: Some({
let doc = copy doc;
do astsrv::exec(srv) |ctxt| {
- match ctxt.ast_map.get(&doc.id()) {
+ match ctxt.ast_map.get(doc.id()) {
ast_map::node_item(@ast::item {
node: ast::item_const(ty, _), _
}, _) => {
let sig = {
let variant = copy *variant;
do astsrv::exec(srv.clone()) |copy variant, ctxt| {
- match ctxt.ast_map.get(&doc_id) {
+ match ctxt.ast_map.get(doc_id) {
ast_map::node_item(@ast::item {
node: ast::item_enum(ref enum_definition, _), _
}, _) => {
method_name: ~str
) -> Option<~str> {
do astsrv::exec(srv) |copy method_name, ctxt| {
- match ctxt.ast_map.get(&item_id) {
+ match ctxt.ast_map.get(item_id) {
ast_map::node_item(@ast::item {
node: ast::item_trait(_, _, ref methods), _
}, _) => {
let (trait_types, self_ty) = {
let doc = copy doc;
do astsrv::exec(srv) |ctxt| {
- match ctxt.ast_map.get(&doc.id()) {
+ match ctxt.ast_map.get(doc.id()) {
ast_map::node_item(@ast::item {
node: ast::item_impl(_, opt_trait_type, self_ty, _), _
}, _) => {
sig: {
let doc = copy doc;
do astsrv::exec(srv) |ctxt| {
- match ctxt.ast_map.get(&doc.id()) {
+ match ctxt.ast_map.get(doc.id()) {
ast_map::node_item(@ast::item {
ident: ident,
node: ast::item_ty(ty, ref params), _
sig: {
let doc = copy doc;
do astsrv::exec(srv) |ctxt| {
- match ctxt.ast_map.get(&doc.id()) {
+ match ctxt.ast_map.get(doc.id()) {
ast_map::node_item(item, _) => {
let item = strip_struct_extra_stuff(item);
Some(pprust::item_to_str(item,
}
}
- pure fn find(&self, k: &K) -> Option<V> {
+ pure fn find(&self, k: K) -> Option<V> {
unsafe {
- match self.search_tbl(k, k.hash_keyed(0,0) as uint) {
+ match self.search_tbl(&k, k.hash_keyed(0,0) as uint) {
NotFound => None,
FoundFirst(_, entry) => Some(entry.value),
FoundAfter(_, entry) => Some(entry.value)
return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1));
}
- pure fn get(&self, k: &K) -> V {
+ pure fn get(&self, k: K) -> V {
let opt_v = self.find(k);
if opt_v.is_none() {
die!(fmt!("Key not found in table: %?", k));
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: ops::Index<K, V> {
pure fn index(&self, k: K) -> V {
unsafe {
- self.get(&k)
+ self.get(k)
}
}
}
#[cfg(test)]
mod tests {
use core::option::None;
+ use core::option;
use core::uint;
use super::*;
assert (hm_uu.insert(10u, 12u));
assert (hm_uu.insert(11u, 13u));
assert (hm_uu.insert(12u, 14u));
- assert (hm_uu.get(&11) == 13u);
- assert (hm_uu.get(&12) == 14u);
- assert (hm_uu.get(&10) == 12u);
+ assert (hm_uu.get(11u) == 13u);
+ assert (hm_uu.get(12u) == 14u);
+ assert (hm_uu.get(10u) == 12u);
assert (!hm_uu.insert(12u, 14u));
- assert (hm_uu.get(&12) == 14u);
+ assert (hm_uu.get(12u) == 14u);
assert (!hm_uu.insert(12u, 12u));
- assert (hm_uu.get(&12) == 12u);
+ assert (hm_uu.get(12u) == 12u);
let ten: ~str = ~"ten";
let eleven: ~str = ~"eleven";
let twelve: ~str = ~"twelve";
assert (hm_su.insert(~"ten", 12u));
assert (hm_su.insert(eleven, 13u));
assert (hm_su.insert(~"twelve", 14u));
- assert (hm_su.get(&eleven) == 13u);
- assert (hm_su.get(&~"eleven") == 13u);
- assert (hm_su.get(&~"twelve") == 14u);
- assert (hm_su.get(&~"ten") == 12u);
+ assert (hm_su.get(eleven) == 13u);
+ assert (hm_su.get(~"eleven") == 13u);
+ assert (hm_su.get(~"twelve") == 14u);
+ assert (hm_su.get(~"ten") == 12u);
assert (!hm_su.insert(~"twelve", 14u));
- assert (hm_su.get(&~"twelve") == 14u);
+ assert (hm_su.get(~"twelve") == 14u);
assert (!hm_su.insert(~"twelve", 12u));
- assert (hm_su.get(&~"twelve") == 12u);
+ assert (hm_su.get(~"twelve") == 12u);
debug!("uint -> str");
let hm_us: HashMap<uint, ~str> =
HashMap::<uint, ~str>();
assert (hm_us.insert(10u, ~"twelve"));
assert (hm_us.insert(11u, ~"thirteen"));
assert (hm_us.insert(12u, ~"fourteen"));
- assert hm_us.get(&11) == ~"thirteen";
- assert hm_us.get(&12) == ~"fourteen";
- assert hm_us.get(&10) == ~"twelve";
+ assert hm_us.get(11u) == ~"thirteen";
+ assert hm_us.get(12u) == ~"fourteen";
+ assert hm_us.get(10u) == ~"twelve";
assert (!hm_us.insert(12u, ~"fourteen"));
- assert hm_us.get(&12) == ~"fourteen";
+ assert hm_us.get(12u) == ~"fourteen";
assert (!hm_us.insert(12u, ~"twelve"));
- assert hm_us.get(&12) == ~"twelve";
+ assert hm_us.get(12u) == ~"twelve";
debug!("str -> str");
let hm_ss: HashMap<~str, ~str> =
HashMap::<~str, ~str>();
assert (hm_ss.insert(ten, ~"twelve"));
assert (hm_ss.insert(eleven, ~"thirteen"));
assert (hm_ss.insert(twelve, ~"fourteen"));
- assert hm_ss.get(&~"eleven") == ~"thirteen";
- assert hm_ss.get(&~"twelve") == ~"fourteen";
- assert hm_ss.get(&~"ten") == ~"twelve";
+ assert hm_ss.get(~"eleven") == ~"thirteen";
+ assert hm_ss.get(~"twelve") == ~"fourteen";
+ assert hm_ss.get(~"ten") == ~"twelve";
assert (!hm_ss.insert(~"twelve", ~"fourteen"));
- assert hm_ss.get(&~"twelve") == ~"fourteen";
+ assert hm_ss.get(~"twelve") == ~"fourteen";
assert (!hm_ss.insert(~"twelve", ~"twelve"));
- assert hm_ss.get(&~"twelve") == ~"twelve";
+ assert hm_ss.get(~"twelve") == ~"twelve";
debug!("*** finished test_simple");
}
debug!("-----");
i = 0u;
while i < num_to_insert {
- debug!("get(%u) = %u", i, hm_uu.get(&i));
- assert (hm_uu.get(&i) == i * i);
+ debug!("get(%u) = %u", i, hm_uu.get(i));
+ assert (hm_uu.get(i) == i * i);
i += 1u;
}
assert (hm_uu.insert(num_to_insert, 17u));
- assert (hm_uu.get(&num_to_insert) == 17u);
+ assert (hm_uu.get(num_to_insert) == 17u);
debug!("-----");
i = 0u;
while i < num_to_insert {
- debug!("get(%u) = %u", i, hm_uu.get(&i));
- assert (hm_uu.get(&i) == i * i);
+ debug!("get(%u) = %u", i, hm_uu.get(i));
+ assert (hm_uu.get(i) == i * i);
i += 1u;
}
debug!("str -> str");
while i < num_to_insert {
debug!("get(\"%s\") = \"%s\"",
uint::to_str_radix(i, 2u),
- hm_ss.get(&uint::to_str_radix(i, 2u)));
- assert hm_ss.get(&uint::to_str_radix(i, 2u)) ==
+ hm_ss.get(uint::to_str_radix(i, 2u)));
+ assert hm_ss.get(uint::to_str_radix(i, 2u)) ==
uint::to_str_radix(i * i, 2u);
i += 1u;
}
assert (hm_ss.insert(uint::to_str_radix(num_to_insert, 2u),
uint::to_str_radix(17u, 2u)));
- assert hm_ss.get(&uint::to_str_radix(num_to_insert, 2u)) ==
+ assert hm_ss.get(uint::to_str_radix(num_to_insert, 2u)) ==
uint::to_str_radix(17u, 2u);
debug!("-----");
i = 0u;
while i < num_to_insert {
debug!("get(\"%s\") = \"%s\"",
uint::to_str_radix(i, 2u),
- hm_ss.get(&uint::to_str_radix(i, 2u)));
- assert hm_ss.get(&uint::to_str_radix(i, 2u)) ==
+ hm_ss.get(uint::to_str_radix(i, 2u)));
+ assert hm_ss.get(uint::to_str_radix(i, 2u)) ==
uint::to_str_radix(i * i, 2u);
i += 1u;
}
debug!("-----");
i = 1u;
while i < num_to_insert {
- debug!("get(%u) = %u", i, hm.get(&i));
- assert (hm.get(&i) == i * i);
+ debug!("get(%u) = %u", i, hm.get(i));
+ assert (hm.get(i) == i * i);
i += 2u;
}
debug!("-----");
i = 1u;
while i < num_to_insert {
- debug!("get(%u) = %u", i, hm.get(&i));
- assert (hm.get(&i) == i * i);
+ debug!("get(%u) = %u", i, hm.get(i));
+ assert (hm.get(i) == i * i);
i += 2u;
}
debug!("-----");
debug!("-----");
i = 0u;
while i < num_to_insert {
- debug!("get(%u) = %u", i, hm.get(&i));
- assert (hm.get(&i) == i * i);
+ debug!("get(%u) = %u", i, hm.get(i));
+ assert (hm.get(i) == i * i);
i += 1u;
}
debug!("-----");
assert (hm.len() == num_to_insert);
i = 0u;
while i < num_to_insert {
- debug!("get(%u) = %u", i, hm.get(&i));
- assert (hm.get(&i) == i * i);
+ debug!("get(%u) = %u", i, hm.get(i));
+ assert (hm.get(i) == i * i);
i += 1u;
}
debug!("*** finished test_removal");
fn test_find() {
let key = ~"k";
let map = HashMap::<~str, ~str>();
- assert map.find(&key).is_none();
+ assert (option::is_none(&map.find(key)));
map.insert(key, ~"val");
- assert map.find(&key).get() == ~"val";
+ assert (option::get(map.find(key)) == ~"val");
}
#[test]
(~"c", 3)
]);
assert map.len() == 3u;
- assert map.get(&~"a") == 1;
- assert map.get(&~"b") == 2;
- assert map.get(&~"c") == 3;
+ assert map.get(~"a") == 1;
+ assert map.get(~"b") == 2;
+ assert map.get(~"c") == 3;
}
#[test]
map.update_with_key(~"cat", 2, addMoreToCount);
// check the total counts
- assert map.find(&~"cat").get() == 10;
- assert map.find(&~"ferret").get() == 3;
- assert map.find(&~"mongoose").get() == 1;
+ assert 10 == option::get(map.find(~"cat"));
+ assert 3 == option::get(map.find(~"ferret"));
+ assert 1 == option::get(map.find(~"mongoose"));
// sadly, no mythical animals were counted!
- assert map.find(&~"unicorn").is_none();
+ assert None == map.find(~"unicorn");
}
}
}
pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
- match map.find(&id) {
+ match map.find(id) {
None => {
fmt!("unknown node (id=%d)", id)
}
pub fn node_item_query<Result>(items: map, id: node_id,
query: fn(@item) -> Result,
error_msg: ~str) -> Result {
- match items.find(&id) {
+ match items.find(id) {
Some(node_item(it, _)) => query(it),
_ => die!(error_msg)
}
/* using idents and token::special_idents would make the
the macro names be hygienic */
let extname = cx.parse_sess().interner.get(pth.idents[0]);
- match exts.find(extname) {
+ match exts.find(*extname) {
None => {
cx.span_fatal(pth.span,
fmt!("macro undefined: '%s'", *extname))
ast::meta_name_value(ref n, _) => (*n),
ast::meta_list(ref n, _) => (*n)
};
- match exts.find(&mname) {
+ match exts.find(mname) {
None | Some(NormalTT(_)) | Some(ItemTT(*)) => items,
Some(ItemDecorator(dec_fn)) => {
cx.bt_push(ExpandedFrom({call_site: attr.span,
};
let extname = cx.parse_sess().interner.get(pth.idents[0]);
- let expanded = match exts.find(extname) {
+ let expanded = match exts.find(*extname) {
None => cx.span_fatal(pth.span,
fmt!("macro undefined: '%s!'", *extname)),
assert(vec::len(pth.idents) == 1u);
let extname = cx.parse_sess().interner.get(pth.idents[0]);
- let (fully_expanded, sp) = match exts.find(extname) {
+ let (fully_expanded, sp) = match exts.find(*extname) {
None =>
cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", *extname)),
arg_reader as reader, argument_gram);
// Extract the arguments:
- let lhses:~[@named_match] = match argument_map.get(&lhs_nm) {
+ let lhses:~[@named_match] = match argument_map.get(lhs_nm) {
@matched_seq(s, _) => s,
_ => cx.span_bug(sp, ~"wrong-structured lhs")
};
- let rhses:~[@named_match] = match argument_map.get(&rhs_nm) {
+ let rhses:~[@named_match] = match argument_map.get(rhs_nm) {
@matched_seq(s, _) => s,
_ => cx.span_bug(sp, ~"wrong-structured rhs")
};
}
fn lookup_cur_matched(r: tt_reader, name: ident) -> @named_match {
- lookup_cur_matched_by_matched(r, r.interpolations.get(&name))
+ lookup_cur_matched_by_matched(r, r.interpolations.get(name))
}
enum lis {
lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str)
pub impl <T:Eq IterBytes Hash Const Copy> hash_interner<T>: Interner<T> {
fn intern(val: T) -> uint {
- match self.map.find(&val) {
+ match self.map.find(val) {
Some(idx) => return idx,
None => {
let new_idx = self.vect.len();
// the unused ty param is necessary so this gets monomorphized
pub fn request<T: Copy>(req: header_map) {
- let _x = copy *(copy *req.get(&~"METHOD"))[0u];
+ let _x = copy *(copy *req.get(~"METHOD"))[0u];
}
}
for uint::range(0, num_keys) |i| {
- assert map.get(&i) == i+1;
+ assert map.get(i) == i+1;
}
}
}
for uint::range(0, num_keys) |i| {
let s = uint::to_str(i);
- assert map.get(&s) == i;
+ assert map.get(s) == i;
}
}
}
let mut found = 0;
for int::range(0, 1000) |_i| {
- match s.find(&r.gen_str(10)) {
+ match s.find(r.gen_str(10)) {
Some(_) => { found += 1; }
None => { }
}
// given a map, search for the frequency of a pattern
fn find(mm: HashMap<~[u8], uint>, key: ~str) -> uint {
- match mm.find(&str::to_bytes(str::to_lower(key))) {
+ match mm.find(str::to_bytes(str::to_lower(key))) {
option::None => { return 0u; }
option::Some(num) => { return num; }
}
while prev <= i {
if lines.contains_key_ref(&prev) {
debug!("WS %u", prev);
- cout.write(lines.get(&prev));
+ cout.write(lines.get(prev));
done += 1_u;
lines.remove(&prev);
prev += 1_u;
fn emit(im: oldmap::HashMap<~str, int>, ctrl: SharedChan<ctrl_proto>, key: ~str,
val: ~str) {
let mut c;
- match im.find(&key) {
+ match im.find(copy key) {
Some(_c) => { c = _c }
None => {
let (pp, cc) = stream();
mapper_done => { num_mappers -= 1; }
find_reducer(k, cc) => {
let mut c;
- match reducers.find(&str::from_bytes(k)) {
+ match reducers.find(str::from_bytes(k)) {
Some(_c) => { c = _c; }
None => { c = 0; }
}