Skip to content

Commit 99d44d2

Browse files
committed
librustc: Remove copy expressions from the language.
1 parent 99b33f7 commit 99d44d2

File tree

21 files changed

+13
-103
lines changed

21 files changed

+13
-103
lines changed

src/librustc/middle/cfg/construct.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ impl CFGBuilder {
394394
}
395395

396396
ast::expr_addr_of(_, e) |
397-
ast::expr_copy(e) |
398397
ast::expr_loop_body(e) |
399398
ast::expr_do_body(e) |
400399
ast::expr_cast(e, _) |
@@ -520,4 +519,4 @@ impl CFGBuilder {
520519
fn is_method_call(&self, expr: &ast::expr) -> bool {
521520
self.method_map.contains_key(&expr.id)
522521
}
523-
}
522+
}

src/librustc/middle/const_eval.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ pub fn classify(e: &expr,
9090
}
9191
}
9292

93-
ast::expr_copy(inner) |
9493
ast::expr_unary(_, _, inner) |
9594
ast::expr_paren(inner) => {
9695
classify(inner, tcx)

src/librustc/middle/dataflow.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
754754
}
755755

756756
ast::expr_addr_of(_, e) |
757-
ast::expr_copy(e) |
758757
ast::expr_loop_body(e) |
759758
ast::expr_do_body(e) |
760759
ast::expr_cast(e, _) |

