Skip to content

Commit 85c5ca0

Browse files
authored
Merge pull request #637 from folkertdev/min-max-assoc-constants
use associated constants for `NAN`, `MIN` and `MAX`
2 parents a0d8e21 + d8ab401 commit 85c5ca0

9 files changed

Lines changed: 28 additions & 29 deletions

File tree

proptest/src/arbitrary/_alloc/char.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ multiplex_alloc! {
2222
core::char::decode_utf16, std::char::decode_utf16
2323
}
2424

25-
const VEC_MAX: usize = ::core::u16::MAX as usize;
25+
const VEC_MAX: usize = u16::MAX as usize;
2626

2727
use crate::arbitrary::*;
2828
use crate::strategy::statics::static_map;

proptest/src/arbitrary/_std/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ mod var_error {
7777
#[cfg(target_os = "windows")]
7878
fn osstring_invalid_string() -> impl Strategy<Value = OsString> {
7979
use std::os::windows::ffi::OsStringExt;
80-
let size = 1..::std::u16::MAX as usize;
81-
let vec_gen = crate::collection::vec(..::std::u16::MAX, size.clone());
80+
let size = 1..u16::MAX as usize;
81+
let vec_gen = crate::collection::vec(..u16::MAX, size.clone());
8282
(size, vec_gen).prop_map(|(p, mut sbuf)| {
8383
// Not quite a uniform distribution due to clamping,
8484
// but probably good enough

proptest/src/arbitrary/_std/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use super::string::not_utf8_bytes;
2222

2323
arbitrary!(CString,
2424
SFnPtrMap<VecStrategy<RangeInclusive<u8>>, Self>, SizeRange;
25-
args => static_map(vec(1..=::std::u8::MAX, args + 1), |mut vec| {
25+
args => static_map(vec(1..=u8::MAX, args + 1), |mut vec| {
2626
vec.pop().unwrap();
2727
// Could use: Self::from_vec_unchecked(vec) safely.
2828
Self::new(vec).unwrap()

proptest/src/arbitrary/_std/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ arbitrary!(FromUtf8Error, SFnPtrMap<BoxedStrategy<Vec<u8>>, Self>;
7070
pub(crate) fn not_utf8_bytes(
7171
allow_null: bool,
7272
) -> impl Strategy<Value = Vec<u8>> {
73-
let prefix = collection::vec(any::<char>(), ..::std::u16::MAX as usize);
73+
let prefix = collection::vec(any::<char>(), ..u16::MAX as usize);
7474
let suffix = gen_el_bytes(allow_null);
7575
(prefix, suffix).prop_map(move |(prefix_bytes, el_bytes)| {
7676
let iter = prefix_bytes.iter();

proptest/src/char.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'a> CharStrategy<'a> {
207207
}
208208
}
209209

210-
const WHOLE_RANGE: &[CharRange] = &['\x00'..=::core::char::MAX];
210+
const WHOLE_RANGE: &[CharRange] = &['\x00'..=char::MAX];
211211

212212
/// Creates a `CharStrategy` which picks from literally any character, with the
213213
/// default biases.
@@ -327,8 +327,8 @@ mod test {
327327
proptest! {
328328
#[test]
329329
fn stays_in_range(input_ranges in collection::vec(
330-
(0..::std::char::MAX as u32,
331-
0..::std::char::MAX as u32),
330+
(0..char::MAX as u32,
331+
0..char::MAX as u32),
332332
1..5))
333333
{
334334
let input = ranges(Cow::Owned(input_ranges.iter().map(

proptest/src/collection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ use crate::tuple::TupleValueTree;
3232
//==============================================================================
3333

3434
/// The minimum and maximum range/bounds on the size of a collection.
35-
/// The interval must form a subset of `[0, std::usize::MAX)`.
35+
/// The interval must form a subset of `[0, usize::MAX)`.
3636
///
37-
/// A value like `0..=std::usize::MAX` will still be accepted but will silently
38-
/// truncate the maximum to `std::usize::MAX - 1`.
37+
/// A value like `0..=usize::MAX` will still be accepted but will silently
38+
/// truncate the maximum to `usize::MAX - 1`.
3939
///
4040
/// The `Default` is `0..PROPTEST_MAX_DEFAULT_SIZE_RANGE`. The max can be set with
4141
/// the `PROPTEST_MAX_DEFAULT_SIZE_RANGE` env var, which defaults to `100`.

proptest/src/num.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ macro_rules! numeric_api {
185185
$crate::num::$incl::<$sample_typ>(
186186
runner,
187187
self.start.into(),
188-
::core::$typ::MAX.into(),
188+
<$typ>::MAX.into(),
189189
)
190190
.into(),
191-
::core::$typ::MAX,
191+
<$typ>::MAX,
192192
))
193193
}
194194
}
@@ -199,10 +199,10 @@ macro_rules! numeric_api {
199199

200200
fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self> {
201201
Ok(BinarySearch::new_clamped(
202-
::core::$typ::MIN,
202+
<$typ>::MIN,
203203
$crate::num::$uniform::<$sample_typ>(
204204
runner,
205-
::core::$typ::MIN.into(),
205+
<$typ>::MIN.into(),
206206
self.end.into(),
207207
)
208208
.into(),
@@ -217,10 +217,10 @@ macro_rules! numeric_api {
217217

218218
fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self> {
219219
Ok(BinarySearch::new_clamped(
220-
::core::$typ::MIN,
220+
<$typ>::MIN,
221221
$crate::num::$incl::<$sample_typ>(
222222
runner,
223-
::core::$typ::MIN.into(),
223+
<$typ>::MIN.into(),
224224
self.end.into(),
225225
)
226226
.into(),
@@ -718,7 +718,7 @@ macro_rules! float_any {
718718
// signalling bit. Assume the `NAN` constant is a quiet NaN as
719719
// interpreted by the hardware and generate values based on
720720
// that.
721-
let quiet_or = ::core::$typ::NAN.to_bits() &
721+
let quiet_or = $typ::NAN.to_bits() &
722722
($typ::EXP_MASK | ($typ::EXP_MASK >> 1));
723723
let signaling_or = (quiet_or ^ ($typ::EXP_MASK >> 1)) |
724724
$typ::EXP_MASK;
@@ -1277,13 +1277,13 @@ mod test {
12771277
#[test]
12781278
fn float_simplifies_to_smallest_normal() {
12791279
let mut runner = TestRunner::default();
1280-
let mut value = (::std::f64::MIN_POSITIVE..2.0)
1280+
let mut value = (f64::MIN_POSITIVE..2.0)
12811281
.new_tree(&mut runner)
12821282
.unwrap();
12831283

12841284
while value.simplify() {}
12851285

1286-
assert_eq!(::std::f64::MIN_POSITIVE, value.current());
1286+
assert_eq!(f64::MIN_POSITIVE, value.current());
12871287
}
12881288

12891289
macro_rules! float_generation_test_body {
@@ -1343,8 +1343,7 @@ mod test {
13431343
}
13441344

13451345
let is_quiet = raw & ($typ::EXP_MASK >> 1)
1346-
== ::std::$typ::NAN.to_bits()
1347-
& ($typ::EXP_MASK >> 1);
1346+
== $typ::NAN.to_bits() & ($typ::EXP_MASK >> 1);
13481347
if is_quiet {
13491348
// x86/AMD64 turn signalling NaNs into quiet
13501349
// NaNs quite aggressively depending on what

proptest/src/string.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ fn unicode_class_strategy(
244244
// Multiple instances of the latter range to partially make up
245245
// for the bias of having such a tiny range in the control
246246
// characters.
247-
'\x0B'..=::core::char::MAX,
248-
'\x0B'..=::core::char::MAX,
249-
'\x0B'..=::core::char::MAX,
250-
'\x0B'..=::core::char::MAX,
251-
'\x0B'..=::core::char::MAX,
247+
'\x0B'..=char::MAX,
248+
'\x0B'..=char::MAX,
249+
'\x0B'..=char::MAX,
250+
'\x0B'..=char::MAX,
251+
'\x0B'..=char::MAX,
252252
];
253253

254254
let dotnnl = |x: &hir::ClassUnicodeRange, y: &hir::ClassUnicodeRange| {

proptest/src/test_runner/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ pub struct Config {
356356
/// Give up on shrinking if more than this number of iterations of the test
357357
/// code are run.
358358
///
359-
/// Setting this to `std::u32::MAX` causes the actual limit to be four
359+
/// Setting this to `u32::MAX` causes the actual limit to be four
360360
/// times the number of test cases.
361361
///
362362
/// Setting this value to `0` disables shrinking altogether.
363363
///
364364
/// Note that the type of this field will change in a future version of
365365
/// proptest to better accommodate its special values.
366366
///
367-
/// The default is `std::u32::MAX`, which can be overridden by setting the
367+
/// The default is `u32::MAX`, which can be overridden by setting the
368368
/// `PROPTEST_MAX_SHRINK_ITERS` environment variable. (The variable is only
369369
/// considered when the `std` feature is enabled, which it is by default.)
370370
pub max_shrink_iters: u32,

0 commit comments

Comments
 (0)