Skip to content

Commit aa4278a

Browse files
committed
Require values to be copyable when cast
Closes #2222
1 parent a65af01 commit aa4278a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/rustc/middle/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
141141
alt e.node {
142142
expr_assign(_, ex) | expr_assign_op(_, _, ex) |
143143
expr_unary(box(_), ex) | expr_unary(uniq(_), ex) |
144-
expr_ret(some(ex)) { maybe_copy(cx, ex); }
144+
expr_ret(some(ex)) | expr_cast(ex, _) { maybe_copy(cx, ex); }
145145
expr_copy(expr) { check_copy_ex(cx, expr, false); }
146146
// Vector add copies.
147147
expr_binary(add, ls, rs) { maybe_copy(cx, ls); maybe_copy(cx, rs); }

src/rustc/middle/typeck.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ impl of region_scope for @fn_ctxt {
376376
}
377377

378378
enum anon_rscope = {anon: ty::region, base: region_scope};
379-
fn in_anon_rscope<RS: region_scope>(self: RS, r: ty::region) -> @anon_rscope {
379+
fn in_anon_rscope<RS: region_scope copy>(self: RS, r: ty::region)
380+
-> @anon_rscope {
380381
@anon_rscope({anon: r, base: self as region_scope})
381382
}
382383
impl of region_scope for @anon_rscope {
@@ -395,7 +396,7 @@ impl of region_scope for self_rscope {
395396
}
396397

397398
enum binding_rscope = {base: region_scope};
398-
fn in_binding_rscope<RS: region_scope>(self: RS) -> @binding_rscope {
399+
fn in_binding_rscope<RS: region_scope copy>(self: RS) -> @binding_rscope {
399400
let base = self as region_scope;
400401
@binding_rscope({base: base})
401402
}
@@ -410,7 +411,7 @@ impl of region_scope for @binding_rscope {
410411
}
411412
}
412413

413-
fn ast_region_to_region<AC: ast_conv, RS: region_scope>(
414+
fn ast_region_to_region<AC: ast_conv, RS: region_scope copy>(
414415
self: AC, rscope: RS, span: span, a_r: ast::region) -> ty::region {
415416

416417
alt a_r.node {
@@ -437,16 +438,16 @@ fn ast_region_to_region<AC: ast_conv, RS: region_scope>(
437438
// Parses the programmer's textual representation of a type into our
438439
// internal notion of a type. `getter` is a function that returns the type
439440
// corresponding to a definition ID:
440-
fn ast_ty_to_ty<AC: ast_conv, RS: region_scope>(
441+
fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>(
441442
self: AC, rscope: RS, &&ast_ty: @ast::ty) -> ty::t {
442443

443-
fn ast_mt_to_mt<AC: ast_conv, RS: region_scope>(
444+
fn ast_mt_to_mt<AC: ast_conv, RS: region_scope copy>(
444445
self: AC, rscope: RS, mt: ast::mt) -> ty::mt {
445446

446447
ret {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl};
447448
}
448449

449-
fn instantiate<AC: ast_conv, RS: region_scope>(
450+
fn instantiate<AC: ast_conv, RS: region_scope copy>(
450451
self: AC, rscope: RS, sp: span, id: ast::def_id,
451452
path_id: ast::node_id, args: [@ast::ty]) -> ty::t {
452453

@@ -478,7 +479,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope>(
478479
ret ty;
479480
}
480481

481-
fn mk_vstore<AC: ast_conv, RS: region_scope>(
482+
fn mk_vstore<AC: ast_conv, RS: region_scope copy>(
482483
self: AC, rscope: RS, a_seq_ty: @ast::ty, vst: ty::vstore) -> ty::t {
483484

484485
let tcx = self.tcx();
@@ -819,7 +820,7 @@ fn replace_bound_regions(
819820
}
820821
}
821822

822-
fn ty_of_arg<AC: ast_conv, RS: region_scope>(
823+
fn ty_of_arg<AC: ast_conv, RS: region_scope copy>(
823824
self: AC, rscope: RS, a: ast::arg) -> ty::arg {
824825

825826
fn arg_mode(tcx: ty::ctxt, m: ast::mode, ty: ty::t) -> ast::mode {
@@ -849,7 +850,7 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope>(
849850
let mode = arg_mode(self.tcx(), a.mode, ty);
850851
{mode: mode, ty: ty}
851852
}
852-
fn ty_of_fn_decl<AC: ast_conv, RS: region_scope>(
853+
fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy>(
853854
self: AC, rscope: RS,
854855
proto: ast::proto,
855856
decl: ast::fn_decl) -> ty::fn_ty {

0 commit comments

Comments
 (0)