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/subdiagnostic example struct /struct field fluent slugs outdated #1913

Open
jieyouxu opened this issue Feb 26, 2024 · 0 comments
Open

Comments

@jieyouxu
Copy link
Member

jieyouxu commented Feb 26, 2024

The example on https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html is given as

#[derive(Diagnostic)]
#[diag(hir_analysis_field_already_declared, code = E0124)]
pub struct FieldAlreadyDeclared {
    pub field_name: Ident,
    #[primary_span]
    #[label]
    pub span: Span,
    #[label(previous_decl_label)]
    pub prev_span: Span,
}

but I believe this doesn't work anymore because the label's slug needs to be prefixed by the crate name, so the example needs to become e.g.

#[derive(Diagnostic)]
#[diag(hir_analysis_field_already_declared, code = E0124)]
pub struct FieldAlreadyDeclared {
    pub field_name: Ident,
    #[primary_span]
    #[label]
    pub span: Span,
    #[label(hir_analysis_previous_decl_label)]
    pub prev_span: Span,
}

Probably worth mentioning more explicitly because I wasted 15 minutes trying to debug why my label slugs weren't working lol

@jieyouxu jieyouxu changed the title Diagnostic/subdiagnostic struct /struct field fluent slugs outdated Diagnostic/subdiagnostic example struct /struct field fluent slugs outdated Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant