Always warn when implicitly copying a generic type

This commit is contained in:
Marijn Haverbeke 2011-09-13 13:40:38 +02:00
parent 38e86d708b
commit e945164879

View file

@ -399,8 +399,7 @@ fn test_scope(cx: ctx, sc: scope, r: restrict, p: ast::path) {
_ {}
}
if prob != valid && cant_copy(cx, r) {
let msg =
alt prob {
let msg = alt prob {
overwritten(sp, wpt) {
{span: sp, msg: "overwriting " + ast_util::path_name(wpt)}
}
@ -515,7 +514,7 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) }
ty::ty_fn(_, _, _, _, _) | ty::ty_native_fn(_, _, _) |
ty::ty_obj(_) { 4u }
ty::ty_str. | ty::ty_vec(_) { 50u }
ty::ty_str. | ty::ty_vec(_) | ty::ty_param(_, _) { 50u }
ty::ty_uniq(t) { 1u + score_ty(tcx, t) }
ty::ty_tag(_, ts) | ty::ty_tup(ts) {
let sum = 0u;
@ -527,7 +526,6 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
for f in fs { sum += score_ty(tcx, f.mt.ty); }
sum
}
ty::ty_param(_, _) { 5u }
};
}
ret score_ty(tcx, ty) > 8u;