Skip to content

diagnostic::on_unimplemented notes not displayed #130084

Closed
@konnorandrews

Description

@konnorandrews

Code

#[diagnostic::on_unimplemented(
    message = "my message",
    label = "my label",
    note = "my note",
)]
pub trait ProviderLt {}

pub trait ProviderExt {
    fn request<R>(&self) {
        todo!()
    }
}

impl<T: ?Sized + ProviderLt> ProviderExt for T {}

struct B;


fn main() {
    B.request();
}

Current output

error[E0599]: my message
  --> src/main.rs:20:7
   |
16 | struct B;
   | -------- method `request` not found for this struct because it doesn't satisfy `B: ProviderExt` or `B: ProviderLt`
...
20 |     B.request();
   |       ^^^^^^^ my label
   |
note: trait bound `B: ProviderLt` was not satisfied
  --> src/main.rs:14:18
   |
14 | impl<T: ?Sized + ProviderLt> ProviderExt for T {}
   |                  ^^^^^^^^^^  -----------     -
   |                  |
   |                  unsatisfied trait bound introduced here
note: the trait `ProviderLt` must be implemented
  --> src/main.rs:6:1
   |
6  | pub trait ProviderLt {}
   | ^^^^^^^^^^^^^^^^^^^^
   = help: items from traits can only be used if the trait is implemented and in scope
note: `ProviderExt` defines an item `request`, perhaps you need to implement it
  --> src/main.rs:8:1
   |
8  | pub trait ProviderExt {
   | ^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0599`.

Desired output

"my note" should appear somewhere in the diagnostic.

Rationale and extra context

Note are displayed in other cases, its something to do with the extra notes this one code generates.

Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f17d6d22abfdaa2607c3002779e5aa16

Other cases

No response

Rust Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-diagnostic-infraDiagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself.T-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