librustc: Add a lint mode for unnecessary `copy` and remove a bunch of them.

This commit is contained in:
Patrick Walton 2013-06-27 17:41:35 -07:00
parent 8c082658be
commit b4e674f6e6
59 changed files with 256 additions and 235 deletions

View File

@ -177,7 +177,7 @@ impl Arena {
// Allocate a new chunk.
let chunk_size = at_vec::capacity(self.pod_head.data);
let new_min_chunk_size = num::max(n_bytes, chunk_size);
self.chunks = @mut MutCons(copy self.pod_head, self.chunks);
self.chunks = @mut MutCons(self.pod_head, self.chunks);
self.pod_head =
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), true);
@ -219,7 +219,7 @@ impl Arena {
// Allocate a new chunk.
let chunk_size = at_vec::capacity(self.head.data);
let new_min_chunk_size = num::max(n_bytes, chunk_size);
self.chunks = @mut MutCons(copy self.head, self.chunks);
self.chunks = @mut MutCons(self.head, self.chunks);
self.head =
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), false);

View File

@ -318,8 +318,12 @@ pub mod reader {
let TaggedDoc { tag: r_tag, doc: r_doc } =
doc_at(self.parent.data, self.pos);
debug!("self.parent=%?-%? self.pos=%? r_tag=%? r_doc=%?-%?",
copy self.parent.start, copy self.parent.end,
copy self.pos, r_tag, r_doc.start, r_doc.end);
self.parent.start,
self.parent.end,
self.pos,
r_tag,
r_doc.start,
r_doc.end);
if r_tag != (exp_tag as uint) {
fail!("expected EBML doc with tag %? but found tag %?", exp_tag, r_tag);
}

View File

@ -240,7 +240,7 @@ pub mod v4 {
err_msg: ~"uv_ip4_name produced invalid result.",
})
} else {
Ok(Ipv4(copy(new_addr)))
Ok(Ipv4(new_addr))
}
}
}
@ -312,12 +312,10 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t,
let mut curr_addr = res;
loop {
let new_ip_addr = if ll::is_ipv4_addrinfo(curr_addr) {
Ipv4(copy((
*ll::addrinfo_as_sockaddr_in(curr_addr))))
Ipv4(*ll::addrinfo_as_sockaddr_in(curr_addr))
}
else if ll::is_ipv6_addrinfo(curr_addr) {
Ipv6(copy((
*ll::addrinfo_as_sockaddr_in6(curr_addr))))
Ipv6(*ll::addrinfo_as_sockaddr_in6(curr_addr))
}
else {
debug!("curr_addr is not of family AF_INET or \

View File

@ -682,8 +682,8 @@ fn listen_common(host_ip: ip::IpAddr,
// will defeat a move sigil, as is done to the host_ip
// arg above.. this same pattern works w/o complaint in
// tcp::connect (because the iotask::interact cb isn't
// nested within a std::comm::listen block)
let loc_ip = copy(host_ip);
// nested within a core::comm::listen block)
let loc_ip = host_ip;
do iotask::interact(iotask) |loop_ptr| {
unsafe {
match uv::ll::tcp_init(loop_ptr, server_stream_ptr) {

View File

@ -124,7 +124,7 @@ fn rustc_help() {
fn find_cmd(command_string: &str) -> Option<Command> {
do COMMANDS.iter().find_ |command| {
command.cmd == command_string
}.map_consume(|x| copy *x)
}.map_consume(|x| *x)
}
fn cmd_help(args: &[~str]) -> ValidUsage {

View File

@ -35,11 +35,9 @@ pub fn strip_items(crate: &ast::crate, in_cfg: in_cfg_pred)
fold_mod: |a,b| fold_mod(ctxt, a, b),
fold_block: |a,b| fold_block(ctxt, a, b),
fold_foreign_mod: |a,b| fold_foreign_mod(ctxt, a, b),
fold_item_underscore: |a,b| {
// Bad copy.
fold_item_underscore(ctxt, copy a, b)
},
.. *fold::default_ast_fold()};
fold_item_underscore: |a,b| fold_item_underscore(ctxt, a, b),
.. *fold::default_ast_fold()
};
let fold = fold::make_fold(precursor);
@fold.fold_crate(crate)

View File

@ -538,14 +538,12 @@ impl<'self> EachItemContext<'self> {
fn each_item_of_module(&mut self, def_id: ast::def_id) -> bool {
// This item might not be in this crate. If it's not, look it up.
let (_cdata, items) = if def_id.crate == self.cdata.cnum {
let items = reader::get_doc(reader::Doc(self.cdata.data),
tag_items);
(self.cdata, items)
let items = if def_id.crate == self.cdata.cnum {
reader::get_doc(reader::Doc(self.cdata.data), tag_items)
} else {
let crate_data = (self.get_crate_data)(def_id.crate);
let root = reader::Doc(crate_data.data);
(crate_data, reader::get_doc(root, tag_items))
reader::get_doc(root, tag_items)
};
// Look up the item.
@ -717,14 +715,14 @@ pub fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt,
item_path.init().to_owned()
};
match decode_inlined_item(cdata, tcx, copy path, item_doc) {
Some(ref ii) => csearch::found((/*bad*/copy *ii)),
Some(ref ii) => csearch::found(*ii),
None => {
match item_parent_item(item_doc) {
Some(did) => {
let did = translate_def_id(cdata, did);
let parent_item = lookup_item(did.node, cdata.data);
match decode_inlined_item(cdata, tcx, path, parent_item) {
Some(ref ii) => csearch::found_parent(did, (/*bad*/copy *ii)),
Some(ref ii) => csearch::found_parent(did, *ii),
None => csearch::not_found
}
}

View File

@ -780,8 +780,12 @@ fn encode_info_for_method(ecx: &EncodeContext,
}
let mut combined_ty_params = opt_vec::Empty;
for owner_generics.ty_params.iter().advance |x| { combined_ty_params.push(copy *x) }
for method_generics.ty_params.iter().advance |x| { combined_ty_params.push(copy *x) }
for owner_generics.ty_params.iter().advance |x| {
combined_ty_params.push(copy *x)
}
for method_generics.ty_params.iter().advance |x| {
combined_ty_params.push(copy *x)
}
let len = combined_ty_params.len();
encode_type_param_bounds(ebml_w, ecx, &combined_ty_params);
@ -1392,14 +1396,14 @@ fn synthesize_crate_attrs(ecx: &EncodeContext,
for crate.node.attrs.iter().advance |attr| {
attrs.push(
if "link" != attr::get_attr_name(attr) {
copy *attr
*attr
} else {
match attr.node.value.node {
meta_list(_, ref l) => {
found_link_attr = true;;
synthesize_link_attr(ecx, /*bad*/copy *l)
}
_ => copy *attr
_ => *attr
}
});
}

View File

@ -371,7 +371,10 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
match st.tcx.rcache.find(&key) {
Some(&tt) => return tt,
None => {
let mut ps = PState {pos: pos ,.. copy *st};
let mut ps = PState {
pos: pos,
.. *st
};
let tt = parse_ty(&mut ps, conv);
st.tcx.rcache.insert(key, tt);
return tt;

View File

@ -218,7 +218,7 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
val(const_bool(false)),
0u, left_ty)
}
ref u => (/*bad*/copy *u)
ref u => *u,
}
}
ty::ty_enum(eid, _) => {
@ -226,7 +226,7 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
match is_useful_specialized(cx, m, v, variant(va.id),
va.args.len(), left_ty) {
not_useful => (),
ref u => return (/*bad*/copy *u)
ref u => return *u,
}
}
not_useful
@ -243,7 +243,7 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
for uint::range(0, max_len + 1) |n| {
match is_useful_specialized(cx, m, v, vec(n), n, left_ty) {
not_useful => (),
ref u => return (/*bad*/copy *u)
ref u => return *u,
}
}
not_useful
@ -258,15 +258,15 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
match is_useful(cx,
&m.iter().filter_map(|r| default(cx, *r)).collect::<matrix>(),
v.tail()) {
useful_ => useful(left_ty, /*bad*/copy *ctor),
ref u => (/*bad*/copy *u)
useful_ => useful(left_ty, *ctor),
ref u => *u,
}
}
}
}
Some(ref v0_ctor) => {
let arity = ctor_arity(cx, v0_ctor, left_ty);
is_useful_specialized(cx, m, v, /*bad*/copy *v0_ctor, arity, left_ty)
is_useful_specialized(cx, m, v, *v0_ctor, arity, left_ty)
}
}
}
@ -283,7 +283,7 @@ pub fn is_useful_specialized(cx: &MatchCheckCtxt,
cx, &ms, specialize(cx, v, &ctor, arity, lty).get());
match could_be_useful {
useful_ => useful(lty, ctor),
ref u => (/*bad*/copy *u)
ref u => *u,
}
}
@ -355,7 +355,7 @@ pub fn missing_ctor(cx: &MatchCheckCtxt,
let r = pat_ctor_id(cx, r[0]);
for r.iter().advance |id| {
if !found.contains(id) {
found.push(/*bad*/copy *id);
found.push(*id);
}
}
}
@ -680,9 +680,8 @@ pub fn specialize(cx: &MatchCheckCtxt,
}
pat_range(lo, hi) => {
let (c_lo, c_hi) = match *ctor_id {
val(ref v) => ((/*bad*/copy *v), (/*bad*/copy *v)),
range(ref lo, ref hi) =>
((/*bad*/copy *lo), (/*bad*/copy *hi)),
val(ref v) => (*v, *v),
range(ref lo, ref hi) => (*lo, *hi),
single => return Some(r.tail().to_owned()),
_ => fail!("type error")
};

View File

@ -83,6 +83,7 @@ pub enum lint {
type_limits,
default_methods,
unused_unsafe,
copy_implicitly_copyable,
managed_heap_memory,
owned_heap_memory,
@ -259,6 +260,14 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
default: warn
}),
("copy_implicitly_copyable",
LintSpec {
lint: copy_implicitly_copyable,
desc: "detect unnecessary uses of `copy` on implicitly copyable \
values",
default: warn
}),
("unused_variable",
LintSpec {
lint: unused_variable,
@ -514,7 +523,7 @@ impl Context {
// item_stopping_visitor has overridden visit_fn(&fk_method(... ))
// to be a no-op, so manually invoke visit_fn.
Method(m) => {
let fk = visit::fk_method(copy m.ident, &m.generics, m);
let fk = visit::fk_method(m.ident, &m.generics, m);
for self.visitors.iter().advance |&(orig, stopping)| {
(orig.visit_fn)(&fk, &m.decl, &m.body, m.span, m.id,
(self, stopping));
@ -935,6 +944,26 @@ fn lint_unused_unsafe() -> visit::vt<@mut Context> {
})
}
fn lint_copy_implicitly_copyable() -> visit::vt<@mut Context> {
visit::mk_vt(@visit::Visitor {
visit_expr: |e, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
match e.node {
ast::expr_copy(subexpr) => {
let ty = ty::expr_ty(cx.tcx, subexpr);
if !ty::type_moves_by_default(cx.tcx, ty) {
cx.span_lint(copy_implicitly_copyable,
e.span,
"unnecessary `copy`; this value is implicitly copyable");
}
}
_ => ()
}
visit::visit_expr(e, (cx, vt));
},
.. *visit::default_visitor()
})
}
fn lint_unused_mut() -> visit::vt<@mut Context> {
fn check_pat(cx: &Context, p: @ast::pat) {
let mut used = false;
@ -1147,6 +1176,7 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
cx.add_lint(lint_heap());
cx.add_lint(lint_type_limits());
cx.add_lint(lint_unused_unsafe());
cx.add_lint(lint_copy_implicitly_copyable());
cx.add_lint(lint_unused_mut());
cx.add_lint(lint_session());
cx.add_lint(lint_unnecessary_allocations());

View File

@ -680,7 +680,7 @@ impl Liveness {
*/
pub fn live_on_exit(&self, ln: LiveNode, var: Variable)
-> Option<LiveNodeKind> {
self.live_on_entry(copy self.successors[*ln], var)
self.live_on_entry(self.successors[*ln], var)
}
pub fn used_on_entry(&self, ln: LiveNode, var: Variable) -> bool {
@ -697,7 +697,7 @@ impl Liveness {
pub fn assigned_on_exit(&self, ln: LiveNode, var: Variable)
-> Option<LiveNodeKind> {
self.assigned_on_entry(copy self.successors[*ln], var)
self.assigned_on_entry(self.successors[*ln], var)
}
pub fn indices(&self, ln: LiveNode, op: &fn(uint)) {
@ -768,14 +768,14 @@ impl Liveness {
wr.write_str("[ln(");
wr.write_uint(*ln);
wr.write_str(") of kind ");
wr.write_str(fmt!("%?", copy self.ir.lnks[*ln]));
wr.write_str(fmt!("%?", self.ir.lnks[*ln]));
wr.write_str(" reads");
self.write_vars(wr, ln, |idx| self.users[idx].reader );
wr.write_str(" writes");
self.write_vars(wr, ln, |idx| self.users[idx].writer );
wr.write_str(" ");
wr.write_str(" precedes ");
wr.write_str((copy self.successors[*ln]).to_str());
wr.write_str((self.successors[*ln]).to_str());
wr.write_str("]");
}
}
@ -813,9 +813,9 @@ impl Liveness {
let mut changed = false;
do self.indices2(ln, succ_ln) |idx, succ_idx| {
let users = &mut *self.users;
changed |= copy_if_invalid(copy users[succ_idx].reader,
changed |= copy_if_invalid(users[succ_idx].reader,
&mut users[idx].reader);
changed |= copy_if_invalid(copy users[succ_idx].writer,
changed |= copy_if_invalid(users[succ_idx].writer,
&mut users[idx].writer);
if users[succ_idx].used && !users[idx].used {
users[idx].used = true;

View File

@ -604,7 +604,7 @@ impl DetermineRpCtxt {
token::get_ident_interner()),
ast_map::node_id_to_str(self.ast_map, self.item_id,
token::get_ident_interner()),
copy self.ambient_variance);
self.ambient_variance);
let vec = do self.dep_map.find_or_insert_with(from) |_| {
@mut ~[]
};

View File

@ -394,8 +394,8 @@ impl ImportResolution {
pub fn target_for_namespace(&self, namespace: Namespace)
-> Option<Target> {
match namespace {
TypeNS => return copy self.type_target,
ValueNS => return copy self.value_target
TypeNS => return self.type_target,
ValueNS => return self.value_target,
}
}
@ -795,7 +795,7 @@ pub fn Resolver(session: Session,
let this = Resolver {
session: @session,
lang_items: copy lang_items,
lang_items: lang_items,
crate: crate,
// The outermost module has def ID 0; this is not reflected in the
@ -2477,9 +2477,9 @@ impl Resolver {
let new_import_resolution =
@mut ImportResolution(privacy, id);
new_import_resolution.value_target =
copy target_import_resolution.value_target;
target_import_resolution.value_target;
new_import_resolution.type_target =
copy target_import_resolution.type_target;
target_import_resolution.type_target;
module_.import_resolutions.insert
(*ident, new_import_resolution);
@ -2531,7 +2531,7 @@ impl Resolver {
self.session.str_of(ident),
self.module_to_str(containing_module),
self.module_to_str(module_),
copy dest_import_resolution.privacy);
dest_import_resolution.privacy);
// Merge the child item into the import resolution.
if name_bindings.defined_in_public_namespace(ValueNS) {
@ -2810,7 +2810,7 @@ impl Resolver {
debug!("(resolving item in lexical scope) using \
import resolution");
self.used_imports.insert(import_resolution.id(namespace));
return Success(copy target);
return Success(target);
}
}
}
@ -2888,7 +2888,7 @@ impl Resolver {
}
Success(target) => {
// We found the module.
return Success(copy target);
return Success(target);
}
}
}
@ -3079,7 +3079,7 @@ impl Resolver {
debug!("(resolving name in module) resolved to \
import");
self.used_imports.insert(import_resolution.id(namespace));
return Success(copy target);
return Success(target);
}
Some(_) => {
debug!("(resolving name in module) name found, \
@ -3204,7 +3204,7 @@ impl Resolver {
let mut exports2 = ~[];
self.add_exports_for_module(&mut exports2, module_);
match /*bad*/copy module_.def_id {
match module_.def_id {
Some(def_id) => {
self.export_map2.insert(def_id.node, exports2);
debug!("(computing exports) writing exports for %d (some)",

View File

@ -2953,7 +2953,7 @@ pub fn trans_crate(sess: session::Session,
-> (ContextRef, ModuleRef, LinkMeta) {
// Before we touch LLVM, make sure that multithreading is enabled.
if unsafe { !llvm::LLVMRustStartMultithreading() } {
sess.bug("couldn't enable multi-threaded LLVM");
//sess.bug("couldn't enable multi-threaded LLVM");
}
let mut symbol_hasher = hash::default_state();

View File

@ -59,7 +59,7 @@ pub fn count_insn(cx: block, category: &str) {
let len = v.len();
let mut i = 0u;
while i < len {
mm.insert(copy v[i], i);
mm.insert(v[i], i);
i += 1u;
}

View File

@ -696,7 +696,7 @@ pub fn trans_call_inner(in_cx: block,
let ret_flag_result = bool_to_i1(bcx, Load(bcx, ret_flag.get()));
bcx = do with_cond(bcx, ret_flag_result) |bcx| {
{
let r = (copy bcx.fcx.loop_ret);
let r = bcx.fcx.loop_ret;
for r.iter().advance |&(flagptr, _)| {
Store(bcx, C_bool(true), flagptr);
Store(bcx, C_bool(false), bcx.fcx.llretptr.get());

View File

@ -459,7 +459,7 @@ pub fn trans_expr_fn(bcx: block,
body,
llfn,
no_self,
/*bad*/ copy bcx.fcx.param_substs,
bcx.fcx.param_substs,
user_id,
[],
real_return_type,

View File

@ -351,7 +351,7 @@ pub fn trans_cont(bcx: block, label_opt: Option<ident>) -> block {
pub fn trans_ret(bcx: block, e: Option<@ast::expr>) -> block {
let _icx = push_ctxt("trans_ret");
let mut bcx = bcx;
let dest = match copy bcx.fcx.loop_ret {
let dest = match bcx.fcx.loop_ret {
Some((flagptr, retptr)) => {
// This is a loop body return. Must set continue flag (our retptr)
// to false, return flag to true, and then store the value in the

View File

@ -393,7 +393,7 @@ pub fn make_mono_id(ccx: @mut CrateContext,
precise_param_ids.iter().zip(uses_iter).transform(|(id, uses)| {
if ccx.sess.no_monomorphic_collapse() {
match copy *id {
match *id {
(a, b) => mono_precise(a, b)
}
} else {
@ -432,7 +432,7 @@ pub fn make_mono_id(ccx: @mut CrateContext,
}
None => {
precise_param_ids.iter().transform(|x| {
let (a, b) = copy *x;
let (a, b) = *x;
mono_precise(a, b)
}).collect()
}

View File

@ -63,7 +63,7 @@ use middle::typeck::infer::glb::Glb;
use middle::typeck::infer::lub::Lub;
use middle::typeck::infer::sub::Sub;
use middle::typeck::infer::to_str::InferStr;
use middle::typeck::infer::unify::{InferCtxtMethods};
use middle::typeck::infer::unify::InferCtxtMethods;
use middle::typeck::infer::{InferCtxt, cres, ures};
use middle::typeck::infer::{TypeTrace};
use util::common::indent;

View File

@ -511,8 +511,7 @@ pub fn lattice_var_and_t<L:LatticeDir + Combine,
debug!("bnd=None");
let a_bounds = this.with_bnd(a_bounds, copy *b);
do this.combine_fields().bnds(&a_bounds.lb, &a_bounds.ub).then {
this.infcx().set(copy a_id,
Root(copy a_bounds, copy nde_a.rank));
this.infcx().set(copy a_id, Root(copy a_bounds, nde_a.rank));
Ok(copy *b)
}
}

View File

@ -77,11 +77,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(copy *a) )
eq_tys(self, a.ty, b.ty).then(|| Ok(*a))
}
m_imm | m_const => {
// Otherwise we can be covariant:
self.tys(a.ty, b.ty).chain(|_t| Ok(copy *a) )
self.tys(a.ty, b.ty).chain(|_t| Ok(*a) )
}
}
}

View File

@ -33,18 +33,18 @@ impl<T:Clone> Clone for Fold<T> {
fn clone(&self) -> Fold<T> {
Fold {
ctxt: self.ctxt.clone(),
fold_doc: copy self.fold_doc,
fold_crate: copy self.fold_crate,
fold_item: copy self.fold_item,
fold_mod: copy self.fold_mod,
fold_nmod: copy self.fold_nmod,
fold_fn: copy self.fold_fn,
fold_const: copy self.fold_const,
fold_enum: copy self.fold_enum,
fold_trait: copy self.fold_trait,
fold_impl: copy self.fold_impl,
fold_type: copy self.fold_type,
fold_struct: copy self.fold_struct
fold_doc: self.fold_doc,
fold_crate: self.fold_crate,
fold_item: self.fold_item,
fold_mod: self.fold_mod,
fold_nmod: self.fold_nmod,
fold_fn: self.fold_fn,
fold_const: self.fold_const,
fold_enum: self.fold_enum,
fold_trait: self.fold_trait,
fold_impl: self.fold_impl,
fold_type: self.fold_type,
fold_struct: self.fold_struct
}
}
}

View File

@ -63,9 +63,9 @@ fn fold_item(
let doc = fold::default_seq_fold_item(fold, doc);
doc::ItemDoc {
brief: maybe_apply_op(copy fold.ctxt, &doc.brief),
desc: maybe_apply_op(copy fold.ctxt, &doc.desc),
sections: apply_to_sections(copy fold.ctxt, copy doc.sections),
brief: maybe_apply_op(fold.ctxt, &doc.brief),
desc: maybe_apply_op(fold.ctxt, &doc.desc),
sections: apply_to_sections(fold.ctxt, copy doc.sections),
.. doc
}
}
@ -84,12 +84,12 @@ fn fold_enum(
fold: &fold::Fold<NominalOp<Op>>,
doc: doc::EnumDoc) -> doc::EnumDoc {
let doc = fold::default_seq_fold_enum(fold, doc);
let fold_copy = copy *fold;
let fold_copy = *fold;
doc::EnumDoc {
variants: do doc.variants.map |variant| {
doc::VariantDoc {
desc: maybe_apply_op(copy fold_copy.ctxt, &variant.desc),
desc: maybe_apply_op(fold_copy.ctxt, &variant.desc),
.. copy *variant
}
},
@ -104,7 +104,7 @@ fn fold_trait(
let doc = fold::default_seq_fold_trait(fold, doc);
doc::TraitDoc {
methods: apply_to_methods(copy fold.ctxt, copy doc.methods),
methods: apply_to_methods(fold.ctxt, copy doc.methods),
.. doc
}
}
@ -113,12 +113,11 @@ fn apply_to_methods(
op: NominalOp<Op>,
docs: ~[doc::MethodDoc]
) -> ~[doc::MethodDoc] {
let op = copy op;
do docs.map |doc| {
doc::MethodDoc {
brief: maybe_apply_op(copy op, &doc.brief),
desc: maybe_apply_op(copy op, &doc.desc),
sections: apply_to_sections(copy op, copy doc.sections),
brief: maybe_apply_op(op, &doc.brief),
desc: maybe_apply_op(op, &doc.desc),
sections: apply_to_sections(op, copy doc.sections),
.. copy *doc
}
}
@ -131,7 +130,7 @@ fn fold_impl(
let doc = fold::default_seq_fold_impl(fold, doc);
doc::ImplDoc {
methods: apply_to_methods(copy fold.ctxt, copy doc.methods),
methods: apply_to_methods(fold.ctxt, copy doc.methods),
.. doc
}
}

View File

@ -327,7 +327,7 @@ pub fn find_and_install_dependencies(ctxt: &Ctx,
// :-(
debug!("In find_and_install_dependencies...");
let my_workspace = copy *workspace;
let my_ctxt = copy *ctxt;
let my_ctxt = *ctxt;
for c.each_view_item() |vi: &ast::view_item| {
debug!("A view item!");
match vi.node {

View File

@ -38,9 +38,9 @@ unsafe fn each_live_alloc(read_next_before: bool,
use rt::local_heap;
let box = local_heap::live_allocs();
let mut box: *mut BoxRepr = transmute(copy box);
let mut box: *mut BoxRepr = transmute(box);
while box != mut_null() {
let next_before = transmute(copy (*box).header.next);
let next_before = transmute((*box).header.next);
let uniq =
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
@ -51,7 +51,7 @@ unsafe fn each_live_alloc(read_next_before: bool,
if read_next_before {
box = next_before;
} else {
box = transmute(copy (*box).header.next);
box = transmute((*box).header.next);
}
}
return true;
@ -126,7 +126,7 @@ pub unsafe fn annihilate() {
// callback, as the original value may have been freed.
for each_live_alloc(false) |box, uniq| {
if !uniq {
let tydesc: *TyDesc = transmute(copy (*box).header.type_desc);
let tydesc: *TyDesc = transmute((*box).header.type_desc);
let data = transmute(&(*box).data);
call_drop_glue(tydesc, data);
}

View File

@ -476,7 +476,7 @@ fn try_recv_<T:Send>(p: &mut Packet<T>) -> Option<T> {
// sometimes blocking the thing we are waiting on.
task::yield();
}
debug!("woke up, p.state = %?", copy p.header.state);
debug!("woke up, p.state = %?", p.header.state);
}
Blocked => if first {
fail!("blocking on already blocked packet")

View File

@ -27,7 +27,9 @@ pub fn path_name_i(idents: &[ident]) -> ~str {
idents.map(|i| token::interner_get(i.name)).connect("::")
}
pub fn path_to_ident(p: &Path) -> ident { copy *p.idents.last() }
pub fn path_to_ident(p: &Path) -> ident {
*p.idents.last()
}
pub fn local_def(id: node_id) -> def_id {
ast::def_id { crate: local_crate, node: id }
@ -297,9 +299,9 @@ pub trait inlined_item_utils {
impl inlined_item_utils for inlined_item {
fn ident(&self) -> ident {
match *self {
ii_item(i) => /* FIXME (#2543) */ copy i.ident,
ii_foreign(i) => /* FIXME (#2543) */ copy i.ident,
ii_method(_, _, m) => /* FIXME (#2543) */ copy m.ident,
ii_item(i) => i.ident,
ii_foreign(i) => i.ident,
ii_method(_, _, m) => m.ident,
}
}

View File

@ -269,7 +269,7 @@ pub fn sort_meta_items(items: &[@ast::meta_item]) -> ~[@ast::meta_item] {
.. /*bad*/ copy **m
}
}
_ => /*bad*/ copy *m
_ => *m
}
}
}

View File

@ -354,7 +354,7 @@ impl CodeMap {
pub fn span_to_filename(&self, sp: span) -> FileName {
let lo = self.lookup_char_pos(sp.lo);
return /* FIXME (#2543) */ copy lo.file.name;
lo.file.name
}
pub fn span_to_lines(&self, sp: span) -> @FileLines {

View File

@ -257,7 +257,7 @@ impl ExtCtxt {
Some(@ExpnInfo {
call_site: span {lo: cs.lo, hi: cs.hi,
expn_info: *self.backtrace},
callee: copy *callee});
callee: *callee});
}
}
}

View File

@ -347,7 +347,7 @@ impl AstBuilder for @ExtCtxt {
fn strip_bounds(&self, generics: &Generics) -> Generics {
let new_params = do generics.ty_params.map |ty_param| {
ast::TyParam { bounds: opt_vec::Empty, ..copy *ty_param }
ast::TyParam { bounds: opt_vec::Empty, ..*ty_param }
};
Generics {
ty_params: new_params,
@ -611,13 +611,13 @@ impl AstBuilder for @ExtCtxt {
}
fn lambda0(&self, _span: span, blk: ast::blk) -> @ast::expr {
let ext_cx = *self;
let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
let blk_e = self.expr(blk.span, ast::expr_block(copy blk));
quote_expr!(|| $blk_e )
}
fn lambda1(&self, _span: span, blk: ast::blk, ident: ast::ident) -> @ast::expr {
let ext_cx = *self;
let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
let blk_e = self.expr(blk.span, ast::expr_block(copy blk));
quote_expr!(|$ident| $blk_e )
}

View File

@ -323,7 +323,7 @@ impl<'self> TraitDef<'self> {
let mut trait_generics = self.generics.to_generics(cx, span, type_ident, generics);
// Copy the lifetimes
for generics.lifetimes.iter().advance |l| {
trait_generics.lifetimes.push(copy *l)
trait_generics.lifetimes.push(*l)
};
// Create the type parameters.
for generics.ty_params.iter().advance |ty_param| {

View File

@ -45,7 +45,7 @@ use extra::bitv::Bitv;
pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
debug!("initializing colive analysis");
let num_states = proto.num_states();
let mut colive: ~[~Bitv] = do (copy proto.states).iter().transform() |state| {
let mut colive: ~[~Bitv] = do proto.states.iter().transform() |state| {
let mut bv = ~Bitv::new(num_states, false);
for state.reachable |s| {
bv.set(s.id, true);
@ -85,10 +85,11 @@ pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
}
if self_live.len() > 0 {
let states = self_live.map(|s| copy s.name).connect(" ");
let states = self_live.map(|s| s.name).connect(" ");
debug!("protocol %s is unbounded due to loops involving: %s",
copy proto.name, states);
proto.name,
states);
// Someday this will be configurable with a warning
//cx.span_warn(empty_span(),
@ -98,9 +99,8 @@ pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
// states));
proto.bounded = Some(false);
}
else {
debug!("protocol %s is bounded. yay!", copy proto.name);
} else {
debug!("protocol %s is bounded. yay!", proto.name);
proto.bounded = Some(true);
}
}

View File

@ -65,7 +65,7 @@ pub fn expand_proto(cx: @ExtCtxt, _sp: span, id: ast::ident,
tt: ~[ast::token_tree]) -> base::MacResult {
let sess = cx.parse_sess();
let cfg = cx.cfg();
let tt_rdr = new_tt_reader(copy cx.parse_sess().span_diagnostic,
let tt_rdr = new_tt_reader(cx.parse_sess().span_diagnostic,
None,
copy tt);
let rdr = tt_rdr as @reader;

View File

@ -382,7 +382,7 @@ impl gen_init for protocol {
cx.ty_path(path(~[cx.ident_of("super"),
cx.ident_of("__Buffer")],
copy self.span)
self.span)
.add_tys(cx.ty_vars_global(&params)), None)
}
@ -432,7 +432,7 @@ impl gen_init for protocol {
let mut client_states = ~[];
let mut server_states = ~[];
for (copy self.states).iter().advance |s| {
for self.states.iter().advance |s| {
items.push_all_move(s.to_type_decls(cx));
client_states.push_all_move(s.to_endpoint_decls(cx, send));
@ -443,11 +443,11 @@ impl gen_init for protocol {
items.push(self.gen_buffer_type(cx))
}
items.push(cx.item_mod(copy self.span,
items.push(cx.item_mod(self.span,
cx.ident_of("client"),
~[], ~[],
client_states));
items.push(cx.item_mod(copy self.span,
items.push(cx.item_mod(self.span,
cx.ident_of("server"),
~[], ~[],
server_states));
@ -455,12 +455,11 @@ impl gen_init for protocol {
// XXX: Would be nice if our generated code didn't violate
// Rust coding conventions
let allows = cx.attribute(
copy self.span,
cx.meta_list(copy self.span,
self.span,
cx.meta_list(self.span,
@"allow",
~[cx.meta_word(copy self.span, @"non_camel_case_types"),
cx.meta_word(copy self.span, @"unused_mut")]));
cx.item_mod(copy self.span, cx.ident_of(copy self.name),
~[allows], ~[], items)
~[cx.meta_word(self.span, @"non_camel_case_types"),
cx.meta_word(self.span, @"unused_mut")]));
cx.item_mod(self.span, cx.ident_of(self.name), ~[allows], ~[], items)
}
}

View File

@ -214,9 +214,8 @@ pub trait visitor<Tproto, Tstate, Tmessage> {
pub fn visit<Tproto, Tstate, Tmessage, V: visitor<Tproto, Tstate, Tmessage>>(
proto: protocol, visitor: V) -> Tproto {
// the copy keywords prevent recursive use of dvec
let states: ~[Tstate] = do (copy proto.states).iter().transform |&s| {
let messages: ~[Tmessage] = do (copy s.messages).iter().transform |m| {
let states: ~[Tstate] = do proto.states.iter().transform |&s| {
let messages: ~[Tmessage] = do s.messages.iter().transform |m| {
let message(name, span, tys, this, next) = copy *m;
visitor.visit_message(name, span, tys, this, next)
}.collect();

View File

@ -22,11 +22,9 @@ pub fn expand_trace_macros(cx: @ExtCtxt,
-> base::MacResult {
let sess = cx.parse_sess();
let cfg = cx.cfg();
let tt_rdr = new_tt_reader(
copy cx.parse_sess().span_diagnostic,
None,
tt.to_owned()
);
let tt_rdr = new_tt_reader(cx.parse_sess().span_diagnostic,
None,
tt.to_owned());
let rdr = tt_rdr as @reader;
let rust_parser = Parser(
sess,

View File

@ -53,8 +53,9 @@ pub fn add_new_extension(cx: @ExtCtxt,
// Parse the macro_rules! invocation (`none` is for no interpolations):
let arg_reader = new_tt_reader(copy cx.parse_sess().span_diagnostic,
None, copy arg);
let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic,
None,
copy arg);
let argument_map = parse_or_else(cx.parse_sess(),
cx.cfg(),
arg_reader as @reader,

View File

@ -285,7 +285,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
}
matched_seq(*) => {
r.sp_diag.span_fatal(
copy r.cur_span, /* blame the macro writer */
r.cur_span, /* blame the macro writer */
fmt!("variable '%s' is still repeating at this depth",
ident_to_str(&ident)));
}

View File

@ -87,7 +87,7 @@ fn fold_meta_item_(mi: @meta_item, fld: @ast_fold) -> @meta_item {
)
}
meta_name_value(id, s) => {
meta_name_value(id, /* FIXME (#2543) */ copy s)
meta_name_value(id, s)
}
},
span: fld.new_span(mi.span) }
@ -258,11 +258,15 @@ fn noop_fold_struct_field(sf: @struct_field, fld: @ast_fold)
-> @struct_field {
let fold_attribute = |x| fold_attribute_(x, fld);
@spanned { node: ast::struct_field_ { kind: copy sf.node.kind,
id: sf.node.id,
ty: fld.fold_ty(&sf.node.ty),
attrs: sf.node.attrs.map(|e| fold_attribute(*e)) },
span: sf.span }
@spanned {
node: ast::struct_field_ {
kind: sf.node.kind,
id: sf.node.id,
ty: fld.fold_ty(&sf.node.ty),
attrs: sf.node.attrs.map(|e| fold_attribute(*e))
},
span: sf.span
}
}
pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
@ -346,7 +350,7 @@ fn fold_trait_ref(p: &trait_ref, fld: @ast_fold) -> trait_ref {
fn fold_struct_field(f: @struct_field, fld: @ast_fold) -> @struct_field {
@spanned {
node: ast::struct_field_ {
kind: copy f.node.kind,
kind: f.node.kind,
id: fld.new_id(f.node.id),
ty: fld.fold_ty(&f.node.ty),
attrs: /* FIXME (#2543) */ copy f.node.attrs,
@ -439,7 +443,7 @@ pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ {
let pth_ = fld.fold_path(pth);
let fs = do fields.map |f| {
ast::field_pat {
ident: /* FIXME (#2543) */ copy f.ident,
ident: f.ident,
pat: fld.fold_pat(f.pat)
}
};
@ -743,7 +747,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
None => None
};
ast::variant_ {
name: /* FIXME (#2543) */ copy v.name,
name: v.name,
attrs: attrs,
kind: kind,
id: fld.new_id(v.id),
@ -753,7 +757,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
}
fn noop_fold_ident(i: ident, _fld: @ast_fold) -> ident {
/* FIXME (#2543) */ copy i
i
}
fn noop_fold_path(p: &Path, fld: @ast_fold) -> Path {
@ -837,7 +841,7 @@ impl ast_fold for AstFoldFns {
fn fold_struct_field(@self, sf: @struct_field) -> @struct_field {
@spanned {
node: ast::struct_field_ {
kind: copy sf.node.kind,
kind: sf.node.kind,
id: sf.node.id,
ty: self.fold_ty(&sf.node.ty),
attrs: copy sf.node.attrs,

View File

@ -94,7 +94,7 @@ fn dup_string_reader(r: @mut StringReader) -> @mut StringReader {
curr: r.curr,
filemap: r.filemap,
peek_tok: copy r.peek_tok,
peek_span: copy r.peek_span
peek_span: r.peek_span
}
}
@ -103,20 +103,20 @@ impl reader for StringReader {
// return the next token. EFFECT: advances the string_reader.
fn next_token(@mut self) -> TokenAndSpan {
let ret_val = TokenAndSpan {
tok: copy self.peek_tok,
sp: copy self.peek_span,
tok: /*bad*/copy self.peek_tok,
sp: self.peek_span,
};
string_advance_token(self);
ret_val
}
fn fatal(@mut self, m: ~str) -> ! {
self.span_diagnostic.span_fatal(copy self.peek_span, m)
self.span_diagnostic.span_fatal(self.peek_span, m)
}
fn span_diag(@mut self) -> @span_handler { self.span_diagnostic }
fn peek(@mut self) -> TokenAndSpan {
TokenAndSpan {
tok: copy self.peek_tok,
sp: copy self.peek_span,
tok: /*bad*/copy self.peek_tok,
sp: self.peek_span,
}
}
fn dup(@mut self) -> @reader { dup_string_reader(self) as @reader }
@ -126,13 +126,13 @@ impl reader for TtReader {
fn is_eof(@mut self) -> bool { self.cur_tok == token::EOF }
fn next_token(@mut self) -> TokenAndSpan { tt_next_token(self) }
fn fatal(@mut self, m: ~str) -> ! {
self.sp_diag.span_fatal(copy self.cur_span, m);
self.sp_diag.span_fatal(self.cur_span, m);
}
fn span_diag(@mut self) -> @span_handler { self.sp_diag }
fn peek(@mut self) -> TokenAndSpan {
TokenAndSpan {
tok: copy self.cur_tok,
sp: copy self.cur_span,
sp: self.cur_span,
}
}
fn dup(@mut self) -> @reader { dup_tt_reader(self) as @reader }
@ -144,7 +144,7 @@ fn string_advance_token(r: @mut StringReader) {
match (consume_whitespace_and_comments(r)) {
Some(comment) => {
r.peek_tok = copy comment.tok;
r.peek_span = copy comment.sp;
r.peek_span = comment.sp;
},
None => {
if is_eof(r) {

View File

@ -307,7 +307,7 @@ pub fn filemap_to_tts(sess: @mut ParseSess, filemap: @FileMap)
// it appears to me that the cfg doesn't matter here... indeed,
// parsing tt's probably shouldn't require a parser at all.
let cfg = ~[];
let srdr = lexer::new_string_reader(copy sess.span_diagnostic, filemap);
let srdr = lexer::new_string_reader(sess.span_diagnostic, filemap);
let p1 = Parser(sess, cfg, srdr as @reader);
p1.parse_all_token_trees()
}
@ -316,11 +316,7 @@ pub fn filemap_to_tts(sess: @mut ParseSess, filemap: @FileMap)
pub fn tts_to_parser(sess: @mut ParseSess,
tts: ~[ast::token_tree],
cfg: ast::crate_cfg) -> Parser {
let trdr = lexer::new_tt_reader(
copy sess.span_diagnostic,
None,
tts
);
let trdr = lexer::new_tt_reader(sess.span_diagnostic, None, tts);
Parser(sess, cfg, trdr as @reader)
}

View File

@ -329,8 +329,9 @@ impl ParserObsoleteMethods for Parser {
pub fn try_parse_obsolete_priv_section(&self, attrs: &[attribute])
-> bool {
if self.is_keyword(keywords::Priv) && self.look_ahead(1) == token::LBRACE {
self.obsolete(copy *self.span, ObsoletePrivSection);
if self.is_keyword(keywords::Priv) && self.look_ahead(1) ==
token::LBRACE {
self.obsolete(*self.span, ObsoletePrivSection);
self.eat_keyword(keywords::Priv);
self.bump();
while *self.token != token::RBRACE {

View File

@ -236,8 +236,8 @@ pub fn Parser(sess: @mut ParseSess,
sess: sess,
cfg: cfg,
token: @mut copy tok0.tok,
span: @mut copy tok0.sp,
last_span: @mut copy tok0.sp,
span: @mut tok0.sp,
last_span: @mut tok0.sp,
buffer: @mut ([copy tok0, .. 4]),
buffer_start: @mut 0,
buffer_end: @mut 0,
@ -530,7 +530,7 @@ impl Parser {
// advance the parser by one token
pub fn bump(&self) {
*self.last_span = copy *self.span;
*self.last_span = *self.span;
let next = if *self.buffer_start == *self.buffer_end {
self.reader.next_token()
} else {
@ -538,8 +538,8 @@ impl Parser {
*self.buffer_start = (*self.buffer_start + 1) & 3;
next
};
*self.token = copy next.tok;
*self.span = copy next.sp;
*self.token = /*bad*/copy next.tok;
*self.span = next.sp;
*self.tokens_consumed += 1u;
}
// EFFECT: replace the current token and span with the given one
@ -565,7 +565,7 @@ impl Parser {
return copy self.buffer[(*self.buffer_start + dist - 1) & 3].tok;
}
pub fn fatal(&self, m: &str) -> ! {
self.sess.span_diagnostic.span_fatal(*copy self.span, m)
self.sess.span_diagnostic.span_fatal(*self.span, m)
}
pub fn span_fatal(&self, sp: span, m: &str) -> ! {
self.sess.span_diagnostic.span_fatal(sp, m)
@ -574,10 +574,10 @@ impl Parser {
self.sess.span_diagnostic.span_note(sp, m)
}
pub fn bug(&self, m: &str) -> ! {
self.sess.span_diagnostic.span_bug(*copy self.span, m)
self.sess.span_diagnostic.span_bug(*self.span, m)
}
pub fn warn(&self, m: &str) {
self.sess.span_diagnostic.span_warn(*copy self.span, m)
self.sess.span_diagnostic.span_warn(*self.span, m)
}
pub fn span_err(&self, sp: span, m: &str) {
self.sess.span_diagnostic.span_err(sp, m)
@ -608,7 +608,7 @@ impl Parser {
pub fn get_lifetime(&self, tok: &token::Token) -> ast::ident {
match *tok {
token::LIFETIME(ref ident) => copy *ident,
token::LIFETIME(ref ident) => *ident,
_ => self.bug("not a lifetime"),
}
}
@ -1259,7 +1259,7 @@ impl Parser {
self.obsolete(*self.last_span, ObsoleteLifetimeNotation);
match *self.token {
token::IDENT(sid, _) => {
let span = copy self.span;
let span = self.span;
self.bump();
Some(ast::Lifetime {
id: self.get_id(),
@ -1347,7 +1347,7 @@ impl Parser {
pub fn parse_lifetime(&self) -> ast::Lifetime {
match *self.token {
token::LIFETIME(i) => {
let span = copy self.span;
let span = self.span;
self.bump();
return ast::Lifetime {
id: self.get_id(),
@ -1358,7 +1358,7 @@ impl Parser {
// Also accept the (obsolete) syntax `foo/`
token::IDENT(i, _) => {
let span = copy self.span;
let span = self.span;
self.bump();
self.expect(&token::BINOP(token::SLASH));
self.obsolete(*self.last_span, ObsoleteLifetimeNotation);
@ -2981,7 +2981,7 @@ impl Parser {
let lo = self.span.lo;
if self.eat_keyword(keywords::Unsafe) {
self.obsolete(copy *self.span, ObsoleteUnsafeBlock);
self.obsolete(*self.span, ObsoleteUnsafeBlock);
}
self.expect(&token::LBRACE);
@ -2996,7 +2996,7 @@ impl Parser {
let lo = self.span.lo;
if self.eat_keyword(keywords::Unsafe) {
self.obsolete(copy *self.span, ObsoleteUnsafeBlock);
self.obsolete(*self.span, ObsoleteUnsafeBlock);
}
self.expect(&token::LBRACE);
let (inner, next) = self.parse_inner_attrs_and_next();
@ -3581,7 +3581,7 @@ impl Parser {
ty = self.parse_ty(false);
opt_trait_ref
} else if self.eat(&token::COLON) {
self.obsolete(copy *self.span, ObsoleteImplSyntax);
self.obsolete(*self.span, ObsoleteImplSyntax);
Some(self.parse_trait_ref())
} else {
None
@ -3626,7 +3626,7 @@ impl Parser {
self.parse_region_param();
let generics = self.parse_generics();
if self.eat(&token::COLON) {
self.obsolete(copy *self.span, ObsoleteClassTraits);
self.obsolete(*self.span, ObsoleteClassTraits);
let _ = self.parse_trait_ref_list(&token::LBRACE);
}
@ -3710,7 +3710,7 @@ impl Parser {
let a_var = self.parse_name_and_ty(vis, attrs);
match *self.token {
token::SEMI => {
self.obsolete(copy *self.span, ObsoleteFieldTerminator);
self.obsolete(*self.span, ObsoleteFieldTerminator);
self.bump();
}
token::COMMA => {
@ -3718,13 +3718,9 @@ impl Parser {
}
token::RBRACE => {}
_ => {
self.span_fatal(
copy *self.span,
fmt!(
"expected `,`, or '}' but found `%s`",
self.this_token_to_str()
)
);
self.span_fatal(*self.span,
fmt!("expected `,`, or '}' but found `%s`",
self.this_token_to_str()));
}
}
a_var
@ -4043,26 +4039,19 @@ impl Parser {
must_be_named_mod = true;
self.expect_keyword(keywords::Mod);
} else if *self.token != token::LBRACE {
self.span_fatal(
copy *self.span,
fmt!(
"expected `{` or `mod` but found `%s`",
self.this_token_to_str()
)
);
self.span_fatal(*self.span,
fmt!("expected `{` or `mod` but found `%s`",
self.this_token_to_str()));
}
let (sort, ident) = match *self.token {
token::IDENT(*) => (ast::named, self.parse_ident()),
_ => {
if must_be_named_mod {
self.span_fatal(
copy *self.span,
fmt!(
"expected foreign module name but found `%s`",
self.this_token_to_str()
)
);
self.span_fatal(*self.span,
fmt!("expected foreign module name but \
found `%s`",
self.this_token_to_str()));
}
(ast::anonymous,

View File

@ -424,7 +424,7 @@ impl Printer {
pub fn check_stack(&mut self, k: int) {
if !self.scan_stack_empty {
let x = self.scan_top();
match copy self.token[x] {
match self.token[x] {
BEGIN(_) => {
if k > 0 {
self.size[self.scan_pop()] = self.size[x] +

View File

@ -803,9 +803,17 @@ pub fn print_ty_method(s: @ps, m: &ast::ty_method) {
hardbreak_if_not_bol(s);
maybe_print_comment(s, m.span.lo);
print_outer_attributes(s, m.attrs);
print_ty_fn(s, None, None, &None, m.purity, ast::Many,
&m.decl, Some(m.ident), &None, Some(&m.generics),
Some(/*bad*/ copy m.explicit_self.node));
print_ty_fn(s,
None,
None,
&None,
m.purity,
ast::Many,
&m.decl,
Some(m.ident),
&None,
Some(&m.generics),
Some(m.explicit_self.node));
word(s.s, ";");
}

View File

@ -361,18 +361,12 @@ pub fn visit_fn_decl<E: Copy>(fd: &fn_decl, (e, v): (E, vt<E>)) {
// because it is not a default impl of any method, though I doubt that really
// clarifies anything. - Niko
pub fn visit_method_helper<E: Copy>(m: &method, (e, v): (E, vt<E>)) {
(v.visit_fn)(
&fk_method(
/* FIXME (#2543) */ copy m.ident,
&m.generics,
m
),
&m.decl,
&m.body,
m.span,
m.id,
(e, v)
);
(v.visit_fn)(&fk_method(m.ident, &m.generics, m),
&m.decl,
&m.body,
m.span,
m.id,
(e, v));
}
pub fn visit_fn<E: Copy>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span,

View File

@ -89,7 +89,7 @@ pub fn main() {
let nyan : cat = cat(0u, 2, ~"nyan");
let whitefang : dog = dog();
annoy_neighbors(@(copy nyan) as @noisy);
annoy_neighbors(@(copy whitefang) as @noisy);
annoy_neighbors(@whitefang as @noisy);
assert_eq!(nyan.meow_count(), 10u);
assert_eq!(*whitefang.volume, 1);
}

View File

@ -50,7 +50,7 @@ struct A { a: @int }
fn thing(x: A) -> thing {
thing {
x: copy x
x: x
}
}

View File

@ -21,7 +21,7 @@ pub fn main() {
f(&mut x);
assert_eq!(x.a, 100);
x.a = 20;
let mut y = copy x;
let mut y = x;
f(&mut y);
assert_eq!(x.a, 20);
}

View File

@ -14,9 +14,9 @@ fn main() {
println(v[3].to_str());
println(v[4].to_str());
let v: @mut [int] = @mut [ 3, ..5 ];
println((copy v[0]).to_str());
println((copy v[1]).to_str());
println((copy v[2]).to_str());
println((copy v[3]).to_str());
println((copy v[4]).to_str());
println((v[0]).to_str());
println((v[1]).to_str());
println((v[2]).to_str());
println((v[3]).to_str());
println((v[4]).to_str());
}

View File

@ -18,7 +18,7 @@ fn f(p: @mut Point) { assert!((p.z == 12)); p.z = 13; assert!((p.z == 13)); }
pub fn main() {
let a: Point = Point {x: 10, y: 11, z: 12};
let b: @mut Point = @mut copy a;
let b: @mut Point = @mut a;
assert_eq!(b.z, 12);
f(b);
assert_eq!(a.z, 12);

View File

@ -27,5 +27,5 @@ fn nyan(kitty: cat, _kitty_info: KittyInfo) {
pub fn main() {
let mut kitty = cat();
nyan(copy kitty, KittyInfo {kitty: copy kitty});
nyan(kitty, KittyInfo {kitty: kitty});
}

View File

@ -10,7 +10,7 @@
fn double<T:Copy>(a: T) -> ~[T] { return ~[copy a] + ~[a]; }
fn double_int(a: int) -> ~[int] { return ~[copy a] + ~[a]; }
fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; }
pub fn main() {
let mut d = double(1);

View File

@ -16,6 +16,6 @@ struct Refs { refs: ~[int], n: int }
pub fn main() {
let e = @mut Refs{refs: ~[], n: 0};
let f: @fn() = || error!(copy e.n);
let f: @fn() = || error!(e.n);
e.refs.push(1);
}

View File

@ -43,7 +43,7 @@ fn runtest2(f: extern fn(), frame_backoff: u32, last_stk: *u8) -> u32 {
// We switched stacks, go back and try to hit the dynamic linker
frame_backoff
} else {
let frame_backoff = runtest2(copy f, frame_backoff, curr_stk);
let frame_backoff = runtest2(f, frame_backoff, curr_stk);
if frame_backoff > 1u32 {
frame_backoff - 1u32
} else if frame_backoff == 1u32 {

View File

@ -36,7 +36,6 @@ impl<T> E<T> {
macro_rules! check_option {
($e:expr: $T:ty) => {{
// FIXME #6000: remove the copy
check_option!(copy $e: $T, |ptr| assert!(*ptr == $e));
}};
($e:expr: $T:ty, |$v:ident| $chk:expr) => {{
@ -49,7 +48,6 @@ macro_rules! check_option {
macro_rules! check_fancy {
($e:expr: $T:ty) => {{
// FIXME #6000: remove the copy
check_fancy!(copy $e: $T, |ptr| assert!(*ptr == $e));
}};
($e:expr: $T:ty, |$v:ident| $chk:expr) => {{