]>
Commit | Line | Data |
---|---|---|
1 | // ignore-tidy-linelength | |
2 | ||
3 | #![feature(rustc_attrs)] | |
4 | ||
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; | |
11 | ||
12 | fn foobar<U: Clone, T: Foo<u8, U, u32>>() -> T { | |
13 | panic!() | |
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> { | |
18 | /// Builds a container with elements from an external iterator. | |
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() { | |
27 | let x = vec![1u8, 2, 3, 4]; | |
28 | let y: Option<Vec<u8>> = collect(x.iter()); // this should give approximately the same error for x.iter().collect() | |
29 | //~^ ERROR | |
30 | ||
31 | let x: String = foobar(); //~ ERROR | |
32 | } |