Skip to content

Ambiguity between type ascription and absolute paths #64242

Open
@matklad

Description

@matklad

I am not sure, but I think the following program should be valid:

type X = ();

fn main() {
    let ():::X = ();
}

It currently fails with

error: expected identifier, found `:`
 --> /home/matklad/tmp/main.rs:4:13
  |
4 |     let ():::X = ();
  |             ^ expected identifier

because we don't try to decompose :: token.

I am not sure what should be the behavior of

type X = ();

fn main() {
    let Y:::X = ();
}

but I lean towards allowing it as well, looks like it requires only constant look-ahead to handle.

Anyway, rg ':::' --type rust shows that we don't have a test here.

@petrochenkov what are your thoughts on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an ASTT-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