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 missing Wrapping methods, use doc_comment! #49393

Closed
wants to merge 4 commits into from

Conversation

clarfonthey
Copy link
Contributor

Part of #32463.

@rust-highfive
Copy link
Collaborator

r? @kennytm

(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 Mar 26, 2018
@kennytm
Copy link
Member

kennytm commented Mar 27, 2018

r? @SimonSapin

@TimNN
Copy link
Contributor

TimNN commented Apr 2, 2018

Your PR failed on Travis. 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.
Resolving deltas: 100% (612388/612388), completed with 4838 local objects.
---
[00:00:44] configure: rust.quiet-tests     := True
---
[00:38:19] .........................................................................i..........................
[00:38:25] ................i...................................................................................
---
[00:38:59] ............................................................................................i.......
[00:39:06] ................................................................i...................................
---
[00:39:58] .............................................i......................................................
---
[00:43:37] .............................i......................................................................
[00:43:51] ..............................................................i.....................................
[00:44:06] ...............................................i....................................................
[00:44:25] ....................................................................................................
[00:44:46] ....................................................................................................
[00:45:07] ....................................................................................................
[00:45:31] .i................................................................................................i.
[00:45:59] ........................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:46:05] ............
[00:46:34] ....................................................................................................
[00:47:07] ...............................................................ii...................................
[00:47:54] ..........................i....................................................i.ii.................
[00:48:32] .......................................................................................iiiiiii......
---
[00:50:29] ....................................i...............................................................
[00:50:36] ....................................................................................................
[00:50:44] ..................i............................................................ii.iii...............
[00:50:51] ....................................................................................................
[00:50:58] ........i..............................i............................................................
[00:51:06] ....................................................................................................
[00:51:12] .....................i..............................................................................
[00:51:20] ....................................................................................................
[00:51:30] ....................................................................................................
[00:51:40] ....................................................................................................
[00:51:51] ....................................................................................................
[00:52:03] ....................................................................................................
[00:52:11] ..............i.....................................................................................
[00:52:21] .................i..ii..............................................................................
[00:52:31] ....................................................................................................
[00:52:41] ....................................................................................................
[00:52:50] ....................................................................................i...............
[00:53:00] ..............................i.....................................................................
---
[00:53:37] ...........................i........................................................................
[00:53:38] ....................................................................i...............................
[00:53:39] ................i.......................................................
---
[00:53:53] ...........i........................
---
[00:54:23] i...i..ii....i.............ii........iii......i..i...i...ii..i..i..ii.....
---
[00:54:26] i.......i......................i......
---
[00:55:02] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[00:55:03] ....ii...
---
[01:03:25] ...i................................................................................................
---
[01:05:10] ......................................i.............................................................
[01:05:29] ....................................................................................................
[01:05:48] .............................................i......................................................
---
[01:07:17] ........................................................ii..........................................
---
[01:08:19] .............................................................i......................................
---
[01:11:16] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "core" "--" "--quiet"
[01:11:16] expected success, got: exit code: 101
[01:11:16]
[01:11:16]
[01:11:16] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:11:16] Build completed unsuccessfully in 0:33:48
[01:11:16] Makefile:58: recipe for target 'check' failed
[01:11:16] make: *** [check] Error 1

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.

@kennytm
Copy link
Member

kennytm commented Apr 2, 2018

The actual error is doc-tests in core. Basically missing imports.

[01:11:16] ---- num/wrapping.rs - num::wrapping::Wrapping<u128>::is_power_of_two (line 684) stdout ----
[01:11:16] 	error[E0425]: cannot find function `Wrapping` in this scope
[01:11:16]  --> num/wrapping.rs:685:9
[01:11:16]   |
[01:11:16] 4 | assert!(Wrapping(16).is_power_of_two());
[01:11:16]   |         ^^^^^^^^ not found in this scope
[01:11:16] help: possible candidate is found in another module, you can import it into scope
[01:11:16]   |
[01:11:16] 3 | use std::num::Wrapping;
[01:11:16]   |
...

@clarfonthey
Copy link
Contributor Author

Will fix that later today. Also was thinking of revamping the Wrapping docs to use doc_comment!, so, I'll do that also.

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

scottmcm commented Apr 3, 2018

Sorry for giving you a bad commit; I sent a PR for the fix this morning: clarfonthey#2

@TimNN
Copy link
Contributor

TimNN commented Apr 3, 2018

