about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
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
commita7c07cf7315c8ed74723d0e251ef01847e75a892 (patch)
treef77baa32a483e03b249a07cf149fe6346c083bcc /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
parent5ce70ed8dafeb3029cc7b493570a6f3e1c2f422b (diff)
parent73c34cbaf71b40bd7944b3eb3d64009b93d05873 (diff)
downloadrust-a7c07cf7315c8ed74723d0e251ef01847e75a892.tar.gz
rust-a7c07cf7315c8ed74723d0e251ef01847e75a892.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 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions