Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong precedence between as and &[mut] #1851

Closed
oxalica opened this issue Sep 15, 2019 · 0 comments · Fixed by #1951
Closed

Wrong precedence between as and &[mut] #1851

oxalica opened this issue Sep 15, 2019 · 0 comments · Fixed by #1951

Comments

@oxalica
Copy link
Contributor

oxalica commented Sep 15, 2019

A common example:

fn main() {
    let a = 1;
    let _ = &a as *const _;
}

Will be parsed as:

<... omitted ...>
          REF_EXPR@[39; 53)
            AMP@[39; 40) "&"
            CAST_EXPR@[40; 53)
              PATH_EXPR@[40; 41)
                PATH@[40; 41)
                  PATH_SEGMENT@[40; 41)
                    NAME_REF@[40; 41)
                      IDENT@[40; 41) "a"
              WHITESPACE@[41; 42) " "
              AS_KW@[42; 44) "as"
              WHITESPACE@[44; 45) " "
              POINTER_TYPE@[45; 53)
                STAR@[45; 46) "*"
                CONST_KW@[46; 51) "const"
                WHITESPACE@[51; 52) " "
                PLACEHOLDER_TYPE@[52; 53)
                  UNDERSCORE@[52; 53) "_"
<... omitted ...>

The &[mut] operator should have higher precedence than as.

Related issue: #279 (closed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant