Point at const
definition when used instead of a binding in a let
statement
After: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | const PAT: u32 = 0; | -------------- missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable ... LL | let PAT = v1; | ^^^ | | | pattern `1_u32..=u32::MAX` not covered | help: introduce a variable instead: `PAT_var` | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` ``` Before: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | let PAT = v1; | ^^^ | | | pattern `1_u32..=u32::MAX` not covered | missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `PAT_var` | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` ```
This commit is contained in:
parent
917a50a039
commit
ff2f7a7a83
18 changed files with 78 additions and 28 deletions
|
@ -860,8 +860,10 @@ pub(crate) struct PatternNotCovered<'s, 'tcx> {
|
|||
pub(crate) uncovered: Uncovered,
|
||||
#[subdiagnostic]
|
||||
pub(crate) inform: Option<Inform>,
|
||||
#[label(mir_build_confused)]
|
||||
pub(crate) interpreted_as_const: Option<Span>,
|
||||
#[subdiagnostic]
|
||||
pub(crate) interpreted_as_const: Option<InterpretedAsConst>,
|
||||
pub(crate) interpreted_as_const_sugg: Option<InterpretedAsConst>,
|
||||
#[subdiagnostic]
|
||||
pub(crate) adt_defined_here: Option<AdtDefinedHere<'tcx>>,
|
||||
#[note(mir_build_privately_uninhabited)]
|
||||
|
@ -913,7 +915,6 @@ impl<'tcx> Subdiagnostic for AdtDefinedHere<'tcx> {
|
|||
code = "{variable}_var",
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
#[label(mir_build_confused)]
|
||||
pub(crate) struct InterpretedAsConst {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue