-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Misleading error message with precedence issue involving "as" #36367
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
Comments
Ready-to-paste example : fn main() {
let i : i64 = 5 ;
if i as usize < std::mem::size_of::<i64>() {
println!("Case A");
}
if i as usize < 5 {
println!("Case B");
}
} |
I just discovered that "usize", "i64", and stuff like this can actually be a variable name. This might why the error is so confusing. |
See also #36206. |
We spit out the garbage below today. Presumably, this means that usize<...> is what's being parsed.
|
Mark-Simulacrum
added
the
A-diagnostics
Area: Messages for errors, warnings, and lints
label
May 13, 2017
Closing as fixed since we suggest what's happening today.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider the following code:
This code has a precedence issue:
as
binds looser than<
, so I think this attempts to parse what comes after theas
as a type,usize<std::mem::size_of ...
, parsing the<
as a generic. That results in the following error message:This leads the user down the wrong path. Ideally, rustc should provide an error that hints at the precedence issue instead.
The text was updated successfully, but these errors were encountered: