diff options
| author | bors <bors@rust-lang.org> | 2013-05-07 01:27:38 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-07 01:27:38 -0700 |
| commit | bdb52e58b43736b1351fa20a2b3dcff619a5fd09 (patch) | |
| tree | 6873690a04e9827ccc9d6f4ad31ca5a3891da369 /src/test | |
| parent | 7b2020f2c3f51de0dd4dcfe4a107673eda6f25e7 (diff) | |
| parent | e7f6c4c75406c3ecd117d7213e1be3438454b47e (diff) | |
auto merge of #6251 : thestinger/rust/non_owned, r=pcwalton
Also fixed the docstring on `TC_ONCE_CLOSURE` (was accidentally the same as `TC_MUTABLE`) and shifted the `TC_EMPTY_ENUM` bit left by one since whatever previously used that bit has been removed.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/mutable-enum.rs | 19 | ||||
| -rw-r--r-- | src/test/compile-fail/mutable-struct.rs | 19 | ||||
| -rw-r--r-- | src/test/compile-fail/non_owned-enum.rs | 19 | ||||
| -rw-r--r-- | src/test/compile-fail/non_owned-struct.rs | 19 |
4 files changed, 76 insertions, 0 deletions
diff --git a/src/test/compile-fail/mutable-enum.rs b/src/test/compile-fail/mutable-enum.rs new file mode 100644 index 00000000000..2368e5eb5c5 --- /dev/null +++ b/src/test/compile-fail/mutable-enum.rs @@ -0,0 +1,19 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[mutable] +enum Foo { A } + +fn bar<T: Const>(_: T) {} + +fn main() { + let x = A; + bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Const` +} diff --git a/src/test/compile-fail/mutable-struct.rs b/src/test/compile-fail/mutable-struct.rs new file mode 100644 index 00000000000..ee040506c40 --- /dev/null +++ b/src/test/compile-fail/mutable-struct.rs @@ -0,0 +1,19 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[mutable] +struct Foo { a: int } + +fn bar<T: Const>(_: T) {} + +fn main() { + let x = Foo { a: 5 }; + bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Const` +} diff --git a/src/test/compile-fail/non_owned-enum.rs b/src/test/compile-fail/non_owned-enum.rs new file mode 100644 index 00000000000..79c2be8183a --- /dev/null +++ b/src/test/compile-fail/non_owned-enum.rs @@ -0,0 +1,19 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[non_owned] +enum Foo { A } + +fn bar<T: Owned>(_: T) {} + +fn main() { + let x = A; + bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Owned` +} diff --git a/src/test/compile-fail/non_owned-struct.rs b/src/test/compile-fail/non_owned-struct.rs new file mode 100644 index 00000000000..2d0bc9a7e8e --- /dev/null +++ b/src/test/compile-fail/non_owned-struct.rs @@ -0,0 +1,19 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[non_owned] +struct Foo { a: int } + +fn bar<T: Owned>(_: T) {} + +fn main() { + let x = Foo { a: 5 }; + bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Owned` +} |
