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

Implemented MIN and MAX constants for the non-zero integer types.#89065 #89077

Closed
wants to merge 14 commits into from

Conversation

mjclements
Copy link

@mjclements mjclements commented Sep 18, 2021

This implements the feature requested in #89065 . I wrote some tests, but it appears that non-stable features aren't supposed to be tested in the normal nonzero.rs test file. Is there a place to add tests for non-stable features?

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 18, 2021
@mjclements mjclements changed the title Implemented MIN and MAX constants for the non-zero integer types. #89076 Implemented MIN and MAX constants for the non-zero integer types.#89065 Sep 19, 2021
( $( $MinVal:expr , $Ty: ident($Int: ty); )+ ) => {
$(
impl $Ty {
#[unstable(feature = "nonzero_max", issue = "89065")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't see a reason to use two separate feature gates for min and max.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed. 591b89d

Comment on lines 906 to 907
// SAFETY: Since the MAX value, for any supported integer type, is greater than 0, the MAX will always be non-zero.
pub const MAX : $Ty = unsafe { $Ty::new_unchecked(<$Int>::MAX) };
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// SAFETY: Since the MAX value, for any supported integer type, is greater than 0, the MAX will always be non-zero.
pub const MAX : $Ty = unsafe { $Ty::new_unchecked(<$Int>::MAX) };
pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap();

Since we're in a const context this is guaranteed to get evaluated (and potentially fail if you pass in a zero after all) at compile time. No need for unsafe.

Same for the min case below. Unfortunately unwrap_or isn't const yet or we could get rid of the $MinVal input entirely.

Copy link
Author

Choose a reason for hiding this comment

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

I agree! I really wanted to get rid of that $MinVal, but couldn't find a clean way. Fixed the unsafe.
591b89d

// SAFETY: In the signed case, the minimum integer is negative, and therefore non-zero.
// SAFETY: In the unsignedd case, we use one, which is non-zero.
pub const MIN : $Ty = unsafe { $Ty::new_unchecked($MinVal)};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation looks off here. Did the formatter really demand it like that?

Copy link
Member

Choose a reason for hiding this comment

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

It's a macro, it should be formatted manually.

Copy link
Author

Choose a reason for hiding this comment

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

Do you have specific advice on how to format it? I noticed that macros needed manual formatting. Wasn't sure if I had it right though @ibraheemdev .

Copy link
Contributor

Choose a reason for hiding this comment

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

This closing brace, and the analogous one in nonzero_constants_signed should be unindented by one level = four spaces. The rest looks fine.

Comment on lines 899 to 930
macro_rules! nonzero_min_max {
( $( $MinVal:expr , $Ty: ident($Int: ty); )+ ) => {
$(
impl $Ty {
#[unstable(feature = "nonzero_min_max", issue = "89065")]
#[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")]
pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap() ;
#[unstable(feature = "nonzero_min_max", issue = "89065")]
#[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")]
/// # Examples
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($MinVal), ";")]
pub const MIN : $Ty = $Ty::new($MinVal).unwrap();
}
)+
}
}

nonzero_min_max! {
1 , NonZeroU8(u8);
1 , NonZeroU16(u16);
1 , NonZeroU32(u32);
1 , NonZeroU64(u64);
1 , NonZeroU128(u128);
1 , NonZeroUsize(usize);
i8::MIN , NonZeroI8(i8);
i16::MIN , NonZeroI16(i16);
i32::MIN , NonZeroI32(i32);
i64::MIN , NonZeroI64(i64);
i128::MIN , NonZeroI128(i128);
isize::MIN , NonZeroIsize(isize);
}
Copy link
Member

@ibraheemdev ibraheemdev Sep 21, 2021

Choose a reason for hiding this comment

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

Suggested change
macro_rules! nonzero_min_max {
( $( $MinVal:expr , $Ty: ident($Int: ty); )+ ) => {
$(
impl $Ty {
#[unstable(feature = "nonzero_min_max", issue = "89065")]
#[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")]
pub const MAX : $Ty = $Ty::new(<$Int>::MAX).unwrap() ;
#[unstable(feature = "nonzero_min_max", issue = "89065")]
#[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")]
/// # Examples
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($MinVal), ";")]
pub const MIN : $Ty = $Ty::new($MinVal).unwrap();
}
)+
}
}
nonzero_min_max! {
1 , NonZeroU8(u8);
1 , NonZeroU16(u16);
1 , NonZeroU32(u32);
1 , NonZeroU64(u64);
1 , NonZeroU128(u128);
1 , NonZeroUsize(usize);
i8::MIN , NonZeroI8(i8);
i16::MIN , NonZeroI16(i16);
i32::MIN , NonZeroI32(i32);
i64::MIN , NonZeroI64(i64);
i128::MIN , NonZeroI128(i128);
isize::MIN , NonZeroIsize(isize);
}
macro_rules! nonzero_min_max {
( $( $Ty:ident($Int:ty) => $min_val:expr, $max_val:expr )+ ) => {
$(
impl $Ty {
#[unstable(feature = "nonzero_min_max", issue = "89065")]
#[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")]
pub const MAX : $Ty = $Ty::new($max_val).unwrap() ;
#[unstable(feature = "nonzero_min_max", issue = "89065")]
#[doc = concat!("The minimum value for a`", stringify!($Ty), "`.")]
/// # Examples
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN, ", stringify!($MinVal), ";")]
pub const MIN: $Ty = $Ty::new($min_val).unwrap();
}
)+
}
}
nonzero_min_max! {
NonZeroU8 => 1, u8::MAX;
NonZeroU16 => 1, u16::MAX;
NonZeroU32 => 1, u32::MAX;
NonZeroU64 => 1, u64::MAX;
NonZeroU128 => 1, u128::MAX;
NonZeroUsize => 1, usize::MAX;
NonZeroI8 => i8::MIN, i8::MAX;
NonZeroI16 => i16::MIN, i16::MAX;
NonZeroI32 => i32::MIN, i32::MAX;
NonZeroI64 => i64::MIN, i64::MAX;
NonZeroI128 => i128::MIN, i128::MAX;
NonZeroIsize => isize::MIN, isize::MAX;
}

Copy link
Member

Choose a reason for hiding this comment

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

Formatting is up to you, but I'd probably do something like this.

@LingMan
Copy link
Contributor

LingMan commented Sep 21, 2021

Mirroring part of a comment from @kpreid so it doesn't get forgotten about:

  • NonZeroI*::{MIN,MAX} are a little weird, because in all other integer cases, all integers between MIN and MAX exist, but in the case of nonzero signed integers, there's also a hole in the middle. This seems an oddity worth thinking about and possibly documenting.

I agree that this hole should be called out explicitly in the documentation.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@mjclements
Copy link
Author

Mirroring part of a comment from @kpreid so it doesn't get forgotten about:

  • NonZeroI*::{MIN,MAX} are a little weird, because in all other integer cases, all integers between MIN and MAX exist, but in the case of nonzero signed integers, there's also a hole in the middle. This seems an oddity worth thinking about and possibly documenting.

I agree that this hole should be called out explicitly in the documentation.

I think this is resolved.

Copy link
Contributor

@kpreid kpreid left a comment

Choose a reason for hiding this comment

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

I agree that the zero case has been mentioned adequately, but since I looked, here's some minor suggestions (all to do with the documentation or formatting).

#[unstable(feature = "nonzero_min_max", issue = "89065")]
#[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")]
/// # Examples
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this and the below example need a ``` ... ``` code block, for formatting (though they're not very interesting as doctests).

I think including some blank lines as done above for nonzero_unsigned_signed_operations (such as ``` above and below the Examples header, and a normal blank line between the MAX and MIN definitions) but before would also make the macro code more readable even if it doesn't affect the documentation output.

$(
impl $Ty {
#[unstable(feature = "nonzero_min_max", issue = "89065")]
#[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")]
Copy link
Contributor

Choose a reason for hiding this comment

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

In for a`", there should be a space between a and `, and the sentence needs a period at the end.

// SAFETY: In the signed case, the minimum integer is negative, and therefore non-zero.
// SAFETY: In the unsignedd case, we use one, which is non-zero.
pub const MIN : $Ty = unsafe { $Ty::new_unchecked($MinVal)};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This closing brace, and the analogous one in nonzero_constants_signed should be unindented by one level = four spaces. The rest looks fine.

#[unstable(feature = "nonzero_min_max", issue = "89065")]
#[doc = concat!("The maximum value for a`", stringify!($Ty), "` is the same as `", stringify!($Int), "`")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX, ", stringify!($Int), "::MAX);")]
/// Note, while most integer types are defined for every whole number between MIN and
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be either Note that, while or Note: while rather than Note, while, but I'm not sure whether others would agree with that grammar nitpick.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I'd vote for Note: While with a capital W.

mjclements and others added 2 commits September 24, 2021 12:20
Co-authored-by: LingMan <LingMan@users.noreply.github.com>
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-10 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
.................................................................................................... 1500/3539
.................................................................................................... 1600/3539
.................................................................................................... 1700/3539
.................................................................................................... 1800/3539
................................................F.F..........F...F...........F..F.............FF.... 1900/3539
.........F...F...........FF..............FF..............FF.............FF..............FF.......... 2000/3539
..FF.............F.F................................................................................ 2100/3539
.................................................................................................... 2300/3539
.................................................................................................... 2400/3539
.................................................................................................... 2500/3539
.................................................................................................... 2600/3539
---
---- src/num/nonzero.rs - num::nonzero::NonZeroI128::MAX (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI128`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI128::MAX, i128::MAX);
  |            ^^^^^^^^^^^ use of undeclared type `NonZeroI128`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroI128::MIN (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI128`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI128::MIN, i128::MIN);
  |            ^^^^^^^^^^^ use of undeclared type `NonZeroI128`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroI16::MAX (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI16`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI16::MAX, i16::MAX);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroI16`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroI16::MIN (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI16`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI16::MIN, i16::MIN);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroI16`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroI32::MAX (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI32`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI32::MAX, i32::MAX);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroI32`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroI32::MIN (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI32`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI32::MIN, i32::MIN);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroI32`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroI64::MIN (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI64`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI64::MIN, i64::MIN);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroI64`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroI64::MAX (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI64`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI64::MAX, i64::MAX);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroI64`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroI8::MAX (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI8`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI8::MAX, i8::MAX);
  |            ^^^^^^^^^ use of undeclared type `NonZeroI8`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroI8::MIN (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroI8`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroI8::MIN, i8::MIN);
  |            ^^^^^^^^^ use of undeclared type `NonZeroI8`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroIsize::MIN (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroIsize`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroIsize::MIN, isize::MIN);
  |            ^^^^^^^^^^^^ use of undeclared type `NonZeroIsize`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroIsize::MAX (line 927) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroIsize`
 --> src/num/nonzero.rs:928:12
  |
4 | assert_eq!(NonZeroIsize::MAX, isize::MAX);
  |            ^^^^^^^^^^^^ use of undeclared type `NonZeroIsize`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU128::MAX (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU128`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU128::MAX, u128::MAX);
  |            ^^^^^^^^^^^ use of undeclared type `NonZeroU128`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU128::MIN (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU128`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU128::MIN, u128::MIN);
  |            ^^^^^^^^^^^ use of undeclared type `NonZeroU128`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU16::MIN (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU16`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU16::MIN, u16::MIN);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroU16`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU16::MAX (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU16`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU16::MAX, u16::MAX);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroU16`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU32::MAX (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU32`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU32::MAX, u32::MAX);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroU32`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU32::MIN (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU32`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU32::MIN, u32::MIN);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroU32`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU64::MAX (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU64`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU64::MAX, u64::MAX);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroU64`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU64::MIN (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU64`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU64::MIN, u64::MIN);
  |            ^^^^^^^^^^ use of undeclared type `NonZeroU64`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU8::MAX (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU8`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU8::MAX, u8::MAX);
  |            ^^^^^^^^^ use of undeclared type `NonZeroU8`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroU8::MIN (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroU8`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroU8::MIN, u8::MIN);
  |            ^^^^^^^^^ use of undeclared type `NonZeroU8`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroUsize::MAX (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroUsize`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroUsize::MAX, usize::MAX);
  |            ^^^^^^^^^^^^ use of undeclared type `NonZeroUsize`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
Couldn't compile the test.
---- src/num/nonzero.rs - num::nonzero::NonZeroUsize::MIN (line 967) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NonZeroUsize`
 --> src/num/nonzero.rs:968:12
  |
4 | assert_eq!(NonZeroUsize::MIN, usize::MIN);
  |            ^^^^^^^^^^^^ use of undeclared type `NonZeroUsize`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.
---

error: test failed, to rerun pass '--doc'


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "16" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/library/test/Cargo.toml" "-p" "core" "--" "--quiet"


Build completed unsuccessfully in 0:18:22

}

nonzero_constants_unsigned! {
NonZeroU8(u8);
Copy link
Member

Choose a reason for hiding this comment

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

Indentation mismatch here.

@joshtriplett
Copy link
Member

It looks like this is failing because it needs to reference these types with a path.

@joshtriplett joshtriplett 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 Oct 4, 2021
@apiraino apiraino added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Oct 14, 2021
@camelid camelid 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 5, 2021
@JohnCSimon
Copy link
Member

Ping from triage:
@mjclements Can you please address the build failures?

@JohnCSimon
Copy link
Member

Ping from triage:
@mjclements
I'm closing this due to inactivity, Please reopen when you are ready to continue with this. Thank you.

@rustbot label: +S-inactive

@JohnCSimon JohnCSimon closed this Jan 30, 2022
@rustbot rustbot added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Jan 30, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 11, 2022
Implement `MIN`/`MAX` constants for non-zero integers

This adds the associated [`MIN`](https://doc.rust-lang.org/stable/std/primitive.usize.html#associatedconstant.MIN)/[`MAX`](https://doc.rust-lang.org/stable/std/primitive.usize.html#associatedconstant.MAX) constants to `NonZero{U,I}{8,16,32,64,128,size}`, requested in rust-lang#89065.

This reimplements rust-lang#89077 due that PR being stagnant for 4 months. I am fine with closing this in favor of that one if the author revisits it. If so, I'd like to see that PR have the docs link to the `$Int`'s constants.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.