Skip to content

Field access of block: discrepancy between parser-lalr and rustc #28379

Closed as not planned
@rprichard

Description

@rprichard
struct S { f: u32 }
fn main() {
    { S { f: 42 } }.f; // rustc accepts, parser-lalr rejects
    { 42 } as i32; // rustc and parser-lalr reject
    { 42 } == 42; // rustc and parser-lalr reject
}

The grammar in src/grammar/parser-lalr.y should probably be relaxed to accept the first example.

AFAIK, Rust could allow the other two cases (and others), because there are no statements or expressions that begin with as or ==.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-grammarArea: The grammar of RustC-bugCategory: This is a bug.I-needs-decisionIssue: In need of a decision.P-mediumMedium priorityT-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions