-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Reject negative literals for unsigned or char types in pattern ranges and literals #136304
Conversation
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
HIR ty lowering was modified cc @fmease |
This comment has been minimized.
This comment has been minimized.
6c69f93
to
91c5c59
Compare
error[E0277]: the trait bound `u8: Neg` is not satisfied | ||
--> $DIR/signed_ranges.rs:14:9 | ||
| | ||
LL | -10..253 => {} | ||
| ^^^ the trait `Neg` is not implemented for `u8` |
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 tried improving this error by having it point to where we got the u8
type information from (the scrutinee), but adding the right obligations for that didn't work out, so I'll need to do some more debugging.
But this is also the exact same diagnostic we get on stable and beta, so...
@rustbot ready |
91c5c59
to
76ba91c
Compare
Going back to the same error we had before is plenty enough. @bors r+ |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#136242 (Remove `LateContext::match_def_path()`) - rust-lang#136274 (Check Sizedness of return type in WF) - rust-lang#136284 (Allow using named consts in pattern types) - rust-lang#136477 (Fix a couple NLL TLS spans ) - rust-lang#136497 (Report generic mismatches when calling bodyless trait functions) - rust-lang#136520 (Remove unnecessary layout assertions for object-safe receivers) - rust-lang#136526 (mir_build: Rename `thir::cx::Cx` to `ThirBuildCx` and remove `UserAnnotatedTyHelpers`) Failed merges: - rust-lang#136304 (Reject negative literals for unsigned or char types in pattern ranges and literals) r? `@ghost` `@rustbot` modify labels: rollup
☔ The latest upstream changes (presumably #136549) made this pull request unmergeable. Please resolve the merge conflicts. |
76ba91c
to
f44794f
Compare
…eril Reject negative literals for unsigned or char types in pattern ranges and literals It sucks a bit that we have to duplicate the work here (normal expressions just get this for free from the `ExprKind::UnOp(UnOp::Neg, ...)` typeck logic. In rust-lang#134228 I caused ```rust fn main() { match 42_u8 { -10..255 => {}, _ => {} } } ``` to just compile without even a lint. I can't believe we didn't have tests for this Amusingly rust-lang#136302 will also register a delayed bug in `lit_to_const` for this, so we'll have a redundancy if something like this fails again.
…eril Reject negative literals for unsigned or char types in pattern ranges and literals It sucks a bit that we have to duplicate the work here (normal expressions just get this for free from the `ExprKind::UnOp(UnOp::Neg, ...)` typeck logic. In rust-lang#134228 I caused ```rust fn main() { match 42_u8 { -10..255 => {}, _ => {} } } ``` to just compile without even a lint. I can't believe we didn't have tests for this Amusingly rust-lang#136302 will also register a delayed bug in `lit_to_const` for this, so we'll have a redundancy if something like this fails again.
Rollup of 12 pull requests Successful merges: - rust-lang#132547 (cg_gcc: Directly use rustc_abi instead of reexports) - rust-lang#135572 (tests: Port `split-debuginfo` to rmake.rs) - rust-lang#135964 (Make cenum_impl_drop_cast a hard error) - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe}) - rust-lang#136304 (Reject negative literals for unsigned or char types in pattern ranges and literals) - rust-lang#136418 (uefi: process: Add support for command environment variables) - rust-lang#136449 (std: move network code into `sys`) - rust-lang#136517 (implement inherent str constructors) - rust-lang#136536 (Rename and Move some UI tests to more suitable subdirs) - rust-lang#136537 (Update `compiler-builtins` to 0.1.145) - rust-lang#136555 (Rename `slice::take...` methods to `split_off...`) - rust-lang#136567 (Arbitrary self types v2: recursion test) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang#132547 (cg_gcc: Directly use rustc_abi instead of reexports) - rust-lang#135572 (tests: Port `split-debuginfo` to rmake.rs) - rust-lang#135964 (Make cenum_impl_drop_cast a hard error) - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe}) - rust-lang#136304 (Reject negative literals for unsigned or char types in pattern ranges and literals) - rust-lang#136418 (uefi: process: Add support for command environment variables) - rust-lang#136449 (std: move network code into `sys`) - rust-lang#136517 (implement inherent str constructors) - rust-lang#136536 (Rename and Move some UI tests to more suitable subdirs) - rust-lang#136537 (Update `compiler-builtins` to 0.1.145) - rust-lang#136555 (Rename `slice::take...` methods to `split_off...`) - rust-lang#136567 (Arbitrary self types v2: recursion test) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#136304 - oli-obk:push-ymxoklvzrpvx, r=Nadrieril Reject negative literals for unsigned or char types in pattern ranges and literals It sucks a bit that we have to duplicate the work here (normal expressions just get this for free from the `ExprKind::UnOp(UnOp::Neg, ...)` typeck logic. In rust-lang#134228 I caused ```rust fn main() { match 42_u8 { -10..255 => {}, _ => {} } } ``` to just compile without even a lint. I can't believe we didn't have tests for this Amusingly rust-lang#136302 will also register a delayed bug in `lit_to_const` for this, so we'll have a redundancy if something like this fails again.
It sucks a bit that we have to duplicate the work here (normal expressions just get this for free from the
ExprKind::UnOp(UnOp::Neg, ...)
typeck logic.In #134228 I caused
to just compile without even a lint.
I can't believe we didn't have tests for this
Amusingly #136302 will also register a delayed bug in
lit_to_const
for this, so we'll have a redundancy if something like this fails again.