Skip to content

More accurate suggestion for missing binop trait bounds #96442

Open
@estebank

Description

@estebank

#94034 (comment)

We currently emit

LL | impl<B: std::ops::Add> Add for D<B> {
   |       +++++++++++++++

but it should be

LL | impl<B: std::ops::Add<Output = B>> Add for D<B> {
   |       +++++++++++++++++++++++++++

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
P-lowLow priority
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
D-papercutDiagnostics: An error or lint that needs small tweaks.
D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.
on Apr 26, 2022
willcrichton

willcrichton commented on Apr 26, 2022

@willcrichton
Contributor

I will take a stab at this soon. I am fairly certain I know how to do it -- there's an Expectation type that describes the expected return type, and if that expectation exists, we can use it to bound Output=<Expectation>.

I tried implementing that today. This is the core change: willcrichton@e652939#diff-ea6f9d55e90333a1f5fc5e202d46862a6a031410831f2df42317ac024f821162R519-R539

This change seems to introduce some noise in other tests involving binops that will require manual fixing. But maybe next weekend I will try to finish this.

@rustbot claim

added a commit that references this issue on Jul 16, 2022

Auto merge of rust-lang#96482 - willcrichton:fix-trait-suggestion-for…

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-papercutDiagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.P-lowLow priorityT-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

      Participants

      @willcrichton@estebank

      Issue actions

        More accurate suggestion for missing binop trait bounds · Issue #96442 · rust-lang/rust