auto merge of #5443 : alexcrichton/rust/less-bad-copy, r=catamorphism

Removes a lot of instances of `/*bad*/ copy` throughout libsyntax/librustc. On the plus side, this shaves about 2s off of the runtime when compiling `librustc` with optimizations.

Ideally I would have run a profiler to figure out which copies are the most critical to remove, but in reality there was a liberal amount of `git grep`s along with some spot checking and removing the easy ones.
This commit is contained in:
bors 2013-03-20 00:09:47 -07:00
commit db4dc1ffe2
47 changed files with 469 additions and 472 deletions

View File

@ -194,8 +194,7 @@ pub mod write {
let opts = sess.opts;
if sess.time_llvm_passes() { llvm::LLVMRustEnableTimePasses(); }
let mut pm = mk_pass_manager();
let td = mk_target_data(
/*bad*/copy sess.targ_cfg.target_strs.data_layout);
let td = mk_target_data(sess.targ_cfg.target_strs.data_layout);
llvm::LLVMAddTargetData(td.lltd, pm.llpm);
// FIXME (#2812): run the linter here also, once there are llvm-c
// bindings for it.
@ -866,8 +865,9 @@ pub fn link_binary(sess: Session,
// to be found at compile time so it is still entirely up to outside
// forces to make sure that library can be found at runtime.
let addl_paths = /*bad*/copy sess.opts.addl_lib_search_paths;
for addl_paths.each |path| { cc_args.push(~"-L" + path.to_str()); }
for sess.opts.addl_lib_search_paths.each |path| {
cc_args.push(~"-L" + path.to_str());
}
// The names of the extern libraries
let used_libs = cstore::get_used_libraries(cstore);

View File

@ -45,8 +45,8 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path)
// where rustrt is and we know every rust program needs it
let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess));
let target_triple = /*bad*/copy sess.opts.target_triple;
let rpaths = get_rpaths(os, &sysroot, output, libs, target_triple);
let rpaths = get_rpaths(os, &sysroot, output, libs,
sess.opts.target_triple);
rpaths_to_flags(rpaths)
}
@ -140,8 +140,8 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
let abs2 = abs2.normalize();
debug!("finding relative path from %s to %s",
abs1.to_str(), abs2.to_str());
let split1 = /*bad*/copy abs1.components;
let split2 = /*bad*/copy abs2.components;
let split1: &[~str] = abs1.components;
let split2: &[~str] = abs2.components;
let len1 = vec::len(split1);
let len2 = vec::len(split2);
fail_unless!(len1 > 0);

View File

