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

Show the values and computation that would overflow a const evaluation or propagation #73513

Merged
merged 1 commit into from
Jun 26, 2020

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jun 19, 2020

Fixes #71134

In contrast to the example in the issue it doesn't use individual spans for each operand. The effort required to implement that is quite high compared to the little (if at all) benefit it would bring to diagnostics.

cc @shepmaster

The way this is implemented it is also fairly easy to do the same for overflow panics at runtime, but that should be done in a separate PR since it may have runtime performance implications.

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 19, 2020
@estebank
Copy link
Contributor

estebank commented Jun 19, 2020

r=me on the changes with green CI

I have one nitpick to change the output slightly, but I'm not blocking this PR on it:

error: this arithmetic operation will overflow
  --> $DIR/const-err2.rs:19:13
   |
LL |     let a = -std::i8::MIN;
   |             ^^^^^^^^^^^^^ attempt to negate `-128` would be greater than `i8::MAX`
   |
   = note: `#[deny(arithmetic_overflow)]` on by default

or some other wording that mentions the type.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-8 of your PR failed (pretty log, 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.
##[section]Starting: Linux x86_64-gnu-llvm-8
##[section]Starting: Initialize job
Agent name: 'Azure Pipelines 2'
Agent machine name: 'fv-az578'
Current agent version: '2.170.1'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200614.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200614.1/images/linux/Ubuntu1604-README.md
##[endgroup]
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Download all required tasks.
Downloading task: Bash (3.163.3)
Checking job knob settings.
   Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} 
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Configure Job Name
==============================================================================
---
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/380b736d-29f3-4d24-8e3c-db27483ffc14.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/73513/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
---
##[command]git remote add origin https://github.com/rust-lang/rust
##[command]git config gc.auto 0
##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
##[command]git config --get-all http.proxy
##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/73513/merge:refs/remotes/pull/73513/merge
---
 ---> 31fea614d2f3
Step 5/8 : ENV RUST_CONFIGURE_ARGS       --build=x86_64-unknown-linux-gnu       --llvm-root=/usr/lib/llvm-8       --enable-llvm-link-shared       --set rust.thin-lto-import-instr-limit=10
 ---> Using cache
 ---> 4195cadf126d
Step 6/8 : ENV SCRIPT python2.7 ../x.py test --exclude src/tools/tidy &&            python2.7 ../x.py test src/test/mir-opt --pass=build                                   --target=armv5te-unknown-linux-gnueabi &&            python2.7 ../x.py test src/tools/tidy
 ---> 4e90f6b48f05
Step 7/8 : ENV NO_DEBUG_ASSERTIONS=1
 ---> Using cache
 ---> dfa0a356d899
---
Set({"src/librustc_parse_format"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_passes"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_plugin_impl"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_privacy"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_query_system"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_save_analysis"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_serialize"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_session"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_span"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
---
Set({"src/librustc_parse_format"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_passes"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_plugin_impl"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_privacy"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_query_system"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_save_analysis"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_serialize"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_session"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_span"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
---
   Compiling rustc_parse_format v0.0.0 (/checkout/src/librustc_parse_format)
   Compiling chalk-rust-ir v0.10.0
   Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
   Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
   Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
   Compiling chalk-solve v0.10.0
   Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
   Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
   Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
   Compiling rustc_parse_format v0.0.0 (/checkout/src/librustc_parse_format)
   Compiling chalk-rust-ir v0.10.0
   Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
   Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
   Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
   Compiling chalk-solve v0.10.0
   Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
   Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
   Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
.................................................................................................... 1900/10329
.................................................................................................... 2000/10329
.................i..i............................................................................... 2100/10329
.................................................................................................... 2200/10329
.......iiiii........................................................................................ 2300/10329
.................................................................................................... 2500/10329
.................................................................................................... 2600/10329
.................................................................................................... 2700/10329
.................................................................................................... 2800/10329
---
.................................................................................................... 5300/10329
.........................................................................................i.......... 5400/10329
...................................................................................i................ 5500/10329
.................................................................................................... 5600/10329
..ii.ii........i...i................................................................................ 5700/10329
........................................................i........................................... 5900/10329
.................................................................................................... 6000/10329
..........ii.....................................i.................................................. 6100/10329
.................................................................................................... 6200/10329
.................................................................................................... 6200/10329
.................................................................................................... 6300/10329
.........................................................................ii...i..ii...........i..... 6400/10329
.................................................................................................... 6600/10329
.................................................................................................... 6700/10329
.................................................................................................... 6800/10329
.................................................................................................... 6800/10329
.......i..ii........................................................................................ 6900/10329
.................................................................................................... 7100/10329
..............................................................i..................................... 7200/10329
.................................................................................................... 7300/10329
.................................................................................................... 7400/10329
---
.................................................................................................... 8200/10329
.................................................................................................... 8300/10329
.................................................................................................... 8400/10329
.......i............................................................................................ 8500/10329
.............................................................iiiiii.iiiiii.i........................ 8600/10329
..................i................................................................................. 8800/10329
.................................................................................................... 8900/10329
.................................................................................................... 9000/10329
.................................................................................................... 9100/10329
---
............FF...F...F.......F.....F.........................i......F............................... 100/107
.......
failures:

---- [mir-opt] mir-opt/const_prop/bad_op_div_by_zero.rs stdout ----
46 +                                          // + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:19
47 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
48           assert(!move _4, "attempt to divide by zero") -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
+                                            // ty::Const
+                                            // + ty: i32
+                                            // + val: Value(Scalar(0x00000001))
+                                            // mir::Constant
+                                            // + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:15
+                                            // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
50   
51       bb1: {

91 +                                          // mir::Constant
91 +                                          // mir::Constant
92 +                                          // + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:19
93 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+                                            // ty::Const
+                                            // + ty: i32
+                                            // + val: Value(Scalar(0x00000001))
+                                            // mir::Constant
+                                            // + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:15
+                                            // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
95   
96       bb2: {


thread '[mir-opt] mir-opt/const_prop/bad_op_div_by_zero.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/const_prop/bad_op_div_by_zero/rustc.main.ConstProp.diff', src/tools/compiletest/src/runtest.rs:3194:25


---- [mir-opt] mir-opt/const_prop/bad_op_mod_by_zero.rs stdout ----
46 +                                          // + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
47 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
48           assert(!move _4, "attempt to calculate the remainder with a divisor of zero") -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
+                                            // ty::Const
+                                            // + ty: i32
+                                            // + val: Value(Scalar(0x00000001))
+                                            // mir::Constant
+                                            // + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:15
+                                            // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
50   
51       bb1: {

91 +                                          // mir::Constant
91 +                                          // mir::Constant
92 +                                          // + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
93 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+                                            // ty::Const
+                                            // + ty: i32
+                                            // + val: Value(Scalar(0x00000001))
+                                            // mir::Constant
+                                            // + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:15
+                                            // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
95   
96       bb2: {


thread '[mir-opt] mir-opt/const_prop/bad_op_mod_by_zero.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/const_prop/bad_op_mod_by_zero/rustc.main.ConstProp.diff', src/tools/compiletest/src/runtest.rs:3194:25
---- [mir-opt] mir-opt/const_prop/checked_add.rs stdout ----
---- [mir-opt] mir-opt/const_prop/checked_add.rs stdout ----
34 +                                          // + span: $DIR/checked_add.rs:5:18: 5:23
35 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
36 +         assert(!const false, "attempt to add with overflow") -> bb1; // scope 0 at $DIR/checked_add.rs:5:18: 5:23
- +                                          // ty::Const
+                                            // ty::Const
38 +                                          // + ty: bool
39 +                                          // + val: Value(Scalar(0x00))


41 +                                          // + span: $DIR/checked_add.rs:5:18: 5:23
42 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+ +                                          // ty::Const
+                                            // + ty: u32
+                                            // + val: Value(Scalar(0x00000001))
+                                            // mir::Constant
+                                            // + span: $DIR/checked_add.rs:5:18: 5:19
+                                            // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
+                                            // ty::Const
+                                            // + ty: u32
+                                            // + val: Value(Scalar(0x00000001))
+                                            // mir::Constant
+                                            // + span: $DIR/checked_add.rs:5:22: 5:23
+                                            // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
44   
45       bb1: {


thread '[mir-opt] mir-opt/const_prop/checked_add.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff', src/tools/compiletest/src/runtest.rs:3194:25
---- [mir-opt] mir-opt/const_prop/indirect.rs stdout ----
23                                            // mir::Constant
23                                            // mir::Constant
24 -                                          // + span: $DIR/indirect.rs:5:14: 5:18
25 -                                          // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
- -         _3 = CheckedAdd(move _2, const 1u8); // scope 0 at $DIR/indirect.rs:5:13: 5:29
+ -         _3 = CheckedAdd(_2, const 1u8);  // scope 0 at $DIR/indirect.rs:5:13: 5:29
27 +                                          // + span: $DIR/indirect.rs:5:13: 5:25
28 +                                          // + literal: Const { ty: u8, val: Value(Scalar(0x02)) }
29 +         _3 = (const 3u8, const false);   // scope 0 at $DIR/indirect.rs:5:13: 5:29

37 -         assert(!move (_3.1: bool), "attempt to add with overflow") -> bb1; // scope 0 at $DIR/indirect.rs:5:13: 5:29
38 +                                          // + span: $DIR/indirect.rs:5:13: 5:29
39 +                                          // + literal: Const { ty: u8, val: Value(Scalar(0x03)) }
- +                                          // ty::Const
+                                            // ty::Const
41 +                                          // + ty: bool
42 +                                          // + val: Value(Scalar(0x00))

50 +                                          // mir::Constant
50 +                                          // mir::Constant
51 +                                          // + span: $DIR/indirect.rs:5:13: 5:29
52 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+ +                                          // ty::Const
+                                            // + ty: u8
+                                            // + val: Value(Scalar(0x01))
+                                            // mir::Constant
+                                            // + span: $DIR/indirect.rs:5:28: 5:29
+                                            // + literal: Const { ty: u8, val: Value(Scalar(0x01)) }
54   
55       bb1: {


thread '[mir-opt] mir-opt/const_prop/indirect.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff', src/tools/compiletest/src/runtest.rs:3194:25
---- [mir-opt] mir-opt/const_prop/optimizes_into_variable.rs stdout ----
---- [mir-opt] mir-opt/const_prop/optimizes_into_variable.rs stdout ----
47 +                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
48 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
49 +         assert(!const false, "attempt to add with overflow") -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
- +                                          // ty::Const
+                                            // ty::Const
51 +                                          // + ty: bool
52 +                                          // + val: Value(Scalar(0x00))


54 +                                          // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18
55 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+ +                                          // ty::Const
+                                            // + ty: i32
+                                            // + val: Value(Scalar(0x00000002))
+                                            // mir::Constant
+                                            // + span: $DIR/optimizes_into_variable.rs:12:13: 12:14
+                                            // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
+                                            // ty::Const
+                                            // + ty: i32
+                                            // + val: Value(Scalar(0x00000002))
+                                            // mir::Constant
+                                            // + span: $DIR/optimizes_into_variable.rs:12:17: 12:18
+                                            // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
57   
58       bb1: {


thread '[mir-opt] mir-opt/const_prop/optimizes_into_variable.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff', src/tools/compiletest/src/runtest.rs:3194:25
---- [mir-opt] mir-opt/const_prop/return_place.rs stdout ----
---- [mir-opt] mir-opt/const_prop/return_place.rs stdout ----
29 +                                          // + span: $DIR/return_place.rs:6:5: 6:10
30 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
31 +         assert(!const false, "attempt to add with overflow") -> bb1; // scope 0 at $DIR/return_place.rs:6:5: 6:10
- +                                          // ty::Const
+                                            // ty::Const
33 +                                          // + ty: bool
34 +                                          // + val: Value(Scalar(0x00))


36 +                                          // + span: $DIR/return_place.rs:6:5: 6:10
37 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+ +                                          // ty::Const
+                                            // + ty: u32
+                                            // + val: Value(Scalar(0x00000002))
+                                            // mir::Constant
+                                            // + span: $DIR/return_place.rs:6:5: 6:6
+                                            // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
+                                            // ty::Const
+                                            // + ty: u32
+                                            // + val: Value(Scalar(0x00000002))
+                                            // mir::Constant
+                                            // + span: $DIR/return_place.rs:6:9: 6:10
+                                            // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
39   
40       bb1: {


thread '[mir-opt] mir-opt/const_prop/return_place.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff', src/tools/compiletest/src/runtest.rs:3194:25
---- [mir-opt] mir-opt/issue-41697.rs stdout ----
---- [mir-opt] mir-opt/issue-41697.rs stdout ----
19                                          // + span: $DIR/issue-41697.rs:18:21: 18:22
20                                          // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
21         assert(!move (_1.1: bool), "attempt to add with overflow") -> [success: bb2, unwind: bb1]; // scope 0 at $DIR/issue-41697.rs:18:19: 18:22
+                                          // ty::Const
+                                          // + ty: usize
+                                          // + val: Value(Scalar(0x0000000000000001))
+                                          // mir::Constant
+                                          // + span: $DIR/issue-41697.rs:18:19: 18:20
+                                          // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+                                          // ty::Const
+                                          // + ty: usize
+                                          // + val: Value(Scalar(0x0000000000000001))
+                                          // mir::Constant
+                                          // + span: $DIR/issue-41697.rs:18:21: 18:22
+                                          // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
23 
23 
24     bb1 (cleanup): {

thread '[mir-opt] mir-opt/issue-41697.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/issue-41697/64bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir', src/tools/compiletest/src/runtest.rs:3194:25

failures:
    [mir-opt] mir-opt/const_prop/bad_op_div_by_zero.rs
    [mir-opt] mir-opt/const_prop/bad_op_mod_by_zero.rs
---

thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:348:22


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/mir-opt" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "mir-opt" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-8/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -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" "8.0.0" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
Build completed unsuccessfully in 1:01:00
Build completed unsuccessfully in 1:01:00
== clock drift check ==
  local time: Fri Jun 19 18:27:11 UTC 2020
  network time: Fri, 19 Jun 2020 18:27:11 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/73513/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: rust-lang/rust (GitHub)
##[section]Finishing: Checkout rust-lang/rust@refs/pull/73513/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (3577) (python)
##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 20, 2020

or some other wording that mentions the type.

Unfortunately we don't have the type available at that time. I could probably get ConstInt to emit a type so you'd have -128_i8 instead of just -128

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 20, 2020

cc @RalfJung this touches a little bit of miri-engine error handling

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 20, 2020

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Jun 20, 2020

⌛ Trying commit a1b92b4456b18789a1d8decfd9136a752c811a1a with merge 54b2e11bab628c62703dc119d93e1807bba5e4c7...


error: this arithmetic operation will overflow
--> $DIR/issue-69020-assoc-const-arith-overflow.rs:34:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| ^^^^^^^^^^^^ attempt to add with overflow
| ^^^^^^^^^^^^ attempt to compute `2147483647 + 1` which would overflow
Copy link
Member

Choose a reason for hiding this comment

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

So computations are enclosed in ` but constants are not? Are we doing that consistently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no

@rust-highfive

This comment has been minimized.

(2, _) => write!(fmt, "_u16")?,
(4, _) => write!(fmt, "_u32")?,
(8, _) => write!(fmt, "_u64")?,
(16, _) => write!(fmt, "_u128")?,
Copy link
Member

Choose a reason for hiding this comment

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

Why the _? Is there precedent for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was under the impression that that's the proper way to do this. I think clippy also suggests everything with an underscore

Copy link
Member

Choose a reason for hiding this comment

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

No strong opinion, I just don't think I have seen this before.

Copy link
Member

Choose a reason for hiding this comment

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

Are we emitting any other diagnostics in rustc like this? I haven't seen any either, but I could be out of touch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't checked

@@ -0,0 +1,111 @@
use crate::mir::interpret::truncate;
use rustc_target::abi::Size;
Copy link
Member

Choose a reason for hiding this comment

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

Now this file is even more removed from ConstValue, which it seems closely related to.^^

Maybe call this ty/const.rs, with the plan to move ConstValue here as part of #72396?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const isn't possible, but consts.

@rust-highfive

This comment has been minimized.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 20, 2020

Heh, the PR already bitrotted. I rebased and sqashed the commits

@rust-highfive

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 21, 2020

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

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 21, 2020

@estebank there were significant changes to the test output, can you have another look to see if you're still ok with this?

@rust-highfive

This comment has been minimized.

@estebank
Copy link
Contributor

Only nitpicks would ve that we always say overflow even when it underflows and that we could potentially recommend changing types, but these things are very minor and shouldn't block this pr. I worry slightly that overflow is jargon that we never introduce, which is why I suggested the wordier labels before, but at the same time it is very common wording for people coming from other langs. None of these things needs to be addressed now.

@RalfJung
Copy link
Member

(FWIW I feel like "underflow" is much stranger jargon than "overflow". I'd call it "overflow" even when it's wrapping around negatively. But maybe I'm the odd one out there.)

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 23, 2020
@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 25, 2020

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jun 25, 2020

📌 Commit 78b549f6607be49c6b6a49c3a2465a9756bf56f7 has been approved by estebank

@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 Jun 25, 2020
@bors
Copy link
Contributor

bors commented Jun 25, 2020

⌛ Testing commit 78b549f6607be49c6b6a49c3a2465a9756bf56f7 with merge f7a7b6b77c6f06c2d97eed7b96e34156a753505b...

@bors
Copy link
Contributor

bors commented Jun 25, 2020

💔 Test failed - checks-azure

@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 Jun 25, 2020
@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 26, 2020

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jun 26, 2020

📌 Commit 819cde5 has been approved by estebank

@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 Jun 26, 2020
@bors
Copy link
Contributor

bors commented Jun 26, 2020

⌛ Testing commit 819cde5 with merge 7750c3d...

@bors
Copy link
Contributor

bors commented Jun 26, 2020

☀️ Test successful - checks-azure
Approved by: estebank
Pushing 7750c3d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 26, 2020
@bors bors merged commit 7750c3d into rust-lang:master Jun 26, 2020
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #73513!

Tested on commit 7750c3d.
Direct link to PR: #73513

💔 miri on windows: test-pass → test-fail (cc @oli-obk @eddyb @RalfJung).
💔 miri on linux: test-pass → test-fail (cc @oli-obk @eddyb @RalfJung).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Jun 26, 2020
Tested on commit rust-lang/rust@7750c3d.
Direct link to PR: <rust-lang/rust#73513>

💔 miri on windows: test-pass → test-fail (cc @oli-obk @eddyb @RalfJung).
💔 miri on linux: test-pass → test-fail (cc @oli-obk @eddyb @RalfJung).
@oli-obk oli-obk deleted the const_binop_overflow branch June 26, 2020 18:42
@cuviper cuviper added this to the 1.46 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Show values that lead to an arithmetic overflow when computing constants
8 participants