diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index c51fba8a62b71..b177aa34bdf6f 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1940,7 +1940,7 @@ pub impl TypeContents { } fn nonconst(_cx: ctxt) -> TypeContents { - TC_MUTABLE + TC_MUTABLE + TC_OWNED_CLOSURE } fn moves_by_default(&self, cx: ctxt) -> bool { diff --git a/src/test/compile-fail/owned-trait-not-const.rs b/src/test/compile-fail/owned-trait-not-const.rs new file mode 100644 index 0000000000000..55daaa59b25e2 --- /dev/null +++ b/src/test/compile-fail/owned-trait-not-const.rs @@ -0,0 +1,23 @@ +// Copyright 2013 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. + +extern mod std; + +pub trait Foo +{ +} + +fn c(_: T) {} + +fn test(a: ~Foo) { + c(a); //~ ERROR instantiating a type parameter with an incompatible type `~Foo`, which does not fulfill `Const` +} + +fn main() { }