Your PR failed on Travis. 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.
Resolving deltas: 100% (609943/609943), completed with 4836 local objects.
---
[00:00:44] configure: rust.quiet-tests     := True
---
[00:58:29] ..........................................................................i.........................
[00:58:38] .................i..................................................................................
---
[00:59:21] .............................................................................................i......
[00:59:30] .................................................................i..................................
---
[01:00:45] .............................................i......................................................
---
[01:06:04] .............................i......................................................................
[01:06:24] ..............................................................i.....................................
[01:06:43] ...............................................i....................................................
[01:07:09] ....................................................................................................
[01:07:38] ....................................................................................................
[01:08:06] ....................................................................................................
[01:08:38] .i................................................................................................i.
[01:08:56] ........................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[01:09:27] ............................................................
[01:10:07] ....................................................................................................
[01:10:55] ...............................................................ii...................................
[01:11:34] ..........................i....................test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[01:11:58] ................................i.ii.................
[01:12:52] .......................................................................................iiiiiii......
---
[01:15:56] ....................................i...............................................................
[01:16:06] ....................................................................................................
[01:16:16] ..................i............................................................ii.iii...............
[01:16:25] ....................................................................................................
[01:16:35] ........i..............................i............................................................
[01:16:45] ....................................................................................................
[01:16:53] .....................i..............................................................................
---
[01:18:08] ..............i.....................................................................................
[01:18:20] .................i..ii..............................................................................
[01:18:32] ....................................................................................................
[01:18:45] ....................................................................................................
[01:18:56] ....................................................................................i...............
[01:19:08] ..............................i.....................................................................
---
[01:19:50] ...........................i........................................................................
[01:19:52] ....................................................................i...............................
[01:19:53] ................i.......................................................
---
[01:20:13] ...........i........................
---
[01:20:50] i...i..ii....i.............ii........iii......i..i...i...ii..i..i..ii.....
---
[01:20:54] i.......i......................i......
---
[01:21:45] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:21:46] ....ii...
---
[01:35:15] ...i................................................................................................
---
[01:37:58] ......................................i.............................................................
[01:38:29] ....................................................................................................
[01:38:58] .............................................i......................................................
---
[01:41:01] ..........................................................ii........................................
---
[01:42:33] ..............................................................i.....................................
---
[01:45:44] .......................................................F..F...........F..F...........F..F...........
[01:46:06] F..F...........F..F...........F..F..................................................................
---
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:689:9
[01:46:52]   |
[01:46:52] 8 | assert!(Wrapping(16).is_power_of_two());
[01:46:52]   |         ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:690:10
[01:46:52]   |
[01:46:52] 9 | assert!(!Wrapping(10).is_power_of_two());
[01:46:52]   |          ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:691:10
[01:46:52]    |
[01:46:52] 10 | assert!(!Wrapping(0).is_power_of_two());
[01:46:52]    |          ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:46:52]
[01:46:52] ---- num/wrapping.rs - num::wrapping::Wrapping<u128>::next_power_of_two (line 707) stdout ----
[01:46:52]  error[E0432]: unresolved import `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:710:5
[01:46:52]   |
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:12
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:45
[01:46:52]   |
[01:46:52] 8 | assert_apping;
[01:46:52]    |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:50
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |                                                  ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52]
[01:46:52] ---- num/wrapping.rs - num::wrapping::Wrapping<u16>::is_power_of_two (line 684) stdout ----
[01:46:52]  error[E0432]: unresolved import `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:687:5
[01:46:52]   |
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:689:9
[01:46:52]   |
[01:46:52] 8 | assert!(Wrapping(16).is_power_of_two());
[01:46:52]   |         ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:690:10
[01:46:52]   |
[01:46:52] 9 | assert!(!Wrapping(10).is_power_of_two());
[01:46:52]   |          ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:691:10
[01:46:52]    |
[01:46:52] 10 | assert!(!Wrapping(0).is_power_of_two());
[01:46:52]    |          ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52]
[01:46:52] ---- num/wrapping.rs - num::wrapping::Wrapping<u16>::next_power_of_two (line 707) stdout ----
[01:46:52]  error[E0432]: unresolved import `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:710:5
[01:46:52]   |
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:12
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:45
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:12
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:45
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:12
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]    |
[01:46:52] 5  | use std::num::Wrapping;
[01:46:52]    |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:50
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |                                                  ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52]
[01:46:52] ---- num/wrapping.rs - num::wrapping::Wrapping<u32>::is_power_of_two (line 684) stdout ----
[01:46:52]  error[E0432]: unresolved import `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:687:5
[01:46:52]   |
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:689:9
[01:46:52]   |
[01:46:52] 8 | assert!(Wrapping(16).is_power_of_two());
[01:46:52]   |         ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:690:10
[01:46:52]   |
[01:46:52] 9 | assert!(!Wrapping(10).is_power_of_two());
[01:46:52]   |          ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:691:10
[01:46:52]    |
[01:46:52] 10 | assert!(!Wrapping(0).is_power_of_two());
[01:46:52]    |          ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52]
[01:46:52] ---- num/wrapping.rs - num::wrapping::Wrapping<u32>::next_power_of_two (line 707) stdout ----
[01:46:52]  error[E0432]: unresolved import `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:710:5
[01:46:52]   |
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:12
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:45
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:12
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:45
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:12
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]    |
[01:46:52] 5  | use std::num::Wrapping;
[01:46:52]    |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:50
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |                                                  ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52]
[01:46:52] ---- num/wrapping.rs - num::wrapping::Wrapping<u64>::is_power_of_two (line 684) stdout ----
[01:46:52]  error[E0432]: unresolved import `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:687:5
[01:46:52]   |
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:689:9
[01:46:52]   |
[01:46:52] 8 | assert!(Wrapping(16).is_power_of_two());
[01:46:52]   |         ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:690:10
[01:46:52]   |
[01:46:52] 9 | assert!(!Wrapping(10).is_power_of_two());
[01:46:52]   |          ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:691:10
[01:46:52]    |
[01:46:52] 10 | assert!(!Wrapping(0).is_power_of_two());
[01:46:52]    |          ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52]
[01:46:52] ---- num/wrapping.rs - num::wrapping::Wrapping<u64>::next_power_of_two (line 707) stdout ----
[01:46:52]  error[E0432]: unresolved import `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:710:5
[01:46:52]   |
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:12
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:45
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:12
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:45
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:12
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]    |
[01:46:52] 5  | use std::num::Wrapping;
[01:46:52]    |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:50
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |                                                  ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52]
[01:46:52] ---- num/wrapping.rs - num::wrapping::Wrapping<u8>::is_power_of_two (line 684) stdout ----
[01:46:52]  error[E0432]: unresolved import `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:687:5
[01:46:52]   |
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:689:9
[01:46:52]   |
[01:46:52] 8 | assert!(Wrapping(16).is_power_of_two());
[01:46:52]   |         ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:690:10
[01:46:52]   |
[01:46:52] 9 | assert!(!Wrapping(10).is_power_of_nction `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:12
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:45
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:12
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:45
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:12
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]    |
[01:46:52] 5  | use std::num::Wrapping;
[01:46:52]    |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:50
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |                                                  ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52]
[01:46rror: unused import: `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:687:5
---
[01:46:52]   = note: #[deny(unused_imports)] implied by #[deny(warnings)]
[01:46:52]
[01:46:52] thread 'rustc' panicked at 'couldn't compile the test', librustdoc/test.rs:306:13
[01:46:52]
[01:46:52] ---- num/wrapping.rs - num::wrapping::Wrapping<usize>::next_power_of_two (line 707) stdout ----
[01:46:52]  error[E0432]: unresolved import `std::num::wrapping`
[01:46:52]  --> num/wrapping.rs:710:5
[01:46:52]   |
[01:46:52] 6 | use std::num::wrapping;
[01:46:52]   |     ^^^^^^^^^^^^^^^^^^ no `wrapping` in `num`. Did you mean to use `Wrapping`?
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:12
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:712:45
[01:46:52]   |
[01:46:52] 8 | assert_eq!(Wrapping(2).next_power_of_two(), Wrapping(2));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:12
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]  --> num/wrapping.rs:713:45
[01:46:52]   |
[01:46:52] 9 | assert_eq!(Wrapping(3).next_power_of_two(), Wrapping(4));
[01:46:52]   |                                             ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]   |
[01:46:52] 5 | use std::num::Wrapping;
[01:46:52]   |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/wrapping.rs:714:12
[01:46:52]    |
[01:46:52] 10 | assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
[01:46:52]    |            ^^^^^^^^ not found in this scope
[01:46:52] help: possible candidate is found in another module, you can import it into scope
[01:46:52]    |
[01:46:52] 5  | use std::num::Wrapping;
[01:46:52]    |
[01:46:52]
[01:46:52] error[E0425]: cannot find function `Wrapping` in this scope
[01:46:52]   --> num/     num/wrapping.rs - num::wrapping::Wrapping<u64>::next_power_of_two (line 707)
---
[01:46:52] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "core" "--" "--quiet"
[01:46:52] expected success, got: exit code: 101
[01:46:52]
[01:46:52]
[01:46:52] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:46:52] Build completed unsuccessfully in 0:49:26
[01:46:52] Makefile:58: recipe for target 'check' failed
[01:46:52] make: *** [check] Error 1

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.

