Add simple tests for Sized
This commit is contained in:
parent
32cd9b3274
commit
5113f68a86
7 changed files with 75 additions and 0 deletions
14
src/test/compile-fail/unsized-bare-typaram.rs
Normal file
14
src/test/compile-fail/unsized-bare-typaram.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// error-pattern: instantiating a type parameter with an incompatible type
|
||||||
|
fn bar<T: Sized>() { }
|
||||||
|
fn foo<T>() { bar::<T>() }
|
||||||
|
fn main() { }
|
14
src/test/compile-fail/unsized-enum.rs
Normal file
14
src/test/compile-fail/unsized-enum.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// error-pattern: instantiating a type parameter with an incompatible type
|
||||||
|
fn bar<T: Sized>() { }
|
||||||
|
fn foo<T>() { bar::<Option<T>>() }
|
||||||
|
fn main() { }
|
17
src/test/compile-fail/unsized-struct.rs
Normal file
17
src/test/compile-fail/unsized-struct.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// error-pattern: instantiating a type parameter with an incompatible type
|
||||||
|
|
||||||
|
struct Foo<T> { data: T }
|
||||||
|
|
||||||
|
fn bar<T: Sized>() { }
|
||||||
|
fn foo<T>() { bar::<Foo<T>>() }
|
||||||
|
fn main() { }
|
BIN
src/test/run-pass/sized-borrowed-pointer
Executable file
BIN
src/test/run-pass/sized-borrowed-pointer
Executable file
Binary file not shown.
15
src/test/run-pass/sized-borrowed-pointer.rs
Normal file
15
src/test/run-pass/sized-borrowed-pointer.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// Possibly-dynamic size of typaram should be cleared at pointer boundary.
|
||||||
|
|
||||||
|
fn bar<T: Sized>() { }
|
||||||
|
fn foo<T>() { bar::<&T>() }
|
||||||
|
fn main() { }
|
BIN
src/test/run-pass/sized-owned-pointer
Executable file
BIN
src/test/run-pass/sized-owned-pointer
Executable file
Binary file not shown.
15
src/test/run-pass/sized-owned-pointer.rs
Normal file
15
src/test/run-pass/sized-owned-pointer.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// Possibly-dynamic size of typaram should be cleared at pointer boundary.
|
||||||
|
|
||||||
|
fn bar<T: Sized>() { }
|
||||||
|
fn foo<T>() { bar::<~T>() }
|
||||||
|
fn main() { }
|
Loading…
Add table
Add a link
Reference in a new issue