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

ra_syntax: errors on a type cast + comparison #595

Closed
ordian opened this issue Jan 22, 2019 · 6 comments
Closed

ra_syntax: errors on a type cast + comparison #595

ordian opened this issue Jan 22, 2019 · 6 comments
Labels

Comments

@ordian
Copy link

ordian commented Jan 22, 2019

fn is_empty<T: ?Sized>(ptr: *const T) -> bool {
    return ptr as *const usize as usize <= 256;
    //                                   ^^^   
    // ra_syntax expects a type, COMMA, R_ANGLE or SEMI 
}
@DJMcNab
Copy link
Contributor

DJMcNab commented Feb 2, 2019

The relevant code in libsyntax starts here - @matklad, I'm not sure how to make this work in our infra?

@matklad
Copy link
Member

matklad commented Feb 11, 2019

@DJMcNab missing link to linsyntax source?

@DJMcNab
Copy link
Contributor

DJMcNab commented Feb 11, 2019

Oops. I'm on mobile so can't link now, but it's a line about creating a Snapshot and reloading it on syntax errors in the parsed trait bound

@matklad
Copy link
Member

matklad commented Feb 11, 2019

I think that logic exists solely for the purpose of better error message. it should be possible to parse this without lookahead. See rust-lang/rust#42578 and the state of the code before that PR for how this should be done.

We'll add backtracking later, of course, but for the start it's better to keep things simple.

@matklad
Copy link
Member

matklad commented Feb 11, 2019

Specifically, the following is still error in rustc:

return ptr as *const usize as usize < 256;

@kiljacken
Copy link
Contributor

This is working now, so issue can be closed.

@matklad matklad closed this as completed Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants