mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Test that Self properly works in filters
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_on_unimplemented(on(
|
||||
all(A = "{integer}", any(Self = "[{integral}; _]",)),
|
||||
message = "an array of type `{Self}` cannot be built directly from an iterator",
|
||||
))]
|
||||
pub trait FromIterator<A>: Sized {
|
||||
fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self;
|
||||
}
|
||||
fn main() {
|
||||
let iter = 0..42_8;
|
||||
let x: [u8; 8] = FromIterator::from_iter(iter);
|
||||
//~^ ERROR an array of type `[u8; 8]` cannot be built directly from an iterator
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
error[E0277]: an array of type `[u8; 8]` cannot be built directly from an iterator
|
||||
--> $DIR/use_self_no_underscore.rs:12:22
|
||||
|
|
||||
LL | let x: [u8; 8] = FromIterator::from_iter(iter);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromIterator<{integer}>` is not implemented for `[u8; 8]`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/use_self_no_underscore.rs:7:1
|
||||
|
|
||||
LL | pub trait FromIterator<A>: Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Reference in New Issue
Block a user