diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index c55335ea190..88c70f5557c 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -1289,6 +1289,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // don't supply any form of builtin impl. if !this.tcx().sess.features.borrow().opt_out_copy { return Ok(ParameterBuiltin) + } else { + // Older, backwards compatibility behavior: + if + Some(def_id) == tcx.lang_items.no_copy_bound() || + Some(def_id) == tcx.lang_items.managed_bound() || + ty::has_dtor(tcx, def_id) + { + return Err(Unimplemented); + } } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 73fae976097..573c63eb6af 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -104,7 +104,6 @@ use {CrateCtxt, lookup_def_ccx, no_params, require_same_types}; use TypeAndSubsts; use middle::lang_items::TypeIdLangItem; use lint; -use util::common::ErrorReported; use util::common::{block_query, indenter, loop_query}; use util::ppaux::{mod, UserString, Repr}; use util::nodemap::{DefIdMap, FnvHashMap, NodeMap}; diff --git a/src/test/compile-fail/opt-out-copy-bad.rs b/src/test/compile-fail/opt-out-copy-bad.rs new file mode 100644 index 00000000000..80f8a154d58 --- /dev/null +++ b/src/test/compile-fail/opt-out-copy-bad.rs @@ -0,0 +1,42 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(opt_out_copy)] + +// Test that when using the `opt-out-copy` feature we still consider +// destructors to be non-movable + +struct CantCopyThis; + +impl Drop for CantCopyThis { + fn drop(&mut self) { } +} + +struct IWantToCopyThis { + but_i_cant: CantCopyThis, +} + +impl Copy for IWantToCopyThis {} +//~^ ERROR the trait `Copy` may not be implemented for this type + +enum CantCopyThisEither { + A, + B(::std::kinds::marker::NoCopy), +} + +enum IWantToCopyThisToo { + ButICant(CantCopyThisEither), +} + +impl Copy for IWantToCopyThisToo {} +//~^ ERROR the trait `Copy` may not be implemented for this type + +fn main() {} +