rust-lang / rust-lang/rust

`rustc_on_unimplemented` should work on specific trait methods

Open
#135,117 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics C-enhancement D-diagnostic-infra T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
`var_with_complicated_type >= another_var_with_complicated_type`
Current output
implementation for `ComplicatedType < ComplicatedType` and `ComplicatedType > ComplicatedType`
Desired output
implementation for `ComplicatedType >= ComplicatedType`
Rationale and extra context

rustc_on_unimplemented should be applicable to specific trait methods, in addition to the trait as a whole. Then, if the error involves calling a specific trait method, the compiler can give a more specific error message.

In the specific case of PartialOrd, this would also avoid repeating both type names twice.

Other cases

Rust Version
git commit 7349f6b50359fd1f11738765b8deec5ee02d8710
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the rustc_on_unimplemented attribute is applied to traits and how PartialOrd diagnostics are produced. Determine where method-specific handling would fit, then verify that comparisons such as >= produce only the relevant ComplicatedType >= ComplicatedType message while existing trait-level behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.