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