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

Sign extend constants in range patterns #49949

Merged
merged 1 commit into from
Apr 19, 2018

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Apr 13, 2018

@oli-obk oli-obk added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 13, 2018
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 13, 2018
@@ -1096,7 +1101,11 @@ pub fn compare_const_vals(a: &ConstVal, b: &ConstVal, ty: Ty) -> Option<Ordering
// FIXME(oli-obk): report cmp errors?
l.try_cmp(r).ok()
},
ty::TyInt(_) => Some((a as i128).cmp(&(b as i128))),
ty::TyInt(_) => {
let a = interpret::sign_extend(tcx, a, ty).expect("layout error for TyInt");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the only actual change in this PR. Everything else is just moving things around.

The issue was that we represent constants in their native bit width, so casting to i128 didn't work out for e.g. -1u8, which is 0xFF, and stays that when casting to i128 (meaning it would be 255 instead of -1)

@Mark-Simulacrum
Copy link
Member

These changes look good to me, but I'd like to r? @eddyb

@eddyb
Copy link
Member

eddyb commented Apr 17, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Apr 17, 2018

📌 Commit 45529b5 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 17, 2018
@kennytm
Copy link
Member

kennytm commented Apr 17, 2018

@bors p=4

@bors
Copy link
Contributor

bors commented Apr 18, 2018

⌛ Testing commit 45529b5357cbaa1ac90893547566cd534c6a41a4 with merge 87eeb04b1f0e8b104fe801966ba0653a134e0056...

@bors
Copy link
Contributor

bors commented Apr 18, 2018

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 18, 2018
@rust-highfive
Copy link
Collaborator

Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:44:41] error: ui test compiled successfully!
[00:44:41] status: exit code: 0
[00:44:41] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-eval/const_signed_pat.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-musl" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-eval/const_signed_pat.stage2-x86_64-unknown-linux-musl" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-musl/native/rust-test-helpers" "-Clinker=/musl-x86_64/bin/musl-gcc" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-eval/const_signed_pat.stage2-x86_64-unknown-linux-musl.aux" "-A" "unused"
---
[00:44:41] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-musl/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-musl" "--mode" "ui" "--target" "x86_64-unknown-linux-musl" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--linker" "/musl-x86_64/bin/musl-gcc" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-musl/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "6.0.0\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:011d4f32:start=1524013541693346629,finish=1524013541709936711,duration=16590082
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:011481c0
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:011481c0:start=1524013541715595792,finish=1524013541721678707,duration=6082915
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:04590e78
$ dmesg | grep -i kill
[   10.738005] init: failsafe main process (1092) killed by TERM signal

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

// option. This file may not be copied, modified, or distributed
// except according to those terms.

// must-compile-successfully
Copy link
Member

Choose a reason for hiding this comment

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

This has been renamed to // compile-pass on master (it is still // must-compile-successfully on beta).

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 18, 2018
@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 19, 2018

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Apr 19, 2018

📌 Commit b22c9c0 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 19, 2018
@bors
Copy link
Contributor

bors commented Apr 19, 2018

⌛ Testing commit b22c9c0 with merge 5fe6b58...

bors added a commit that referenced this pull request Apr 19, 2018
Sign extend constants in range patterns

fixes  #49940

r? @Mark-Simulacrum
@bors
Copy link
Contributor

bors commented Apr 19, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing 5fe6b58 to master...

@bors bors merged commit b22c9c0 into rust-lang:master Apr 19, 2018
@bors bors mentioned this pull request Apr 19, 2018
@pnkfelix pnkfelix added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Apr 19, 2018
@nagisa nagisa added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 19, 2018
bors added a commit that referenced this pull request Apr 19, 2018
[beta] backport various PRs

original PRs:

* #49949 (not yet merged at the time of writing)
* #49947 (long running const eval error -> warning)
* #49833 (static recursion)
* #49876 (no clippy in stable rls)
* #49904 (Work around LLVM debuginfo problem in librustc_driver. )
@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 20, 2018
@alexcrichton
Copy link
Member

Backported in #50027

@oli-obk oli-obk deleted the const_signed_pat branch April 23, 2018 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in 1.26: lower range bound must be less than or equal to upper
9 participants