Skip to content

Support #[diagnostic::on_unimplemented] on methods #148512

@estebank

Description

@estebank

The following code

struct SetFoo; struct SetBar; struct S<Foo, Bar>(Foo, Bar); impl S<SetFoo, ()> { #[diagnostic::on_unimplemented(message= "builder with missing mandatory fields", label="you must set every mandatory field")] fn build() {} } fn main() { S::<(), SetBar>::build(); }

should let you customize the output of E0599. Currently, it is

error[E0599]: no function or associated item named `build` found for struct `S<(), SetBar>` in the current scope --> src/main.rs:11:22 | 4 | struct S<Foo, Bar>(Foo, Bar); | ------------------ function or associated item `build` not found for this struct ... 11 | S::<(), SetBar>::build(); | ^^^^^ function or associated item not found in `S<(), SetBar>` | = note: the function or associated item was found for - `S<SetFoo, ()>` 

but it should allow you to output

error[E0599]: builder with missing mandatory fields --> src/main.rs:11:22 | 4 | struct S<Foo, Bar>(Foo, Bar); | ------------------ function or associated item `build` not found for this struct ... 11 | S::<(), SetBar>::build(); | ^^^^^ you must set every mandatory field | = note: function or associated item not found in `S<(), SetBar>` = note: the function or associated item was found for - `S<SetFoo, ()>` 

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsF-on_unimplementedError messages that can be tackled with `#[rustc_on_unimplemented]`P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions