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
Labels
A-diagnostics Area: diagnostics A-diagnostics-infra Area: diagnostics infrastructure A-translation Area: diagnostics translation and other translations E-medium Difficulty: might require some prior knowledge or code reading I-outdated Issue: info is outdated T-compiler Relevant to compiler team

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
@jieyouxu jieyouxu added T-compiler Relevant to compiler team A-diagnostics Area: diagnostics A-diagnostics-infra Area: diagnostics infrastructure A-translation Area: diagnostics translation and other translations I-outdated Issue: info is outdated E-medium Difficulty: might require some prior knowledge or code reading labels Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: diagnostics A-diagnostics-infra Area: diagnostics infrastructure A-translation Area: diagnostics translation and other translations E-medium Difficulty: might require some prior knowledge or code reading I-outdated Issue: info is outdated T-compiler Relevant to compiler team
Projects
None yet
Development

No branches or pull requests

1 participant