diagnostic::on_unimplemented fails to trigger
Open
Nobody has claimed this yet.
A-diagnostics
D-diagnostic-infra
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
#[diagnostic::on_unimplemented(
message = "message",
)]
pub trait ProviderLt {}
pub trait ProviderExt {
fn request<R>(&self) {
todo!()
}
}
impl<T: ?Sized + ProviderLt> ProviderExt for T {}
struct A<'a>(&'a ());
struct B; // works
fn main() {
A(&()).request();
B.request(); // works
}
Current output
error[E0599]: the method `request` exists for struct `A<'_>`, but its trait bounds were not satisfied
--> src/main.rs:19:12
|
14 | struct A<'a>(&'a ());
| ------------ method `request` not found for this struct because it doesn't satisfy `A<'_>: ProviderExt` or `A<'_>: ProviderLt`
...
19 | A(&()).request();
| ^^^^^^^ method cannot be called on `A<'_>` due to unsatisfied trait bounds
|
note: trait bound `A<'_>: ProviderLt` was not satisfied
--> src/main.rs:12:18
|
12 | impl<T: ?Sized + ProviderLt> ProviderExt for T {}
| ^^^^^^^^^^ ----------- -
| |
| unsatisfied trait bound introduced here
note: the trait `ProviderLt` must be implemented
--> src/main.rs:4:1
|
4 | 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:6:1
|
6 | pub trait ProviderExt {
| ^^^^^^^^^^^^^^^^^^^^^
error[E0599]: message
--> src/main.rs:21:7
|
16 | struct B; // works
| -------- method `request` not found for this struct because it doesn't satisfy `B: ProviderExt` or `B: ProviderLt`
...
21 | B.request(); // works
| ^^^^^^^ method cannot be called on `B` due to unsatisfied trait bounds
|
note: trait bound `B: ProviderLt` was not satisfied
--> src/main.rs:12:18
|
12 | impl<T: ?Sized + ProviderLt> ProviderExt for T {}
| ^^^^^^^^^^ ----------- -
| |
| unsatisfied trait bound introduced here
note: the trait `ProviderLt` must be implemented
--> src/main.rs:4:1
|
4 | 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:6:1
|
6 | pub trait ProviderExt {
| ^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0599`.
Desired output
The first error should also be using the "message" message like the second one.
Rationale and extra context
Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f9313422f1b0da95507832b37b234c30
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the case from the issue's src/main.rs snippet using the linked Rust Playground or rustc 1.81.0, then trace the diagnostic::on_unimplemented handling for the two E0599 errors. Done means the first error uses the specified "message" text, matching the second error, with regression coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100