Skip to content

Remove redundant phrasing from trait bound diagnostic #99418

Closed as not planned
Closed as not planned
@joseph-gio

Description

@joseph-gio

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=5c8b3650fbcd3671c608fd2e6ed118ad

fn foo(x: impl std::ops::Add) {
    todo!()
}

struct X<T>(T);
impl<T: std::ops::Add<Output = T>> std::ops::Add for X<T> {
    type Output = Self;
    fn add(self, rhs: Self) -> Self {
        Self(self.0 + rhs.0)
    }
}

fn main() {
    foo(X("x"));
}

The current output is:

note: required because of the requirements on the impl of `Add` for `X<&str>`

Ideally the output should look like:

note: required by the impl of `Add` for `X<&str>`

The original phrasing is distracting and contributes to visual noise.

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