Skip to content

Commit 42abbd8

Browse files
committed
Auto merge of rust-lang#70884 - Dylan-DPC:rollup-r3raqdf, r=jonas-schievink
Rollup of 5 pull requests Successful merges: - rust-lang#70201 (Small tweaks in ToOwned::clone_into) - rust-lang#70762 (Miri leak check: memory reachable through globals is not leaked) - rust-lang#70846 (Keep codegen units unmerged when building compiler builtins) - rust-lang#70854 (Use assoc int submodules) - rust-lang#70857 (Don't import integer and float modules, use assoc consts 2) Failed merges: r? @ghost
2 parents 39b6253 + 89d661f commit 42abbd8

File tree

39 files changed

+255
-156
lines changed

39 files changed

+255
-156
lines changed

src/liballoc/raw_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ unsafe impl<#[may_dangle] T, A: AllocRef> Drop for RawVec<T, A> {
608608

609609
#[inline]
610610
fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
611-
if mem::size_of::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
611+
if mem::size_of::<usize>() < 8 && alloc_size > isize::MAX as usize {
612612
Err(CapacityOverflow)
613613
} else {
614614
Ok(())

src/liballoc/slice.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -733,14 +733,14 @@ impl<T: Clone> ToOwned for [T] {
733733
fn clone_into(&self, target: &mut Vec<T>) {
734734
// drop anything in target that will not be overwritten
735735
target.truncate(self.len());
736-
let len = target.len();
737-
738-
// reuse the contained values' allocations/resources.
739-
target.clone_from_slice(&self[..len]);
740736

741737
// target.len <= self.len due to the truncate above, so the
742-
// slice here is always in-bounds.
743-
target.extend_from_slice(&self[len..]);
738+
// slices here are always in-bounds.
739+
let (init, tail) = self.split_at(target.len());
740+
741+
// reuse the contained values' allocations/resources.
742+
target.clone_from_slice(init);
743+
target.extend_from_slice(tail);
744744
}
745745
}
746746

src/liballoc/tests/arc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn trait_object() {
5050

5151
#[test]
5252
fn float_nan_ne() {
53-
let x = Arc::new(std::f32::NAN);
53+
let x = Arc::new(f32::NAN);
5454
assert!(x != x);
5555
assert!(!(x == x));
5656
}

src/liballoc/tests/btree/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ fn test_range_large() {
475475

476476
#[test]
477477
fn test_range_inclusive_max_value() {
478-
let max = std::usize::MAX;
478+
let max = usize::MAX;
479479
let map: BTreeMap<_, _> = vec![(max, 0)].into_iter().collect();
480480

481481
assert_eq!(map.range(max..=max).collect::<Vec<_>>(), &[(&max, &0)]);

src/liballoc/tests/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn trait_object() {
5050

5151
#[test]
5252
fn float_nan_ne() {
53-
let x = Rc::new(std::f32::NAN);
53+
let x = Rc::new(f32::NAN);
5454
assert!(x != x);
5555
assert!(!(x == x));
5656
}

src/libcore/benches/num/dec2flt/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::f64;
21
use test::Bencher;
32

43
#[bench]

src/libcore/benches/num/flt2dec/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mod strategy {
55

66
use core::num::flt2dec::MAX_SIG_DIGITS;
77
use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded};
8-
use std::f64;
98
use std::io::Write;
109
use std::vec::Vec;
1110
use test::Bencher;

src/libcore/tests/iter.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ fn test_cmp_by() {
7676
#[test]
7777
fn test_partial_cmp_by() {
7878
use core::cmp::Ordering;
79-
use core::f64;
8079

8180
let f = |x: i32, y: i32| (x * x).partial_cmp(&y);
8281
let xs = || [1, 2, 3, 4].iter().copied();
@@ -2894,7 +2893,7 @@ fn test_is_sorted() {
28942893
assert!(![1, 3, 2].iter().is_sorted());
28952894
assert!([0].iter().is_sorted());
28962895
assert!(std::iter::empty::<i32>().is_sorted());
2897-
assert!(![0.0, 1.0, std::f32::NAN].iter().is_sorted());
2896+
assert!(![0.0, 1.0, f32::NAN].iter().is_sorted());
28982897
assert!([-2, -1, 0, 3].iter().is_sorted());
28992898
assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs()));
29002899
assert!(!["c", "bb", "aaa"].iter().is_sorted());

src/libcore/tests/num/dec2flt/rawfp.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use core::num::dec2flt::rawfp::RawFloat;
22
use core::num::dec2flt::rawfp::{fp_to_float, next_float, prev_float, round_normal};
33
use core::num::diy_float::Fp;
4-
use std::f32;
5-
use std::f64;
64

75
fn integer_decode(f: f64) -> (u64, i16, i8) {
86
RawFloat::integer_decode(f)

src/libcore/tests/num/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ test_impl_from! { test_u32f64, u32, f64 }
205205
// Float -> Float
206206
#[test]
207207
fn test_f32f64() {
208-
use core::f32;
209-
210208
let max: f64 = f32::MAX.into();
211209
assert_eq!(max as f32, f32::MAX);
212210
assert!(max.is_normal());
@@ -704,5 +702,5 @@ macro_rules! test_float {
704702
};
705703
}
706704

707-
test_float!(f32, f32, ::core::f32::INFINITY, ::core::f32::NEG_INFINITY, ::core::f32::NAN);
708-
test_float!(f64, f64, ::core::f64::INFINITY, ::core::f64::NEG_INFINITY, ::core::f64::NAN);
705+
test_float!(f32, f32, f32::INFINITY, f32::NEG_INFINITY, f32::NAN);
706+
test_float!(f64, f64, f64::INFINITY, f64::NEG_INFINITY, f64::NAN);

src/libcore/tests/ops.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,23 @@ fn test_range_inclusive() {
6161

6262
#[test]
6363
fn test_range_is_empty() {
64-
use core::f32::*;
65-
6664
assert!(!(0.0..10.0).is_empty());
6765
assert!((-0.0..0.0).is_empty());
6866
assert!((10.0..0.0).is_empty());
6967

70-
assert!(!(NEG_INFINITY..INFINITY).is_empty());
71-
assert!((EPSILON..NAN).is_empty());
72-
assert!((NAN..EPSILON).is_empty());
73-
assert!((NAN..NAN).is_empty());
68+
assert!(!(f32::NEG_INFINITY..f32::INFINITY).is_empty());
69+
assert!((f32::EPSILON..f32::NAN).is_empty());
70+
assert!((f32::NAN..f32::EPSILON).is_empty());
71+
assert!((f32::NAN..f32::NAN).is_empty());
7472

7573
assert!(!(0.0..=10.0).is_empty());
7674
assert!(!(-0.0..=0.0).is_empty());
7775
assert!((10.0..=0.0).is_empty());
7876

79-
assert!(!(NEG_INFINITY..=INFINITY).is_empty());
80-
assert!((EPSILON..=NAN).is_empty());
81-
assert!((NAN..=EPSILON).is_empty());
82-
assert!((NAN..=NAN).is_empty());
77+
assert!(!(f32::NEG_INFINITY..=f32::INFINITY).is_empty());
78+
assert!((f32::EPSILON..=f32::NAN).is_empty());
79+
assert!((f32::NAN..=f32::EPSILON).is_empty());
80+
assert!((f32::NAN..=f32::NAN).is_empty());
8381
}
8482

8583
#[test]

src/libcore/tests/slice.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1108,14 +1108,14 @@ mod slice_index {
11081108

11091109
// note: using 0 specifically ensures that the result of overflowing is 0..0,
11101110
// so that `get` doesn't simply return None for the wrong reason.
1111-
bad: data[0 ..= ::std::usize::MAX];
1111+
bad: data[0 ..= usize::MAX];
11121112
message: "maximum usize";
11131113
}
11141114

11151115
in mod rangetoinclusive_overflow {
11161116
data: [0, 1];
11171117

1118-
bad: data[..= ::std::usize::MAX];
1118+
bad: data[..= usize::MAX];
11191119
message: "maximum usize";
11201120
}
11211121
} // panic_cases!
@@ -1709,7 +1709,7 @@ fn test_is_sorted() {
17091709
assert!(![1, 3, 2].is_sorted());
17101710
assert!([0].is_sorted());
17111711
assert!(empty.is_sorted());
1712-
assert!(![0.0, 1.0, std::f32::NAN].is_sorted());
1712+
assert!(![0.0, 1.0, f32::NAN].is_sorted());
17131713
assert!([-2, -1, 0, 3].is_sorted());
17141714
assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs()));
17151715
assert!(!["c", "bb", "aaa"].is_sorted());

src/libcore/tests/time.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn creation() {
1414
#[test]
1515
#[should_panic]
1616
fn new_overflow() {
17-
let _ = Duration::new(::core::u64::MAX, 1_000_000_000);
17+
let _ = Duration::new(u64::MAX, 1_000_000_000);
1818
}
1919

2020
#[test]
@@ -86,7 +86,7 @@ fn checked_add() {
8686
Duration::new(0, 500_000_000).checked_add(Duration::new(0, 500_000_001)),
8787
Some(Duration::new(1, 1))
8888
);
89-
assert_eq!(Duration::new(1, 0).checked_add(Duration::new(::core::u64::MAX, 0)), None);
89+
assert_eq!(Duration::new(1, 0).checked_add(Duration::new(u64::MAX, 0)), None);
9090
}
9191

9292
#[test]
@@ -133,7 +133,7 @@ fn checked_mul() {
133133
assert_eq!(Duration::new(1, 1).checked_mul(3), Some(Duration::new(3, 3)));
134134
assert_eq!(Duration::new(0, 500_000_001).checked_mul(4), Some(Duration::new(2, 4)));
135135
assert_eq!(Duration::new(0, 500_000_001).checked_mul(4000), Some(Duration::new(2000, 4000)));
136-
assert_eq!(Duration::new(::core::u64::MAX - 1, 0).checked_mul(2), None);
136+
assert_eq!(Duration::new(u64::MAX - 1, 0).checked_mul(2), None);
137137
}
138138

139139
#[test]

src/libcore/tests/tuple.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::cmp::Ordering::{Equal, Greater, Less};
2-
use std::f64::NAN;
32

43
#[test]
54
fn test_clone() {
@@ -34,12 +33,12 @@ fn test_partial_ord() {
3433
assert!(big >= small);
3534
assert!(big >= big);
3635

37-
assert!(!((1.0f64, 2.0f64) < (NAN, 3.0)));
38-
assert!(!((1.0f64, 2.0f64) <= (NAN, 3.0)));
39-
assert!(!((1.0f64, 2.0f64) > (NAN, 3.0)));
40-
assert!(!((1.0f64, 2.0f64) >= (NAN, 3.0)));
41-
assert!(((1.0f64, 2.0f64) < (2.0, NAN)));
42-
assert!(!((2.0f64, 2.0f64) < (2.0, NAN)));
36+
assert!(!((1.0f64, 2.0f64) < (f64::NAN, 3.0)));
37+
assert!(!((1.0f64, 2.0f64) <= (f64::NAN, 3.0)));
38+
assert!(!((1.0f64, 2.0f64) > (f64::NAN, 3.0)));
39+
assert!(!((1.0f64, 2.0f64) >= (f64::NAN, 3.0)));
40+
assert!(((1.0f64, 2.0f64) < (2.0, f64::NAN)));
41+
assert!(!((2.0f64, 2.0f64) < (2.0, f64::NAN)));
4342
}
4443

4544
#[test]

src/librustc_codegen_ssa/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
15281528
}
15291529
}
15301530

1531-
pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;
1531+
pub const CODEGEN_WORKER_ID: usize = usize::MAX;
15321532

15331533
/// `FatalError` is explicitly not `Send`.
15341534
#[must_use]

src/librustc_codegen_ssa/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
507507
}
508508
}
509509

510-
pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;
510+
pub const CODEGEN_WORKER_ID: usize = usize::MAX;
511511

512512
pub fn codegen_crate<B: ExtraBackendMethods>(
513513
backend: B,

src/librustc_errors/emitter.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ impl EmitterWriter {
13611361
let mut multilines = FxHashMap::default();
13621362

13631363
// Get the left-side margin to remove it
1364-
let mut whitespace_margin = std::usize::MAX;
1364+
let mut whitespace_margin = usize::MAX;
13651365
for line_idx in 0..annotated_file.lines.len() {
13661366
let file = annotated_file.file.clone();
13671367
let line = &annotated_file.lines[line_idx];
@@ -1373,19 +1373,19 @@ impl EmitterWriter {
13731373
}
13741374
}
13751375
}
1376-
if whitespace_margin == std::usize::MAX {
1376+
if whitespace_margin == usize::MAX {
13771377
whitespace_margin = 0;
13781378
}
13791379

13801380
// Left-most column any visible span points at.
1381-
let mut span_left_margin = std::usize::MAX;
1381+
let mut span_left_margin = usize::MAX;
13821382
for line in &annotated_file.lines {
13831383
for ann in &line.annotations {
13841384
span_left_margin = min(span_left_margin, ann.start_col);
13851385
span_left_margin = min(span_left_margin, ann.end_col);
13861386
}
13871387
}
1388-
if span_left_margin == std::usize::MAX {
1388+
if span_left_margin == usize::MAX {
13891389
span_left_margin = 0;
13901390
}
13911391

@@ -1421,7 +1421,7 @@ impl EmitterWriter {
14211421
} else {
14221422
termize::dimensions()
14231423
.map(|(w, _)| w.saturating_sub(code_offset))
1424-
.unwrap_or(std::usize::MAX)
1424+
.unwrap_or(usize::MAX)
14251425
};
14261426

14271427
let margin = Margin::new(

src/librustc_index/bit_set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ impl<'a, T: Idx> BitIter<'a, T> {
307307
// additional state about whether we have started.
308308
BitIter {
309309
word: 0,
310-
offset: std::usize::MAX - (WORD_BITS - 1),
310+
offset: usize::MAX - (WORD_BITS - 1),
311311
iter: words.iter(),
312312
marker: PhantomData,
313313
}

src/librustc_mir/interpret/machine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub trait AllocMap<K: Hash + Eq, V> {
5151
where
5252
K: Borrow<Q>;
5353

54-
/// Returns data based the keys and values in the map.
54+
/// Returns data based on the keys and values in the map.
5555
fn filter_map_collect<T>(&self, f: impl FnMut(&K, &V) -> Option<T>) -> Vec<T>;
5656

5757
/// Returns a reference to entry `k`. If no such entry exists, call
@@ -79,7 +79,7 @@ pub trait AllocMap<K: Hash + Eq, V> {
7979
/// and some use case dependent behaviour can instead be applied.
8080
pub trait Machine<'mir, 'tcx>: Sized {
8181
/// Additional memory kinds a machine wishes to distinguish from the builtin ones
82-
type MemoryKind: ::std::fmt::Debug + MayLeak + Eq + 'static;
82+
type MemoryKind: ::std::fmt::Debug + ::std::fmt::Display + MayLeak + Eq + 'static;
8383

8484
/// Tag tracked alongside every pointer. This is used to implement "Stacked Borrows"
8585
/// <https://www.ralfj.de/blog/2018/08/07/stacked-borrows.html>.

0 commit comments

Comments
 (0)