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 more const int ops #53697

Merged
merged 5 commits into from
Sep 3, 2018
Merged

Add more const int ops #53697

merged 5 commits into from
Sep 3, 2018

Conversation

TimDiekmann
Copy link
Member

@TimDiekmann TimDiekmann commented Aug 25, 2018

r? @oli-obk

Tracking Issue: #53718

list of const fns in this PR:

  • feature = const_int_rotate
    • rotate_left
    • rotate_right
  • feature = const_int_wrapping
    • wrapping_add
    • wrapping_sub
    • wrapping_mul
    • wrapping_shl
    • wrapping_shr
  • feature = const_int_overflowing
    • overflowing_add
    • overflowing_sub
    • overflowing_mul
    • overflowing_shl
    • overflowing_shr
  • feature = const_int_sign
    • is_positive
    • is_negative
  • feature = const_int_conversion
    • reverse_bits
    • to_le_bytes
    • to_ne_bytes
    • from_be_bytes
    • from_le_bytes
    • from_ne_bytes
    • reverse_bits

@rust-highfive

This comment has been minimized.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 25, 2018
src/librustc_mir/interpret/const_eval.rs Outdated Show resolved Hide resolved
@TimDiekmann TimDiekmann changed the title Add more const int ops [WIP] Add more const int ops Aug 25, 2018
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@TimDiekmann TimDiekmann changed the title [WIP] Add more const int ops Add more const int ops Aug 26, 2018
@oli-obk oli-obk added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Aug 26, 2018
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of 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:44] ....................................................................................................
[00:44:46] ....................................................................................................
[00:44:49] ....................................................................................................
[00:44:53] ........i...........................................................................................
[00:44:57] ...............................................................................FFFF.F...............
[00:45:03] .................ii.iii.............................................................................
[00:45:06] ....................................................................................................
[00:45:08] ....................................................................................................
[00:45:10] ....................................................................................................
---
[00:46:36] ---- [ui] ui/consts/const-int-rotate.rs stdout ----
[00:46:36] 
[00:46:36] error: ui test compiled successfully!
[00:46:36] status: exit code: 0
[00:46:36] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-int-rotate.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-int-rotate/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-int-rotate/auxiliary" "-A" "unused"
[00:46:36] ------------------------------------------
[00:46:36] 
[00:46:36] ------------------------------------------
[00:46:36] stderr:
---
[00:46:36] ---- [ui] ui/consts/const-int-sign.rs stdout ----
[00:46:36] 
[00:46:36] error: ui test compiled successfully!
[00:46:36] status: exit code: 0
[00:46:36] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-int-sign.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-int-sign/a" "-Crp[00:46:36] 
[00:46:36] thread '[ui] ui/consts/const-int-wrapping.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3196:9
[00:46:36] 
[00:46:36] failures:
[00:46:36]     [ui] ui/consts/const-int-conversion.rs
[00:46:36]     [ui] ui/consts/const-int-overflowing.rs
---
[00:46:36] 
[00:46:36] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:497:22
[00:46:36] 
[00:46:36] 
[00:46:36] 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-gnu/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-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "5.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:46:36] 
[00:46:36] 
[00:46:36] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:46:36] Build completed unsuccessfully in 0:03:02
[00:46:36] Build completed unsuccessfully in 0:03:02
[00:46:36] make: *** [check] Error 1
[00:46:36] Makefile:58: recipe for target 'check' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:04dde61b
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@bors
Copy link
Contributor

bors commented Aug 29, 2018

☔ The latest upstream changes (presumably #53671) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of 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.
##########################                                                36.2%
######################################################################## 100.0%
[00:01:59] extracting /checkout/obj/build/cache/2018-08-01/cargo-beta-x86_64-unknown-linux-gnu.tar.gz
[00:01:59]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:22] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:22] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:22] Makefile:81: recipe for target 'prepare' failed
[00:02:22] make: *** [prepare] Error 1
[00:02:23] Command failed. Attempt 2/5:
[00:02:23]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:23]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:23] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:23] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:23] Makefile:81: recipe for target 'prepare' failed
[00:02:23] make: *** [prepare] Error 1
[00:02:25] Command failed. Attempt 3/5:
[00:02:25]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:25]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:26] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:26] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:26] Makefile:81: recipe for target 'prepare' failed
[00:02:26] make: *** [prepare] Error 1
[00:02:29] Command failed. Attempt 4/5:
[00:02:29]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:29]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:29] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:29] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:29] make: *** [prepare] Error 1
[00:02:29] Makefile:81: recipe for target 'prepare' failed
[00:02:33] Command failed. Attempt 5/5:
[00:02:33]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:33]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:34] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:34] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:34] Makefile:81: recipe for target 'prepare' failed
[00:02:34] make: *** [prepare] Error 1
[00:02:34] The command has failed after 5 attempts.
travis_time:end:000f2b98:start=1535757820279338279,finish=1535757990449408057,duration=170170069778
---
travis_time:end:05a6fff6:start=1535757990866516336,finish=1535757990874825456,duration=8309120
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:1ecd35de
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1a566b38
travis_time:start:1a566b38
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0272bba5
$ dmesg | grep -i kill

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)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of 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.
#######################################################                   76.7%
######################################################################## 100.0%
[00:02:23] extracting /checkout/obj/build/cache/2018-08-01/cargo-beta-x86_64-unknown-linux-gnu.tar.gz
[00:02:25]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:47] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:47] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:47] Makefile:81: recipe for target 'prepare' failed
[00:02:47] make: *** [prepare] Error 1
[00:02:48] Command failed. Attempt 2/5:
[00:02:48]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:48]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:49] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:49] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:49] make: *** [prepare] Error 1
[00:02:49] Makefile:81: recipe for target 'prepare' failed
[00:02:51] Command failed. Attempt 3/5:
[00:02:51]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:51]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:51] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:51] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:51] make: *** [prepare] Error 1
[00:02:51] Makefile:81: recipe for target 'prepare' failed
[00:02:54] Command failed. Attempt 4/5:
[00:02:54]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:54]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:55] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:55] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:55] make: *** [prepare] Error 1
[00:02:55] Makefile:81: recipe for target 'prepare' failed
[00:02:59] Command failed. Attempt 5/5:
[00:02:59]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:59]     Updating registry `https://github.com/rust-lang/crates.io-index`
[00:02:59] error: the lock file needs to be updated but --locked was passed to prevent this
[00:02:59] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:02:59] Makefile:81: recipe for target 'prepare' failed
[00:02:59] make: *** [prepare] Error 1
[00:02:59] The command has failed after 5 attempts.
travis_time:end:0b4ab0c9:start=1535758972819127765,finish=1535759160192839620,duration=187373711855
---
travis_time:end:0be20c09:start=1535759160590333652,finish=1535759160596840153,duration=6506501
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:24632646
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0bff49ea
travis_time:start:0bff49ea
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:07c7933e
$ dmesg | grep -i kill

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)

@bors
Copy link
Contributor

bors commented Sep 1, 2018

☔ The latest upstream changes (presumably #53762) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

One function without annotations and a test nit, lgmt otherwise

src/libcore/num/mod.rs Outdated Show resolved Hide resolved
src/test/run-pass/const-int-conversion.rs Outdated Show resolved Hide resolved
@oli-obk
Copy link
Contributor

oli-obk commented Sep 3, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Sep 3, 2018

📌 Commit 4811e5b has been approved by oli-obk

@bors bors removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Sep 3, 2018
@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 Sep 3, 2018
@bors
Copy link
Contributor

bors commented Sep 3, 2018

⌛ Testing commit 4811e5b with merge cd5c26f...

bors added a commit that referenced this pull request Sep 3, 2018
Add more const int ops

r? @oli-obk

Tracking Issue: #53718

list of `const fn`s in this PR:

- `feature = const_int_rotate`
  - `rotate_left`
  - `rotate_right`
- `feature = const_int_wrapping`
  - `wrapping_add`
  - `wrapping_sub`
  - `wrapping_mul`
  - `wrapping_shl`
  - `wrapping_shr`
- `feature = const_int_overflowing`
  - `overflowing_add`
  - `overflowing_sub`
  - `overflowing_mul`
  - `overflowing_shl`
  - `overflowing_shr`
- `feature = const_int_sign`
  - `is_positive`
  - `is_negative`
- `feature = const_int_conversion`
  - `reverse_bits`
  - `to_le_bytes`
  - `to_ne_bytes`
  - `from_be_bytes`
  - `from_le_bytes`
  - `from_ne_bytes`
  - `reverse_bits`
@bors
Copy link
Contributor

bors commented Sep 3, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing cd5c26f to master...

@RalfJung
Copy link
Member

RalfJung commented Sep 6, 2018

This PR broke miri's test suite.

In particular, this PR fails to properly flag undefined behavior when an unchecked_ intrinsic is called with a bad argument. This check is missing.

@TimDiekmann can you either remove the two "unchecked" intrinsics again, or implement the check that miri performs? Note that "unchecked" means "it is UB to violate the requirement", and detecting such UB is an explicit goal for the miri engine.

kennytm added a commit to kennytm/rust that referenced this pull request Sep 7, 2018
…s, r=oli-obk

Add unchecked_shl/shr check for intrinsics to fix miri's test suit

r? @RalfJung

cc @oli-obk

rust-lang#53697 broke miri's test suite as described in [this comment](rust-lang#53697 (comment)). This PR adds test for the `unchecked_shr/shl` for the intrinsics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants