Skip to content

Commit 96e1481

Browse files
committed
---
yaml --- r: 167711 b: refs/heads/master c: 9675488 h: refs/heads/master i: 167709: 01c49cb 167707: 0465c13 167703: b68f853 167695: d75d1b2 167679: 1969c7c v: v3
1 parent 925b28d commit 96e1481

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6cb425d964637da3ffa99cac902bf8fe696baf08
2+
refs/heads/master: 9675488ef9480365c2d26e23bfd649128037880f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: c89417130f042c58adc60012e7cddc4ef70b70b9
55
refs/heads/try: 5204084bd2e46af7cc6e0147430e44dd0d657bbb
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2014 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 we reliably check the value of the associated type.
12+
13+
#![crate_type = "lib"]
14+
#![feature(associated_types)]
15+
#![no_implicit_prelude]
16+
17+
use std::option::Option::{None, Some, mod};
18+
use std::vec::Vec;
19+
20+
trait Iterator {
21+
type Item;
22+
23+
fn next(&mut self) -> Option<Self::Item>;
24+
}
25+
26+
fn is_iterator_of<A, I: Iterator<Item=A>>(_: &I) {}
27+
28+
struct Adapter<I> {
29+
iter: I,
30+
found_none: bool,
31+
}
32+
33+
impl<T, I> Iterator for Adapter<I> where I: Iterator<Item=Option<T>> {
34+
type Item = T;
35+
36+
fn next(&mut self) -> Option<T> {
37+
loop {}
38+
}
39+
}
40+
41+
fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) {
42+
is_iterator_of::<Option<T>, _>(&it); // Sanity check
43+
let adapter = Adapter { iter: it, found_none: false };
44+
is_iterator_of::<T, _>(&adapter); // OK
45+
is_iterator_of::<Option<T>, _>(&adapter); //~ ERROR type mismatch
46+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 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 we are able to have an impl that defines an associated type
12+
// before the actual trait.
13+
14+
#![feature(associated_types)]
15+
impl X for f64 { type Y = int; }
16+
trait X {type Y; }
17+
fn main() {}

0 commit comments

Comments
 (0)