mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 19:23:50 +00:00
8ac7d0eef5
For #90528.
29 lines
801 B
Rust
29 lines
801 B
Rust
// Issue #90528: provide helpful suggestions when a trait bound is unsatisfied
|
|
// due to a missed unsizing coercion.
|
|
//
|
|
// This test exercises array variables and a trait implemented on immmutable slices.
|
|
|
|
trait Read {}
|
|
|
|
impl Read for &[u8] {}
|
|
|
|
fn wants_read(_: impl Read) {}
|
|
|
|
fn main() {
|
|
let x = [0u8];
|
|
wants_read(x);
|
|
//~^ ERROR the trait bound `[u8; 1]: Read` is not satisfied
|
|
wants_read(&x);
|
|
//~^ ERROR the trait bound `&[u8; 1]: Read` is not satisfied
|
|
wants_read(&x[..]);
|
|
|
|
let x = &[0u8];
|
|
wants_read(x);
|
|
//~^ ERROR the trait bound `&[u8; 1]: Read` is not satisfied
|
|
wants_read(&x);
|
|
//~^ ERROR the trait bound `&&[u8; 1]: Read` is not satisfied
|
|
wants_read(*x);
|
|
//~^ ERROR the trait bound `[u8; 1]: Read` is not satisfied
|
|
wants_read(&x[..]);
|
|
}
|