Skip to content

E0623 Lifetime elision error emitted twice #90250

Open
@Noratrieb

Description

@Noratrieb

Given the following code:

fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
    core::mem::swap(&mut slice_a, &mut slice_b);
}

The current output is:

error[E0623]: lifetime mismatch
 --> test.rs:2:35
  |
1 | fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
  |                 ---------           --------- these two types are declared with different lifetimes...
2 |     core::mem::swap(&mut slice_a, &mut slice_b);
  |                                   ^^^^^^^^^^^^ ...but data from `slice_b` flows into `slice_a` here

error[E0623]: lifetime mismatch
 --> test.rs:2:35
  |
1 | fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
  |                 ---------           ---------
  |                 |
  |                 these two types are declared with different lifetimes...
2 |     core::mem::swap(&mut slice_a, &mut slice_b);
  |                                   ^^^^^^^^^^^^ ...but data from `slice_a` flows into `slice_b` here

This error is emitted twice, event though both errors have the same cause.

Ideally it would only be emitted for one direction.

Related: #90179

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