diff options
| author | bors <bors@rust-lang.org> | 2015-01-20 23:03:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-20 23:03:09 +0000 |
| commit | 29bd9a06efd2f8c8a7b1102e2203cc0e6ae2dcba (patch) | |
| tree | 98824cc18b1c65ff09f383438d79ad2d0a0e2ea8 /src/test | |
| parent | 583c5c589ed02e5b6b14a576e35e0ce68988d949 (diff) | |
| parent | 631896dc1996d239a532b0ce02d5fe886660149e (diff) | |
Auto merge of #21439 - alexcrichton:rollup, r=alexcrichton
Continuation of https://github.com/rust-lang/rust/pull/21428
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/coerce-mut.rs | 20 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-12028.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/method-self-arg-2.rs | 5 | ||||
| -rw-r--r-- | src/test/compile-fail/slice-mut.rs | 6 | ||||
| -rw-r--r-- | src/test/run-pass/issue-21384.rs | 27 | ||||
| -rw-r--r-- | src/test/run-pass/issue-21402.rs | 18 |
6 files changed, 74 insertions, 4 deletions
diff --git a/src/test/compile-fail/coerce-mut.rs b/src/test/compile-fail/coerce-mut.rs new file mode 100644 index 00000000000..30c1b66a7b8 --- /dev/null +++ b/src/test/compile-fail/coerce-mut.rs @@ -0,0 +1,20 @@ +// Copyright 2015 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. + +fn f(x: &mut i32) {} + +fn main() { + let x = 0; + f(&x); + //~^ ERROR mismatched types + //~| expected `&mut i32` + //~| found `&_` + //~| values differ in mutability +} diff --git a/src/test/compile-fail/issue-12028.rs b/src/test/compile-fail/issue-12028.rs index 24ffc5e9ee3..980385ce4cc 100644 --- a/src/test/compile-fail/issue-12028.rs +++ b/src/test/compile-fail/issue-12028.rs @@ -43,7 +43,7 @@ impl<H: StreamHasher> Hash<H> for u8 { impl<H: StreamHasher> StreamHash<H> for u8 { fn input_stream(&self, stream: &mut H::S) { - Stream::input(&*stream, &[*self]); + Stream::input(stream, &[*self]); } } diff --git a/src/test/compile-fail/method-self-arg-2.rs b/src/test/compile-fail/method-self-arg-2.rs index ad255ecd9c0..dd5b2004145 100644 --- a/src/test/compile-fail/method-self-arg-2.rs +++ b/src/test/compile-fail/method-self-arg-2.rs @@ -22,6 +22,7 @@ fn main() { let y = &mut x; Foo::bar(&x); //~ERROR cannot borrow `x` - let x = Foo; - Foo::baz(&x); //~ERROR cannot borrow immutable borrowed content as mutable + let mut x = Foo; + let y = &mut x; + Foo::baz(&mut x); //~ERROR cannot borrow `x` } diff --git a/src/test/compile-fail/slice-mut.rs b/src/test/compile-fail/slice-mut.rs index 0e1dd0d8f6c..a1747f3b6bd 100644 --- a/src/test/compile-fail/slice-mut.rs +++ b/src/test/compile-fail/slice-mut.rs @@ -13,5 +13,9 @@ fn main() { let x: &[isize] = &[1, 2, 3, 4, 5]; // Immutable slices are not mutable. - let y: &mut[_] = &x[2..4]; //~ ERROR cannot borrow immutable borrowed content as mutable + let y: &mut[_] = &x[2..4]; + //~^ ERROR mismatched types + //~| expected `&mut [_]` + //~| found `&_` + //~| values differ in mutability } diff --git a/src/test/run-pass/issue-21384.rs b/src/test/run-pass/issue-21384.rs new file mode 100644 index 00000000000..0ec33d218f9 --- /dev/null +++ b/src/test/run-pass/issue-21384.rs @@ -0,0 +1,27 @@ +// 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 <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. + +fn test<T : Clone>(arg: T) -> T { + arg.clone() +} + +#[derive(PartialEq)] +struct Test(int); + +fn main() { + // Check that ranges implement clone + assert!(test(1..5) == (1..5)); + assert!(test(..5) == (..5)); + assert!(test(1..) == (1..)); + assert!(test(FullRange) == (FullRange)); + + // Check that ranges can still be used with non-clone limits + assert!((Test(1)..Test(5)) == (Test(1)..Test(5))); +} diff --git a/src/test/run-pass/issue-21402.rs b/src/test/run-pass/issue-21402.rs new file mode 100644 index 00000000000..6be7cea2928 --- /dev/null +++ b/src/test/run-pass/issue-21402.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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. + +#[derive(Hash)] +struct Foo { + a: Vec<bool>, + b: (bool, bool), + c: [bool; 2], +} + +fn main() {} |
