Skip to content

Incorrect argument index highlighting an error for type mismatch on static trait function calls #122938

Open
@arduano

Description

@arduano
use std::fmt::Debug;

fn run() {
    let mut not_int = String::new();
    Foo::write_to(123, not_int); // Error span is on the wrong argument here
}

pub trait Foo<W: Debug, Err = ()> {
    fn write_to(self, not_int: W);
}

struct Test;
impl Foo<String> for Test {
    fn write_to(self, not_int: String) {}
}

Playground link

Creates the following error:
image

rustc --version --verbose:

rustc 1.79.0-nightly (85e449a32 2024-03-22)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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