about summary refs log tree commit diff
path: root/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-03-28 07:01:08 +0200
committerGitHub <noreply@github.com>2023-03-28 07:01:08 +0200
commitd57abf382b8a420115ee4f571f130080875b7f08 (patch)
treedb34c00b0baef75837def87c22ee22a54fa43291 /tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff
parent538e8bdcc8d4402c0c4bb95eb47162ca4e11f74d (diff)
parent28b80059ed3ff5ade532e5547af8be0612927fe5 (diff)
downloadrust-d57abf382b8a420115ee4f571f130080875b7f08.tar.gz
rust-d57abf382b8a420115ee4f571f130080875b7f08.zip
Rollup merge of #108548 - jamen:master, r=compiler-errors
Clarify the 'use a constant in a pattern' error message

```rs
use std::borrow::Cow;

const ERROR_CODE: Cow<'_, str> = Cow::Borrowed("23505");

fn main() {
    let x = Cow::from("23505");

    match x {
        ERROR_CODE => {}
    }
}
```
```
error: to use a constant of type `Cow` in a pattern, `Cow` must be annotated with `#[derive(PartialEq, Eq)]`
 --> src/main.rs:9:9
  |
9 |         ERROR_CODE => {}
  |         ^^^^^^^^^^

error: could not compile `playground` due to previous error
```

It seems helpful to link to StructuralEq in this message. I was a little confused, because `Cow<'_, str>` implements PartialEq and Eq, but they're not derived, which I learned is necessary for structural equality and using constants in patterns (thanks to the Rust community Discord server)

For tests, should I update every occurrence of this message? I see tests where this is still a warning and I'm not sure if I should update those.
Diffstat (limited to 'tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff')
0 files changed, 0 insertions, 0 deletions