Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Diagnostic/subdiagnostic example struct /struct field fluent slugs outdated #1913

Open
Labels
A-diagnosticsArea: diagnostics A-diagnostics-infraArea: diagnostics infrastructure A-translationArea: diagnostics translation and other translations E-mediumDifficulty: might require some prior knowledge or code reading I-outdatedIssue: info is outdated T-compilerRelevant to compiler team
@jieyouxu

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: diagnostics A-diagnostics-infraArea: diagnostics infrastructure A-translationArea: diagnostics translation and other translations E-mediumDifficulty: might require some prior knowledge or code reading I-outdatedIssue: info is outdated T-compilerRelevant to compiler team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /