-
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
Added error explanations for E0308, E0309, and E0310 #24576
Conversation
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
that there is a mismatch in the expected type that the compiler inferred, and | ||
the actual type that the user defined a variable as. | ||
|
||
let a: char = 7; // An integral type can't contained in a character, so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "can't be contained".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, fixed
This error occurs when the compiler was unable to infer the concrete type of a | ||
variable. This error can occur for several cases, the most common of which is | ||
that there is a mismatch in the expected type that the compiler inferred, and | ||
the actual type that the user defined a variable as. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean "…variable has." (forgot a 'h')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @cactorium that original is grammatically correct but also difficult to read.
I suggest perhaps:
... the most common of which is a mismatch in the expected type that the compiler inferred for a variable's initializing expression, and the actual type explicitly assigned to the variable.
For example:
let x: i32 = "I am not a number!"; // ~~~ ~~~~~~~~~~~~~~~~~~~~ // | | // | initializing expression; // | compiler infers type `&str` // | // type `i32` assigned to variable `x`
(Or drop the example if you're not into that. :) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's way better worded :)! Thanks!
Nah, it's correct as is. It's the weird part of English where you have to put preposition after the object of the verb (eg. "Where are you going to?"). I'll see if I can come up with a way to make it less confusing though |
For #24407