// 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. #![allow(unknown_features)] #![feature(box_syntax)] // Test sized-ness checking in substitution. use std::marker; // Unbounded. fn f1(x: &X) { f1::(x); } fn f2(x: &X) { f1::(x); f2::(x); } // Bounded. trait T { fn dummy(&self) { } } fn f3(x: &X) { f3::(x); } fn f4(x: &X) { f3::(x); f4::(x); } // Self type. trait T2 { fn f() -> Box; } struct S; impl T2 for S { fn f() -> Box { box S } } fn f5(x: &X) { let _: Box = T2::f(); } fn f6(x: &X) { let _: Box = T2::f(); } trait T3 { fn f() -> Box; } impl T3 for S { fn f() -> Box { box 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 _: Box = T3::f(); } trait T4 { fn dummy(&self) { } fn m1(&self, x: &T4, y: X); fn m2(&self, x: &T5, y: X); } trait T5 { fn dummy(&self) { } // not an error (for now) fn m1(&self, x: &T4); fn m2(&self, x: &T5); } trait T6 { fn dummy(&self) { } fn m1(&self, x: &T4); fn m2(&self, x: &T5); } trait T7 { fn dummy(&self) { } // not an error (for now) fn m1(&self, x: &T4); fn m2(&self, x: &T5); } // The last field in a struct or variant may be unsized struct S2 { f: X, } struct S3 { f1: isize, f2: X, } enum E { V1(X), V2{x: X}, V3(isize, X), V4{u: isize, x: X}, } pub fn main() { }