Skip to content

cargo fix: duplicate diagnostic detection does not handle insert-only replacements #13027

Closed
@ehuss

Description

The following example:

macro_rules! foo {
    () => {
        &1;
    };
}

fn main() {
    foo!();
    foo!();
}

generates a suggestion (on beta 1.55) to insert a fix like this:

let _ = &1;

However, since this diagnostic is triggered from macros, rustc emits two separate machine-applicable suggestions at the exact same spot. That causes rustfix to end up changing the code to:

let _ = let _ = &1;

which fails to compile.

rust-lang/rustfix#131 added detection to avoid applying duplicate suggestions, but I believe it does not handle the case when it is an insert_only suggestion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugCommand-fixS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions