Skip to content

on_unimplemented label and notes are not displayed for transitive bounds #134700

Open
@cramertj

Description

@cramertj

Code

struct S;

#[diagnostic::on_unimplemented(
    message = "unable to generate binding for function",
    label = "Some label",
    note = "note 1",
    note = "note 2",
    note = "note 3",
)]
trait Failure7<'a> {}

impl<'a> Clone for S where S: Failure7<'a> {
    fn clone(&self) -> Self {
        unreachable!()
    }
}

fn main() {
    fn take_clone(_: impl Clone) {}
    take_clone(S);
}

Current output

error[E0277]: the trait bound `S: Clone` is not satisfied
  --> src/main.rs:20:16
   |
20 |     take_clone(S);
   |     ---------- ^ the trait `Clone` is not implemented for `S`
   |     |
   |     required by a bound introduced by this call
   |
note: required for `S` to implement `Clone`
  --> src/main.rs:12:10
   |
12 | impl<'a> Clone for S where S: Failure7<'a> {
   |          ^^^^^     ^          ------------ unsatisfied trait bound introduced here
note: required by a bound in `take_clone`
  --> src/main.rs:19:27
   |
19 |     fn take_clone(_: impl Clone) {}
   |                           ^^^^^ required by this bound in `take_clone`
help: consider borrowing here
   |
20 |     take_clone(&S);
   |                +

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (bin "playground") due to 1 previous error

Rationale and extra context

The output should include the provided label and note values, as it does when depending on the trait bound directly.

Rust Version

1.83.0

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