]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/unsized6.rs
New upstream version 1.13.0+dfsg1
[rustc.git] / src / test / compile-fail / unsized6.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11// Test `?Sized` local variables.
12
9346a6ac 13trait T {}
1a4d82fc
JJ
14
15fn f1<X: ?Sized>(x: &X) {
16 let _: X; // <-- this is OK, no bindings created, no initializer.
9e0c209e 17 let _: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfie
54a0048b 18 let y: X; //~ERROR `X: std::marker::Sized` is not satisfied
9e0c209e 19 let y: (isize, (X, usize));
1a4d82fc
JJ
20}
21fn f2<X: ?Sized + T>(x: &X) {
54a0048b
SL
22 let y: X; //~ERROR `X: std::marker::Sized` is not satisfied
23 let y: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfied
1a4d82fc
JJ
24}
25
26fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
54a0048b
SL
27 let y: X = *x1; //~ERROR `X: std::marker::Sized` is not satisfied
28 let y = *x2; //~ERROR `X: std::marker::Sized` is not satisfied
29 let (y, z) = (*x3, 4); //~ERROR `X: std::marker::Sized` is not satisfied
1a4d82fc
JJ
30}
31fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
54a0048b
SL
32 let y: X = *x1; //~ERROR `X: std::marker::Sized` is not satisfied
33 let y = *x2; //~ERROR `X: std::marker::Sized` is not satisfied
34 let (y, z) = (*x3, 4); //~ERROR `X: std::marker::Sized` is not satisfied
1a4d82fc
JJ
35}
36
54a0048b
SL
37fn g1<X: ?Sized>(x: X) {} //~ERROR `X: std::marker::Sized` is not satisfied
38fn g2<X: ?Sized + T>(x: X) {} //~ERROR `X: std::marker::Sized` is not satisfied
1a4d82fc
JJ
39
40pub fn main() {
41}