From 99cbea51a1df1ef78535654b0d8e674bce25753d Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 26 Sep 2011 19:56:38 -0700 Subject: [PATCH] Don't allow vectors of pinned kinds to be copied --- src/comp/middle/kind.rs | 4 ++++ src/test/compile-fail/vec-pinned-nocopy.rs | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/test/compile-fail/vec-pinned-nocopy.rs diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index d6629f11708..1f88820340d 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -150,6 +150,10 @@ fn check_copy(tcx: ty::ctxt, e: @ast::expr) { demand_kind(tcx, e.span, mt.ty, ast::kind_shared, "unique box interior"); } + ty::ty_vec(mt) { + demand_kind(tcx, e.span, mt.ty, ast::kind_shared, + "vector interior"); + } _ { } } } diff --git a/src/test/compile-fail/vec-pinned-nocopy.rs b/src/test/compile-fail/vec-pinned-nocopy.rs new file mode 100644 index 00000000000..ca880430871 --- /dev/null +++ b/src/test/compile-fail/vec-pinned-nocopy.rs @@ -0,0 +1,10 @@ +// error-pattern: mismatched kind + +resource r(b: bool) { +} + +fn main() { + let i = [r(true)]; + let j; + j = i; +} \ No newline at end of file