Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diagnostic::on_unimplemented notes not displayed #130084

Closed
konnorandrews opened this issue Sep 7, 2024 · 1 comment · Fixed by #130123
Closed

diagnostic::on_unimplemented notes not displayed #130084

konnorandrews opened this issue Sep 7, 2024 · 1 comment · Fixed by #130123
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@konnorandrews
Copy link

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

@konnorandrews konnorandrews added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 7, 2024
@jieyouxu jieyouxu added the D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. label Sep 7, 2024
@FedericoBruzzone
Copy link
Contributor

FedericoBruzzone commented Sep 8, 2024

image

Hi, this would be my first contribution to the rust compiler. I am really excited to try to contribute.

I think I have already solved the problem, I will open the PR as soon as I can.

The note field was being completely ignored. I think what is in the picture is the output that everyone expects, anyway I am waiting for direct feedback.

workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 11, 2024
…r-errors

Report the `note` when specified in `diagnostic::on_unimplemented`

Before this PR the `note` field was completely ignored for some reason, now it is shown (I think) correctly during the hir typechecking phase.

1. Report the `note` when specified in `diagnostic::on_unimplemented`
2. Added a test for unimplemented trait diagnostic
3. Added a test for custom unimplemented trait diagnostic

Close rust-lang#130084

P.S. This is my first PR to rustc.
@bors bors closed this as completed in 5107ff4 Sep 11, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 11, 2024
Rollup merge of rust-lang#130123 - FedericoBruzzone:master, r=compiler-errors

Report the `note` when specified in `diagnostic::on_unimplemented`

Before this PR the `note` field was completely ignored for some reason, now it is shown (I think) correctly during the hir typechecking phase.

1. Report the `note` when specified in `diagnostic::on_unimplemented`
2. Added a test for unimplemented trait diagnostic
3. Added a test for custom unimplemented trait diagnostic

Close rust-lang#130084

P.S. This is my first PR to rustc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants