Skip to content

Duplicated errors on UB inside a promoted #61821

Closed
@estebank

Description

@estebank

The following output should only emit the error once:

#![warn(const_err)]

fn main() {
    &{ [1, 2, 3][4] };
}
error: index out of bounds: the len is 3 but the index is 4
  --> $DIR/array-literal-index-oob.rs:2:7
   |
LL |     &{[1, 2, 3][4]};
   |       ^^^^^^^^^^^^
   |
   = note: `#[deny(const_err)]` on by default

error: reaching this expression at runtime will panic or abort
  --> $DIR/array-literal-index-oob.rs:2:7
   |
LL |     &{[1, 2, 3][4]};
   |     --^^^^^^^^^^^^-
   |       |
   |       index out of bounds: the len is 3 but the index is 4

error: aborting due to 2 previous errors

Follow up to #61598

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.P-lowLow priorityT-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