1 // Issue #90528: provide helpful suggestions when a trait bound is unsatisfied
2 // due to a missed unsizing coercion.
3 //
4 // This test exercises array variables and a trait implemented on mutable slices.
5
6 trait Write {}
7
8 impl Write for &mut [u8] {}
9
wants_write(_: impl Write)10 fn wants_write(_: impl Write) {}
11
main()12 fn main() {
13 let mut x = [0u8];
14 wants_write(x);
15 //~^ ERROR the trait bound `[u8; 1]: Write` is not satisfied
16 wants_write(&mut x);
17 //~^ ERROR the trait bound `&mut [u8; 1]: Write` is not satisfied
18 wants_write(&mut x[..]);
19
20 let x = &mut [0u8];
21 wants_write(x);
22 //~^ ERROR the trait bound `&mut [u8; 1]: Write` is not satisfied
23 wants_write(*x);
24 //~^ ERROR the trait bound `[u8; 1]: Write` is not satisfied
25 wants_write(&mut x[..]);
26 }
27