Skip to content

Commit cb6d018

Browse files
committed
Test that Self properly works in filters
1 parent ec2c213 commit cb6d018

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(rustc_attrs)]
2+
3+
#[rustc_on_unimplemented(on(
4+
all(A = "{integer}", any(Self = "[{integral}; _]",)),
5+
message = "an array of type `{Self}` cannot be built directly from an iterator",
6+
))]
7+
pub trait FromIterator<A>: Sized {
8+
fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self;
9+
}
10+
fn main() {
11+
let iter = 0..42_8;
12+
let x: [u8; 8] = FromIterator::from_iter(iter);
13+
//~^ ERROR an array of type `[u8; 8]` cannot be built directly from an iterator
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0277]: an array of type `[u8; 8]` cannot be built directly from an iterator
2+
--> $DIR/use_self_no_underscore.rs:12:22
3+
|
4+
LL | let x: [u8; 8] = FromIterator::from_iter(iter);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromIterator<{integer}>` is not implemented for `[u8; 8]`
6+
|
7+
help: this trait has no implementations, consider adding one
8+
--> $DIR/use_self_no_underscore.rs:7:1
9+
|
10+
LL | pub trait FromIterator<A>: Sized {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)