// 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(struct_variant)] // Test sized-ness checking in substitution. // Unbounded. fn f1(x: &X) { f1::(x); } fn f2(x: &X) { f1::(x); f2::(x); } // Bounded. trait T for type {} fn f3(x: &X) { f3::(x); } fn f4(x: &X) { f3::(x); f4::(x); } // Self type. trait T2 for type { fn f() -> ~Self; } struct S; impl T2 for S { fn f() -> ~S { ~S } } fn f5(x: &X) { let _: ~X = T2::f(); } fn f6(x: &X) { let _: ~X = T2::f(); } trait T3 for type { fn f() -> ~Self; } impl T3 for S { fn f() -> ~S { ~S } } fn f7(x: &X) { // This is valid, but the unsized bound on X is irrelevant because any type // which implements T3 must have statically known size. let _: ~X = T3::f(); } trait T4 { fn m1(x: &T4); fn m2(x: &T5); } trait T5 { fn m1(x: &T4); // not an error (for now) fn m2(x: &T5); } trait T6 { fn m1(x: &T4); fn m2(x: &T5); } trait T7 { fn m1(x: &T4); // not an error (for now) fn m2(x: &T5); } // The last field in a struct or variant may be unsized struct S2 { f: X, } struct S3 { f1: int, f2: X, } enum E { V1(X), V2{x: X}, V3(int, X), V4{u: int, x: X}, } pub fn main() { }