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

Added error explanations for E0308, E0309, and E0310 #24576

Merged
merged 4 commits into from
May 7, 2015

Conversation

cactorium
Copy link
Contributor

For #24407

@rust-highfive
Copy link
Collaborator

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
Copy link
Contributor

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".

Copy link
Contributor Author

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.
Copy link
Contributor

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')

Copy link
Member

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. :) )

Copy link
Contributor Author

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!

@cactorium
Copy link
Contributor Author

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

@pnkfelix
Copy link
Member

pnkfelix commented May 6, 2015

@bors r+ 4174aa4 rollup

steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 7, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this pull request May 7, 2015
bors added a commit that referenced this pull request May 7, 2015
@bors bors merged commit 4174aa4 into rust-lang:master May 7, 2015
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 this pull request may close these issues.

7 participants