Skip to content

Commit b51ff9f

Browse files
committed
2 parents 3dfb29e + 182db6e commit b51ff9f

11 files changed

+255
-0
lines changed

src/test/auxiliary/issue_20389.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2015 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+
#![feature(associated_types)]
12+
13+
pub trait T {
14+
type C;
15+
}

src/test/compile-fail/issue-18819.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2015 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+
#![feature(associated_types)]
12+
13+
trait Foo {
14+
type Item;
15+
}
16+
17+
struct X;
18+
19+
impl Foo for X {
20+
type Item = bool;
21+
}
22+
23+
fn print_x(_: &Foo, extra: &str) {
24+
println!("{}", extra);
25+
}
26+
27+
fn main() {
28+
print_x(X); //~error this function takes 2 parameters but 1 parameter was supplied
29+
}

src/test/compile-fail/issue-19883.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2015 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+
#![feature(associated_types)]
12+
13+
trait From<Src> {
14+
type Output;
15+
16+
fn from(src: Src) -> <Self as From<Src>>::Output;
17+
}
18+
19+
trait To {
20+
// This is a typo, the return type should be `<Dst as From<Self>>::Output`
21+
fn to<Dst: From<Self>>(self) -> <Dst as From<Self>>::Dst {
22+
//~ error: the trait `core::kinds::Sized` is not implemented
23+
From::from(self)
24+
}
25+
}
26+
27+
fn main() {}

src/test/compile-fail/issue-20005.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2015 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+
#![feature(associated_types)]
12+
13+
trait From<Src> {
14+
type Result;
15+
16+
fn from(src: Src) -> Self::Result;
17+
}
18+
19+
trait To {
20+
fn to<Dst>(self) -> <Dst as From<Self>>::Result where Dst: From<Self> {
21+
From::from(self) //~error: type annotations required
22+
}
23+
}
24+
25+
fn main() {}

src/test/run-pass/issue-17732.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2015 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+
#![feature(associated_types)]
12+
trait Person {
13+
type string;
14+
}
15+
16+
struct Someone<P: Person>;
17+
18+
fn main() {}

src/test/run-pass/issue-19479.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2015 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+
#![feature(associated_types)]
12+
trait Base {}
13+
trait AssocA {
14+
type X: Base;
15+
}
16+
trait AssocB {
17+
type Y: Base;
18+
}
19+
impl<T: AssocA> AssocB for T {
20+
type Y = <T as AssocA>::X;
21+
}
22+
23+
fn main() {}

src/test/run-pass/issue-19631.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2015 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+
#![feature(associated_types)]
12+
13+
trait PoolManager {
14+
type C;
15+
}
16+
17+
struct InnerPool<M> {
18+
manager: M,
19+
}
20+
21+
impl<M> InnerPool<M> where M: PoolManager {}
22+
23+
fn main() {}

src/test/run-pass/issue-19632.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 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+
#![feature(associated_types)]
12+
13+
trait PoolManager {
14+
type C;
15+
}
16+
17+
struct InnerPool<M: PoolManager> {
18+
manager: M,
19+
}
20+
21+
fn main() {}

src/test/run-pass/issue-19850.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2015 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 that `<Type as Trait>::Output` and `Self::Output` are accepted as type annotations in let
12+
// bindings
13+
14+
#![feature(associated_types)]
15+
16+
trait Int {
17+
fn one() -> Self;
18+
fn leading_zeros(self) -> uint;
19+
}
20+
21+
trait Foo {
22+
type T : Int;
23+
24+
fn test(&self) {
25+
let r: <Self as Foo>::T = Int::one();
26+
let r: Self::T = Int::one();
27+
}
28+
}
29+
30+
fn main() {}

src/test/run-pass/issue-20009.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015 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+
// Check that associated types are `Sized`
12+
13+
#![feature(associated_types)]
14+
15+
trait Trait {
16+
type Output;
17+
18+
fn is_sized(&self) -> Self::Output;
19+
fn wasnt_sized(&self) -> Self::Output { loop {} }
20+
}
21+
22+
fn main() {}

src/test/run-pass/issue-20389.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015 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+
// aux-build:issue_20389.rs
12+
13+
#![feature(associated_types)]
14+
extern crate issue_20389;
15+
16+
struct Foo;
17+
18+
impl issue_20389::T for Foo {
19+
type C = ();
20+
}
21+
22+
fn main() {}

0 commit comments

Comments
 (0)