@ -132,15 +132,12 @@ pub fn build_configuration(sess: Session, +argv0: ~str, input: input) ->
}
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
fn parse_cfgspecs(cfgspecs: ~[~str],
fn parse_cfgspecs(+cfgspecs: ~[~str],
demitter: diagnostic::Emitter) -> ast::crate_cfg {
let mut meta = ~[];
for cfgspecs.each |s| {
do vec::map_consume(cfgspecs) |s| {
let sess = parse::new_parse_sess(Some(demitter));
let m = parse::parse_meta_from_source_str(~"cfgspec", @/*bad*/ copy *s, ~[], sess);
meta.push(m)
parse::parse_meta_from_source_str(~"cfgspec", @s, ~[], sess)
}
return meta;
}
pub enum input {
@ -580,9 +577,9 @@ pub fn build_session_options(+binary: ~str,
let debug_map = session::debugging_opts_map();
for debug_flags.each |debug_flag| {
let mut this_bit = 0u;
for debug_map.each |pair| {
let (name, _, bit) = /*bad*/copy *pair;
if name == *debug_flag { this_bit = bit; break; }
for debug_map.each |tuple| {
let (name, bit) = match *tuple { (ref a, _, b) => (a, b) };
if name == debug_flag { this_bit = bit; break; }
}
if this_bit == 0u {
early_error(demitter, fmt!("unknown debug flag: %s", *debug_flag))
@ -647,7 +644,7 @@ pub fn build_session_options(+binary: ~str,
let target =
match target_opt {
None => host_triple(),
Some(ref s) => (/*bad*/copy *s)
Some(s) => s
};
let addl_lib_search_paths =

View File

@ -1647,7 +1647,7 @@ pub struct TargetData {
dtor: @target_data_res
}
pub fn mk_target_data(string_rep: ~str) -> TargetData {
pub fn mk_target_data(string_rep: &str) -> TargetData {
let lltd =
str::as_c_str(string_rep, |buf| unsafe {
llvm::LLVMCreateTargetData(buf)

View File

@ -142,8 +142,8 @@ fn visit_crate(e: @mut Env, c: ast::crate) {
}
fn visit_view_item(e: @mut Env, i: @ast::view_item) {
match /*bad*/copy i.node {
ast::view_item_extern_mod(ident, meta_items, id) => {
match i.node {
ast::view_item_extern_mod(ident, /*bad*/copy meta_items, id) => {
debug!("resolving extern mod stmt. ident: %?, meta: %?",
ident, meta_items);
let cnum = resolve_crate(e, ident, meta_items, @~"", i.span);
@ -154,8 +154,8 @@ fn visit_view_item(e: @mut Env, i: @ast::view_item) {
}
fn visit_item(e: @mut Env, i: @ast::item) {
match /*bad*/copy i.node {
ast::item_foreign_mod(fm) => {
match i.node {
ast::item_foreign_mod(ref fm) => {
match attr::foreign_abi(i.attrs) {
either::Right(abi) => {
if abi != ast::foreign_abi_cdecl &&

View File

@ -645,7 +645,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
debug!("encoding info for item at %s",
ecx.tcx.sess.codemap.span_to_str(item.span));
match /*bad*/copy item.node {
match item.node {
item_const(_, _) => {
add_to_index();
ebml_w.start_tag(tag_items_data_item);
@ -1196,10 +1196,10 @@ fn synthesize_crate_attrs(ecx: @EncodeContext,
if *attr::get_attr_name(attr) != ~"link" {
/*bad*/copy *attr
} else {
match /*bad*/copy attr.node.value.node {
meta_list(_, l) => {
match attr.node.value.node {
meta_list(_, ref l) => {
found_link_attr = true;;
synthesize_link_attr(ecx, l)
synthesize_link_attr(ecx, /*bad*/copy *l)
}
_ => /*bad*/copy *attr
}

View File

@ -639,14 +639,14 @@ fn encode_vtable_origin(ecx: @e::EncodeContext,
ebml_w: writer::Encoder,
vtable_origin: typeck::vtable_origin) {
do ebml_w.emit_enum(~"vtable_origin") {
match /*bad*/copy vtable_origin {
typeck::vtable_static(def_id, tys, vtable_res) => {
match vtable_origin {
typeck::vtable_static(def_id, ref tys, vtable_res) => {
do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) {
do ebml_w.emit_enum_variant_arg(0u) {
ebml_w.emit_def_id(def_id)
}
do ebml_w.emit_enum_variant_arg(1u) {
ebml_w.emit_tys(ecx, /*bad*/copy tys);
ebml_w.emit_tys(ecx, /*bad*/copy *tys);
}
do ebml_w.emit_enum_variant_arg(2u) {
encode_vtable_res(ecx, ebml_w, vtable_res);

View File

@ -139,7 +139,7 @@ fn req_loans_in_expr(ex: @ast::expr,
}
// Special checks for various kinds of expressions:
match /*bad*/copy ex.node {
match ex.node {
ast::expr_addr_of(mutbl, base) => {
let base_cmt = self.bccx.cat_expr(base);
@ -150,10 +150,10 @@ fn req_loans_in_expr(ex: @ast::expr,
visit::visit_expr(ex, self, vt);
}
ast::expr_call(f, args, _) => {
ast::expr_call(f, ref args, _) => {
let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f));
let scope_r = ty::re_scope(ex.id);
for vec::each2(args, arg_tys) |arg, arg_ty| {
for vec::each2(*args, arg_tys) |arg, arg_ty| {
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
ast::by_ref => {
let arg_cmt = self.bccx.cat_expr(*arg);
@ -165,11 +165,11 @@ fn req_loans_in_expr(ex: @ast::expr,
visit::visit_expr(ex, self, vt);
}
ast::expr_method_call(rcvr, _, _, args, _) => {
ast::expr_method_call(rcvr, _, _, ref args, _) => {
let arg_tys = ty::ty_fn_args(ty::node_id_to_type(self.tcx(),
ex.callee_id));
let scope_r = ty::re_scope(ex.id);
for vec::each2(args, arg_tys) |arg, arg_ty| {
for vec::each2(*args, arg_tys) |arg, arg_ty| {
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
ast::by_ref => {
let arg_cmt = self.bccx.cat_expr(*arg);

View File

@ -243,8 +243,8 @@ pub fn is_useful(cx: @MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
}
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
let max_len = do m.foldr(0) |r, max_len| {
match /*bad*/copy r[0].node {
pat_vec(before, _, after) => {
match r[0].node {
pat_vec(ref before, _, ref after) => {
uint::max(before.len() + after.len(), max_len)
}
_ => max_len
@ -299,7 +299,7 @@ pub fn is_useful_specialized(cx: @MatchCheckCtxt,
pub fn pat_ctor_id(cx: @MatchCheckCtxt, p: @pat) -> Option<ctor> {
let pat = raw_pat(p);
match /*bad*/copy pat.node {
match pat.node {
pat_wild => { None }
pat_ident(_, _, _) | pat_enum(_, _) => {
match cx.tcx.def_map.find(&pat.id) {
@ -324,7 +324,7 @@ pub fn pat_ctor_id(cx: @MatchCheckCtxt, p: @pat) -> Option<ctor> {
pat_box(_) | pat_uniq(_) | pat_tup(_) | pat_region(*) => {
Some(single)
}
pat_vec(before, slice, after) => {
pat_vec(ref before, slice, ref after) => {
match slice {
Some(_) => None,
None => Some(vec(before.len() + after.len()))
@ -448,8 +448,8 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
}
pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint {
match /*bad*/copy ty::get(ty).sty {
ty::ty_tup(fs) => fs.len(),
match ty::get(ty).sty {
ty::ty_tup(ref fs) => fs.len(),
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u,
ty::ty_enum(eid, _) => {
let id = match ctor { variant(id) => id,
@ -704,7 +704,7 @@ pub fn is_refutable(cx: @MatchCheckCtxt, pat: &pat) -> bool {
_ => ()
}
match /*bad*/copy pat.node {
match pat.node {
pat_box(sub) | pat_uniq(sub) | pat_region(sub) |
pat_ident(_, _, Some(sub)) => {
is_refutable(cx, sub)
@ -715,13 +715,13 @@ pub fn is_refutable(cx: @MatchCheckCtxt, pat: &pat) -> bool {
false
}
pat_lit(_) | pat_range(_, _) => { true }
pat_struct(_, fields, _) => {
pat_struct(_, ref fields, _) => {
fields.any(|f| is_refutable(cx, f.pat))
}
pat_tup(elts) => {
pat_tup(ref elts) => {
elts.any(|elt| is_refutable(cx, *elt))
}
pat_enum(_, Some(args)) => {
pat_enum(_, Some(ref args)) => {
args.any(|a| is_refutable(cx, *a))
}
pat_enum(_,_) => { false }

View File

@ -81,7 +81,7 @@ pub fn classify(e: @expr,
Some(x) => x,
None => {
let cn =
match /*bad*/copy e.node {
match e.node {
ast::expr_lit(lit) => {
match lit.node {
ast::lit_str(*) |
@ -101,9 +101,9 @@ pub fn classify(e: @expr,
classify(b, def_map, tcx))
}
ast::expr_tup(es) |
ast::expr_vec(es, ast::m_imm) => {
join_all(vec::map(es, |e| classify(*e, def_map, tcx)))
ast::expr_tup(ref es) |
ast::expr_vec(ref es, ast::m_imm) => {
join_all(vec::map(*es, |e| classify(*e, def_map, tcx)))
}
ast::expr_vstore(e, vstore) => {

View File

@ -56,7 +56,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
Some(df) => {
let mut def = df;
while i < depth {
match copy def {
match def {
ast::def_upvar(_, inner, _, _) => { def = *inner; }
_ => break
}

View File

@ -360,8 +360,8 @@ pub impl Context {
let metas =
attr::attr_metas(attr::find_attrs_by_name(attrs, level_name));
for metas.each |meta| {
match /*bad*/copy meta.node {
ast::meta_list(_, metas) => {
match meta.node {
ast::meta_list(_, ref metas) => {
for metas.each |meta| {
match meta.node {
ast::meta_word(ref lintname) => {
@ -653,8 +653,8 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
}
fn check_item_default_methods(cx: ty::ctxt, item: @ast::item) {
match /*bad*/copy item.node {
ast::item_trait(_, _, methods) => {
match item.node {
ast::item_trait(_, _, ref methods) => {
for methods.each |method| {
match *method {
ast::required(*) => {}

View File

@ -383,7 +383,7 @@ pub impl IrMaps {
}
fn variable_name(&mut self, var: Variable) -> @~str {
match copy self.var_kinds[*var] {
match self.var_kinds[*var] {
Local(LocalInfo {ident: nm, _}) |
Arg(_, nm, _) => self.tcx.sess.str_of(nm),
ImplicitRet => @~"<implicit-ret>"
@ -1065,8 +1065,8 @@ pub impl Liveness {
fn propagate_through_decl(&self, decl: @decl, succ: LiveNode)
-> LiveNode {
match /*bad*/copy decl.node {
decl_local(locals) => {
match decl.node {
decl_local(ref locals) => {
do locals.foldr(succ) |local, succ| {
self.propagate_through_local(*local, succ)
}
@ -1097,7 +1097,7 @@ pub impl Liveness {
self.define_bindings_in_pat(local.node.pat, succ)
}
fn propagate_through_exprs(&self, exprs: ~[@expr],
fn propagate_through_exprs(&self, exprs: &[@expr],
succ: LiveNode) -> LiveNode {
do exprs.foldr(succ) |expr, succ| {
self.propagate_through_expr(*expr, succ)
@ -1116,7 +1116,7 @@ pub impl Liveness {
debug!("propagate_through_expr: %s",
expr_to_str(expr, self.tcx.sess.intr()));
match /*bad*/copy expr.node {
match expr.node {
// Interesting cases with control flow or which gen/kill
expr_path(_) => {
@ -1283,8 +1283,8 @@ pub impl Liveness {
self.propagate_through_expr(expr, succ)
}
expr_vec(exprs, _) => {
self.propagate_through_exprs(exprs, succ)
expr_vec(ref exprs, _) => {
self.propagate_through_exprs(*exprs, succ)
}
expr_repeat(element, count, _) => {
@ -1299,29 +1299,29 @@ pub impl Liveness {
}
}
expr_call(f, args, _) => {
expr_call(f, ref args, _) => {
// calling a fn with bot return type means that the fn
// will fail, and hence the successors can be ignored
let t_ret = ty::ty_fn_ret(ty::expr_ty(self.tcx, f));
let succ = if ty::type_is_bot(t_ret) {self.s.exit_ln}
else {succ};
let succ = self.propagate_through_exprs(args, succ);
let succ = self.propagate_through_exprs(*args, succ);
self.propagate_through_expr(f, succ)
}
expr_method_call(rcvr, _, _, args, _) => {
expr_method_call(rcvr, _, _, ref args, _) => {
// calling a method with bot return type means that the method
// will fail, and hence the successors can be ignored
let t_ret = ty::ty_fn_ret(ty::node_id_to_type(self.tcx,
expr.callee_id));
let succ = if ty::type_is_bot(t_ret) {self.s.exit_ln}
else {succ};
let succ = self.propagate_through_exprs(args, succ);
let succ = self.propagate_through_exprs(*args, succ);
self.propagate_through_expr(rcvr, succ)
}
expr_tup(exprs) => {
self.propagate_through_exprs(exprs, succ)
expr_tup(ref exprs) => {
self.propagate_through_exprs(*exprs, succ)
}
expr_binary(op, l, r) if ast_util::lazy_binop(op) => {
@ -1350,7 +1350,7 @@ pub impl Liveness {
self.propagate_through_expr(e, succ)
}
expr_inline_asm(_, ins, outs, _, _, _) =>{
expr_inline_asm(_, ref ins, ref outs, _, _, _) =>{
let succ = do ins.foldr(succ) |&(_, expr), succ| {
self.propagate_through_expr(expr, succ)
};
@ -1579,7 +1579,7 @@ fn check_arm(arm: &arm, &&self: @Liveness, vt: vt<@Liveness>) {
}
fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
match /*bad*/copy expr.node {
match expr.node {
expr_path(_) => {
for self.variable_from_def_map(expr.id, expr.span).each |var| {
let ln = self.live_node(expr.id, expr.span);
@ -1624,7 +1624,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
visit::visit_expr(expr, self, vt);
}
expr_inline_asm(_, ins, outs, _, _, _) => {
expr_inline_asm(_, ref ins, ref outs, _, _, _) => {
for ins.each |&(_, in)| {
(vt.visit_expr)(in, self, vt);
}

View File

@ -1106,7 +1106,7 @@ pub fn field_mutbl(tcx: ty::ctxt,
node_id: ast::node_id)
-> Option<ast::mutability> {
// Need to refactor so that struct/enum fields can be treated uniformly.
match /*bad*/copy ty::get(base_ty).sty {
match ty::get(base_ty).sty {
ty::ty_struct(did, _) => {
for ty::lookup_struct_fields(tcx, did).each |fld| {
if fld.ident == f_name {

View File

@ -544,8 +544,8 @@ pub fn check_crate(tcx: ty::ctxt,
visit::visit_expr(expr, method_map, visitor);
},
visit_pat: |pattern, method_map, visitor| {
match /*bad*/copy pattern.node {
pat_struct(_, fields, _) => {
match pattern.node {
pat_struct(_, ref fields, _) => {
match ty::get(ty::pat_ty(tcx, pattern)).sty {
ty_struct(id, _) => {
if id.crate != local_crate ||

View File

@ -1080,7 +1080,7 @@ pub impl Resolver {
let sp = item.span;
let privacy = visibility_to_privacy(item.vis);
match /*bad*/copy item.node {
match item.node {
item_mod(ref module_) => {
let (name_bindings, new_parent) =
self.add_child(ident, parent, ForbidDuplicateModules, sp);
@ -1099,7 +1099,7 @@ pub impl Resolver {
visit_mod(module_, sp, item.id, new_parent, visitor);
}
item_foreign_mod(fm) => {
item_foreign_mod(ref fm) => {
let new_parent = match fm.sort {
named => {
let (name_bindings, new_parent) =
@ -1196,7 +1196,7 @@ pub impl Resolver {
visit_item(item, new_parent, visitor);
}
item_impl(_, trait_ref_opt, ty, methods) => {
item_impl(_, trait_ref_opt, ty, ref methods) => {
// If this implements an anonymous trait and it has static
// methods, then add all the static methods within to a new
// module, if the type was defined within this module.
@ -1401,8 +1401,8 @@ pub impl Resolver {
parent: ReducedGraphParent,
&&_visitor: vt<ReducedGraphParent>) {
let privacy = visibility_to_privacy(view_item.vis);
match /*bad*/copy view_item.node {
view_item_use(view_paths) => {
match view_item.node {
view_item_use(ref view_paths) => {
for view_paths.each |view_path| {
// Extract and intern the module part of the path. For
// globs and lists, the path is found directly in the AST;
@ -1571,7 +1571,7 @@ pub impl Resolver {
new_parent: ReducedGraphParent) {
match def {
def_mod(def_id) | def_foreign_mod(def_id) => {
match copy child_name_bindings.type_def {
match child_name_bindings.type_def {
Some(TypeNsDef { module_def: Some(copy module_def), _ }) => {
debug!("(building reduced graph for external crate) \
already created module");
@ -1790,7 +1790,7 @@ pub impl Resolver {
// Process the static methods. First,
// create the module.
let type_module;
match copy child_name_bindings.type_def {
match child_name_bindings.type_def {
Some(TypeNsDef {
module_def: Some(copy module_def),
_
@ -2008,10 +2008,13 @@ pub impl Resolver {
}
fn idents_to_str(@mut self, idents: &[ident]) -> ~str {
let ident_strs = do idents.map |ident| {
/*bad*/ copy *self.session.str_of(*ident)
let mut first = true;
let mut result = ~"";
for idents.each |ident| {
if first { first = false; } else { result += "::" };
result += *self.session.str_of(*ident);
};
str::connect(ident_strs, "::")
return result;
}
fn import_directive_subclass_to_str(@mut self,
@ -2511,22 +2514,22 @@ pub impl Resolver {
// Merge the two import resolutions at a finer-grained
// level.
match copy target_import_resolution.value_target {
match target_import_resolution.value_target {
None => {
// Continue.
}
Some(value_target) => {
Some(copy value_target) => {
dest_import_resolution.value_target =
Some(copy value_target);
Some(value_target);
}
}
match copy target_import_resolution.type_target {
match target_import_resolution.type_target {
None => {
// Continue.
}
Some(type_target) => {
Some(copy type_target) => {
dest_import_resolution.type_target =
Some(copy type_target);
Some(type_target);
}
}
}
@ -3149,7 +3152,7 @@ pub impl Resolver {
let mut exports2 = ~[];
self.add_exports_for_module(&mut exports2, module_);
match copy module_.def_id {
match /*bad*/copy module_.def_id {
Some(def_id) => {
self.export_map2.insert(def_id.node, exports2);
debug!("(computing exports) writing exports for %d (some)",
@ -3448,12 +3451,12 @@ pub impl Resolver {
// Items with the !resolve_unexported attribute are X-ray contexts.
// This is used to allow the test runner to run unexported tests.
let orig_xray_flag = self.xray_context;
if contains_name(attr_metas(/*bad*/copy item.attrs),
if contains_name(attr_metas(item.attrs),
~"!resolve_unexported") {
self.xray_context = Xray;
}
match /*bad*/copy item.node {
match item.node {
// enum item: resolve all the variants' discrs,
// then resolve the ty params
@ -3578,7 +3581,7 @@ pub impl Resolver {
self.type_ribs.pop();
}
item_struct(struct_def, ref generics) => {
item_struct(ref struct_def, ref generics) => {
self.resolve_struct(item.id,
generics,
struct_def.fields,
@ -3593,7 +3596,7 @@ pub impl Resolver {
}
}
item_foreign_mod(foreign_module) => {
item_foreign_mod(ref foreign_module) => {
do self.with_scope(Some(item.ident)) {
for foreign_module.items.each |foreign_item| {
match foreign_item.node {
@ -3639,7 +3642,7 @@ pub impl Resolver {
}
self.resolve_function(OpaqueFunctionRibKind,
Some(@/*bad*/copy *fn_decl),
Some(fn_decl),
HasTypeParameters
(generics,
item.id,
@ -3721,7 +3724,7 @@ pub impl Resolver {
fn resolve_function(@mut self,
rib_kind: RibKind,
optional_declaration: Option<@fn_decl>,
optional_declaration: Option<&fn_decl>,
type_parameters: TypeParameters,
block: &blk,
self_binding: SelfBinding,
@ -3868,7 +3871,7 @@ pub impl Resolver {
};
self.resolve_function(rib_kind,
Some(@/*bad*/copy method.decl),
Some(&method.decl),
type_parameters,
&method.body,
self_binding,
@ -4133,7 +4136,7 @@ pub impl Resolver {
}
}
match copy result_def {
match result_def {
Some(def) => {
// Write the result into the def map.
debug!("(resolving type) writing resolution for `%s` \
@ -4681,7 +4684,7 @@ pub impl Resolver {
}
}
match copy search_result {
match search_result {
Some(dl_def(def)) => {
debug!("(resolving path in local ribs) resolved `%s` to \
local: %?",
@ -4823,7 +4826,7 @@ pub impl Resolver {
}
None => {
let wrong_name = self.idents_to_str(
/*bad*/copy path.idents);
path.idents);
if self.name_exists_in_scope_struct(wrong_name) {
self.session.span_err(expr.span,
fmt!("unresolved name: `%s`. \
@ -4855,7 +4858,7 @@ pub impl Resolver {
expr_fn_block(ref fn_decl, ref block) => {
self.resolve_function(FunctionRibKind(expr.id, block.node.id),
Some(@/*bad*/copy *fn_decl),
Some(fn_decl),
NoTypeParameters,
block,
NoSelfBinding,
@ -5007,7 +5010,7 @@ pub impl Resolver {
let mut search_module = self.current_module;
loop {
// Look for the current trait.
match copy self.current_trait_refs {
match /*bad*/copy self.current_trait_refs {
Some(trait_def_ids) => {
for trait_def_ids.each |trait_def_id| {
self.add_trait_info_if_containing_method(

View File

@ -501,12 +501,13 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
let tcx = bcx.tcx();
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
do enter_match(bcx, tcx.def_map, m, col, val) |p| {
match /*bad*/copy p.node {
ast::pat_enum(_, subpats) => {
match p.node {
ast::pat_enum(_, ref subpats) => {
if opt_eq(tcx, &variant_opt(bcx, p.id), opt) {
Some(option::get_or_default(subpats,
vec::from_elem(variant_size,
dummy)))
match *subpats {
None => Some(vec::from_elem(variant_size, dummy)),
_ => copy *subpats
}
} else {
None
}
@ -534,7 +535,7 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
ast::pat_range(l1, l2) => {
if opt_eq(tcx, &range(l1, l2), opt) {Some(~[])} else {None}
}
ast::pat_struct(_, field_pats, _) => {
ast::pat_struct(_, ref field_pats, _) => {
if opt_eq(tcx, &variant_opt(bcx, p.id), opt) {
// Look up the struct variant ID.
let struct_id;
@ -565,14 +566,14 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
None
}
}
ast::pat_vec(before, slice, after) => {
ast::pat_vec(ref before, slice, ref after) => {
match slice {
Some(_) => {
Some(slice) => {
let n = before.len() + after.len();
let i = before.len();
if opt_eq(tcx, &vec_len_ge(n, i), opt) {
Some(vec::concat(
&[before, ~[slice.get()], after]))
Some(vec::append_one(copy *before, slice) +
*after)
} else {
None
}
@ -580,7 +581,7 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
None => {
let n = before.len();
if opt_eq(tcx, &vec_len_eq(n), opt) {
Some(copy before)
Some(copy *before)
} else {
None
}
@ -611,10 +612,10 @@ pub fn enter_rec_or_struct(bcx: block,
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
do enter_match(bcx, dm, m, col, val) |p| {
match /*bad*/copy p.node {
ast::pat_struct(_, fpats, _) => {
match p.node {
ast::pat_struct(_, ref fpats, _) => {
let mut pats = ~[];
for vec::each(fields) |fname| {
for fields.each |fname| {
match fpats.find(|p| p.ident == *fname) {
None => pats.push(dummy),
Some(pat) => pats.push(pat.pat)
@ -642,8 +643,8 @@ pub fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r],
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
do enter_match(bcx, dm, m, col, val) |p| {
match /*bad*/copy p.node {
ast::pat_tup(elts) => {
match p.node {
ast::pat_tup(/*bad*/copy elts) => {
Some(elts)
}
_ => {
@ -670,8 +671,8 @@ pub fn enter_tuple_struct(bcx: block,
let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()};
do enter_match(bcx, dm, m, col, val) |p| {
match /*bad*/copy p.node {
ast::pat_enum(_, Some(elts)) => Some(elts),
match p.node {
ast::pat_enum(_, Some(/*bad*/copy elts)) => Some(elts),
_ => {
assert_is_binding_or_wild(bcx, p);
Some(vec::from_elem(n_elts, dummy))
@ -774,7 +775,7 @@ pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] {
let mut found = ~[];
for m.each |br| {
let cur = br.pats[col];
match /*bad*/copy cur.node {
match cur.node {
ast::pat_lit(l) => {
add_to_set(ccx.tcx, &mut found, lit(ExprLit(l)));
}
@ -811,7 +812,7 @@ pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] {
ast::pat_range(l1, l2) => {
add_to_set(ccx.tcx, &mut found, range(l1, l2));
}
ast::pat_vec(before, slice, after) => {
ast::pat_vec(ref before, slice, ref after) => {
let opt = match slice {
None => vec_len_eq(before.len()),
Some(_) => vec_len_ge(before.len() + after.len(),
@ -902,10 +903,10 @@ pub fn collect_record_or_struct_fields(bcx: block,
-> ~[ast::ident] {
let mut fields: ~[ast::ident] = ~[];
for vec::each(m) |br| {
match /*bad*/copy br.pats[col].node {
ast::pat_struct(_, fs, _) => {
match br.pats[col].node {
ast::pat_struct(_, ref fs, _) => {
match ty::get(node_id_type(bcx, br.pats[col].id)).sty {
ty::ty_struct(*) => extend(&mut fields, fs),
ty::ty_struct(*) => extend(&mut fields, *fs),
_ => ()
}
}
@ -1300,8 +1301,8 @@ pub fn compile_submatch(bcx: block,
if any_tup_pat(m, col) {
let tup_ty = node_id_type(bcx, pat_id);
let tup_repr = adt::represent_type(bcx.ccx(), tup_ty);
let n_tup_elts = match /*bad*/copy ty::get(tup_ty).sty {
ty::ty_tup(elts) => elts.len(),
let n_tup_elts = match ty::get(tup_ty).sty {
ty::ty_tup(ref elts) => elts.len(),
_ => ccx.sess.bug(~"non-tuple type in tuple pattern")
};
let tup_vals = do vec::from_fn(n_tup_elts) |i| {
@ -1701,8 +1702,8 @@ pub fn bind_irrefutable_pat(bcx: block,
let mut bcx = bcx;
// Necessary since bind_irrefutable_pat is called outside trans_match
match /*bad*/copy pat.node {
ast::pat_ident(_, _,inner) => {
match pat.node {
ast::pat_ident(_, _, ref inner) => {
if pat_is_variant_or_struct(bcx.tcx().def_map, pat) {
return bcx;
}
@ -1740,7 +1741,7 @@ pub fn bind_irrefutable_pat(bcx: block,
bcx, *inner_pat, val, true, binding_mode);
}
}
ast::pat_enum(_, sub_pats) => {
ast::pat_enum(_, ref sub_pats) => {
match bcx.tcx().def_map.find(&pat.id) {
Some(ast::def_variant(enum_id, var_id)) => {
let repr = adt::represent_node(bcx, pat.id);
@ -1762,14 +1763,14 @@ pub fn bind_irrefutable_pat(bcx: block,
}
}
Some(ast::def_struct(*)) => {
match sub_pats {
match *sub_pats {
None => {
// This is a unit-like struct. Nothing to do here.
}
Some(elems) => {
Some(ref elems) => {
// This is the tuple struct case.
let repr = adt::represent_node(bcx, pat.id);
for vec::eachi(elems) |i, elem| {
for elems.eachi |i, elem| {
let fldptr = adt::trans_field_ptr(bcx, repr,
val, 0, i);
bcx = bind_irrefutable_pat(bcx,
@ -1786,12 +1787,12 @@ pub fn bind_irrefutable_pat(bcx: block,
}
}
}
ast::pat_struct(_, fields, _) => {
ast::pat_struct(_, ref fields, _) => {
let tcx = bcx.tcx();
let pat_ty = node_id_type(bcx, pat.id);
let pat_repr = adt::represent_type(bcx.ccx(), pat_ty);
do expr::with_field_tys(tcx, pat_ty, None) |discr, field_tys| {
for vec::each(fields) |f| {
for fields.each |f| {
let ix = ty::field_idx_strict(tcx, f.ident, field_tys);
let fldptr = adt::trans_field_ptr(bcx, pat_repr, val,
discr, ix);
@ -1803,9 +1804,9 @@ pub fn bind_irrefutable_pat(bcx: block,
}
}
}
ast::pat_tup(elems) => {
ast::pat_tup(ref elems) => {
let repr = adt::represent_node(bcx, pat.id);
for vec::eachi(elems) |i, elem| {
for elems.eachi |i, elem| {
let fldptr = adt::trans_field_ptr(bcx, repr, val, 0, i);
bcx = bind_irrefutable_pat(bcx,
*elem,

View File

@ -638,7 +638,7 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
}
let mut cx = cx;
match /*bad*/copy ty::get(t).sty {
match ty::get(t).sty {
ty::ty_struct(*) => {
let repr = adt::represent_type(cx.ccx(), t);
do expr::with_field_tys(cx.tcx(), t, None) |discr, field_tys| {
@ -653,9 +653,9 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
let (base, len) = tvec::get_base_and_len(cx, av, t);
cx = tvec::iter_vec_raw(cx, base, t, len, f);
}
ty::ty_tup(args) => {
ty::ty_tup(ref args) => {
let repr = adt::represent_type(cx.ccx(), t);
for vec::eachi(args) |i, arg| {
for args.eachi |i, arg| {
let llfld_a = adt::trans_field_ptr(cx, repr, av, 0, i);
cx = f(cx, llfld_a, *arg);
}
@ -756,9 +756,9 @@ pub fn cast_shift_rhs(op: ast::binop,
pub fn fail_if_zero(cx: block, span: span, divmod: ast::binop,
rhs: ValueRef, rhs_t: ty::t) -> block {
let text = if divmod == ast::div {
~"divide by zero"
@~"divide by zero"
} else {
~"modulo zero"
@~"modulo zero"
};
let is_zero = match ty::get(rhs_t).sty {
ty::ty_int(t) => {
@ -775,7 +775,7 @@ pub fn fail_if_zero(cx: block, span: span, divmod: ast::binop,
}
};
do with_cond(cx, is_zero) |bcx| {
controlflow::trans_fail(bcx, Some(span), @/*bad*/copy text)
controlflow::trans_fail(bcx, Some(span), text)
}
}
@ -914,7 +914,7 @@ pub fn get_landing_pad(bcx: block) -> BasicBlockRef {
let mut cached = None, pad_bcx = bcx; // Guaranteed to be set below
do in_lpad_scope_cx(bcx) |inf| {
// If there is a valid landing pad still around, use it
match copy inf.landing_pad {
match inf.landing_pad {
Some(target) => cached = Some(target),
None => {
pad_bcx = lpad_block(bcx, ~"unwind");
@ -944,7 +944,7 @@ pub fn get_landing_pad(bcx: block) -> BasicBlockRef {
// We store the retval in a function-central alloca, so that calls to
// Resume can find it.
match copy bcx.fcx.personality {
match bcx.fcx.personality {
Some(addr) => Store(pad_bcx, llretval, addr),
None => {
let addr = alloca(pad_bcx, val_ty(llretval));
@ -1143,9 +1143,9 @@ pub fn trans_stmt(cx: block, s: ast::stmt) -> block {
bcx = expr::trans_into(cx, e, expr::Ignore);
}
ast::stmt_decl(d, _) => {
match /*bad*/copy d.node {
ast::decl_local(locals) => {
for vec::each(locals) |local| {
match d.node {
ast::decl_local(ref locals) => {
for locals.each |local| {
bcx = init_local(bcx, *local);
if cx.sess().opts.extra_debuginfo {
debuginfo::create_local_var(bcx, *local);
@ -1390,9 +1390,9 @@ pub fn block_locals(b: &ast::blk, it: &fn(@ast::local)) {
for vec::each(b.node.stmts) |s| {
match s.node {
ast::stmt_decl(d, _) => {
match /*bad*/copy d.node {
ast::decl_local(locals) => {
for vec::each(locals) |local| {
match d.node {
ast::decl_local(ref locals) => {
for locals.each |local| {
it(*local);
}
}
@ -1771,7 +1771,7 @@ pub fn trans_closure(ccx: @CrateContext,
let fcx = new_fn_ctxt_w_id(ccx, path, llfndecl, id, impl_id, param_substs,
Some(body.span));
let raw_llargs = create_llargs_for_fn_args(fcx, ty_self,
/*bad*/copy decl.inputs);
decl.inputs);
// Set GC for function.
if ccx.sess.opts.gc {
@ -1871,8 +1871,8 @@ pub fn trans_enum_variant(ccx: @CrateContext,
param_substs, None);
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args);
let ty_param_substs = match param_substs {
Some(ref substs) => /*bad*/copy substs.tys,
None => ~[]
Some(ref substs) => { copy substs.tys }
None => ~[]
};
let bcx = top_scope_block(fcx, None), lltop = bcx.llbb;
let arg_tys = ty::ty_fn_args(node_id_type(bcx, variant.node.id));
@ -1932,8 +1932,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
param_substs,
None);
// XXX: Bad copy.
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, copy fn_args);
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args);
let bcx = top_scope_block(fcx, None);
let lltop = bcx.llbb;
@ -1942,7 +1941,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
// XXX is there a better way to reconstruct the ty::t?
let ty_param_substs = match param_substs {
Some(ref substs) => /*bad*/copy substs.tys,
Some(ref substs) => { copy substs.tys }
None => ~[]
};
let ctor_ty = ty::subst_tps(ccx.tcx, ty_param_substs, None,
@ -2022,7 +2021,7 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: ast::enum_def,
match variant.node.kind {
ast::tuple_variant_kind(ref args) if args.len() > 0 => {
let llfn = get_item_val(ccx, variant.node.id);
trans_enum_variant(ccx, id, *variant, /*bad*/copy *args,
trans_enum_variant(ccx, id, *variant, *args,
disr_val, None, llfn);
}
ast::tuple_variant_kind(_) => {
@ -2051,7 +2050,7 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) {
// tjc: ?
_ => fail!(~"trans_item"),
};
match /*bad*/copy item.node {
match item.node {
ast::item_fn(ref decl, purity, ref generics, ref body) => {
if purity == ast::extern_fn {
let llfndecl = get_item_val(ccx, item.id);
@ -2096,11 +2095,11 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) {
ast::item_foreign_mod(ref foreign_mod) => {
let abi = match attr::foreign_abi(item.attrs) {
Right(abi_) => abi_,
Left(ref msg) => ccx.sess.span_fatal(item.span, /*bad*/copy *msg)
Left(msg) => ccx.sess.span_fatal(item.span, msg)
};
foreign::trans_foreign_mod(ccx, foreign_mod, abi);
}
ast::item_struct(struct_def, generics) => {
ast::item_struct(struct_def, ref generics) => {
if !generics.is_type_parameterized() {
trans_struct_def(ccx, struct_def, path, item.id);
}
@ -2124,7 +2123,7 @@ pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def,
// otherwise this is a unit-like struct.
Some(ctor_id) if struct_def.fields.len() > 0 => {
let llfndecl = get_item_val(ccx, ctor_id);
trans_tuple_struct(ccx, /*bad*/copy struct_def.fields,
trans_tuple_struct(ccx, struct_def.fields,
ctor_id, None, llfndecl);
}
Some(_) | None => {}
@ -2405,7 +2404,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
i.id,
i.attrs)
};
set_inline_hint_if_appr(/*bad*/copy i.attrs, llfn);
set_inline_hint_if_appr(i.attrs, llfn);
llfn
}
_ => fail!(~"get_item_val: weird result in table")
@ -2479,8 +2478,8 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
ast_map::node_variant(ref v, enm, pth) => {
let llfn;
match /*bad*/copy (*v).node.kind {
ast::tuple_variant_kind(args) => {
match v.node.kind {
ast::tuple_variant_kind(ref args) => {
fail_unless!(args.len() != 0u);
let pth = vec::append(/*bad*/copy *pth,
~[path_name(enm.ident),
@ -2543,7 +2542,7 @@ pub fn register_method(ccx: @CrateContext,
let pth = vec::append(/*bad*/copy *pth, ~[path_name((ccx.names)(~"meth")),
path_name(m.ident)]);
let llfn = register_fn_full(ccx, m.span, pth, id, m.attrs, mty);
set_inline_hint_if_appr(/*bad*/copy m.attrs, llfn);
set_inline_hint_if_appr(m.attrs, llfn);
llfn
}
@ -3013,8 +3012,8 @@ pub fn trans_crate(sess: session::Session,
llvm::LLVMModuleCreateWithNameInContext
(buf, llvm::LLVMGetGlobalContext())
});
let data_layout = /*bad*/copy sess.targ_cfg.target_strs.data_layout;
let targ_triple = /*bad*/copy sess.targ_cfg.target_strs.target_triple;
let data_layout: &str = sess.targ_cfg.target_strs.data_layout;
let targ_triple: &str = sess.targ_cfg.target_strs.target_triple;
let _: () =
str::as_c_str(data_layout,
|buf| llvm::LLVMSetDataLayout(llmod, buf));
@ -3022,8 +3021,7 @@ pub fn trans_crate(sess: session::Session,
str::as_c_str(targ_triple,
|buf| llvm::LLVMSetTarget(llmod, buf));
let targ_cfg = sess.targ_cfg;
let td = mk_target_data(
/*bad*/copy sess.targ_cfg.target_strs.data_layout);
let td = mk_target_data(sess.targ_cfg.target_strs.data_layout);
let tn = mk_type_names();
let intrinsics = declare_intrinsics(llmod);
if sess.opts.extra_debuginfo {

View File

@ -70,10 +70,9 @@ pub fn count_insn(cx: block, category: &str) {
let mut s = ~".";
i = 0u;
while i < len {
let e = /*bad*/copy v[i];
i = mm.get(&e);
i = mm.get(&v[i]);
s += ~"/";
s += e;
s += v[i];
i += 1u;
}

View File

@ -1291,14 +1291,14 @@ pub type mono_id = @mono_id_;
impl to_bytes::IterBytes for mono_param_id {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match /*bad*/copy *self {
mono_precise(t, mids) =>
to_bytes::iter_bytes_3(&0u8, &ty::type_id(t), &mids, lsb0, f),
match *self {
mono_precise(t, ref mids) =>
to_bytes::iter_bytes_3(&0u8, &ty::type_id(t), mids, lsb0, f),
mono_any => 1u8.iter_bytes(lsb0, f),
mono_any => 1u8.iter_bytes(lsb0, f),
mono_repr(ref a, ref b, ref c, ref d) =>
to_bytes::iter_bytes_5(&2u8, a, b, c, d, lsb0, f)
mono_repr(ref a, ref b, ref c, ref d) =>
to_bytes::iter_bytes_5(&2u8, a, b, c, d, lsb0, f)
}
}
}
@ -1340,7 +1340,7 @@ pub fn path_str(sess: session::Session, p: &[path_elt]) -> ~str {
}
pub fn monomorphize_type(bcx: block, t: ty::t) -> ty::t {
match /*bad*/copy bcx.fcx.param_substs {
match bcx.fcx.param_substs {
Some(substs) => {
ty::subst_tps(bcx.tcx(), substs.tys, substs.self_ty, t)
}
@ -1367,7 +1367,7 @@ pub fn expr_ty_adjusted(bcx: block, ex: @ast::expr) -> ty::t {
pub fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
let tcx = bcx.tcx();
let params = ty::node_id_to_type_params(tcx, id);
match /*bad*/copy bcx.fcx.param_substs {
match bcx.fcx.param_substs {
Some(substs) => {
do vec::map(params) |t| {
ty::subst_tps(tcx, substs.tys, substs.self_ty, *t)
@ -1396,7 +1396,7 @@ pub fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, +vt: typeck::vtable_origin)
let tcx = fcx.ccx.tcx;
match vt {
typeck::vtable_static(trait_id, tys, sub) => {
let tys = match /*bad*/copy fcx.param_substs {
let tys = match fcx.param_substs {
Some(substs) => {
do vec::map(tys) |t| {
ty::subst_tps(tcx, substs.tys, substs.self_ty, *t)

View File

@ -242,7 +242,7 @@ pub fn const_expr(cx: @CrateContext, e: @ast::expr) -> ValueRef {
fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
unsafe {
let _icx = cx.insn_ctxt("const_expr");
return match /*bad*/copy e.node {
return match e.node {
ast::expr_lit(lit) => consts::const_lit(cx, e, *lit),
ast::expr_binary(b, e1, e2) => {
let te1 = const_expr(cx, e1);
@ -438,7 +438,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
ast::expr_addr_of(ast::m_imm, sub) => {
const_addr_of(cx, const_expr(cx, sub))
}
ast::expr_tup(es) => {
ast::expr_tup(ref es) => {
let ety = ty::expr_ty(cx.tcx, e);
let repr = adt::represent_type(cx, ety);
adt::trans_const(cx, repr, 0, es.map(|e| const_expr(cx, *e)))
@ -460,24 +460,24 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
adt::trans_const(cx, repr, discr, cs)
}
}
ast::expr_vec(es, ast::m_imm) => {
let (v, _, _) = const_vec(cx, e, es);
ast::expr_vec(ref es, ast::m_imm) => {
let (v, _, _) = const_vec(cx, e, *es);
v
}
ast::expr_vstore(e, ast::expr_vstore_fixed(_)) => {
const_expr(cx, e)
}
ast::expr_vstore(sub, ast::expr_vstore_slice) => {
match /*bad*/copy sub.node {
ast::expr_lit(lit) => {
match sub.node {
ast::expr_lit(ref lit) => {
match lit.node {
ast::lit_str(*) => { const_expr(cx, sub) }
_ => { cx.sess.span_bug(e.span,
~"bad const-slice lit") }
}
}
ast::expr_vec(es, ast::m_imm) => {
let (cv, sz, llunitty) = const_vec(cx, e, es);
ast::expr_vec(ref es, ast::m_imm) => {
let (cv, sz, llunitty) = const_vec(cx, e, *es);
let llty = val_ty(cv);
let gv = do str::as_c_str("const") |name| {
llvm::LLVMAddGlobal(cx.llmod, llty, name)
@ -525,7 +525,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
}
}
}
ast::expr_call(callee, args, _) => {
ast::expr_call(callee, ref args, _) => {
match cx.tcx.def_map.find(&callee.id) {
Some(ast::def_struct(_)) => {
let ety = ty::expr_ty(cx.tcx, e);

View File

@ -520,7 +520,7 @@ fn create_struct(cx: @CrateContext, t: ty::t, fields: ~[ty::field],
return mdval;
}
fn create_tuple(cx: @CrateContext, t: ty::t, elements: ~[ty::t], span: span)
fn create_tuple(cx: @CrateContext, t: ty::t, elements: &[ty::t], span: span)
-> @Metadata<TyDescMetadata> {
let fname = filename_from_span(cx, span);
let file_node = create_file(cx, fname);
@ -648,46 +648,46 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
}*/
let sty = copy ty::get(t).sty;
match copy sty {
match sty {
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) | ty::ty_uint(_)
| ty::ty_float(_) => create_basic_type(cx, t, span),
ty::ty_estr(_vstore) => {
cx.sess.span_bug(span, ~"debuginfo for estr NYI")
},
ty::ty_enum(_did, _substs) => {
ty::ty_enum(_did, ref _substs) => {
cx.sess.span_bug(span, ~"debuginfo for enum NYI")
}
ty::ty_box(_mt) => {
ty::ty_box(ref _mt) => {
cx.sess.span_bug(span, ~"debuginfo for box NYI")
},
ty::ty_uniq(_mt) => {
ty::ty_uniq(ref _mt) => {
cx.sess.span_bug(span, ~"debuginfo for uniq NYI")
},
ty::ty_evec(_mt, _vstore) => {
ty::ty_evec(ref _mt, ref _vstore) => {
cx.sess.span_bug(span, ~"debuginfo for evec NYI")
},
ty::ty_ptr(mt) => {
ty::ty_ptr(ref mt) => {
let pointee = create_ty(cx, mt.ty, span);
create_pointer_type(cx, t, span, pointee)
},
ty::ty_rptr(_region, _mt) => {
ty::ty_rptr(ref _region, ref _mt) => {
cx.sess.span_bug(span, ~"debuginfo for rptr NYI")
},
ty::ty_bare_fn(_barefnty) => {
ty::ty_bare_fn(ref _barefnty) => {
cx.sess.span_bug(span, ~"debuginfo for bare_fn NYI")
},
ty::ty_closure(_closurety) => {
ty::ty_closure(ref _closurety) => {
cx.sess.span_bug(span, ~"debuginfo for closure NYI")
},
ty::ty_trait(_did, _substs, _vstore) => {
ty::ty_trait(_did, ref _substs, ref _vstore) => {
cx.sess.span_bug(span, ~"debuginfo for trait NYI")
},
ty::ty_struct(did, substs) => {
let fields = ty::struct_fields(cx.tcx, did, &substs);
ty::ty_struct(did, ref substs) => {
let fields = ty::struct_fields(cx.tcx, did, substs);
create_struct(cx, t, fields, span)
},
ty::ty_tup(elements) => {
create_tuple(cx, t, elements, span)
ty::ty_tup(ref elements) => {
create_tuple(cx, t, *elements, span)
},
_ => cx.sess.bug(~"debuginfo: unexpected type in create_ty")
}
@ -853,8 +853,8 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
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, _, _, _) => {
match item.node {
ast::item_fn(ref decl, _, _, _) => {
(item.ident, decl.output, item.id)
}
_ => fcx.ccx.sess.span_bug(item.span, ~"create_function: item \
@ -865,8 +865,8 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
(method.ident, method.decl.output, method.id)
}
ast_map::node_expr(expr) => {
match /*bad*/copy expr.node {
ast::expr_fn_block(decl, _) => {
match expr.node {
ast::expr_fn_block(ref decl, _) => {
((dbg_cx.names)(~"fn"), decl.output, expr.id)
}
_ => fcx.ccx.sess.span_bug(expr.span,

View File

@ -792,7 +792,7 @@ pub fn emit_tydescs(ccx: @CrateContext) {
// tydesc type. Then we'll recast each function to its real type when
// calling it.
let take_glue =
match copy ti.take_glue {
match ti.take_glue {
None => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
Some(v) => {
unsafe {
@ -802,7 +802,7 @@ pub fn emit_tydescs(ccx: @CrateContext) {
}
};
let drop_glue =
match copy ti.drop_glue {
match ti.drop_glue {
None => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
Some(v) => {
unsafe {
@ -812,7 +812,7 @@ pub fn emit_tydescs(ccx: @CrateContext) {
}
};
let free_glue =
match copy ti.free_glue {
match ti.free_glue {
None => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
Some(v) => {
unsafe {
@ -822,7 +822,7 @@ pub fn emit_tydescs(ccx: @CrateContext) {
}
};
let visit_glue =
match copy ti.visit_glue {
match ti.visit_glue {
None => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
Some(v) => {
unsafe {

View File

@ -320,12 +320,12 @@ pub fn trans_static_method_callee(bcx: block,
let vtbls = resolve_vtables_in_fn_ctxt(
bcx.fcx, ccx.maps.vtable_map.get(&callee_id));
match /*bad*/copy vtbls[bound_index] {
typeck::vtable_static(impl_did, rcvr_substs, rcvr_origins) => {
match vtbls[bound_index] {
typeck::vtable_static(impl_did, ref rcvr_substs, rcvr_origins) => {
let mth_id = method_with_name(bcx.ccx(), impl_did, mname);
let callee_substs = combine_impl_and_methods_tps(
bcx, mth_id, impl_did, callee_id, rcvr_substs);
bcx, mth_id, impl_did, callee_id, *rcvr_substs);
let callee_origins = combine_impl_and_methods_origins(
bcx, mth_id, impl_did, callee_id, rcvr_origins);
@ -347,7 +347,7 @@ pub fn trans_static_method_callee(bcx: block,
}
}
pub fn method_from_methods(ms: ~[@ast::method], name: ast::ident)
pub fn method_from_methods(ms: &[@ast::method], name: ast::ident)
-> Option<ast::def_id> {
ms.find(|m| m.ident == name).map(|m| ast_util::local_def(m.id))
}
@ -360,7 +360,7 @@ pub fn method_with_name(ccx: @CrateContext, impl_id: ast::def_id,
node: ast::item_impl(_, _, _, ref ms),
_
}, _) => {
method_from_methods(/*bad*/copy *ms, name).get()
method_from_methods(*ms, name).get()
}
_ => fail!(~"method_with_name")
}
@ -376,7 +376,7 @@ pub fn method_with_name_or_default(ccx: @CrateContext, impl_id: ast::def_id,
ast_map::node_item(@ast::item {
node: ast::item_impl(_, _, _, ref ms), _
}, _) => {
let did = method_from_methods(/*bad*/copy *ms, name);
let did = method_from_methods(*ms, name);
if did.is_some() {
return did.get();
} else {
@ -440,7 +440,7 @@ pub fn trans_monomorphized_callee(bcx: block,
-> Callee {
let _icx = bcx.insn_ctxt("impl::trans_monomorphized_callee");
return match vtbl {
typeck::vtable_static(impl_did, rcvr_substs, rcvr_origins) => {
typeck::vtable_static(impl_did, ref rcvr_substs, rcvr_origins) => {
let ccx = bcx.ccx();
let mname = ty::trait_methods(ccx.tcx, trait_id)[n_method].ident;
let mth_id = method_with_name_or_default(
@ -453,7 +453,7 @@ pub fn trans_monomorphized_callee(bcx: block,
// create a concatenated set of substitutions which includes
// those from the impl and those from the method:
let callee_substs = combine_impl_and_methods_tps(
bcx, mth_id, impl_did, callee_id, rcvr_substs);
bcx, mth_id, impl_did, callee_id, *rcvr_substs);
let callee_origins = combine_impl_and_methods_origins(
bcx, mth_id, impl_did, callee_id, rcvr_origins);
@ -490,7 +490,7 @@ pub fn combine_impl_and_methods_tps(bcx: block,
mth_did: ast::def_id,
impl_did: ast::def_id,
callee_id: ast::node_id,
+rcvr_substs: ~[ty::t])
rcvr_substs: &[ty::t])
-> ~[ty::t] {
/*!
*
@ -514,7 +514,7 @@ pub fn combine_impl_and_methods_tps(bcx: block,
let node_substs = node_id_type_params(bcx, callee_id);
debug!("rcvr_substs=%?", rcvr_substs.map(|t| bcx.ty_to_str(*t)));
let ty_substs
= vec::append(rcvr_substs,
= vec::append(rcvr_substs.to_vec(),
vec::tailn(node_substs,
node_substs.len() - n_m_tps));
debug!("n_m_tps=%?", n_m_tps);

View File

@ -98,7 +98,7 @@ fn traverse_public_mod(cx: ctx, mod_id: node_id, m: &_mod) {
fn traverse_public_item(cx: ctx, item: @item) {
if cx.rmap.contains_key(&item.id) { return; }
cx.rmap.insert(item.id, ());
match /*bad*/copy item.node {
match item.node {
item_mod(ref m) => traverse_public_mod(cx, item.id, m),
item_foreign_mod(ref nm) => {
if !traverse_exports(cx, item.id) {

View File

@ -75,7 +75,7 @@ pub impl Reflector {
PointerCast(bcx, static_ti.tydesc, T_ptr(self.tydesc_ty))
}
fn c_mt(&mut self, mt: ty::mt) -> ~[ValueRef] {
fn c_mt(&mut self, mt: &ty::mt) -> ~[ValueRef] {
~[self.c_uint(mt.mutbl as uint),
self.c_tydesc(mt.ty)]
}
@ -151,7 +151,7 @@ pub impl Reflector {
debug!("reflect::visit_ty %s",
ty_to_str(bcx.ccx().tcx, t));
match /*bad*/copy ty::get(t).sty {
match ty::get(t).sty {
ty::ty_bot => self.leaf(~"bot"),
ty::ty_nil => self.leaf(~"nil"),
ty::ty_bool => self.leaf(~"bool"),
@ -170,7 +170,7 @@ pub impl Reflector {
ty::ty_float(ast::ty_f32) => self.leaf(~"f32"),
ty::ty_float(ast::ty_f64) => self.leaf(~"f64"),
ty::ty_unboxed_vec(mt) => {
ty::ty_unboxed_vec(ref mt) => {
let values = self.c_mt(mt);
self.visit(~"vec", values)
}
@ -179,30 +179,30 @@ pub impl Reflector {
let (name, extra) = self.vstore_name_and_extra(t, vst);
self.visit(~"estr_" + name, extra)
}
ty::ty_evec(mt, vst) => {
ty::ty_evec(ref mt, vst) => {
let (name, extra) = self.vstore_name_and_extra(t, vst);
let extra = extra + self.c_mt(mt);
self.visit(~"evec_" + name, extra)
}
ty::ty_box(mt) => {
ty::ty_box(ref mt) => {
let extra = self.c_mt(mt);
self.visit(~"box", extra)
}
ty::ty_uniq(mt) => {
ty::ty_uniq(ref mt) => {
let extra = self.c_mt(mt);
self.visit(~"uniq", extra)
}
ty::ty_ptr(mt) => {
ty::ty_ptr(ref mt) => {
let extra = self.c_mt(mt);
self.visit(~"ptr", extra)
}
ty::ty_rptr(_, mt) => {
ty::ty_rptr(_, ref mt) => {
let extra = self.c_mt(mt);
self.visit(~"rptr", extra)
}
ty::ty_tup(tys) => {
let extra = ~[self.c_uint(vec::len(tys))]
ty::ty_tup(ref tys) => {
let extra = ~[self.c_uint(tys.len())]
+ self.c_size_and_align(t);
do self.bracketed(~"tup", extra) |this| {
for tys.eachi |i, t| {
@ -254,7 +254,7 @@ pub impl Reflector {
let extra = ~[this.c_uint(i),
this.c_slice(
bcx.ccx().sess.str_of(field.ident))]
+ this.c_mt(field.mt);
+ this.c_mt(&field.mt);
this.visit(~"class_field", extra);
}
}
@ -293,7 +293,7 @@ pub impl Reflector {
ty::ty_trait(_, _, _) => self.leaf(~"trait"),
ty::ty_infer(_) => self.leaf(~"infer"),
ty::ty_err => self.leaf(~"err"),
ty::ty_param(p) => {
ty::ty_param(ref p) => {
let extra = ~[self.c_uint(p.idx)];
self.visit(~"param", extra)
}

View File

@ -361,7 +361,7 @@ pub fn write_content(bcx: block,
bcx.expr_to_str(vstore_expr));
let _indenter = indenter();
match /*bad*/copy content_expr.node {
match content_expr.node {
ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => {
match dest {
Ignore => {
@ -376,7 +376,7 @@ pub fn write_content(bcx: block,
}
}
}
ast::expr_vec(elements, _) => {
ast::expr_vec(ref elements, _) => {
match dest {
Ignore => {
for elements.each |element| {
@ -467,11 +467,11 @@ pub fn vec_types(bcx: block, vec_ty: ty::t) -> VecTypes {
pub fn elements_required(bcx: block, content_expr: @ast::expr) -> uint {
//! Figure out the number of elements we need to store this content
match /*bad*/copy content_expr.node {
match content_expr.node {
ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => {
s.len() + 1
},
ast::expr_vec(es, _) => es.len(),
ast::expr_vec(ref es, _) => es.len(),
ast::expr_repeat(_, count_expr, _) => {
ty::eval_repeat_count(bcx.tcx(), count_expr)
}

View File

@ -176,7 +176,7 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef {
}
// XXX: This is a terrible terrible copy.
let llty = match /*bad*/copy ty::get(t).sty {
let llty = match ty::get(t).sty {
ty::ty_nil | ty::ty_bot => T_nil(),
ty::ty_bool => T_bool(),
ty::ty_int(t) => T_int_ty(cx, t),
@ -199,22 +199,22 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef {
ty::ty_estr(ty::vstore_box) => {
T_box_ptr(T_box(cx, T_vec(cx, T_i8())))
}
ty::ty_evec(mt, ty::vstore_box) => {
ty::ty_evec(ref mt, ty::vstore_box) => {
T_box_ptr(T_box(cx, T_vec(cx, type_of(cx, mt.ty))))
}
ty::ty_box(mt) => T_box_ptr(T_box(cx, type_of(cx, mt.ty))),
ty::ty_box(ref mt) => T_box_ptr(T_box(cx, type_of(cx, mt.ty))),
ty::ty_opaque_box => T_box_ptr(T_box(cx, T_i8())),
ty::ty_uniq(mt) => T_unique_ptr(T_unique(cx, type_of(cx, mt.ty))),
ty::ty_evec(mt, ty::vstore_uniq) => {
ty::ty_uniq(ref mt) => T_unique_ptr(T_unique(cx, type_of(cx, mt.ty))),
ty::ty_evec(ref mt, ty::vstore_uniq) => {
T_unique_ptr(T_unique(cx, T_vec(cx, type_of(cx, mt.ty))))
}
ty::ty_unboxed_vec(mt) => {
ty::ty_unboxed_vec(ref mt) => {
T_vec(cx, type_of(cx, mt.ty))
}
ty::ty_ptr(mt) => T_ptr(type_of(cx, mt.ty)),
ty::ty_rptr(_, mt) => T_ptr(type_of(cx, mt.ty)),
ty::ty_ptr(ref mt) => T_ptr(type_of(cx, mt.ty)),
ty::ty_rptr(_, ref mt) => T_ptr(type_of(cx, mt.ty)),
ty::ty_evec(mt, ty::vstore_slice(_)) => {
ty::ty_evec(ref mt, ty::vstore_slice(_)) => {
T_struct(~[T_ptr(type_of(cx, mt.ty)),
T_uint_ty(cx, ast::ty_u)])
}
@ -228,7 +228,7 @@ pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef {
T_array(T_i8(), n + 1u /* +1 for trailing null */)
}
ty::ty_evec(mt, ty::vstore_fixed(n)) => {
ty::ty_evec(ref mt, ty::vstore_fixed(n)) => {
T_array(type_of(cx, mt.ty), n)
}

View File

@ -1161,20 +1161,20 @@ pub fn walk_ty(ty: t, f: &fn(t)) {
pub fn maybe_walk_ty(ty: t, f: &fn(t) -> bool) {
if !f(ty) { return; }
match /*bad*/copy get(ty).sty {
match get(ty).sty {
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
ty_estr(_) | ty_type | ty_opaque_box | ty_self |
ty_opaque_closure_ptr(_) | ty_infer(_) | ty_param(_) | ty_err => {
}
ty_box(tm) | ty_evec(tm, _) | ty_unboxed_vec(tm) |
ty_ptr(tm) | ty_rptr(_, tm) => {
ty_box(ref tm) | ty_evec(ref tm, _) | ty_unboxed_vec(ref tm) |
ty_ptr(ref tm) | ty_rptr(_, ref tm) | ty_uniq(ref tm) => {
maybe_walk_ty(tm.ty, f);
}
ty_enum(_, ref substs) | ty_struct(_, ref substs) |
ty_trait(_, ref substs, _) => {
for (*substs).tps.each |subty| { maybe_walk_ty(*subty, f); }
}
ty_tup(ts) => { for ts.each |tt| { maybe_walk_ty(*tt, f); } }
ty_tup(ref ts) => { for ts.each |tt| { maybe_walk_ty(*tt, f); } }
ty_bare_fn(ref ft) => {
for ft.sig.inputs.each |a| { maybe_walk_ty(a.ty, f); }
maybe_walk_ty(ft.sig.output, f);
@ -1183,7 +1183,6 @@ pub fn maybe_walk_ty(ty: t, f: &fn(t) -> bool) {
for ft.sig.inputs.each |a| { maybe_walk_ty(a.ty, f); }
maybe_walk_ty(ft.sig.output, f);
}
ty_uniq(tm) => { maybe_walk_ty(tm.ty, f); }
}
}
@ -1209,20 +1208,20 @@ fn fold_sty(sty: &sty, fldop: &fn(t) -> t) -> sty {
tps: substs.tps.map(|t| fldop(*t))}
}
match /*bad*/copy *sty {
ty_box(tm) => {
match *sty {
ty_box(ref tm) => {
ty_box(mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
}
ty_uniq(tm) => {
ty_uniq(ref tm) => {
ty_uniq(mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
}
ty_ptr(tm) => {
ty_ptr(ref tm) => {
ty_ptr(mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
}
ty_unboxed_vec(tm) => {
ty_unboxed_vec(ref tm) => {
ty_unboxed_vec(mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
}
ty_evec(tm, vst) => {
ty_evec(ref tm, vst) => {
ty_evec(mt {ty: fldop(tm.ty), mutbl: tm.mutbl}, vst)
}
ty_enum(tid, ref substs) => {
@ -1231,8 +1230,8 @@ fn fold_sty(sty: &sty, fldop: &fn(t) -> t) -> sty {
ty_trait(did, ref substs, st) => {
ty_trait(did, fold_substs(substs, fldop), st)
}
ty_tup(ts) => {
let new_ts = vec::map(ts, |tt| fldop(*tt));
ty_tup(ref ts) => {
let new_ts = ts.map(|tt| fldop(*tt));
ty_tup(new_ts)
}
ty_bare_fn(ref f) => {
@ -1243,7 +1242,7 @@ fn fold_sty(sty: &sty, fldop: &fn(t) -> t) -> sty {
let sig = fold_sig(&f.sig, fldop);
ty_closure(ClosureTy {sig: sig, ..copy *f})
}
ty_rptr(r, tm) => {
ty_rptr(r, ref tm) => {
ty_rptr(r, mt {ty: fldop(tm.ty), mutbl: tm.mutbl})
}
ty_struct(did, ref substs) => {
@ -1510,8 +1509,8 @@ pub fn sequence_element_type(cx: ctxt, ty: t) -> t {
}
pub fn get_element_type(ty: t, i: uint) -> t {
match /*bad*/copy get(ty).sty {
ty_tup(ts) => return ts[i],
match get(ty).sty {
ty_tup(ref ts) => return ts[i],
_ => fail!(~"get_element_type called on invalid type")
}
}
@ -2118,7 +2117,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
/// gives a rough estimate of how much space it takes to represent
/// an instance of `ty`. Used for the mode transition.
fn type_size(cx: ctxt, ty: t) -> uint {
match /*bad*/copy get(ty).sty {
match get(ty).sty {
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
ty_ptr(_) | ty_box(_) | ty_uniq(_) | ty_estr(vstore_uniq) |
ty_trait(*) | ty_rptr(*) | ty_evec(_, vstore_uniq) |
@ -2146,7 +2145,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
flds.foldl(0, |s, f| *s + type_size(cx, f.mt.ty))
}
ty_tup(tys) => {
ty_tup(ref tys) => {
tys.foldl(0, |s, t| *s + type_size(cx, *t))
}
@ -2208,7 +2207,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
::util::ppaux::ty_to_str(cx, r_ty),
::util::ppaux::ty_to_str(cx, ty));
let r = match /*bad*/copy get(ty).sty {
let r = match get(ty).sty {
ty_nil |
ty_bot |
ty_bool |
@ -2229,9 +2228,9 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
ty_unboxed_vec(_) => {
false
}
ty_box(mt) |
ty_uniq(mt) |
ty_rptr(_, mt) => {
ty_box(ref mt) |
ty_uniq(ref mt) |
ty_rptr(_, ref mt) => {
return type_requires(cx, seen, r_ty, mt.ty);
}
@ -2255,8 +2254,8 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
r
}
ty_tup(ts) => {
vec::any(ts, |t| type_requires(cx, seen, r_ty, *t))
ty_tup(ref ts) => {
ts.any(|t| type_requires(cx, seen, r_ty, *t))
}
ty_enum(ref did, _) if vec::contains(*seen, did) => {
@ -2297,7 +2296,7 @@ pub fn type_structurally_contains(cx: ctxt,
debug!("type_structurally_contains: %s",
::util::ppaux::ty_to_str(cx, ty));
if test(sty) { return true; }
match /*bad*/copy *sty {
match *sty {
ty_enum(did, ref substs) => {
for vec::each(*enum_variants(cx, did)) |variant| {
for variant.args.each |aty| {
@ -2315,13 +2314,13 @@ pub fn type_structurally_contains(cx: ctxt,
return false;
}
ty_tup(ts) => {
ty_tup(ref ts) => {
for ts.each |tt| {
if type_structurally_contains(cx, *tt, test) { return true; }
}
return false;
}
ty_evec(mt, vstore_fixed(_)) => {
ty_evec(ref mt, vstore_fixed(_)) => {
return type_structurally_contains(cx, mt.ty, test);
}
_ => return false
@ -2375,7 +2374,7 @@ pub fn type_is_signed(ty: t) -> bool {
// that the cycle collector might care about.
pub fn type_is_pod(cx: ctxt, ty: t) -> bool {
let mut result = true;
match /*bad*/copy get(ty).sty {
match get(ty).sty {
// Scalar types
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
ty_type | ty_ptr(_) | ty_bare_fn(_) => result = true,
@ -2395,11 +2394,11 @@ pub fn type_is_pod(cx: ctxt, ty: t) -> bool {
if !type_is_pod(cx, tup_ty) { result = false; }
}
}
ty_tup(elts) => {
ty_tup(ref elts) => {
for elts.each |elt| { if !type_is_pod(cx, *elt) { result = false; } }
}
ty_estr(vstore_fixed(_)) => result = true,
ty_evec(mt, vstore_fixed(_)) | ty_unboxed_vec(mt) => {
ty_evec(ref mt, vstore_fixed(_)) | ty_unboxed_vec(ref mt) => {
result = type_is_pod(cx, mt.ty);
}
ty_param(_) => result = false,
@ -3007,8 +3006,8 @@ pub fn method_call_bounds(tcx: ctxt, method_map: typeck::method_map,
// trait itself. This ought to be harmonized.
let trt_bounds =
ty::lookup_item_type(tcx, trt_id).bounds;
let mth = /*bad*/copy ty::trait_methods(tcx, trt_id)[n_mth];
@(vec::append(/*bad*/copy *trt_bounds, *mth.tps))
@(vec::append(/*bad*/copy *trt_bounds,
*ty::trait_methods(tcx, trt_id)[n_mth].tps))
}
}
}
@ -3528,7 +3527,7 @@ pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[ast::ident] {
node: item_trait(_, _, ref ms),
_
}, _)) =>
match ast_util::split_trait_methods((/*bad*/copy *ms)) {
match ast_util::split_trait_methods(*ms) {
(_, p) => p.map(|method| method.ident)
},
_ => cx.sess.bug(fmt!("provided_trait_methods: %? is not a trait",
@ -3830,9 +3829,8 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] {
node: ast::item_enum(ref enum_definition, _),
_
}, _) => {
let variants = /*bad*/copy (*enum_definition).variants;
let mut disr_val = -1;
@vec::map(variants, |variant| {
@vec::map(enum_definition.variants, |variant| {
match variant.node.kind {
ast::tuple_variant_kind(ref args) => {
let ctor_ty = node_id_to_type(cx, variant.node.id);
@ -3945,7 +3943,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
Some(ast_map::node_item(i,_)) => {
match i.node {
ast::item_struct(struct_def, _) => {
struct_field_tys(/*bad*/copy struct_def.fields)
struct_field_tys(struct_def.fields)
}
_ => cx.sess.bug(~"struct ID bound to non-struct")
}
@ -3953,7 +3951,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
Some(ast_map::node_variant(ref variant, _, _)) => {
match (*variant).node.kind {
ast::struct_variant_kind(struct_def) => {
struct_field_tys(/*bad*/copy struct_def.fields)
struct_field_tys(struct_def.fields)
}
_ => {
cx.sess.bug(~"struct ID bound to enum variant that isn't \
@ -3993,7 +3991,7 @@ pure fn is_public(f: field_ty) -> bool {
}
}
fn struct_field_tys(fields: ~[@struct_field]) -> ~[field_ty] {
fn struct_field_tys(fields: &[@struct_field]) -> ~[field_ty] {
do fields.map |field| {
match field.node.kind {
named_field(ident, mutability, visibility) => {

View File

@ -212,7 +212,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
self: &AC, rscope: &RS, &&ast_ty: @ast::Ty) -> ty::t {
fn ast_mt_to_mt<AC:AstConv, RS:region_scope + Copy + Durable>(
self: &AC, rscope: &RS, mt: ast::mt) -> ty::mt {
self: &AC, rscope: &RS, mt: &ast::mt) -> ty::mt {
ty::mt {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl}
}
@ -223,14 +223,14 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
fn mk_pointer<AC:AstConv,RS:region_scope + Copy + Durable>(
self: &AC,
rscope: &RS,
a_seq_ty: ast::mt,
a_seq_ty: &ast::mt,
vst: ty::vstore,
constr: &fn(ty::mt) -> ty::t) -> ty::t
{
let tcx = self.tcx();
match a_seq_ty.ty.node {
ast::ty_vec(mt) => {
ast::ty_vec(ref mt) => {
let mut mt = ast_mt_to_mt(self, rscope, mt);
if a_seq_ty.mutbl == ast::m_mutbl ||
a_seq_ty.mutbl == ast::m_const {
@ -318,34 +318,34 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
}
tcx.ast_ty_to_ty_cache.insert(ast_ty.id, ty::atttce_unresolved);
let typ = match /*bad*/copy ast_ty.node {
let typ = match ast_ty.node {
ast::ty_nil => ty::mk_nil(tcx),
ast::ty_bot => ty::mk_bot(tcx),
ast::ty_box(mt) => {
ast::ty_box(ref mt) => {
mk_pointer(self, rscope, mt, ty::vstore_box,
|tmt| ty::mk_box(tcx, tmt))
}
ast::ty_uniq(mt) => {
ast::ty_uniq(ref mt) => {
mk_pointer(self, rscope, mt, ty::vstore_uniq,
|tmt| ty::mk_uniq(tcx, tmt))
}
ast::ty_vec(mt) => {
ast::ty_vec(ref mt) => {
tcx.sess.span_err(ast_ty.span,
~"bare `[]` is not a type");
// return /something/ so they can at least get more errors
ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt),
ty::vstore_uniq)
}
ast::ty_ptr(mt) => {
ast::ty_ptr(ref mt) => {
ty::mk_ptr(tcx, ast_mt_to_mt(self, rscope, mt))
}
ast::ty_rptr(region, mt) => {
ast::ty_rptr(region, ref mt) => {
let r = ast_region_to_region(self, rscope, ast_ty.span, region);
mk_pointer(self, rscope, mt, ty::vstore_slice(r),
|tmt| ty::mk_rptr(tcx, r, tmt))
}
ast::ty_tup(fields) => {
let flds = vec::map(fields, |t| ast_ty_to_ty(self, rscope, *t));
ast::ty_tup(ref fields) => {
let flds = fields.map(|t| ast_ty_to_ty(self, rscope, *t));
ty::mk_tup(tcx, flds)
}
ast::ty_bare_fn(ref bf) => {
@ -413,7 +413,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
}
}
}
ast::ty_fixed_length_vec(a_mt, e) => {
ast::ty_fixed_length_vec(ref a_mt, e) => {
match const_eval::eval_const_expr_partial(tcx, e) {
Ok(ref r) => {
match *r {

View File

@ -28,7 +28,7 @@ use syntax::print::pprust;
pub fn check_match(fcx: @mut FnCtxt,
expr: @ast::expr,
discrim: @ast::expr,
arms: ~[ast::arm]) -> bool {
arms: &[ast::arm]) -> bool {
let tcx = fcx.ccx.tcx;
let mut bot;
@ -74,7 +74,7 @@ pub struct pat_ctxt {
}
pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
+subpats: Option<~[@ast::pat]>, expected: ty::t) {
subpats: &Option<~[@ast::pat]>, expected: ty::t) {
// Typecheck the path.
let fcx = pcx.fcx;
@ -162,7 +162,7 @@ pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
// Count the number of subpatterns.
let subpats_len;
match subpats {
match *subpats {
None => subpats_len = arg_len,
Some(ref subpats) => subpats_len = subpats.len()
}
@ -207,7 +207,7 @@ pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
pub fn check_struct_pat_fields(pcx: pat_ctxt,
span: span,
path: @ast::path,
fields: ~[ast::field_pat],
fields: &[ast::field_pat],
class_fields: ~[ty::field_ty],
class_id: ast::def_id,
substitutions: &ty::substs,
@ -258,7 +258,7 @@ pub fn check_struct_pat_fields(pcx: pat_ctxt,
pub fn check_struct_pat(pcx: pat_ctxt, pat_id: ast::node_id, span: span,
expected: ty::t, path: @ast::path,
+fields: ~[ast::field_pat], etc: bool,
fields: &[ast::field_pat], etc: bool,
class_id: ast::def_id, substitutions: &ty::substs) {
let fcx = pcx.fcx;
let tcx = pcx.fcx.ccx.tcx;
@ -299,7 +299,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: pat_ctxt,
span: span,
expected: ty::t,
path: @ast::path,
+fields: ~[ast::field_pat],
fields: &[ast::field_pat],
etc: bool,
enum_id: ast::def_id,
substitutions: &ty::substs) {
@ -336,7 +336,7 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
let fcx = pcx.fcx;
let tcx = pcx.fcx.ccx.tcx;
match /*bad*/copy pat.node {
match pat.node {
ast::pat_wild => {
fcx.write_ty(pat.id, expected);
}
@ -409,22 +409,22 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
}
}
ast::pat_ident(_, path, _) => {
check_pat_variant(pcx, pat, path, Some(~[]), expected);
check_pat_variant(pcx, pat, path, &Some(~[]), expected);
}
ast::pat_enum(path, subpats) => {
ast::pat_enum(path, ref subpats) => {
check_pat_variant(pcx, pat, path, subpats, expected);
}
ast::pat_struct(path, fields, etc) => {
ast::pat_struct(path, ref fields, etc) => {
// Grab the class data that we care about.
let structure = structure_of(fcx, pat.span, expected);
match structure {
ty::ty_struct(cid, ref substs) => {
check_struct_pat(pcx, pat.id, pat.span, expected, path,
fields, etc, cid, substs);
*fields, etc, cid, substs);
}
ty::ty_enum(eid, ref substs) => {
check_struct_like_enum_variant_pat(
pcx, pat.id, pat.span, expected, path, fields, etc, eid,
pcx, pat.id, pat.span, expected, path, *fields, etc, eid,
substs);
}
_ => {
@ -439,9 +439,10 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
// Finally, write in the type.
fcx.write_ty(pat.id, expected);
}
ast::pat_tup(elts) => {
let ex_elts = match structure_of(fcx, pat.span, expected) {
ty::ty_tup(elts) => elts,
ast::pat_tup(ref elts) => {
let s = structure_of(fcx, pat.span, expected);
let ex_elts = match s {
ty::ty_tup(ref elts) => elts,
_ => {
tcx.sess.span_fatal
(pat.span,
@ -449,12 +450,12 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
fcx.infcx().ty_to_str(expected)));
}
};
let e_count = vec::len(elts);
if e_count != vec::len(ex_elts) {
let e_count = elts.len();
if e_count != ex_elts.len() {
tcx.sess.span_fatal
(pat.span, fmt!("mismatched types: expected a tuple \
with %u fields, found one with %u \
fields", vec::len(ex_elts), e_count));
fields", ex_elts.len(), e_count));
}
let mut i = 0u;
for elts.each |elt| {
@ -509,7 +510,7 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
}
}
}
ast::pat_vec(before, slice, after) => {
ast::pat_vec(ref before, slice, ref after) => {
let default_region_var =
fcx.infcx().next_region_var_with_lb(
pat.span, pcx.block_region

View File

@ -1051,7 +1051,7 @@ pub impl LookupContext/&self {
let mut j = i + 1;
while j < candidates.len() {
let candidate_b = /*bad*/copy candidates[j];
let candidate_b = &candidates[j];
debug!("attempting to merge %? and %?",
candidate_a, candidate_b);
let candidates_same = match (&candidate_a.origin,

View File

@ -577,18 +577,18 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
ty::item_path_str(ccx.tcx, local_def(it.id)));
let _indenter = indenter();
match /*bad*/copy it.node {
match it.node {
ast::item_const(_, e) => check_const(ccx, it.span, e, it.id),
ast::item_enum(ref enum_definition, _) => {
check_enum_variants(ccx,
it.span,
/*bad*/copy (*enum_definition).variants,
enum_definition.variants,
it.id);
}
ast::item_fn(ref decl, _, _, ref body) => {
check_bare_fn(ccx, decl, body, it.id, None);
}
ast::item_impl(_, _, ty, ms) => {
ast::item_impl(_, _, ty, ref ms) => {
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);
@ -617,7 +617,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id);
check_bounds_are_used(ccx, t.span, &generics.ty_params, tpt_ty);
}
ast::item_foreign_mod(m) => {
ast::item_foreign_mod(ref m) => {
if syntax::attr::foreign_abi(it.attrs) ==
either::Right(ast::foreign_abi_rust_intrinsic) {
for m.items.each |item| {
@ -1157,7 +1157,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
call_expr_id: ast::node_id,
in_fty: ty::t,
callee_expr: @ast::expr,
args: ~[@ast::expr],
args: &[@ast::expr],
sugar: ast::CallSugar,
deref_args: DerefArgs) -> (ty::t, bool)
{
@ -1309,7 +1309,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
call_expr_id: ast::node_id,
fn_ty: ty::t,
expr: @ast::expr,
+args: ~[@ast::expr],
args: &[@ast::expr],
bot: bool,
sugar: ast::CallSugar) -> bool
{
@ -1331,14 +1331,14 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
sp: span,
call_expr_id: ast::node_id,
f: @ast::expr,
+args: ~[@ast::expr],
args: &[@ast::expr],
sugar: ast::CallSugar)
-> bool {
// Index expressions need to be handled separately, to inform them
// that they appear in call position.
let mut bot = match /*bad*/copy f.node {
ast::expr_field(base, field, tys) => {
check_field(fcx, f, true, base, field, tys)
let mut bot = match f.node {
ast::expr_field(base, field, ref tys) => {
check_field(fcx, f, true, base, field, *tys)
}
_ => check_expr(fcx, f)
};
@ -1358,8 +1358,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
expr: @ast::expr,
rcvr: @ast::expr,
method_name: ast::ident,
+args: ~[@ast::expr],
tps: ~[@ast::Ty],
args: &[@ast::expr],
tps: &[@ast::Ty],
sugar: ast::CallSugar)
-> bool {
let bot = check_expr(fcx, rcvr);
@ -1594,7 +1594,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
fn check_user_unop(fcx: @mut FnCtxt,
op_str: ~str,
mname: ~str,
+mname: ~str,
ex: @ast::expr,
rhs_expr: @ast::expr,
rhs_t: ty::t)
@ -1603,7 +1603,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
ex,
rhs_expr,
rhs_t,
fcx.tcx().sess.ident_of(/*bad*/ copy mname),
fcx.tcx().sess.ident_of(mname),
~[],
DontDerefArgs,
DontAutoderefReceiver) {
@ -1713,7 +1713,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
is_callee: bool,
base: @ast::expr,
field: ast::ident,
tys: ~[@ast::Ty])
tys: &[@ast::Ty])
-> bool {
let tcx = fcx.ccx.tcx;
let bot = check_expr(fcx, base);
@ -1791,8 +1791,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
span: span,
class_id: ast::def_id,
substitutions: &ty::substs,
field_types: ~[ty::field_ty],
ast_fields: ~[ast::field],
field_types: &[ty::field_ty],
ast_fields: &[ast::field],
check_completeness: bool)
-> bool {
let tcx = fcx.ccx.tcx;
@ -1870,7 +1870,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
id: ast::node_id,
span: codemap::span,
class_id: ast::def_id,
fields: ~[ast::field],
fields: &[ast::field],
base_expr: Option<@ast::expr>)
-> bool {
let mut bot = false;
@ -1955,7 +1955,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
span: codemap::span,
enum_id: ast::def_id,
variant_id: ast::def_id,
fields: ~[ast::field])
fields: &[ast::field])
-> bool {
let mut bot = false;
let tcx = fcx.ccx.tcx;
@ -2147,14 +2147,14 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
let tcx = fcx.ccx.tcx;
let id = expr.id;
let mut bot = false;
match /*bad*/copy expr.node {
match expr.node {
ast::expr_vstore(ev, vst) => {
let typ = match /*bad*/copy ev.node {
let typ = match ev.node {
ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => {
let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(*s), vst);
ty::mk_estr(tcx, tt)
}
ast::expr_vec(args, mutbl) => {
ast::expr_vec(ref args, mutbl) => {
let tt = ast_expr_vstore_to_vstore(fcx, ev, args.len(), vst);
let mutability;
match vst {
@ -2317,7 +2317,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
let region_lb = ty::re_scope(expr.id);
instantiate_path(fcx, pth, tpt, expr.span, expr.id, region_lb);
}
ast::expr_inline_asm(_, ins, outs, _, _, _) => {
ast::expr_inline_asm(_, ref ins, ref outs, _, _, _) => {
fcx.require_unsafe(expr.span, ~"use of inline assembly");
for ins.each |&(_, in)| {
@ -2389,7 +2389,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
bot = !may_break(tcx, expr.id, body);
}
ast::expr_match(discrim, ref arms) => {
bot = _match::check_match(fcx, expr, discrim, (/*bad*/copy *arms));
bot = _match::check_match(fcx, expr, discrim, *arms);
}
ast::expr_fn_block(ref decl, ref body) => {
check_expr_fn(fcx, expr, None,
@ -2441,11 +2441,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
};
fcx.write_ty(id, typ);
}
ast::expr_call(f, args, sugar) => {
bot = check_call(fcx, expr.span, expr.id, f, args, sugar);
ast::expr_call(f, ref args, sugar) => {
bot = check_call(fcx, expr.span, expr.id, f, *args, sugar);
}
ast::expr_method_call(rcvr, ident, tps, args, sugar) => {
bot = check_method_call(fcx, expr, rcvr, ident, args, tps, sugar);
ast::expr_method_call(rcvr, ident, ref tps, ref args, sugar) => {
bot = check_method_call(fcx, expr, rcvr, ident, *args, *tps, sugar);
}
ast::expr_cast(e, t) => {
bot = check_expr(fcx, e);
@ -2528,7 +2528,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
}
fcx.write_ty(id, t_1);
}
ast::expr_vec(args, mutbl) => {
ast::expr_vec(ref args, mutbl) => {
let t: ty::t = fcx.infcx().next_ty_var();
for args.each |e| { bot |= check_expr_has_type(fcx, *e, t); }
let typ = ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutbl},
@ -2544,7 +2544,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
ty::vstore_fixed(count));
fcx.write_ty(id, t);
}
ast::expr_tup(elts) => {
ast::expr_tup(ref elts) => {
let flds = unpack_expected(fcx, expected, |sty| {
match *sty { ty::ty_tup(ref flds) => Some(copy *flds), _ => None }
});
@ -2560,11 +2560,11 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
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);
*fields, base_expr);
}
Some(ast::def_variant(enum_id, variant_id)) => {
check_struct_enum_variant(fcx, id, expr.span, enum_id,
variant_id, (/*bad*/copy *fields));
variant_id, *fields);
}
_ => {
tcx.sess.span_bug(path.span, ~"structure constructor does \
@ -2572,8 +2572,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
}
}
}
ast::expr_field(base, field, tys) => {
bot = check_field(fcx, expr, false, base, field, tys);
ast::expr_field(base, field, ref tys) => {
bot = check_field(fcx, expr, false, base, field, *tys);
}
ast::expr_index(base, idx) => {
bot |= check_expr(fcx, base);
@ -2678,8 +2678,8 @@ pub fn check_stmt(fcx: @mut FnCtxt, stmt: @ast::stmt) -> bool {
match stmt.node {
ast::stmt_decl(decl, id) => {
node_id = id;
match /*bad*/copy decl.node {
ast::decl_local(ls) => for ls.each |l| {
match decl.node {
ast::decl_local(ref ls) => for ls.each |l| {
bot |= check_decl_local(fcx, *l);
},
ast::decl_item(_) => {/* ignore for now */ }
@ -2803,11 +2803,11 @@ pub fn check_instantiable(tcx: ty::ctxt,
pub fn check_enum_variants(ccx: @mut CrateCtxt,
sp: span,
+vs: ~[ast::variant],
vs: &[ast::variant],
id: ast::node_id) {
fn do_check(ccx: @mut CrateCtxt,
sp: span,
vs: ~[ast::variant],
vs: &[ast::variant],
id: ast::node_id,
disr_vals: &mut ~[int],
disr_val: &mut int,
@ -2867,7 +2867,7 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt,
arg_tys = None;
do_check(ccx,
sp,
/*bad*/copy vs,
vs,
id,
&mut *disr_vals,
&mut *disr_val,

View File

@ -192,7 +192,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) {
}
}
match /*bad*/copy expr.node {
match expr.node {
ast::expr_path(*) => {
// Avoid checking the use of local variables, as we
// already check their definitions. The def'n always
@ -207,7 +207,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) {
}
}
ast::expr_call(callee, args, _) => {
ast::expr_call(callee, ref args, _) => {
// Check for a.b() where b is a method. Ensure that
// any types in the callee are valid for the entire
// method call.
@ -236,7 +236,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) {
}
}
ast::expr_method_call(rcvr, _, _, args, _) => {
ast::expr_method_call(rcvr, _, _, ref args, _) => {
// Check for a.b() where b is a method. Ensure that
// any types in the callee are valid for the entire
// method call.

View File

@ -610,7 +610,7 @@ pub impl CoherenceChecker {
fn check_privileged_scopes(self, crate: @crate) {
visit_crate(*crate, (), mk_vt(@Visitor {
visit_item: |item, _context, visitor| {
match /*bad*/copy item.node {
match item.node {
item_mod(ref module_) => {
// Then visit the module items.
visit_mod(module_, item.span, item.id, (), visitor);
@ -738,8 +738,8 @@ pub impl CoherenceChecker {
}
}
match /*bad*/copy item.node {
item_impl(_, trait_refs, _, ast_methods) => {
match item.node {
item_impl(_, ref trait_refs, _, ref ast_methods) => {
let mut methods = ~[];
for ast_methods.each |ast_method| {
methods.push(method_to_MethodInfo(*ast_method));

View File

@ -228,9 +228,9 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
trait_ty: ty::t) {
fn store_methods<T>(ccx: &CrateCtxt,
id: ast::node_id,
stuff: ~[T],
stuff: &[T],
f: &fn(v: &T) -> ty::method) {
ty::store_trait_methods(ccx.tcx, id, @vec::map(stuff, f));
ty::store_trait_methods(ccx.tcx, id, @stuff.map(f));
}
fn make_static_method_ty(ccx: &CrateCtxt,
@ -285,7 +285,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
node: ast::item_trait(ref generics, _, ref ms),
_
}, _) => {
store_methods::<ast::trait_method>(ccx, id, (/*bad*/copy *ms), |m| {
store_methods::<ast::trait_method>(ccx, id, *ms, |m| {
let def_id;
match *m {
ast::required(ref ty_method) => {
@ -502,7 +502,7 @@ pub fn check_methods_against_trait(ccx: &CrateCtxt,
rp: Option<ty::region_variance>,
selfty: ty::t,
a_trait_ty: @ast::trait_ref,
impl_ms: ~[ConvertedMethod]) {
impl_ms: &[ConvertedMethod]) {
let tcx = ccx.tcx;
let (did, tpt) = instantiate_trait_ref(ccx, a_trait_ty, rp);
@ -643,8 +643,7 @@ pub fn convert(ccx: &CrateCtxt, it: @ast::item) {
// XXX: Bad copy of `ms` below.
let cms = convert_methods(ccx, *ms, rp, i_bounds);
for trait_ref.each |t| {
check_methods_against_trait(ccx, generics, rp, selfty,
*t, /*bad*/copy cms);
check_methods_against_trait(ccx, generics, rp, selfty, *t, cms);
}
}
ast::item_trait(ref generics, ref supertraits, ref trait_methods) => {
@ -656,7 +655,7 @@ pub fn convert(ccx: &CrateCtxt, it: @ast::item) {
ensure_supertraits(ccx, it.id, it.span, rp, *supertraits);
let (_, provided_methods) =
split_trait_methods(/*bad*/copy *trait_methods);
split_trait_methods(*trait_methods);
let (bounds, _) = mk_substs(ccx, generics, rp);
let _ = convert_methods(ccx, provided_methods, rp, bounds);
}

View File

@ -82,7 +82,7 @@ pub trait Combine {
fn lub(&self) -> Lub;
fn glb(&self) -> Glb;
fn mts(&self, a: ty::mt, b: ty::mt) -> cres<ty::mt>;
fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt>;
fn contratys(&self, a: ty::t, b: ty::t) -> cres<ty::t>;
fn tys(&self, a: ty::t, b: ty::t) -> cres<ty::t>;
fn tps(&self, as_: &[ty::t], bs: &[ty::t]) -> cres<~[ty::t]>;
@ -305,7 +305,7 @@ pub fn super_flds<C:Combine>(
self: &C, a: ty::field, b: ty::field) -> cres<ty::field> {
if a.ident == b.ident {
self.mts(a.mt, b.mt)
self.mts(&a.mt, &b.mt)
.chain(|mt| Ok(ty::field {ident: a.ident, mt: mt}) )
.chain_err(|e| Err(ty::terr_in_field(@e, a.ident)) )
} else {
@ -419,8 +419,8 @@ pub fn super_fn_sigs<C:Combine>(
self: &C, a_f: &ty::FnSig, b_f: &ty::FnSig) -> cres<ty::FnSig>
{
fn argvecs<C:Combine>(self: &C,
+a_args: ~[ty::arg],
+b_args: ~[ty::arg]) -> cres<~[ty::arg]>
a_args: &[ty::arg],
b_args: &[ty::arg]) -> cres<~[ty::arg]>
{
if vec::same_length(a_args, b_args) {
map_vec2(a_args, b_args, |a, b| self.args(*a, *b))
@ -429,7 +429,7 @@ pub fn super_fn_sigs<C:Combine>(
}
}
do argvecs(self, /*bad*/copy a_f.inputs, /*bad*/copy b_f.inputs)
do argvecs(self, a_f.inputs, b_f.inputs)
.chain |inputs| {
do self.tys(a_f.output, b_f.output).chain |output| {
Ok(FnSig {inputs: /*bad*/copy inputs, output: output})
@ -509,7 +509,7 @@ pub fn super_tys<C:Combine>(
}
}
(ty::ty_param(a_p), ty::ty_param(b_p)) if a_p.idx == b_p.idx => {
(ty::ty_param(ref a_p), ty::ty_param(ref b_p)) if a_p.idx == b_p.idx => {
Ok(a)
}
@ -538,31 +538,31 @@ pub fn super_tys<C:Combine>(
}
}
(ty::ty_box(a_mt), ty::ty_box(b_mt)) => {
(ty::ty_box(ref a_mt), ty::ty_box(ref b_mt)) => {
do self.mts(a_mt, b_mt).chain |mt| {
Ok(ty::mk_box(tcx, mt))
}
}
(ty::ty_uniq(a_mt), ty::ty_uniq(b_mt)) => {
(ty::ty_uniq(ref a_mt), ty::ty_uniq(ref b_mt)) => {
do self.mts(a_mt, b_mt).chain |mt| {
Ok(ty::mk_uniq(tcx, mt))
}
}
(ty::ty_ptr(a_mt), ty::ty_ptr(b_mt)) => {
(ty::ty_ptr(ref a_mt), ty::ty_ptr(ref b_mt)) => {
do self.mts(a_mt, b_mt).chain |mt| {
Ok(ty::mk_ptr(tcx, mt))
}
}
(ty::ty_rptr(a_r, a_mt), ty::ty_rptr(b_r, b_mt)) => {
(ty::ty_rptr(a_r, ref a_mt), ty::ty_rptr(b_r, ref b_mt)) => {
let r = if_ok!(self.contraregions(a_r, b_r));
let mt = if_ok!(self.mts(a_mt, b_mt));
Ok(ty::mk_rptr(tcx, r, mt))
}
(ty::ty_evec(a_mt, vs_a), ty::ty_evec(b_mt, vs_b)) => {
(ty::ty_evec(ref a_mt, vs_a), ty::ty_evec(ref b_mt, vs_b)) => {
do self.mts(a_mt, b_mt).chain |mt| {
do self.vstores(ty::terr_vec, vs_a, vs_b).chain |vs| {
Ok(ty::mk_evec(tcx, mt, vs))
@ -576,9 +576,9 @@ pub fn super_tys<C:Combine>(
}
}
(ty::ty_tup(as_), ty::ty_tup(bs)) => {
if vec::same_length(as_, bs) {
map_vec2(as_, bs, |a, b| self.tys(*a, *b) )
(ty::ty_tup(ref as_), ty::ty_tup(ref bs)) => {
if as_.len() == bs.len() {
map_vec2(*as_, *bs, |a, b| self.tys(*a, *b) )
.chain(|ts| Ok(ty::mk_tup(tcx, ts)) )
} else {
Err(ty::terr_tuple_size(

View File

@ -41,7 +41,7 @@ impl Combine for Glb {
fn lub(&self) -> Lub { Lub(**self) }
fn glb(&self) -> Glb { Glb(**self) }
fn mts(&self, a: ty::mt, b: ty::mt) -> cres<ty::mt> {
fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
let tcx = self.infcx.tcx;
debug!("%s.mts(%s, %s)",

View File

@ -47,7 +47,7 @@ impl Combine for Lub {
fn lub(&self) -> Lub { Lub(**self) }
fn glb(&self) -> Glb { Glb(**self) }
fn mts(&self, a: ty::mt, b: ty::mt) -> cres<ty::mt> {
fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
let tcx = self.infcx.tcx;
debug!("%s.mts(%s, %s)",

View File

@ -150,7 +150,7 @@ pub impl ResolveState {
return typ;
}
match /*bad*/ copy ty::get(typ).sty {
match ty::get(typ).sty {
ty::ty_infer(TyVar(vid)) => {
self.resolve_ty_var(vid)
}

View File

@ -69,7 +69,7 @@ impl Combine for Sub {
}
}
fn mts(&self, a: ty::mt, b: ty::mt) -> cres<ty::mt> {
fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> {
debug!("mts(%s <: %s)", a.inf_str(self.infcx), b.inf_str(self.infcx));
if a.mutbl != b.mutbl && b.mutbl != m_const {
@ -80,11 +80,11 @@ impl Combine for Sub {
m_mutbl => {
// If supertype is mut, subtype must match exactly
// (i.e., invariant if mut):
eq_tys(self, a.ty, b.ty).then(|| Ok(a) )
eq_tys(self, a.ty, b.ty).then(|| Ok(copy *a) )
}
m_imm | m_const => {
// Otherwise we can be covariant:
self.tys(a.ty, b.ty).chain(|_t| Ok(a) )
self.tys(a.ty, b.ty).chain(|_t| Ok(copy *a) )
}
}
}

View File

@ -43,7 +43,7 @@ impl InferStr for FnSig {
impl InferStr for ty::mt {
fn inf_str(&self, cx: &InferCtxt) -> ~str {
mt_to_str(cx.tcx, *self)
mt_to_str(cx.tcx, self)
}
}

View File

@ -218,7 +218,7 @@ pub fn region_to_str_space(cx: ctxt, prefix: &str, region: Region) -> ~str {
}
}
pub fn mt_to_str(cx: ctxt, m: mt) -> ~str {
pub fn mt_to_str(cx: ctxt, m: &mt) -> ~str {
let mstr = match m.mutbl {
ast::m_mutbl => "mut ",
ast::m_imm => "",
@ -391,7 +391,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
&m.fty.sig) + ~";"
}
fn field_to_str(cx: ctxt, f: field) -> ~str {
return *cx.sess.str_of(f.ident) + ~": " + mt_to_str(cx, f.mt);
return *cx.sess.str_of(f.ident) + ~": " + mt_to_str(cx, &f.mt);
}
// if there is an id, print that instead of the structural type:
@ -402,7 +402,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
}*/
// pretty print the structural type representation:
return match /*bad*/copy ty::get(typ).sty {
return match ty::get(typ).sty {
ty_nil => ~"()",
ty_bot => ~"!",
ty_bool => ~"bool",
@ -413,15 +413,15 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
ty_uint(t) => ast_util::uint_ty_to_str(t),
ty_float(ast::ty_f) => ~"float",
ty_float(t) => ast_util::float_ty_to_str(t),
ty_box(tm) => ~"@" + mt_to_str(cx, tm),
ty_uniq(tm) => ~"~" + mt_to_str(cx, tm),
ty_ptr(tm) => ~"*" + mt_to_str(cx, tm),
ty_rptr(r, tm) => {
ty_box(ref tm) => ~"@" + mt_to_str(cx, tm),
ty_uniq(ref tm) => ~"~" + mt_to_str(cx, tm),
ty_ptr(ref tm) => ~"*" + mt_to_str(cx, tm),
ty_rptr(r, ref tm) => {
region_to_str_space(cx, ~"&", r) + mt_to_str(cx, tm)
}
ty_unboxed_vec(tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" }
ty_unboxed_vec(ref tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" }
ty_type => ~"type",
ty_tup(elems) => {
ty_tup(ref elems) => {
let strs = elems.map(|elem| ty_to_str(cx, *elem));
~"(" + str::connect(strs, ~",") + ~")"
}
@ -455,7 +455,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
let ty = parameterized(cx, base, substs.self_r, substs.tps);
fmt!("%s%s", trait_store_to_str(cx, s), ty)
}
ty_evec(mt, vs) => {
ty_evec(ref mt, vs) => {
vstore_ty_to_str(cx, fmt!("%s", mt_to_str(cx, mt)), vs)
}
ty_estr(vs) => fmt!("%s%s", vstore_to_str(cx, vs), ~"str"),

View File

@ -65,7 +65,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
// Produces an AST expression that represents a RT::conv record,
// which tells the RT::conv* functions how to perform the conversion
fn make_rt_conv_expr(cx: @ext_ctxt, sp: span, cnv: Conv) -> @ast::expr {
fn make_rt_conv_expr(cx: @ext_ctxt, sp: span, cnv: &Conv) -> @ast::expr {
fn make_flags(cx: @ext_ctxt, sp: span, flags: ~[Flag]) -> @ast::expr {
let mut tmp_expr = make_rt_path_expr(cx, sp, @~"flag_none");
for flags.each |f| {
@ -139,7 +139,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
make_conv_struct(cx, sp, rt_conv_flags, rt_conv_width,
rt_conv_precision, rt_conv_ty)
}
fn make_conv_call(cx: @ext_ctxt, sp: span, conv_type: ~str, cnv: Conv,
fn make_conv_call(cx: @ext_ctxt, sp: span, conv_type: ~str, cnv: &Conv,
arg: @ast::expr) -> @ast::expr {
let fname = ~"conv_" + conv_type;
let path = make_path_vec(cx, @fname);
@ -148,11 +148,11 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
return mk_call_global(cx, arg.span, path, args);
}
fn make_new_conv(cx: @ext_ctxt, sp: span, cnv: Conv, arg: @ast::expr) ->
fn make_new_conv(cx: @ext_ctxt, sp: span, cnv: &Conv, arg: @ast::expr) ->
@ast::expr {
// FIXME: Move validation code into core::extfmt (Issue #2249)
fn is_signed_type(cnv: Conv) -> bool {
fn is_signed_type(cnv: &Conv) -> bool {
match cnv.ty {
TyInt(s) => match s {
Signed => return true,
@ -220,7 +220,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
mk_addr_of(cx, sp, arg))
}
}
fn log_conv(c: Conv) {
fn log_conv(c: &Conv) {
match c.param {
Some(p) => { debug!("param: %s", p.to_str()); }
_ => debug!("param: none")
@ -285,12 +285,12 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
~"for the given format string");
}
debug!("Building conversion:");
log_conv(/*bad*/ copy *conv);
log_conv(conv);
let arg_expr = args[n];
let c_expr = make_new_conv(
cx,
fmt_sp,
/*bad*/ copy *conv,
conv,
arg_expr
);
piece_exprs.push(c_expr);

View File

@ -220,7 +220,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
if col < len {
s1 = str::slice(s, col, len);
} else { s1 = ~""; }
} else { s1 = /*bad*/ copy s; }
} else { s1 = s; }
debug!("pushing line: %s", s1);
lines.push(s1);
}
@ -357,8 +357,8 @@ pub fn gather_comments_and_literals(span_diagnostic:
let TokenAndSpan {tok: tok, sp: sp} = rdr.peek();
if token::is_lit(&tok) {
let s = get_str_from(rdr, bstart);
literals.push(lit {lit: /*bad*/ copy s, pos: sp.lo});
debug!("tok lit: %s", s);
literals.push(lit {lit: s, pos: sp.lo});
} else {
debug!("tok: %s", token::to_str(rdr.interner, &tok));
}

View File

@ -1444,7 +1444,7 @@ pub impl Parser {
let (s, z) = p.parse_sep_and_zerok();
tt_seq(
mk_sp(sp.lo ,p.span.hi),
/*bad*/ copy seq.node,
seq.node,
s,
z
)
@ -1861,7 +1861,7 @@ pub impl Parser {
// Turn on the restriction to stop at | or || so we can parse
// them as the lambda arguments
let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP);
match /*bad*/ copy e.node {
match e.node {
expr_call(f, args, NoSugar) => {
let block = self.parse_lambda_block_expr();
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
@ -2135,7 +2135,7 @@ pub impl Parser {
let lo = self.span.lo;
let mut hi = self.span.hi;
let mut pat;
match copy *self.token {
match *self.token {
token::UNDERSCORE => { self.bump(); pat = pat_wild; }
token::AT => {
self.bump();
@ -2243,7 +2243,7 @@ pub impl Parser {
self.expect(&token::RBRACKET);
pat = ast::pat_vec(before, slice, after);
}
copy tok => {
tok => {
if !is_ident_or_path(&tok)
|| self.is_keyword(&~"true")
|| self.is_keyword(&~"false")
@ -3347,6 +3347,7 @@ pub impl Parser {
VIEW_ITEMS_AND_ITEMS_ALLOWED,
true);
let mut items: ~[@item] = starting_items;
let attrs_remaining_len = attrs_remaining.len();
// looks like this code depends on the invariant that
// outer attributes can't occur on view items (or macros
@ -3355,7 +3356,7 @@ pub impl Parser {
while *self.token != term {
let mut attrs = self.parse_outer_attributes();
if first {
attrs = vec::append(/*bad*/ copy attrs_remaining, attrs);
attrs = attrs_remaining + attrs;
first = false;
}
debug!("parse_mod_items: parse_item_or_view_item(attrs=%?)",
@ -3384,7 +3385,7 @@ pub impl Parser {
debug!("parse_mod_items: attrs=%?", attrs);
}
if first && attrs_remaining.len() > 0u {
if first && attrs_remaining_len > 0u {
// We parsed attributes for the first item but didn't find it
self.fatal(~"expected item");
}

View File

@ -134,7 +134,7 @@ pub fn print_crate(cm: @CodeMap,
}
pub fn print_crate_(s: @ps, &&crate: @ast::crate) {
print_mod(s, crate.node.module, crate.node.attrs);
print_mod(s, &crate.node.module, crate.node.attrs);
print_remaining_comments(s);
eof(s.s);
}
@ -310,7 +310,7 @@ pub fn synth_comment(s: @ps, text: ~str) {
word(s.s, ~"*/");
}
pub fn commasep<IN>(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN)) {
pub fn commasep<IN>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) {
box(s, 0u, b);
let mut first = true;
for elts.each |elt| {
@ -321,7 +321,7 @@ pub fn commasep<IN>(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN)) {
}
pub fn commasep_cmnt<IN>(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN),
pub fn commasep_cmnt<IN>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN),
get_span: &fn(IN) -> codemap::span) {
box(s, 0u, b);
let len = vec::len::<IN>(elts);
@ -340,12 +340,12 @@ pub fn commasep_cmnt<IN>(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN),
end(s);
}
pub fn commasep_exprs(s: @ps, b: breaks, exprs: ~[@ast::expr]) {
pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) {
fn expr_span(&&expr: @ast::expr) -> codemap::span { return expr.span; }
commasep_cmnt(s, b, exprs, print_expr, expr_span);
}
pub fn print_mod(s: @ps, _mod: ast::_mod, attrs: ~[ast::attribute]) {
pub fn print_mod(s: @ps, _mod: &ast::_mod, attrs: ~[ast::attribute]) {
print_inner_attributes(s, attrs);
for _mod.view_items.each |vitem| {
print_view_item(s, *vitem);
@ -353,7 +353,7 @@ pub fn print_mod(s: @ps, _mod: ast::_mod, attrs: ~[ast::attribute]) {
for _mod.items.each |item| { print_item(s, *item); }
}
pub fn print_foreign_mod(s: @ps, nmod: ast::foreign_mod,
pub fn print_foreign_mod(s: @ps, nmod: &ast::foreign_mod,
attrs: ~[ast::attribute]) {
print_inner_attributes(s, attrs);
for nmod.view_items.each |vitem| {
@ -376,12 +376,12 @@ pub fn print_type(s: @ps, &&ty: @ast::Ty) {
pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) {
maybe_print_comment(s, ty.span.lo);
ibox(s, 0u);
match /*bad*/ copy ty.node {
match ty.node {
ast::ty_nil => word(s.s, ~"()"),
ast::ty_bot => word(s.s, ~"!"),
ast::ty_box(mt) => { word(s.s, ~"@"); print_mt(s, mt); }
ast::ty_uniq(mt) => { word(s.s, ~"~"); print_mt(s, mt); }
ast::ty_vec(mt) => {
ast::ty_box(ref mt) => { word(s.s, ~"@"); print_mt(s, mt); }
ast::ty_uniq(ref mt) => { word(s.s, ~"~"); print_mt(s, mt); }
ast::ty_vec(ref mt) => {
word(s.s, ~"[");
match mt.mutbl {
ast::m_mutbl => word_space(s, ~"mut"),
@ -391,15 +391,15 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) {
print_type(s, mt.ty);
word(s.s, ~"]");
}
ast::ty_ptr(mt) => { word(s.s, ~"*"); print_mt(s, mt); }
ast::ty_rptr(lifetime, mt) => {
ast::ty_ptr(ref mt) => { word(s.s, ~"*"); print_mt(s, mt); }
ast::ty_rptr(lifetime, ref mt) => {
word(s.s, ~"&");
print_opt_lifetime(s, lifetime);
print_mt(s, mt);
}
ast::ty_tup(elts) => {
ast::ty_tup(ref elts) => {
popen(s);
commasep(s, inconsistent, elts, print_type);
commasep(s, inconsistent, *elts, print_type);
if elts.len() == 1 {
word(s.s, ~",");
}
@ -416,7 +416,7 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) {
None, None);
}
ast::ty_path(path, _) => print_path(s, path, print_colons),
ast::ty_fixed_length_vec(mt, v) => {
ast::ty_fixed_length_vec(ref mt, v) => {
word(s.s, ~"[");
match mt.mutbl {
ast::m_mutbl => word_space(s, ~"mut"),
@ -443,7 +443,7 @@ pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) {
hardbreak_if_not_bol(s);
maybe_print_comment(s, item.span.lo);
print_outer_attributes(s, item.attrs);
match /*bad*/ copy item.node {
match item.node {
ast::foreign_item_fn(ref decl, purity, ref generics) => {
print_fn(s, decl, Some(purity), item.ident, generics, None,
ast::inherited);
@ -469,7 +469,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
print_outer_attributes(s, item.attrs);
let ann_node = node_item(s, item);
(s.ann.pre)(ann_node);
match /*bad*/ copy item.node {
match item.node {
ast::item_const(ty, expr) => {
head(s, visibility_qualified(item.vis, ~"static"));
print_ident(s, item.ident);
@ -497,7 +497,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
word(s.s, ~" ");
print_block_with_attrs(s, body, item.attrs);
}
ast::item_mod(_mod) => {
ast::item_mod(ref _mod) => {
head(s, visibility_qualified(item.vis, ~"mod"));
print_ident(s, item.ident);
nbsp(s);
@ -505,7 +505,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
print_mod(s, _mod, item.attrs);
bclose(s, item.span);
}
ast::item_foreign_mod(nmod) => {
ast::item_foreign_mod(ref nmod) => {
head(s, visibility_qualified(item.vis, ~"extern"));
print_string(s, *s.intr.get(nmod.abi));
nbsp(s);
@ -767,15 +767,15 @@ pub fn print_tts(s: @ps, &&tts: &[ast::token_tree]) {
pub fn print_variant(s: @ps, v: ast::variant) {
print_visibility(s, v.node.vis);
match /*bad*/ copy v.node.kind {
ast::tuple_variant_kind(args) => {
match v.node.kind {
ast::tuple_variant_kind(ref args) => {
print_ident(s, v.node.name);
if !args.is_empty() {
popen(s);
fn print_variant_arg(s: @ps, arg: ast::variant_arg) {
print_type(s, arg.ty);
}
commasep(s, consistent, args, print_variant_arg);
commasep(s, consistent, *args, print_variant_arg);
pclose(s);
}
}
@ -1103,7 +1103,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
ibox(s, indent_unit);
let ann_node = node_expr(s, expr);
(s.ann.pre)(ann_node);
match /*bad*/ copy expr.node {
match expr.node {
ast::expr_vstore(e, v) => match v {
ast::expr_vstore_fixed(_) => {
print_expr(s, e);
@ -1115,14 +1115,14 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
print_expr(s, e);
}
},
ast::expr_vec(exprs, mutbl) => {
ast::expr_vec(ref exprs, mutbl) => {
ibox(s, indent_unit);
word(s.s, ~"[");
if mutbl == ast::m_mutbl {
word(s.s, ~"mut");
if vec::len(exprs) > 0u { nbsp(s); }
if exprs.len() > 0u { nbsp(s); }
}
commasep_exprs(s, inconsistent, exprs);
commasep_exprs(s, inconsistent, *exprs);
word(s.s, ~"]");
end(s);
}
@ -1159,29 +1159,29 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
}
word(s.s, ~"}");
}
ast::expr_tup(exprs) => {
ast::expr_tup(ref exprs) => {
popen(s);
commasep_exprs(s, inconsistent, exprs);
commasep_exprs(s, inconsistent, *exprs);
if exprs.len() == 1 {
word(s.s, ~",");
}
pclose(s);
}
ast::expr_call(func, args, sugar) => {
let mut base_args = copy args;
ast::expr_call(func, ref args, sugar) => {
let mut base_args = copy *args;
let blk = print_call_pre(s, sugar, &mut base_args);
print_expr(s, func);
print_call_post(s, sugar, &blk, &mut base_args);
}
ast::expr_method_call(func, ident, tys, args, sugar) => {
let mut base_args = copy args;
ast::expr_method_call(func, ident, ref tys, ref args, sugar) => {
let mut base_args = copy *args;
let blk = print_call_pre(s, sugar, &mut base_args);
print_expr(s, func);
word(s.s, ~".");
print_ident(s, ident);
if vec::len(tys) > 0u {
if tys.len() > 0u {
word(s.s, ~"::<");
commasep(s, inconsistent, tys, print_type);
commasep(s, inconsistent, *tys, print_type);
word(s.s, ~">");
}
print_call_post(s, sugar, &blk, &mut base_args);
@ -1356,13 +1356,13 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
word_space(s, ~"=");
print_expr(s, rhs);
}
ast::expr_field(expr, id, tys) => {
ast::expr_field(expr, id, ref tys) => {
print_expr(s, expr);
word(s.s, ~".");
print_ident(s, id);
if vec::len(tys) > 0u {
if tys.len() > 0u {
word(s.s, ~"::<");
commasep(s, inconsistent, tys, print_type);
commasep(s, inconsistent, *tys, print_type);
word(s.s, ~">");
}
}
@ -1454,15 +1454,15 @@ pub fn print_local_decl(s: @ps, loc: @ast::local) {
pub fn print_decl(s: @ps, decl: @ast::decl) {
maybe_print_comment(s, decl.span.lo);
match /*bad*/ copy decl.node {
ast::decl_local(locs) => {
match decl.node {
ast::decl_local(ref locs) => {
space_if_not_bol(s);
ibox(s, indent_unit);
word_nbsp(s, ~"let");
// if any are mut, all are mut
if vec::any(locs, |l| l.node.is_mutbl) {
fail_unless!(vec::all(locs, |l| l.node.is_mutbl));
if locs.any(|l| l.node.is_mutbl) {
fail_unless!(locs.all(|l| l.node.is_mutbl));
word_nbsp(s, ~"mut");
}
@ -1479,7 +1479,7 @@ pub fn print_decl(s: @ps, decl: @ast::decl) {
_ => ()
}
}
commasep(s, consistent, locs, print_local);
commasep(s, consistent, *locs, print_local);
end(s);
}
ast::decl_item(item) => print_item(s, item)
@ -1539,7 +1539,7 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) {
(s.ann.pre)(ann_node);
/* Pat isn't normalized, but the beauty of it
is that it doesn't matter */
match /*bad*/ copy pat.node {
match pat.node {
ast::pat_wild => word(s.s, ~"_"),
ast::pat_ident(binding_mode, path, sub) => {
if refutable {
@ -1563,14 +1563,14 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) {
None => ()
}
}
ast::pat_enum(path, args_) => {
ast::pat_enum(path, ref args_) => {
print_path(s, path, true);
match args_ {
match *args_ {
None => word(s.s, ~"(*)"),
Some(args) => {
Some(ref args) => {
if !args.is_empty() {
popen(s);
commasep(s, inconsistent, args,
commasep(s, inconsistent, *args,
|s, p| print_pat(s, p, refutable));
pclose(s);
} else { }
@ -1851,7 +1851,7 @@ pub fn print_view_path(s: @ps, &&vp: @ast::view_path) {
}
}
pub fn print_view_paths(s: @ps, vps: ~[@ast::view_path]) {
pub fn print_view_paths(s: @ps, vps: &[@ast::view_path]) {
commasep(s, inconsistent, vps, print_view_path);
}
@ -1860,7 +1860,7 @@ pub fn print_view_item(s: @ps, item: @ast::view_item) {
maybe_print_comment(s, item.span.lo);
print_outer_attributes(s, item.attrs);
print_visibility(s, item.vis);
match /*bad*/ copy item.node {
match item.node {
ast::view_item_extern_mod(id, mta, _) => {
head(s, ~"extern mod");
print_ident(s, id);
@ -1871,9 +1871,9 @@ pub fn print_view_item(s: @ps, item: @ast::view_item) {
}
}
ast::view_item_use(vps) => {
ast::view_item_use(ref vps) => {
head(s, ~"use");
print_view_paths(s, vps);
print_view_paths(s, *vps);
}
}
word(s.s, ~";");
@ -1889,7 +1889,7 @@ pub fn print_mutability(s: @ps, mutbl: ast::mutability) {
}
}
pub fn print_mt(s: @ps, mt: ast::mt) {
pub fn print_mt(s: @ps, mt: &ast::mt) {
print_mutability(s, mt.mutbl);
print_type(s, mt.ty);
}
@ -1942,7 +1942,7 @@ pub fn print_ty_fn(s: @ps,
print_onceness(s, onceness);
word(s.s, ~"fn");
match id { Some(id) => { word(s.s, ~" "); print_ident(s, id); } _ => () }
match /*bad*/ copy generics { Some(g) => print_generics(s, g), _ => () }
match generics { Some(g) => print_generics(s, g), _ => () }
zerobreak(s.s);
popen(s);