From 7bef89f9b5da4ab327a39419c176e65d6e8938b1 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 18 Nov 2011 09:46:44 +0100 Subject: [PATCH] Prevent alias pass from inserting implicit copies for noncopyable types Issue #1177 --- src/comp/middle/kind.rs | 2 -- src/comp/middle/ty.rs | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index abc7ee8413b..c8cb5007c04 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -28,8 +28,6 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) -> rval_map { with *visit::default_visitor() }); visit::visit_crate(*crate, ctx, visit); - // FIXME go through alias's copy_map, check implicit copies (either here, - // or in alias.rs) tcx.sess.abort_if_errors(); ret ctx.rval_map; } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 5cd58c130f0..6a1e647e7f9 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1122,9 +1122,9 @@ pure fn type_has_dynamic_size(cx: ctxt, ty: t) -> bool { } } -// Returns true for types where a copy of a value can be distinguished from -// the value itself. I.e. types with mutable content that's not shared through -// a pointer. +// Returns true for noncopyable types and types where a copy of a value can be +// distinguished from the value itself. I.e. types with mutable content that's +// not shared through a pointer. fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool { ret !type_structurally_contains(cx, ty, fn (sty: sty) -> bool { ret alt sty { @@ -1143,7 +1143,7 @@ fn type_allows_implicit_copy(cx: ctxt, ty: t) -> bool { } _ { false } }; - }); + }) && type_kind(cx, t) != ast::kind_noncopyable; } fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {