]>
Commit | Line | Data |
---|---|---|
85aaf69f SL |
1 | // ignore-tidy-linelength |
2 | ||
60c5eb7d | 3 | #![feature(rustc_attrs)] |
85aaf69f | 4 | |
041b39d2 XL |
5 | pub mod Bar { |
6 | #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{Foo}`"] | |
7 | pub trait Foo<Bar, Baz, Quux> {} | |
8 | } | |
9 | ||
10 | use Bar::Foo; | |
85aaf69f SL |
11 | |
12 | fn foobar<U: Clone, T: Foo<u8, U, u32>>() -> T { | |
476ff2be | 13 | panic!() |
85aaf69f SL |
14 | } |
15 | ||
16 | #[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"] | |
17 | trait MyFromIterator<A> { | |
9fa01778 | 18 | /// Builds a container with elements from an external iterator. |
85aaf69f SL |
19 | fn my_from_iter<T: Iterator<Item=A>>(iterator: T) -> Self; |
20 | } | |
21 | ||
22 | fn collect<A, I: Iterator<Item=A>, B: MyFromIterator<A>>(it: I) -> B { | |
23 | MyFromIterator::my_from_iter(it) | |
24 | } | |
25 | ||
26 | pub fn main() { | |
c30ab7b3 | 27 | let x = vec![1u8, 2, 3, 4]; |
85aaf69f SL |
28 | let y: Option<Vec<u8>> = collect(x.iter()); // this should give approximately the same error for x.iter().collect() |
29 | //~^ ERROR | |
7cac9316 | 30 | |
85aaf69f | 31 | let x: String = foobar(); //~ ERROR |
85aaf69f | 32 | } |