about summary refs log tree commit diff
path: root/tests/ui/let-else
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-05-30 18:47:50 +0000
committerMichael Goulet <michael@errs.io>2023-06-08 16:30:05 +0000
commitaf54d584b29e6afd7069bfdad071c43c0aa135f5 (patch)
tree144ab1a99ce868ec48ca7d5b3e5990d12c28c3cb /tests/ui/let-else
parent522ae84e0344669ee64754595dd5f04eed9f0d1c (diff)
downloadrust-af54d584b29e6afd7069bfdad071c43c0aa135f5.tar.gz
rust-af54d584b29e6afd7069bfdad071c43c0aa135f5.zip
More robust as_ref/as_deref suggestions
Diffstat (limited to 'tests/ui/let-else')
-rw-r--r--tests/ui/let-else/let-else-ref-bindings.stderr16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/let-else/let-else-ref-bindings.stderr b/tests/ui/let-else/let-else-ref-bindings.stderr
index ada1805e725..7093b5fa9af 100644
--- a/tests/ui/let-else/let-else-ref-bindings.stderr
+++ b/tests/ui/let-else/let-else-ref-bindings.stderr
@@ -6,6 +6,10 @@ LL |     let Some(ref a): Option<&[u8]> = some else { return };
    |
    = note: expected enum `Option<&[u8]>`
               found enum `Option<Vec<u8>>`
+help: try using `.as_deref()` to convert `Option<Vec<u8>>` to `Option<&[u8]>`
+   |
+LL |     let Some(ref a): Option<&[u8]> = some.as_deref() else { return };
+   |                                          +++++++++++
 
 error[E0308]: mismatched types
   --> $DIR/let-else-ref-bindings.rs:20:38
@@ -15,6 +19,10 @@ LL |     let Some(ref a): Option<&[u8]> = &some else { return };
    |
    = note:   expected enum `Option<&[u8]>`
            found reference `&Option<Vec<u8>>`
+help: try using `.as_deref()` to convert `&Option<Vec<u8>>` to `Option<&[u8]>`
+   |
+LL |     let Some(ref a): Option<&[u8]> = &some.as_deref() else { return };
+   |                                           +++++++++++
 
 error[E0308]: mismatched types
   --> $DIR/let-else-ref-bindings.rs:24:34
@@ -26,6 +34,10 @@ LL |     let Some(a): Option<&[u8]> = some else { return };
    |
    = note: expected enum `Option<&[u8]>`
               found enum `Option<Vec<u8>>`
+help: try using `.as_deref()` to convert `Option<Vec<u8>>` to `Option<&[u8]>`
+   |
+LL |     let Some(a): Option<&[u8]> = some.as_deref() else { return };
+   |                                      +++++++++++
 
 error[E0308]: mismatched types
   --> $DIR/let-else-ref-bindings.rs:27:34
@@ -37,6 +49,10 @@ LL |     let Some(a): Option<&[u8]> = &some else { return };
    |
    = note:   expected enum `Option<&[u8]>`
            found reference `&Option<Vec<u8>>`
+help: try using `.as_deref()` to convert `&Option<Vec<u8>>` to `Option<&[u8]>`
+   |
+LL |     let Some(a): Option<&[u8]> = &some.as_deref() else { return };
+   |                                       +++++++++++
 
 error[E0308]: mismatched types
   --> $DIR/let-else-ref-bindings.rs:44:46