Skip to content

Remove redundant phrasing from trait bound diagnostic #99418

Closed as not planned
Closed as not planned

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.

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 18, 2022
  2. fmease commented on Jul 18, 2022

    @fmease
    Member

    Coincidentally, there is an open PR (#98807) that tries to address this problem. Not sure if it has stalled.

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

    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