@scottmcm
Copy link
Member

scottmcm commented Apr 4, 2018

Sorry, @clarcharr; apparently I shouldn't try to do a quick fix before leaving for work. Hopefully this time I got it right (as I waited for the annoying stage2 build for rustdoc, and the doctests passed locally).

@clarfonthey
Copy link
Contributor Author

@scottmcm No worries; thanks for the changes. :)

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

Ping from triage @SimonSapin! This PR needs your review.

@SimonSapin
Copy link
Contributor

  • signum: looks good
  • abs: implementation looks good, but the doc-comment needs to say more. Please copy the paragraph (and example) from e.g. i32::wrapping_abs.
  • is_positive, is_negative, is_power_of_two: the premise of Tracking issue for integer methods for Wrapping #32463 is that Wrapping(x.0.foo()) is a lot more cumbersome than x.foo(), but for methods returning a boolean x.0.foo() doesn’t seem as bad. So I don’t know if adding these methods on Wrapping is really useful. What do you think?
  • next_power_of_two, wrapping_next_power_of_two: do you have a use case for this? I have a hard time imagining how this would be useful. It looks like I included in the list in Tracking issue for integer methods for Wrapping #32463 two years ago, but the dubiousness-question-mark says I probably didn’t look at it too closely.

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

As far as the docs go, I was planning on moving these docs to use doc_comment! anyway, for consistency with the primitive docs. When I do that I'll simply copy the documentation for wrapping_abs over in its entirety, modifying the examples.

As far as the boolean methods: I personally agree, although I'd use #44724 as a precedent for these being there. There is absolutely no use case for changing the endianness of a single byte, but having the methods exist on all integer types makes creating your own traits a lot easier, as you won't have to handle i8 and u8 separately. I imagine that adding these boolean methods to Wrapping<T> would also be useful for a similar reason. That said, if you would rather not have them, I'd be more than willing to remove them.

For the usefulness of wrapping_next_power_of_two, I'll let @scottmcm answer because I've personally not used either method.

@scottmcm
Copy link
Member

I think these are all consistency arguments, making sure that replacing uN with wN just works and that everything has the full foo(), checked_foo(), and wrapping_foo(). For example,

Wrapped division on unsigned types is just normal division. There's no way wrapping could ever happen. This function exists, so that all operations are accounted for in the wrapping operations.
~ https://doc.rust-lang.org/std/primitive.u32.html#method.wrapping_div

And like how one of the arguments for Ord::min was "I can just change my float code to integer code and it works, no need to replace a.min(b) with cmp::min(a, b)".

@SimonSapin
Copy link
Contributor

I hear the argument that Wrapping should have some next_power_of_two method for consistency, but its proposed behavior seems more like a footgun than anything you’d ever want (though I could be completely wrong). Zero is neither a power of two, nor after ("next" to) the original value.

@clarfonthey
Copy link
Contributor Author

Perhaps wrapping to one might be a better solution?

@scottmcm
Copy link
Member

Well, the next power of two after 200 is definitely 256, and 256 = 0 mod 256, so I do think that wrapping to 0 is the correct output. And I think "doesn't give you a power of two" is no more surprising or a footgun than abs not giving you a non-negative number.

.wrapping_next_power_of_two().wrapping_sub(1) is actually useful, since it never overflows.

@SimonSapin
Copy link
Contributor

I feel like we’re all making suppositions on a theoretical basis here, and maybe we’d better off not add this method until someone comes along who actually wants to use it. Then we can look at the use case and see what behavior is most useful and least of a footgun.

@bors
Copy link
Contributor

bors commented Apr 14, 2018

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

@pietroalbini
Copy link
Member

Ping from triage! What's the status on this?

@shepmaster
Copy link
Member

Thanks for the PR @clarcharr ! Since we haven't heard from you in a few weeks, I'm going to go ahead and close this PR for now to keep the queue tidy. If you have time to address the feedback, we'd love for you to reopen this PR!

@shepmaster shepmaster closed this Apr 30, 2018
@clarfonthey clarfonthey changed the title Add signed-specific methods to Wrapping<T>. Add missing Wrapping methods, use doc_comment! May 5, 2018
@clarfonthey
Copy link
Contributor Author

I finally got around to doing what I wanted for this PR, so, I'm going to open it up again. This adds all of the missing methods from the tracking issue, and uses doc_comment!, copying the examples from the primitives themselves when available.

@clarfonthey
Copy link
Contributor Author

clarfonthey commented May 5, 2018

Err, I can't actually open it, so, I'll let @shepmaster or someone else do it.

(If it makes more sense to open a new PR, I'll do that.)

@kennytm
Copy link
Member

kennytm commented May 5, 2018

@clarcharr It can't be reopened because the branch has been updated. Please open a new PR.

screenshot_2018-05-06 00 11 57_vvpnrm

@shepmaster
Copy link
Member

because the branch has been updated.

Well, that's annoying. We should probably warn people about that in our triage message. Sorry @clarcharr !

bors added a commit that referenced this pull request May 28, 2018
Add missing Wrapping methods, use doc_comment!

Re-opened version of #49393 . Finishing touches for #32463.

Note that this adds `Shl` and `Shr` implementations for `Wrapping<i128>` and `Wrapping<u128>`, which were previously missed. This is technically insta-stable, but I don't know why this would be a problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants