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

0u8..-1 compiles without warning #25206

Closed
bluss opened this issue May 8, 2015 · 7 comments · Fixed by #27026
Closed

0u8..-1 compiles without warning #25206

bluss opened this issue May 8, 2015 · 7 comments · Fixed by #27026
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@bluss
Copy link
Member

bluss commented May 8, 2015

0u8..-1 compiles, runs (as 0..255) without warning or error. Debug assertions don't fire.

We error on 0..-1u8 error: unary negation of unsigned integers may be removed in the future.

We can't "fix" this backwards compatibly after 1.0.

0u8..-1 should either warn or trip debug assertions.

@bombless
Copy link
Contributor

bombless commented May 8, 2015

Hmm we cannot add warning because of compatibly?
I just want to make sure...

@bluss
Copy link
Member Author

bluss commented May 8, 2015

We can add a warning, but to make it a hard error would be breaking.

@nagisa
Copy link
Member

nagisa commented May 9, 2015

I think this should error the same way as 0u8..-1 case errors, for consistency with let x: u8 = -1, which also errors.

@bombless
Copy link
Contributor

FWIW, I think we are contributing to Rust 1.1, so it's fine to break some 1.0 code.

@Stebalien
Copy link
Contributor

@bombless Point releases are not allowed to introduce backwards incompatible changes (except bug fixes). Only major releases (2.0) can do that.

@nagisa
Copy link
Member

nagisa commented May 10, 2015

We could always make it a warning for 1.x series and note it will become an error in next major release.

@bombless
Copy link
Contributor

Hmm if somebody's quick enough to make a patch then we can backport it to beta branch and fix this in time. Also this can be considered a bug anyway.

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label May 10, 2015
bors added a commit that referenced this issue Jul 20, 2015
This commit fixes the negate_unsigned feature gate to appropriately
account for inferred variables.

This is technically a [breaking-change], but I’d consider it a bug fix.

cc @brson for your relnotes.

Fixes #24676
Fixes #26840 
Fixes #25206
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants