From d85b61460aeff77ad149741ea14b80880a2c48a6 Mon Sep 17 00:00:00 2001 From: Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> Date: Thu, 10 Nov 2022 22:26:10 +0100 Subject: [PATCH 1/3] Add a reference to ilog2 in leading_zeros integer docs Asked in #104248 --- library/core/src/num/int_macros.rs | 4 ++++ library/core/src/num/uint_macros.rs | 4 ++++ src/etc/pre-push.sh | 8 +++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 81f050cb283d4..0f4555a8605f7 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -107,6 +107,10 @@ macro_rules! int_impl { /// Returns the number of leading zeros in the binary representation of `self`. /// + /// The + #[doc = concat!("[`", stringify!($SelfTy), "::ilog2()`]")] + /// function returns a consistent number, even if the type widens. + /// /// # Examples /// /// Basic usage: diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 93f65c5c7aaf3..d5c6a5cee9872 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -109,6 +109,10 @@ macro_rules! uint_impl { /// Returns the number of leading zeros in the binary representation of `self`. /// + /// The + #[doc = concat!("[`", stringify!($SelfTy), "::ilog2()`]")] + /// function returns a consistent number, even if the type widens. + /// /// # Examples /// /// Basic usage: diff --git a/src/etc/pre-push.sh b/src/etc/pre-push.sh index be7de3ebaf571..377e7a9af8b7e 100755 --- a/src/etc/pre-push.sh +++ b/src/etc/pre-push.sh @@ -12,11 +12,9 @@ unset GIT_DIR ROOT_DIR="$(git rev-parse --show-toplevel)" COMMAND="$ROOT_DIR/x.py test tidy" -if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then - COMMAND="python $COMMAND" -elif ! command -v python &> /dev/null; then - COMMAND="python3 $COMMAND" -fi + +COMMAND="python3.10 $COMMAND" + echo "Running pre-push script '$COMMAND'" From fb98796892db43ed5db3d38edea5146a4cadcacc Mon Sep 17 00:00:00 2001 From: Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> Date: Fri, 11 Nov 2022 10:53:58 +0100 Subject: [PATCH 2/3] Apply suggestions --- library/core/src/num/int_macros.rs | 4 ++-- library/core/src/num/uint_macros.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 0f4555a8605f7..1d20bdddf0852 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -107,9 +107,9 @@ macro_rules! int_impl { /// Returns the number of leading zeros in the binary representation of `self`. /// - /// The + /// Depending on what you're doing with the value, you might also be interested in the #[doc = concat!("[`", stringify!($SelfTy), "::ilog2()`]")] - /// function returns a consistent number, even if the type widens. + /// function which returns a consistent number, even if the type widens. /// /// # Examples /// diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index d5c6a5cee9872..e5f8e26f2862f 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -109,9 +109,9 @@ macro_rules! uint_impl { /// Returns the number of leading zeros in the binary representation of `self`. /// - /// The + /// Depending on what you're doing with the value, you might also be interested in the #[doc = concat!("[`", stringify!($SelfTy), "::ilog2()`]")] - /// function returns a consistent number, even if the type widens. + /// function which returns a consistent number, even if the type widens. /// /// # Examples /// From a1909b7b07105a9237883634f33b723bfab43dc1 Mon Sep 17 00:00:00 2001 From: Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> Date: Fri, 11 Nov 2022 12:17:32 +0100 Subject: [PATCH 3/3] Try another way --- library/core/src/num/int_macros.rs | 4 ++-- library/core/src/num/uint_macros.rs | 4 ++-- src/etc/pre-push.sh | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 1d20bdddf0852..4ae1f3c37ebd2 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -108,8 +108,7 @@ macro_rules! int_impl { /// Returns the number of leading zeros in the binary representation of `self`. /// /// Depending on what you're doing with the value, you might also be interested in the - #[doc = concat!("[`", stringify!($SelfTy), "::ilog2()`]")] - /// function which returns a consistent number, even if the type widens. + /// [`ilog2`] function which returns a consistent number, even if the type widens. /// /// # Examples /// @@ -120,6 +119,7 @@ macro_rules! int_impl { /// /// assert_eq!(n.leading_zeros(), 0); /// ``` + #[doc = concat!("[`ilog2`]: ", stringify!($SelfT), "::ilog2")] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index e5f8e26f2862f..cd60e09d8809a 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -110,8 +110,7 @@ macro_rules! uint_impl { /// Returns the number of leading zeros in the binary representation of `self`. /// /// Depending on what you're doing with the value, you might also be interested in the - #[doc = concat!("[`", stringify!($SelfTy), "::ilog2()`]")] - /// function which returns a consistent number, even if the type widens. + /// [`ilog2`] function which returns a consistent number, even if the type widens. /// /// # Examples /// @@ -122,6 +121,7 @@ macro_rules! uint_impl { /// /// assert_eq!(n.leading_zeros(), 2); /// ``` + #[doc = concat!("[`ilog2`]: ", stringify!($SelfT), "::ilog2")] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_math", since = "1.32.0")] #[must_use = "this returns the result of the operation, \ diff --git a/src/etc/pre-push.sh b/src/etc/pre-push.sh index 377e7a9af8b7e..be7de3ebaf571 100755 --- a/src/etc/pre-push.sh +++ b/src/etc/pre-push.sh @@ -12,9 +12,11 @@ unset GIT_DIR ROOT_DIR="$(git rev-parse --show-toplevel)" COMMAND="$ROOT_DIR/x.py test tidy" - -COMMAND="python3.10 $COMMAND" - +if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then + COMMAND="python $COMMAND" +elif ! command -v python &> /dev/null; then + COMMAND="python3 $COMMAND" +fi echo "Running pre-push script '$COMMAND'"