Test that Self properly works in filters

This commit is contained in:
mejrs
2025-04-01 02:47:12 +02:00
parent 10ec5cbe96
commit 40e76c1575
2 changed files with 29 additions and 0 deletions
@@ -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`.