Skip to content

SessionDiagnostic derive does not consider #[label = "..."] on Span field valid #100714

Closed
@Xiretza

Description

@Xiretza

I tried this code:

#[derive(SessionDiagnostic)]
#[error(parser::if_expression_missing_condition)]
pub(crate) struct IfExpressionMissingCondition {
    #[primary_span]
    #[label = "condition_label"]
    pub if_span: Span,
    #[label = "block_label"]
    pub block_span: Span,
}

I expected to see this happen: As explained in the current rustc-dev-guide, the error message is fetched from parser_if_expression_missing_condition, and the attributes .condition_label and .block_label of this fluent resource are used to create two note subdiagnostics.

Instead, this happened:

error: `#[label = ...]` is not a valid attribute
   --> compiler/rustc_parse/src/parser/diagnostics.rs:568:5
    |
568 |     #[label = "condition_label"]
    |     ^

Working off current rustc master, 9c20b2a.

cc @davidtwco

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-translationArea: Translation infrastructure, and migrating existing diagnostics to SessionDiagnosticC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions