diff options
| author | bors <bors@rust-lang.org> | 2014-09-08 02:36:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-09-08 02:36:15 +0000 |
| commit | dd626b48c495cbcfdbac7319641bd74d2ec0b370 (patch) | |
| tree | 0f9d477e8e6919d1be4f809629c750f45cc9dbc8 /src/test | |
| parent | aaf141d399097d0ea84288b9ad1dc842a6158a5c (diff) | |
| parent | 742f49c961426be422c479c7e47957c45e560ba6 (diff) | |
| download | rust-dd626b48c495cbcfdbac7319641bd74d2ec0b370.tar.gz rust-dd626b48c495cbcfdbac7319641bd74d2ec0b370.zip | |
auto merge of #16933 : nick29581/rust/dst-rvalue, r=nikomatsakis
Closes #16813 r? @nikomatsakis I feel like I should be checking more things in check_rvalues, but not sure what - I don't properly understand expr_use_visitor
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/dst-bad-assign-2.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/dst-bad-deep.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/dst-rvalue.rs | 20 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-5883.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/unsized3.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/unsized6.rs | 2 |
6 files changed, 30 insertions, 2 deletions
diff --git a/src/test/compile-fail/dst-bad-assign-2.rs b/src/test/compile-fail/dst-bad-assign-2.rs index 08e51038104..76becdc855d 100644 --- a/src/test/compile-fail/dst-bad-assign-2.rs +++ b/src/test/compile-fail/dst-bad-assign-2.rs @@ -43,4 +43,5 @@ pub fn main() { let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; let z: Box<ToBar> = box Bar1 {f: 36}; f5.ptr = *z; //~ ERROR dynamically sized type on lhs of assignment + //~^ ERROR E0161 } diff --git a/src/test/compile-fail/dst-bad-deep.rs b/src/test/compile-fail/dst-bad-deep.rs index cf526392283..e2e387e1a48 100644 --- a/src/test/compile-fail/dst-bad-deep.rs +++ b/src/test/compile-fail/dst-bad-deep.rs @@ -22,4 +22,5 @@ pub fn main() { let g: &Fat<[int]> = &f; let h: &Fat<Fat<[int]>> = &Fat { ptr: *g }; //~^ ERROR trying to initialise a dynamically sized struct + //~^^ ERROR E0161 } diff --git a/src/test/compile-fail/dst-rvalue.rs b/src/test/compile-fail/dst-rvalue.rs new file mode 100644 index 00000000000..52b7ea9efa5 --- /dev/null +++ b/src/test/compile-fail/dst-rvalue.rs @@ -0,0 +1,20 @@ +// 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. + +// Check that dynamically sized rvalues are forbidden + +pub fn main() { + let _x: Box<str> = box *"hello world"; + //~^ ERROR E0161 + + let array: &[int] = &[1, 2, 3]; + let _x: Box<[int]> = box *array; + //~^ ERROR E0161 +} diff --git a/src/test/compile-fail/issue-5883.rs b/src/test/compile-fail/issue-5883.rs index f3bbb8051b7..7ea282c599f 100644 --- a/src/test/compile-fail/issue-5883.rs +++ b/src/test/compile-fail/issue-5883.rs @@ -17,6 +17,8 @@ struct Struct { fn new_struct(r: A+'static) -> Struct { //~^ ERROR variable `r` has dynamically sized type Struct { r: r } //~ ERROR trying to initialise a dynamically sized struct + //~^ ERROR E0161 + //~^^ ERROR E0161 } trait Curve {} diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index 50e109b9934..cf42e79b394 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -51,8 +51,10 @@ fn f8<Sized? X>(x1: &S<X>, x2: &S<X>) { // Test some tuples. fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) { - f5(&(*x1, 34i)); //~ERROR instantiating a type parameter with an incompatible type `(S<X>,int)`, - f5(&(32i, *x2)); //~ERROR instantiating a type parameter with an incompatible type `(int,E<X>)`, + f5(&(*x1, 34i)); //~ERROR E0161 + //~^ ERROR instantiating a type parameter with an incompatible type + f5(&(32i, *x2)); //~ERROR E0161 + //~^ ERROR instantiating a type parameter with an incompatible type } // I would like these to fail eventually. diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs index def1146526b..6618cce0214 100644 --- a/src/test/compile-fail/unsized6.rs +++ b/src/test/compile-fail/unsized6.rs @@ -30,11 +30,13 @@ fn f3<Sized? X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { let y: X = *x1; //~ERROR variable `y` has dynamically sized type `X` let y = *x2; //~ERROR variable `y` has dynamically sized type `X` let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X` + //~^ ERROR E0161 } fn f4<Sized? X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { let y: X = *x1; //~ERROR variable `y` has dynamically sized type `X` let y = *x2; //~ERROR variable `y` has dynamically sized type `X` let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X` + //~^ ERROR E0161 } fn g1<Sized? X>(x: X) {} //~ERROR variable `x` has dynamically sized type `X` |