src/librustc/middle/kind.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,6 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
298298
_ => { }
299299
}
300300
}
301-
expr_copy(expr) => {
302-
// Note: This is the only place where we must check whether the
303-
// argument is copyable. This is not because this is the only
304-
// kind of expression that may copy things, but rather because all
305-
// other copies will have been converted to moves by by the
306-
// `moves` pass if the value is not copyable.
307-
check_copy(cx,
308-
ty::expr_ty(cx.tcx, expr),
309-
expr.span,
310-
"explicit copy requires a copyable argument");
311-
}
312301
expr_repeat(element, count_expr, _) => {
313302
let count = ty::eval_repeat_count(&cx.tcx, count_expr);
314303
if count > 1 {

src/librustc/middle/lint.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ pub enum lint {
8383
type_limits,
8484
default_methods,
8585
unused_unsafe,
86-
copy_implicitly_copyable,
8786

8887
managed_heap_memory,
8988
owned_heap_memory,
@@ -260,14 +259,6 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
260259
default: warn
261260
}),
262261

263-
("copy_implicitly_copyable",
264-
LintSpec {
265-
lint: copy_implicitly_copyable,
266-
desc: "detect unnecessary uses of `copy` on implicitly copyable \
267-
values",
268-
default: warn
269-
}),
270-
271262
("unused_variable",
272263
LintSpec {
273264
lint: unused_variable,
@@ -947,26 +938,6 @@ fn lint_unused_unsafe() -> visit::vt<@mut Context> {
947938
})
948939
}
949940

950-
fn lint_copy_implicitly_copyable() -> visit::vt<@mut Context> {
951-
visit::mk_vt(@visit::Visitor {
952-
visit_expr: |e, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
953-
match e.node {
954-
ast::expr_copy(subexpr) => {
955-
let ty = ty::expr_ty(cx.tcx, subexpr);
956-
if !ty::type_moves_by_default(cx.tcx, ty) {
957-
cx.span_lint(copy_implicitly_copyable,
958-
e.span,
959-
"unnecessary `copy`; this value is implicitly copyable");
960-
}
961-
}
962-
_ => ()
963-
}
964-
visit::visit_expr(e, (cx, vt));
965-
},
966-
.. *visit::default_visitor()
967-
})
968-
}
969-
970941
fn lint_unused_mut() -> visit::vt<@mut Context> {
971942
fn check_pat(cx: &Context, p: @ast::pat) {
972943
let mut used = false;
@@ -1179,7 +1150,6 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
11791150
cx.add_lint(lint_heap());
11801151
cx.add_lint(lint_type_limits());
11811152
cx.add_lint(lint_unused_unsafe());
1182-
cx.add_lint(lint_copy_implicitly_copyable());
11831153
cx.add_lint(lint_unused_mut());
11841154
cx.add_lint(lint_session());
11851155
cx.add_lint(lint_unnecessary_allocations());

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ fn visit_expr(expr: @expr, (this, vt): (@mut IrMaps, vt<@mut IrMaps>)) {
511511
// otherwise, live nodes are not required:
512512
expr_index(*) | expr_field(*) | expr_vstore(*) | expr_vec(*) |
513513
expr_call(*) | expr_method_call(*) | expr_tup(*) | expr_log(*) |
514-
expr_binary(*) | expr_addr_of(*) | expr_copy(*) | expr_loop_body(*) |
514+
expr_binary(*) | expr_addr_of(*) | expr_loop_body(*) |
515515
expr_do_body(*) | expr_cast(*) | expr_unary(*) | expr_break(_) |
516516
expr_again(_) | expr_lit(_) | expr_ret(*) | expr_block(*) |
517517
expr_assign(*) | expr_assign_op(*) | expr_mac(*) |
@@ -1206,7 +1206,6 @@ impl Liveness {
12061206
}
12071207

12081208
expr_addr_of(_, e) |
1209-
expr_copy(e) |
12101209
expr_loop_body(e) |
12111210
expr_do_body(e) |
12121211
expr_cast(e, _) |
@@ -1481,7 +1480,7 @@ fn check_expr(expr: @expr, (this, vt): (@Liveness, vt<@Liveness>)) {
14811480
expr_call(*) | expr_method_call(*) | expr_if(*) | expr_match(*) |
14821481
expr_while(*) | expr_loop(*) | expr_index(*) | expr_field(*) |
14831482
expr_vstore(*) | expr_vec(*) | expr_tup(*) | expr_log(*) |
1484-
expr_binary(*) | expr_copy(*) | expr_loop_body(*) | expr_do_body(*) |
1483+
expr_binary(*) | expr_loop_body(*) | expr_do_body(*) |
14851484
expr_cast(*) | expr_unary(*) | expr_ret(*) | expr_break(*) |
14861485
expr_again(*) | expr_lit(_) | expr_block(*) |
14871486
expr_mac(*) | expr_addr_of(*) | expr_struct(*) | expr_repeat(*) |

src/librustc/middle/mem_categorization.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,13 @@ impl mem_categorization_ctxt {
426426
ast::expr_assign(*) | ast::expr_assign_op(*) |
427427
ast::expr_fn_block(*) | ast::expr_ret(*) | ast::expr_loop_body(*) |
428428
ast::expr_do_body(*) | ast::expr_unary(*) |
429-
ast::expr_method_call(*) | ast::expr_copy(*) | ast::expr_cast(*) |
430-
ast::expr_vstore(*) | ast::expr_vec(*) | ast::expr_tup(*) |
431-
ast::expr_if(*) | ast::expr_log(*) | ast::expr_binary(*) |
432-
ast::expr_while(*) | ast::expr_block(*) | ast::expr_loop(*) |
433-
ast::expr_match(*) | ast::expr_lit(*) | ast::expr_break(*) |
434-
ast::expr_mac(*) | ast::expr_again(*) | ast::expr_struct(*) |
435-
ast::expr_repeat(*) | ast::expr_inline_asm(*) => {
429+
ast::expr_method_call(*) | ast::expr_cast(*) | ast::expr_vstore(*) |
430+
ast::expr_vec(*) | ast::expr_tup(*) | ast::expr_if(*) |
431+
ast::expr_log(*) | ast::expr_binary(*) | ast::expr_while(*) |
432+
ast::expr_block(*) | ast::expr_loop(*) | ast::expr_match(*) |
433+
ast::expr_lit(*) | ast::expr_break(*) | ast::expr_mac(*) |
434+
ast::expr_again(*) | ast::expr_struct(*) | ast::expr_repeat(*) |
435+
ast::expr_inline_asm(*) => {
436436
return self.cat_rvalue_node(expr, expr_ty);
437437
}
438438
}

src/librustc/middle/moves.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,6 @@ impl VisitContext {
454454
self.use_expr(discr, Read, visitor);
455455
}
456456

457-
expr_copy(base) => {
458-
self.use_expr(base, Read, visitor);
459-
}
460-
461457
expr_paren(base) => {
462458
// Note: base is not considered a *component* here, so
463459
// use `expr_mode` not `comp_mode`.

src/librustc/middle/trans/expr.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -631,17 +631,6 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
631631
ast::expr_do_body(blk) => {
632632
return trans_into(bcx, blk, dest);
633633
}
634-
ast::expr_copy(a) => {
635-
// If we just called `trans_into(bcx, a, dest)`, then this
636-
// might *move* the value into `dest` if the value is
637-
// non-copyable. So first get a datum and then do an
638-
// explicit copy.
639-
let datumblk = trans_to_datum(bcx, a);
640-
return match dest {
641-
Ignore => datumblk.bcx,
642-
SaveIn(llval) => datumblk.copy_to(INIT, llval)
643-
};
644-
}
645634
ast::expr_call(f, ref args, _) => {
646635
return callee::trans_call(
647636
bcx, expr, f, callee::ArgExprs(*args), expr.id, dest);

src/librustc/middle/trans/type_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub fn mark_for_expr(cx: &Context, e: &expr) {
306306
match e.node {
307307
expr_vstore(_, _) | expr_vec(_, _) | expr_struct(*) | expr_tup(_) |
308308
expr_unary(_, box(_), _) | expr_unary(_, uniq, _) |
309-
expr_binary(_, add, _, _) | expr_copy(_) | expr_repeat(*) => {
309+
expr_binary(_, add, _, _) | expr_repeat(*) => {
310310
node_type_needs(cx, use_repr, e.id);
311311
}
312312
expr_cast(base, _) => {

src/librustc/middle/ty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3181,7 +3181,6 @@ pub fn expr_kind(tcx: ctxt,
31813181
ast::expr_loop_body(*) |
31823182
ast::expr_do_body(*) |
31833183
ast::expr_block(*) |
3184-
ast::expr_copy(*) |
31853184
ast::expr_repeat(*) |
31863185
ast::expr_lit(@codemap::spanned {node: lit_str(_), _}) |
31873186
ast::expr_vstore(_, ast::expr_vstore_slice) |

src/librustc/middle/typeck/check/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,10 +2518,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
25182518
fcx.write_nil(id);
25192519
}
25202520
}
2521-
ast::expr_copy(a) => {
2522-
check_expr_with_opt_hint(fcx, a, expected);
2523-
fcx.write_ty(id, fcx.expr_ty(a));
2524-
}
25252521
ast::expr_paren(a) => {
25262522
check_expr_with_opt_hint(fcx, a, expected);
25272523
fcx.write_ty(id, fcx.expr_ty(a));

src/librustc/middle/typeck/check/regionck.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,6 @@ pub mod guarantor {
10351035
ast::expr_loop_body(*) |
10361036
ast::expr_do_body(*) |
10371037
ast::expr_block(*) |
1038-
ast::expr_copy(*) |
10391038
ast::expr_repeat(*) |
10401039
ast::expr_vec(*) => {
10411040
assert!(!ty::expr_is_lval(

src/libsyntax/ast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ pub enum expr_ {
455455
expr_do_body(@expr),
456456
expr_block(blk),
457457

458-
expr_copy(@expr),
459458
expr_assign(@expr, @expr),
460459
expr_assign_op(node_id, binop, @expr, @expr),
461460
expr_field(@expr, ident, ~[Ty]),

src/libsyntax/ext/build.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ pub trait AstBuilder {
9494
fn expr_deref(&self, sp: span, e: @ast::expr) -> @ast::expr;
9595
fn expr_unary(&self, sp: span, op: ast::unop, e: @ast::expr) -> @ast::expr;
9696

97-
fn expr_copy(&self, sp: span, e: @ast::expr) -> @ast::expr;
9897
fn expr_managed(&self, sp: span, e: @ast::expr) -> @ast::expr;
9998
fn expr_addr_of(&self, sp: span, e: @ast::expr) -> @ast::expr;
10099
fn expr_mut_addr_of(&self, sp: span, e: @ast::expr) -> @ast::expr;
@@ -442,9 +441,6 @@ impl AstBuilder for @ExtCtxt {
442441
self.expr(sp, ast::expr_unary(self.next_id(), op, e))
443442
}
444443

445-
fn expr_copy(&self, sp: span, e: @ast::expr) -> @ast::expr {
446-
self.expr(sp, ast::expr_copy(e))
447-
}
448444
fn expr_managed(&self, sp: span, e: @ast::expr) -> @ast::expr {
449445
self.expr_unary(sp, ast::box(ast::m_imm), e)
450446
}

src/libsyntax/fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
580580
)
581581
}
582582
expr_block(ref blk) => expr_block(fld.fold_block(blk)),
583-
expr_copy(e) => expr_copy(fld.fold_expr(e)),
584583
expr_assign(el, er) => {
585584
expr_assign(fld.fold_expr(el), fld.fold_expr(er))
586585
}

src/libsyntax/parse/obsolete.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ pub enum ObsoleteSyntax {
6363
ObsoleteNamedExternModule,
6464
ObsoleteMultipleLocalDecl,
6565
ObsoleteMutWithMultipleBindings,
66-
ObsoletePatternCopyKeyword,
6766
}
6867

6968
impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -249,10 +248,6 @@ impl ParserObsoleteMethods for Parser {
249248
"use multiple local declarations instead of e.g. `let mut \
250249
(x, y) = ...`."
251250
),
252-
ObsoletePatternCopyKeyword => (
253-
"`copy` in patterns",
254-
"`copy` in patterns no longer has any effect"
255-
),
256251
};
257252

258253
self.report(sp, kind, kind_str, desc);

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use ast::{crate, crate_cfg, decl, decl_item};
2222
use ast::{decl_local, default_blk, deref, div, enum_def, explicit_self};
2323
use ast::{expr, expr_, expr_addr_of, expr_match, expr_again};
2424
use ast::{expr_assign, expr_assign_op, expr_binary, expr_block};
25-
use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
25+
use ast::{expr_break, expr_call, expr_cast, expr_do_body};
2626
use ast::{expr_field, expr_fn_block, expr_if, expr_index};
2727
use ast::{expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac};
2828
use ast::{expr_method_call, expr_paren, expr_path, expr_repeat};
@@ -84,7 +84,7 @@ use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
8484
use parse::obsolete::{ObsoleteConstItem, ObsoleteFixedLengthVectorType};
8585
use parse::obsolete::{ObsoleteNamedExternModule, ObsoleteMultipleLocalDecl};
8686
use parse::obsolete::{ObsoleteMutWithMultipleBindings};
87-
use parse::obsolete::{ObsoletePatternCopyKeyword, ParserObsoleteMethods};
87+
use parse::obsolete::{ParserObsoleteMethods};
8888
use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident};
8989
use parse::token::{is_ident_or_path};
9090
use parse::token::{is_plain_ident, INTERPOLATED, keywords, special_idents};
@@ -1704,11 +1704,6 @@ impl Parser {
17041704
ex = expr_break(None);
17051705
}
17061706
hi = self.span.hi;
1707-
} else if self.eat_keyword(keywords::Copy) {
1708-
// COPY expression
1709-
let e = self.parse_expr();
1710-
ex = expr_copy(e);
1711-
hi = e.span.hi;
17121707
} else if *self.token == token::MOD_SEP ||
17131708
is_ident(&*self.token) && !self.is_keyword(keywords::True) &&
17141709
!self.is_keyword(keywords::False) {
@@ -2799,10 +2794,6 @@ impl Parser {
27992794
// parse ref pat
28002795
let mutbl = self.parse_mutability();
28012796
pat = self.parse_pat_ident(bind_by_ref(mutbl));
2802-
} else if self.eat_keyword(keywords::Copy) {
2803-
// parse copy pat
2804-
self.obsolete(*self.span, ObsoletePatternCopyKeyword);
2805-
pat = self.parse_pat_ident(bind_infer);
28062797
} else {
28072798
let can_be_enum_or_struct = do self.look_ahead(1) |t| {
28082799
match *t {

src/libsyntax/parse/token.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ pub mod keywords {
566566
As,
567567
Break,
568568
Const,
569-
Copy,
570569
Do,
571570
Else,
572571
Enum,
@@ -609,7 +608,6 @@ pub mod keywords {
609608
As => ident { name: 32, ctxt: 0 },
610609
Break => ident { name: 33, ctxt: 0 },
611610
Const => ident { name: 34, ctxt: 0 },
612-
Copy => ident { name: 35, ctxt: 0 },
613611
Do => ident { name: 36, ctxt: 0 },
614612
Else => ident { name: 37, ctxt: 0 },
615613
Enum => ident { name: 38, ctxt: 0 },

src/libsyntax/print/pprust.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,6 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
13441344
ibox(s, 0u);
13451345
print_block(s, blk);
13461346
}
1347-
ast::expr_copy(e) => { word_space(s, "copy"); print_expr(s, e); }
13481347
ast::expr_assign(lhs, rhs) => {
13491348
print_expr(s, lhs);
13501349
space(s.s);

src/libsyntax/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ pub fn visit_expr<E:Clone>(ex: @expr, (e, v): (E, vt<E>)) {
532532
(v.visit_expr)(b, (e.clone(), v));
533533
(v.visit_expr)(a, (e.clone(), v));
534534
}
535-
expr_copy(a) => (v.visit_expr)(a, (e.clone(), v)),
536535
expr_assign_op(_, _, a, b) => {
537536
(v.visit_expr)(b, (e.clone(), v));
538537
(v.visit_expr)(a, (e.clone(), v));

0 commit comments

Comments
 (0)