Skip to content

Generic parameters VS less then comparison parsing ambiguity #33078

Closed
@matklad

Description

@matklad

The following

fn main() {
    let _ = 1 as i32 < 1;
}

produces a parse error, because the parser expects type parameters after i32, like in 1 as i32<T>. Is this intentional? Looks like there are no tests for this behavior:

user@UNIT-326 [07:47:36 PM] [~/projects/rust/src/test] [master *]
-> % grep "as \\w* <" -R .              
./run-pass/type-macros-hlist.rs:                  < Expr ! ( HList ! [ $ ( $ LHS ) * ] ) as Add < Expr ! (
./run-pass/type-macros-hlist.rs:                  < Expr ! ( $ LHS ) as Add < Expr ! ( $ ( $ RHS ) + ) >> ::

1 as i32 <= 1 and 1 as i32 > 1 are parsed successfully. 1 as i32 << 1 also fails.
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions