summaryrefslogtreecommitdiffstats
path: root/tests/ui/dst/issue-90528-unsizing-suggestion-1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/dst/issue-90528-unsizing-suggestion-1.rs')
-rw-r--r--tests/ui/dst/issue-90528-unsizing-suggestion-1.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/dst/issue-90528-unsizing-suggestion-1.rs b/tests/ui/dst/issue-90528-unsizing-suggestion-1.rs
new file mode 100644
index 000000000..52863e22b
--- /dev/null
+++ b/tests/ui/dst/issue-90528-unsizing-suggestion-1.rs
@@ -0,0 +1,20 @@
+// Issue #90528: provide helpful suggestions when a trait bound is unsatisfied
+// due to a missed unsizing coercion.
+//
+// This test exercises array literals and a trait implemented on immutable slices.
+
+trait Read {}
+
+impl Read for &[u8] {}
+
+fn wants_read(_: impl Read) {}
+
+fn main() {
+ wants_read([0u8]);
+ //~^ ERROR the trait bound `[u8; 1]: Read` is not satisfied
+ wants_read(&[0u8]);
+ //~^ ERROR the trait bound `&[u8; 1]: Read` is not satisfied
+ wants_read(&[0u8][..]);
+ wants_read(&mut [0u8]);
+ //~^ ERROR the trait bound `&mut [u8; 1]: Read` is not satisfied
+}