diff --git a/src/test/auxiliary/issue_20389.rs b/src/test/auxiliary/issue_20389.rs new file mode 100644 index 0000000000000..60e3cb13e2e46 --- /dev/null +++ b/src/test/auxiliary/issue_20389.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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(associated_types)] + +pub trait T { + type C; +} diff --git a/src/test/compile-fail/issue-18819.rs b/src/test/compile-fail/issue-18819.rs new file mode 100644 index 0000000000000..32a51ee065b17 --- /dev/null +++ b/src/test/compile-fail/issue-18819.rs @@ -0,0 +1,29 @@ +// Copyright 2015 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(associated_types)] + +trait Foo { + type Item; +} + +struct X; + +impl Foo for X { + type Item = bool; +} + +fn print_x(_: &Foo, extra: &str) { + println!("{}", extra); +} + +fn main() { + print_x(X); //~error this function takes 2 parameters but 1 parameter was supplied +} diff --git a/src/test/compile-fail/issue-19883.rs b/src/test/compile-fail/issue-19883.rs new file mode 100644 index 0000000000000..5f1d0f4ab7bcf --- /dev/null +++ b/src/test/compile-fail/issue-19883.rs @@ -0,0 +1,27 @@ +// Copyright 2015 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(associated_types)] + +trait From { + type Output; + + fn from(src: Src) -> >::Output; +} + +trait To { + // This is a typo, the return type should be `>::Output` + fn to>(self) -> >::Dst { + //~ error: the trait `core::kinds::Sized` is not implemented + From::from(self) + } +} + +fn main() {} diff --git a/src/test/compile-fail/issue-20005.rs b/src/test/compile-fail/issue-20005.rs new file mode 100644 index 0000000000000..d5b04c1864367 --- /dev/null +++ b/src/test/compile-fail/issue-20005.rs @@ -0,0 +1,25 @@ +// Copyright 2015 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(associated_types)] + +trait From { + type Result; + + fn from(src: Src) -> Self::Result; +} + +trait To { + fn to(self) -> >::Result where Dst: From { + From::from(self) //~error: type annotations required + } +} + +fn main() {} diff --git a/src/test/run-pass/issue-17732.rs b/src/test/run-pass/issue-17732.rs new file mode 100644 index 0000000000000..45d3b53132dbf --- /dev/null +++ b/src/test/run-pass/issue-17732.rs @@ -0,0 +1,18 @@ +// Copyright 2015 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(associated_types)] +trait Person { + type string; +} + +struct Someone; + +fn main() {} diff --git a/src/test/run-pass/issue-19479.rs b/src/test/run-pass/issue-19479.rs new file mode 100644 index 0000000000000..b3354530a0c38 --- /dev/null +++ b/src/test/run-pass/issue-19479.rs @@ -0,0 +1,23 @@ +// Copyright 2015 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(associated_types)] +trait Base {} +trait AssocA { + type X: Base; +} +trait AssocB { + type Y: Base; +} +impl AssocB for T { + type Y = ::X; +} + +fn main() {} diff --git a/src/test/run-pass/issue-19631.rs b/src/test/run-pass/issue-19631.rs new file mode 100644 index 0000000000000..d036bab99f880 --- /dev/null +++ b/src/test/run-pass/issue-19631.rs @@ -0,0 +1,23 @@ +// Copyright 2015 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(associated_types)] + +trait PoolManager { + type C; +} + +struct InnerPool { + manager: M, +} + +impl InnerPool where M: PoolManager {} + +fn main() {} diff --git a/src/test/run-pass/issue-19632.rs b/src/test/run-pass/issue-19632.rs new file mode 100644 index 0000000000000..9bc74e5017305 --- /dev/null +++ b/src/test/run-pass/issue-19632.rs @@ -0,0 +1,21 @@ +// Copyright 2015 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(associated_types)] + +trait PoolManager { + type C; +} + +struct InnerPool { + manager: M, +} + +fn main() {} diff --git a/src/test/run-pass/issue-19850.rs b/src/test/run-pass/issue-19850.rs new file mode 100644 index 0000000000000..cd56fe1868924 --- /dev/null +++ b/src/test/run-pass/issue-19850.rs @@ -0,0 +1,30 @@ +// Copyright 2015 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. + +// Test that `::Output` and `Self::Output` are accepted as type annotations in let +// bindings + +#![feature(associated_types)] + +trait Int { + fn one() -> Self; + fn leading_zeros(self) -> uint; +} + +trait Foo { + type T : Int; + + fn test(&self) { + let r: ::T = Int::one(); + let r: Self::T = Int::one(); + } +} + +fn main() {} diff --git a/src/test/run-pass/issue-20009.rs b/src/test/run-pass/issue-20009.rs new file mode 100644 index 0000000000000..535538793d1cf --- /dev/null +++ b/src/test/run-pass/issue-20009.rs @@ -0,0 +1,22 @@ +// Copyright 2015 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. + +// Check that associated types are `Sized` + +#![feature(associated_types)] + +trait Trait { + type Output; + + fn is_sized(&self) -> Self::Output; + fn wasnt_sized(&self) -> Self::Output { loop {} } +} + +fn main() {} diff --git a/src/test/run-pass/issue-20389.rs b/src/test/run-pass/issue-20389.rs new file mode 100644 index 0000000000000..0ef14149c9430 --- /dev/null +++ b/src/test/run-pass/issue-20389.rs @@ -0,0 +1,22 @@ +// Copyright 2015 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. + +// aux-build:issue_20389.rs + +#![feature(associated_types)] +extern crate issue_20389; + +struct Foo; + +impl issue_20389::T for Foo { + type C = (); +} + +fn main() {}