2015-01-10 18:21:27 +00:00
|
|
|
// ignore-tidy-linelength
|
|
|
|
|
2019-10-25 05:19:07 +00:00
|
|
|
#![feature(rustc_attrs)]
|
2015-01-11 15:23:24 +00:00
|
|
|
|
2017-07-01 00:06:51 +00:00
|
|
|
pub mod Bar {
|
|
|
|
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{Foo}`"]
|
|
|
|
pub trait Foo<Bar, Baz, Quux> {}
|
|
|
|
}
|
|
|
|
|
|
|
|
use Bar::Foo;
|
2015-01-10 18:21:27 +00:00
|
|
|
|
|
|
|
fn foobar<U: Clone, T: Foo<u8, U, u32>>() -> T {
|
2016-10-25 23:28:20 +00:00
|
|
|
panic!()
|
2015-01-10 18:21:27 +00:00
|
|
|
}
|
|
|
|
|
2015-01-11 12:58:06 +00:00
|
|
|
#[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"]
|
2015-01-10 18:21:27 +00:00
|
|
|
trait MyFromIterator<A> {
|
2019-02-09 21:23:30 +00:00
|
|
|
/// Builds a container with elements from an external iterator.
|
2015-01-10 18:21:27 +00:00
|
|
|
fn my_from_iter<T: Iterator<Item=A>>(iterator: T) -> Self;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn collect<A, I: Iterator<Item=A>, B: MyFromIterator<A>>(it: I) -> B {
|
|
|
|
MyFromIterator::my_from_iter(it)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
2016-10-29 21:54:04 +00:00
|
|
|
let x = vec![1u8, 2, 3, 4];
|
2015-01-10 18:21:27 +00:00
|
|
|
let y: Option<Vec<u8>> = collect(x.iter()); // this should give approximately the same error for x.iter().collect()
|
|
|
|
//~^ ERROR
|
2017-04-26 16:42:27 +00:00
|
|
|
|
2015-01-10 18:21:27 +00:00
|
|
|
let x: String = foobar(); //~ ERROR
|
|
|
|
}
|