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

Add long diagnostics for E0046 and E0054 #25190

Merged
merged 2 commits into from May 8, 2015
Merged

Conversation

nham
Copy link
Contributor

@nham nham commented May 7, 2015

cc #24407

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

"##,

E0054: r##"
It is not allowed to cast to a bool. If you are trying to cast a numeric type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could clarify "It is not allowed to cast a numeric type to a bool"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my (admittedly shallow) reading of the code in librustc_typeck/check/cast.rs, it seemed like any casting to bool is disallowed. For example, you can try to cast a bare function to a bool and get E0054.

fn main() {
    fn foo() -> u8 { 5 }
    let x = foo as bool; // error: cannot cast as `bool`, compare with zero instead [E0054]
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! Never mind then!

@alexcrichton
Copy link
Member

@bors: r+ 11a7bad rollup

Manishearth added a commit to Manishearth/rust that referenced this pull request May 8, 2015
bors added a commit that referenced this pull request May 8, 2015
@bors bors merged commit 11a7bad into rust-lang:master May 8, 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.

None yet

5 participants