Skip to content

exhustiveness checking in commented code suggests duplicating comments #101762

Closed
@pro465

Description

@pro465

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=enum%20S%20%7B%0A%20%20%20%20O%2C%0A%20%20%20%20P%2C%0A%20%20%20%20Q%2C%0A%7D%0A%0Afn%20main()%20%7B%0A%20%20%20%20match%20S%3A%3AO%20%7B%0A%20%20%20%20%20%20%20%20S%3A%3AO%20%3D%3E%20%7B%7D%0A%20%20%20%20%20%20%20%20%2F*%0A%20%20%20%20%20%20%20%20%20*%20stuff%2C%20stuff%2C%0A%20%20%20%20%20%20%20%20%20*%20siherfhhsf%0A%20%20%20%20%20%20%20%20%20*%20syrrehhgsdiiey%0A%20%20%20%20%20%20%20%20%20*%2F%0A%20%20%20%20%20%20%20%20S%3A%3AP%20%3D%3E%20%7B%7D%0A%20%20%20%20%7D%0A%7D

The current output is:

Compiling playground v0.0.1 (/playground)
error[[E0004]](https://doc.rust-lang.org/stable/error-index.html#E0004): non-exhaustive patterns: `Q` not covered
 --> src/main.rs:8:11
  |
8 |     match S::O {
  |           ^^^^ pattern `Q` not covered
  |
note: `S` defined here
 --> src/main.rs:4:5
  |
1 | enum S {
  |      -
...
4 |     Q,
  |     ^ not covered
  = note: the matched value is of type `S`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
  |
15~         S::P => {}
16+         /*
17+          * stuff, stuff,
18+          * siherfhhsf
19+          * syrrehhgsdiiey
20+          */
21+         Q => todo!()
  |

Ideally the output should look like:

<proposed output>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions