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

Warning on u8 -> char casts; warning: can't cast this type, #[warn(const_err)] #33291

Closed
bluss opened this issue Apr 30, 2016 · 1 comment · Fixed by #33339
Closed

Warning on u8 -> char casts; warning: can't cast this type, #[warn(const_err)] #33291

bluss opened this issue Apr 30, 2016 · 1 comment · Fixed by #33339

Comments

@bluss
Copy link
Member

bluss commented Apr 30, 2016

This is a new warning in recent nightlies, for u8 -> char casts.

src/bin.rs:71:13: 71:25 warning: can't cast this type, #[warn(const_err)] on by default
src/bin.rs:71     if c >= 33u8 as char && c < 128u8 as char {
                          ^~~~~~~~~~~~
@klingtnet
Copy link
Contributor

I can confirm this:

   Compiling rosc v0.1.4 (file:///home/andreas/personal/dev/rust/rosc)
src/decoder.rs:110:28: 110:39 warning: can't cast this type, #[warn(const_err)] on by default
src/decoder.rs:110             s.trim_matches(0u8 as char)

Manishearth added a commit to Manishearth/rust that referenced this issue May 3, 2016
fix various const eval errors

These were found after const_evaluating arbitrary expressions and linting if the const evaluator failed

fixes rust-lang#33275 (int -> float casts for negative ints)
fixes rust-lang#33291 (int -> char casts (new! wasn't allowed in constants until this PR))

r? @eddyb

cc @bluss @japaric
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 a pull request may close this issue.

2 participants