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

Deprecate old items in RFC 2700 #72885

Closed
wants to merge 2 commits into from

Conversation

tesuji
Copy link
Contributor

@tesuji tesuji commented Jun 1, 2020

The numeric associated constants were stabilized from 1.43.0.
This PR deprecates the following items as of 1.46.0:

  • The old free standing MIN/MAX constants in the integer modules
  • The min_value/max_value methods on the integer types.

cc #68490
cc rust-lang/rfcs#2700

r? @dtolnay
cc @faern, @LukasKalbertodt

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 1, 2020
Comment on lines 128 to 131
#[rustc_deprecated(
since = "1.46.0",
reason = "The associated constant `f64::INFINITY` is now prefered",
suggestion = "f64::INFINITY",
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 am afraid that rustfix cannot handle this suggestion.

For example, what does rustfix do in this case?

use std::f64;
f64::INFINITY;

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 ran the snippet locally. rustfix doesn't do anything except for this case:

 #![warn(deprecated_in_future)]
 
 pub fn foo() -> f64 {
-    use std::f64 as float;
-    float::INFINITY
+    
+    f64::INFINITY
 }

@rust-highfive
Copy link
Collaborator

The job mingw-check 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 mingw-check
##[section]Starting: Initialize job
Agent name: 'Azure Pipelines 22'
Agent machine name: 'fv-az578'
Current agent version: '2.169.1'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200517.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200517.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.2)
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/32d7f996-2038-45f7-8a5f-da6a3f4fca34.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/72885/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/72885/merge:refs/remotes/pull/72885/merge
---
 ---> 3adb0605cc65
Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
 ---> Using cache
 ---> 28dbc326cb7f
Step 7/7 : ENV SCRIPT python3 ../x.py test src/tools/expand-yaml-anchors &&            python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python3 ../x.py build --stage 0 src/tools/build-manifest &&            python3 ../x.py test --stage 0 src/tools/compiletest &&            python3 ../x.py test src/tools/tidy &&            python3 ../x.py doc --stage 0 src/libstd &&            /scripts/validate-toolstate.sh
 ---> 537a01811900
Successfully built 537a01811900
Successfully tagged rust-ci:latest
Built container sha256:537a018119009dc218456238dec90b5530050db1e2a1e166550c218003f6159d
---
    Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
    Checking fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
    Checking rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
    Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir)
    Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
    Checking chalk-rust-ir v0.10.0
    Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse)
    Checking rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
    Checking rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
configure: rust.channel         := nightly
configure: build.submodules     := False
configure: dist.missing-tools   := True
configure: llvm.ccache          := sccache
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 
---
Hugepagesize:       2048 kB
DirectMap4k:      147392 kB
DirectMap2M:     4046848 kB
DirectMap1G:     5242880 kB
+ python3 ../x.py test src/tools/expand-yaml-anchors
Ensuring the YAML anchors in the GitHub Actions config were expanded
Ensuring the YAML anchors in the GitHub Actions config were expanded
Building stage0 tool expand-yaml-anchors (x86_64-unknown-linux-gnu)
   Compiling unicode-xid v0.2.0
   Compiling syn v1.0.11
   Compiling linked-hash-map v0.5.2
   Compiling lazy_static v1.4.0
   Compiling lazy_static v1.4.0
   Compiling yaml-rust v0.4.3
   Compiling quote v1.0.2
   Compiling thiserror-impl v1.0.5
   Compiling thiserror v1.0.5
   Compiling yaml-merge-keys v0.4.0
   Compiling expand-yaml-anchors v0.1.0 (/checkout/src/tools/expand-yaml-anchors)
Build completed successfully in 0:00:27
+ python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu
    Finished dev [unoptimized] target(s) in 0.21s
Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> i686-pc-windows-gnu)
---
    Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
    Checking fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
    Checking rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
    Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir)
    Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
    Checking chalk-rust-ir v0.10.0
    Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse)
    Checking rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
    Checking rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
     use crate::num::FpCategory as Fp;
     use crate::num::*;
-    use crate::f32::consts;
 
     #[test]
     fn test_num_f32() {
Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt" "--config-path" "/checkout" "--edition" "2018" "--unstable-features" "--skip-children" "--check" "/checkout/src/libstd/f32.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
Build completed unsuccessfully in 0:00:35
== clock drift check ==
  local time: Mon Jun  1 13:59:43 UTC 2020
  network time: Mon, 01 Jun 2020 13:59:43 GMT
  network time: Mon, 01 Jun 2020 13:59:43 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/72885/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/72885/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (4036) (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)

@faern
Copy link
Contributor

faern commented Jun 1, 2020

Was it decided to actually deprecate the old constants now? That was met with resistance from some people which is why it was soft-deprecated for now. I'm in favor of fully deprecating them, but I suspect this is too soon after stabilization according to some people(?).

Moving ahead and using min_value() and max_value() etc less is awesome. I did not have the energy or time to migrate the entire repository. If it turns out people are not willing to merge this, I would suggest you split the PR up into two PRs, one for just migrating code over to the newer constants, and you should be able to get that merged much easier.

@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: 'Hosted Agent'
Agent machine name: 'fv-az578'
Current agent version: '2.169.1'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200517.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200517.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.2)
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/1579ad95-5fa4-45ea-8bf3-53d3d46a12e7.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/72885/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/72885/merge:refs/remotes/pull/72885/merge
---
 ---> cb2676f08729
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
 ---> df25ce111862
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
 ---> 599b9ac96b27
Step 7/8 : ENV NO_DEBUG_ASSERTIONS=1
 ---> Using cache
 ---> 091087e35a36
---
   Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
   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 fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
   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)
---
.............................................F.....................................................F 1700/10277
........F..........................................................................i................ 1800/10277
.................................................................................................... 1900/10277
.................................................................................................... 2000/10277
....i..i............................................................................................ 2100/10277
..............................................................................................iiiii. 2200/10277
.................................................................................................... 2400/10277
.................................................................................................... 2500/10277
.................................................................................................... 2600/10277
.................................................................................................... 2700/10277
---
.........................i...............i.......................................................... 5200/10277
.................................................................................................... 5300/10277
.........................................................................i.......................... 5400/10277
...................................................................i................................ 5500/10277
...................................................................................ii.ii........i... 5600/10277
..........................i......................................................................... 5800/10277
..................................i................................................................. 5900/10277
........................................................................................ii.......... 6000/10277
...........................i........................................................................ 6100/10277
...........................i........................................................................ 6100/10277
.................................................................................................... 6200/10277
.................................................................................................... 6300/10277
..................................................ii...i..ii...........i............................ 6400/10277
.................................................................................................... 6600/10277
.................................................................................................... 6700/10277
.................................................................................................... 6700/10277
...................................................................................i..ii............ 6800/10277
.................................................................................................... 7000/10277
.................................................................................................... 7100/10277
.....................................i.............................................................. 7200/10277
.................................................................................................... 7300/10277
---
.................................................................................................... 8200/10277
.................................................................................................... 8300/10277
...........................................................................i........................ 8400/10277
.................................................................................................... 8500/10277
............................iiiiii.iiiiii.i......................................................... 8600/10277
.................................................................................................... 8800/10277
.................................................................................................... 8900/10277
.................................................................................................... 9000/10277
.................................................................................................... 9100/10277
---

1 error[E0080]: evaluation of constant value failed
2   --> $DIR/shift_overflow.rs:3:9
3    |
- LL |     X = 1 << ((u32::max_value() as u64) + 1),
-    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift left with overflow
+ LL |     X = 1 << ((u32::MAX as u64) + 1),
6 
7 error: aborting due to previous error
8 



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-eval/shift_overflow/shift_overflow.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args consts/const-eval/shift_overflow.rs`
error: 1 errors occurred comparing output.
status: exit code: 1
status: exit code: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-eval/shift_overflow.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-eval/shift_overflow" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-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-eval/shift_overflow/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error[E0080]: evaluation of constant value failed
  --> /checkout/src/test/ui/consts/const-eval/shift_overflow.rs:3:9
   |
LL |     X = 1 << ((u32::MAX as u64) + 1), //~ ERROR E0080

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
---

67 error[E0716]: temporary value dropped while borrowed
68   --> $DIR/const-int-conversion.rs:14:29
69    |
- LL |     let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes());
-    |            -------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
+ LL |     let d: &'static [u8] = &(i32::MIN.to_be().to_ne_bytes());
+    |            -------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
73    |            type annotation requires that borrow lasts for `'static`
74 LL |



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-int-conversion/const-int-conversion.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args consts/const-int-conversion.rs`
error: 1 errors occurred comparing output.
status: exit code: 1
status: exit code: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-int-conversion.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-int-conversion" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-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-conversion/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error[E0716]: temporary value dropped while borrowed
  --> /checkout/src/test/ui/consts/const-int-conversion.rs:2:28
   |
LL |     let x: &'static i32 = &(5_i32.reverse_bits());
   |            ------------    ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
   |            type annotation requires that borrow lasts for `'static`
...
LL | }
   | - temporary value is freed at the end of this statement
   | - temporary value is freed at the end of this statement

error[E0716]: temporary value dropped while borrowed
  --> /checkout/src/test/ui/consts/const-int-conversion.rs:4:28
   |
LL |     let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]));
   |            ------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
   |            type annotation requires that borrow lasts for `'static`
...
LL | }
   | - temporary value is freed at the end of this statement
   | - temporary value is freed at the end of this statement

error[E0716]: temporary value dropped while borrowed
  --> /checkout/src/test/ui/consts/const-int-conversion.rs:6:28
   |
LL |     let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]));
   |            ------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
   |            type annotation requires that borrow lasts for `'static`
...
LL | }
   | - temporary value is freed at the end of this statement
   | - temporary value is freed at the end of this statement

error[E0716]: temporary value dropped while borrowed
  --> /checkout/src/test/ui/consts/const-int-conversion.rs:8:28
   |
LL |     let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0])));
   |            ------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
   |            type annotation requires that borrow lasts for `'static`
...
LL | }
   | - temporary value is freed at the end of this statement
   | - temporary value is freed at the end of this statement

error[E0716]: temporary value dropped while borrowed
  --> /checkout/src/test/ui/consts/const-int-conversion.rs:10:29
   |
LL |     let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes());
   |            -------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
   |            type annotation requires that borrow lasts for `'static`
...
LL | }
   | - temporary value is freed at the end of this statement
   | - temporary value is freed at the end of this statement

error[E0716]: temporary value dropped while borrowed
  --> /checkout/src/test/ui/consts/const-int-conversion.rs:12:29
   |
LL |     let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes());
   |            -------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
   |            type annotation requires that borrow lasts for `'static`
...
LL | }
   | - temporary value is freed at the end of this statement
   | - temporary value is freed at the end of this statement

error[E0716]: temporary value dropped while borrowed
  --> /checkout/src/test/ui/consts/const-int-conversion.rs:14:29
   |
LL |     let d: &'static [u8] = &(i32::MIN.to_be().to_ne_bytes());
   |            -------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
   |            type annotation requires that borrow lasts for `'static`
   |            type annotation requires that borrow lasts for `'static`
LL |         //~^ ERROR temporary value dropped while borrowed
   | - temporary value is freed at the end of this statement

error: aborting due to 7 previous errors

---

355 error: any use of this value will cause an error
356   --> $DIR/const-int-unchecked.rs:134:25
357    |
- LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::min_value(), -1) };
-    | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
+ LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) };
360    |                         |
361    |                         overflow executing `unchecked_div`
362 


371 error: any use of this value will cause an error
372   --> $DIR/const-int-unchecked.rs:139:25
373    |
- LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::min_value(), -1) };
-    | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
+ LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) };
376    |                         |
377    |                         overflow executing `unchecked_rem`
378 



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-int-unchecked/const-int-unchecked.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args consts/const-int-unchecked.rs`
error: 1 errors occurred comparing output.
status: exit code: 1
status: exit code: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-int-unchecked.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-int-unchecked" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-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-unchecked/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:15:29
   |
LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) };
   |                             |
   |                             overflowing shift by 8 in `unchecked_shl`
   |
   = note: `#[deny(const_err)]` on by default
   = note: `#[deny(const_err)]` on by default

error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:17:31
   |
LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) };
   |                               |
   |                               overflowing shift by 16 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:19:31
   |
LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) };
   |                               |
   |                               overflowing shift by 32 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:21:31
   |
LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) };
   |                               |
   |                               overflowing shift by 64 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:23:33
   |
LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) };
   |                                 |
   |                                 overflowing shift by 128 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:28:29
   |
LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) };
   |                             |
   |                             overflowing shift by 8 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:30:31
   |
LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) };
   |                               |
   |                               overflowing shift by 16 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:32:31
   |
LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) };
   |                               |
   |                               overflowing shift by 32 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:34:31
   |
LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) };
   |                               |
   |                               overflowing shift by 64 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:36:33
   |
LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) };
   |                                 |
   |                                 overflowing shift by 128 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:41:33
   |
LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) };
   |                                 |
   |                                 overflowing shift by 255 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:43:35
   |
LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) };
   |                                   |
   |                                   overflowing shift by 65535 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:45:35
   |
LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) };
   |                                   |
   |                                   overflowing shift by 4294967295 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:47:35
   |
LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) };
   |                                   |
   |                                   overflowing shift by 18446744073709551615 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:49:37
   |
LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) };
   |                                     |
   |                                     overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:55:40
   |
LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) };
   |                                        |
   |                                        overflowing shift by 250 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:57:42
   |
LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) };
   |                                          |
   |                                          overflowing shift by 65523 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:59:42
   |
LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) };
   |                                          |
   |                                          overflowing shift by 4294967271 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:61:42
   |
LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) };
   |                                          |
   |                                          overflowing shift by 18446744073709551586 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:63:44
   |
LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) };
   |                                            |
   |                                            overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shl`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:70:29
   |
LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
   |                             |
   |                             overflowing shift by 8 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:72:31
   |
LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) };
   |                               |
   |                               overflowing shift by 16 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:74:31
   |
LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) };
   |                               |
   |                               overflowing shift by 32 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:76:31
   |
LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) };
   |                               |
   |                               overflowing shift by 64 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:78:33
   |
LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) };
   |                                 |
   |                                 overflowing shift by 128 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:83:29
   |
LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) };
   |                             |
   |                             overflowing shift by 8 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:85:31
   |
LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) };
   |                               |
   |                               overflowing shift by 16 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:87:31
   |
LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) };
   |                               |
   |                               overflowing shift by 32 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:89:31
   |
LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) };
   |                               |
   |                               overflowing shift by 64 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:91:33
   |
LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) };
   |                                 |
   |                                 overflowing shift by 128 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:96:33
   |
LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) };
   |                                 |
   |                                 overflowing shift by 255 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:98:35
   |
LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) };
   |                                   |
   |                                   overflowing shift by 65535 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:100:35
   |
LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) };
   |                                   |
   |                                   overflowing shift by 4294967295 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:102:35
   |
LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) };
   |                                   |
   |                                   overflowing shift by 18446744073709551615 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:104:37
   |
LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) };
   |                                     |
   |                                     overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:110:40
   |
LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) };
   |                                        |
   |                                        overflowing shift by 250 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:112:42
   |
LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) };
   |                                          |
   |                                          overflowing shift by 65523 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:114:42
   |
LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) };
   |                                          |
   |                                          overflowing shift by 4294967271 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:116:42
   |
LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) };
   |                                          |
   |                                          overflowing shift by 18446744073709551586 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:118:44
   |
LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) };
   |                                            |
   |                                            overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shr`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:123:25
   |
LL | const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) };
   |                         |
   |                         overflow executing `unchecked_add`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:126:25
   |
LL | const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) };
   |                         |
   |                         overflow executing `unchecked_sub`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:129:25
   |
LL | const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) };
   |                         |
   |                         overflow executing `unchecked_mul`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:132:25
   |
LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) };
   |                         |
   |                         dividing by zero

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:134:25
   |
LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) };
   |                         |
   |                         overflow executing `unchecked_div`

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:137:25
   |
LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) };
   |                         |
   |                         calculating the remainder with a divisor of zero

error: any use of this value will cause an error
error: any use of this value will cause an error
  --> /checkout/src/test/ui/consts/const-int-unchecked.rs:139:25
   |
LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) };
   |                         |
   |                         overflow executing `unchecked_rem`

error: aborting due to 47 previous errors
---
test result: FAILED. 10209 passed; 3 failed; 65 ignored; 0 measured; 0 filtered out



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-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"


thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:348:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
Build completed unsuccessfully in 1:04:41
== clock drift check ==
  local time: Mon Jun  1 16:29:34 UTC 2020
  network time: Mon, 01 Jun 2020 16:29:35 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/72885/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/72885/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (3370) (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)

@tesuji tesuji marked this pull request as ready for review June 2, 2020 01:39
LL | if value <= (u32::max_value() as i64) && value >= 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()`
|
= note: `-D clippy::checked-conversions` implied by `-D warnings`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

False negative tracked at rust-lang/rust-clippy#5675

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

As @faern mentioned, we are not ready to start deprecating anything at this point. Could you change the PR to only updating internal usages without any public deprecations?

@dtolnay
Copy link
Member

dtolnay commented Jun 2, 2020

Closing in favor of #72906.

@dtolnay dtolnay closed this Jun 2, 2020
RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 11, 2020
…, r=dtolnay

Migrate to numeric associated consts

The deprecation PR is rust-lang#72885

cc rust-lang#68490
cc rust-lang/rfcs#2700
RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 12, 2020
…, r=dtolnay

Migrate to numeric associated consts

The deprecation PR is rust-lang#72885

cc rust-lang#68490
cc rust-lang/rfcs#2700
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jun 12, 2020
…, r=dtolnay

Migrate to numeric associated consts

The deprecation PR is rust-lang#72885

cc rust-lang#68490
cc rust-lang/rfcs#2700
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 23, 2020
…, r=dtolnay

Migrate to numeric associated consts

The deprecation PR is rust-lang#72885

cc rust-lang#68490
cc rust-lang/rfcs#2700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants