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

Rollup of 5 pull requests #70884

Merged
merged 25 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2c9d857
Miri leak_report: do not report leaks of allocations that are reachab…
RalfJung Apr 4, 2020
fbdff51
avoid printing allocations twice
RalfJung Apr 4, 2020
aecaeab
share more alloc printing code between Miri and MIR dumping
RalfJung Apr 4, 2020
1f3e247
indicate better which kind of memory got leaked
RalfJung Apr 4, 2020
c8b83ba
Keep codegen units unmerged when building compiler builtins
tmiasko Apr 6, 2020
e1a36e8
Bump nomicon submodule
faern Apr 6, 2020
d0a78ea
Bump rust-by-example submodule
faern Apr 6, 2020
01b3293
Bump stdarch submodule
faern Apr 6, 2020
65e10e3
Use assoc const f32::NAN in liballoc
faern Apr 6, 2020
cf1c7ed
Use assoc float consts in libcore
faern Apr 6, 2020
ebcf1e7
Stop importing float module in libserialize
faern Apr 6, 2020
09b5d66
Stop importing float module in libtest
faern Apr 6, 2020
e4fc04b
Use usize::MAX as assoc const in liballoc
faern Apr 6, 2020
3e4396b
Use integer assoc consts in libcore
faern Apr 6, 2020
68b1af6
Don't import integer module in libstd
faern Apr 6, 2020
cf8df01
Use assoc integer constants in libserialize
faern Apr 6, 2020
f7778d3
Use assoc integer constants in librustc_*
faern Apr 6, 2020
e8339e8
Use split_at in slice's ToOwned::clone_into
cuviper Mar 20, 2020
b80fa76
Implement ToOwned::clone_into for CStr
cuviper Mar 20, 2020
f854070
Forward OsStr::clone_into to the inner Vec
cuviper Mar 20, 2020
795bc2c
Rollup merge of #70201 - cuviper:clone_into, r=dtolnay
Dylan-DPC Apr 7, 2020
f2c59bd
Rollup merge of #70762 - RalfJung:miri-leak-check, r=oli-obk
Dylan-DPC Apr 7, 2020
f56fb51
Rollup merge of #70846 - tmiasko:compiler-builtins-codegen-units, r=a…
Dylan-DPC Apr 7, 2020
78c64d0
Rollup merge of #70854 - faern:use-assoc-int-submodules, r=dtolnay
Dylan-DPC Apr 7, 2020
89d661f
Rollup merge of #70857 - faern:use-assoc-int-float-consts, r=dtolnay
Dylan-DPC Apr 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/nomicon
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
2 changes: 1 addition & 1 deletion src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ unsafe impl<#[may_dangle] T, A: AllocRef> Drop for RawVec<T, A> {

#[inline]
fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
if mem::size_of::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
if mem::size_of::<usize>() < 8 && alloc_size > isize::MAX as usize {
Err(CapacityOverflow)
} else {
Ok(())
Expand Down
12 changes: 6 additions & 6 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,14 @@ impl<T: Clone> ToOwned for [T] {
fn clone_into(&self, target: &mut Vec<T>) {
// drop anything in target that will not be overwritten
target.truncate(self.len());
let len = target.len();

// reuse the contained values' allocations/resources.
target.clone_from_slice(&self[..len]);

// target.len <= self.len due to the truncate above, so the
// slice here is always in-bounds.
target.extend_from_slice(&self[len..]);
// slices here are always in-bounds.
let (init, tail) = self.split_at(target.len());

// reuse the contained values' allocations/resources.
target.clone_from_slice(init);
target.extend_from_slice(tail);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn trait_object() {

#[test]
fn float_nan_ne() {
let x = Arc::new(std::f32::NAN);
let x = Arc::new(f32::NAN);
assert!(x != x);
assert!(!(x == x));
}
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ fn test_range_large() {

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

assert_eq!(map.range(max..=max).collect::<Vec<_>>(), &[(&max, &0)]);
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn trait_object() {

#[test]
fn float_nan_ne() {
let x = Rc::new(std::f32::NAN);
let x = Rc::new(f32::NAN);
assert!(x != x);
assert!(!(x == x));
}
Expand Down
1 change: 0 additions & 1 deletion src/libcore/benches/num/dec2flt/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::f64;
use test::Bencher;

#[bench]
Expand Down
1 change: 0 additions & 1 deletion src/libcore/benches/num/flt2dec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod strategy {

use core::num::flt2dec::MAX_SIG_DIGITS;
use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded};
use std::f64;
use std::io::Write;
use std::vec::Vec;
use test::Bencher;
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ fn test_cmp_by() {
#[test]
fn test_partial_cmp_by() {
use core::cmp::Ordering;
use core::f64;

let f = |x: i32, y: i32| (x * x).partial_cmp(&y);
let xs = || [1, 2, 3, 4].iter().copied();
Expand Down Expand Up @@ -2894,7 +2893,7 @@ fn test_is_sorted() {
assert!(![1, 3, 2].iter().is_sorted());
assert!([0].iter().is_sorted());
assert!(std::iter::empty::<i32>().is_sorted());
assert!(![0.0, 1.0, std::f32::NAN].iter().is_sorted());
assert!(![0.0, 1.0, f32::NAN].iter().is_sorted());
assert!([-2, -1, 0, 3].iter().is_sorted());
assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs()));
assert!(!["c", "bb", "aaa"].iter().is_sorted());
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/tests/num/dec2flt/rawfp.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use core::num::dec2flt::rawfp::RawFloat;
use core::num::dec2flt::rawfp::{fp_to_float, next_float, prev_float, round_normal};
use core::num::diy_float::Fp;
use std::f32;
use std::f64;

fn integer_decode(f: f64) -> (u64, i16, i8) {
RawFloat::integer_decode(f)
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/tests/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ test_impl_from! { test_u32f64, u32, f64 }
// Float -> Float
#[test]
fn test_f32f64() {
use core::f32;

let max: f64 = f32::MAX.into();
assert_eq!(max as f32, f32::MAX);
assert!(max.is_normal());
Expand Down Expand Up @@ -704,5 +702,5 @@ macro_rules! test_float {
};
}

test_float!(f32, f32, ::core::f32::INFINITY, ::core::f32::NEG_INFINITY, ::core::f32::NAN);
test_float!(f64, f64, ::core::f64::INFINITY, ::core::f64::NEG_INFINITY, ::core::f64::NAN);
test_float!(f32, f32, f32::INFINITY, f32::NEG_INFINITY, f32::NAN);
test_float!(f64, f64, f64::INFINITY, f64::NEG_INFINITY, f64::NAN);
18 changes: 8 additions & 10 deletions src/libcore/tests/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,23 @@ fn test_range_inclusive() {

#[test]
fn test_range_is_empty() {
use core::f32::*;

assert!(!(0.0..10.0).is_empty());
assert!((-0.0..0.0).is_empty());
assert!((10.0..0.0).is_empty());

assert!(!(NEG_INFINITY..INFINITY).is_empty());
assert!((EPSILON..NAN).is_empty());
assert!((NAN..EPSILON).is_empty());
assert!((NAN..NAN).is_empty());
assert!(!(f32::NEG_INFINITY..f32::INFINITY).is_empty());
assert!((f32::EPSILON..f32::NAN).is_empty());
assert!((f32::NAN..f32::EPSILON).is_empty());
assert!((f32::NAN..f32::NAN).is_empty());

assert!(!(0.0..=10.0).is_empty());
assert!(!(-0.0..=0.0).is_empty());
assert!((10.0..=0.0).is_empty());

assert!(!(NEG_INFINITY..=INFINITY).is_empty());
assert!((EPSILON..=NAN).is_empty());
assert!((NAN..=EPSILON).is_empty());
assert!((NAN..=NAN).is_empty());
assert!(!(f32::NEG_INFINITY..=f32::INFINITY).is_empty());
assert!((f32::EPSILON..=f32::NAN).is_empty());
assert!((f32::NAN..=f32::EPSILON).is_empty());
assert!((f32::NAN..=f32::NAN).is_empty());
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,14 +1108,14 @@ mod slice_index {

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

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

bad: data[..= ::std::usize::MAX];
bad: data[..= usize::MAX];
message: "maximum usize";
}
} // panic_cases!
Expand Down Expand Up @@ -1709,7 +1709,7 @@ fn test_is_sorted() {
assert!(![1, 3, 2].is_sorted());
assert!([0].is_sorted());
assert!(empty.is_sorted());
assert!(![0.0, 1.0, std::f32::NAN].is_sorted());
assert!(![0.0, 1.0, f32::NAN].is_sorted());
assert!([-2, -1, 0, 3].is_sorted());
assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs()));
assert!(!["c", "bb", "aaa"].is_sorted());
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/tests/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn creation() {
#[test]
#[should_panic]
fn new_overflow() {
let _ = Duration::new(::core::u64::MAX, 1_000_000_000);
let _ = Duration::new(u64::MAX, 1_000_000_000);
}

#[test]
Expand Down Expand Up @@ -86,7 +86,7 @@ fn checked_add() {
Duration::new(0, 500_000_000).checked_add(Duration::new(0, 500_000_001)),
Some(Duration::new(1, 1))
);
assert_eq!(Duration::new(1, 0).checked_add(Duration::new(::core::u64::MAX, 0)), None);
assert_eq!(Duration::new(1, 0).checked_add(Duration::new(u64::MAX, 0)), None);
}

#[test]
Expand Down Expand Up @@ -133,7 +133,7 @@ fn checked_mul() {
assert_eq!(Duration::new(1, 1).checked_mul(3), Some(Duration::new(3, 3)));
assert_eq!(Duration::new(0, 500_000_001).checked_mul(4), Some(Duration::new(2, 4)));
assert_eq!(Duration::new(0, 500_000_001).checked_mul(4000), Some(Duration::new(2000, 4000)));
assert_eq!(Duration::new(::core::u64::MAX - 1, 0).checked_mul(2), None);
assert_eq!(Duration::new(u64::MAX - 1, 0).checked_mul(2), None);
}

#[test]
Expand Down
13 changes: 6 additions & 7 deletions src/libcore/tests/tuple.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::cmp::Ordering::{Equal, Greater, Less};
use std::f64::NAN;

#[test]
fn test_clone() {
Expand Down Expand Up @@ -34,12 +33,12 @@ fn test_partial_ord() {
assert!(big >= small);
assert!(big >= big);

assert!(!((1.0f64, 2.0f64) < (NAN, 3.0)));
assert!(!((1.0f64, 2.0f64) <= (NAN, 3.0)));
assert!(!((1.0f64, 2.0f64) > (NAN, 3.0)));
assert!(!((1.0f64, 2.0f64) >= (NAN, 3.0)));
assert!(((1.0f64, 2.0f64) < (2.0, NAN)));
assert!(!((2.0f64, 2.0f64) < (2.0, NAN)));
assert!(!((1.0f64, 2.0f64) < (f64::NAN, 3.0)));
assert!(!((1.0f64, 2.0f64) <= (f64::NAN, 3.0)));
assert!(!((1.0f64, 2.0f64) > (f64::NAN, 3.0)));
assert!(!((1.0f64, 2.0f64) >= (f64::NAN, 3.0)));
assert!(((1.0f64, 2.0f64) < (2.0, f64::NAN)));
assert!(!((2.0f64, 2.0f64) < (2.0, f64::NAN)));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
}
}

pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;
pub const CODEGEN_WORKER_ID: usize = usize::MAX;

/// `FatalError` is explicitly not `Send`.
#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
}
}

pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;
pub const CODEGEN_WORKER_ID: usize = usize::MAX;

pub fn codegen_crate<B: ExtraBackendMethods>(
backend: B,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ impl EmitterWriter {
let mut multilines = FxHashMap::default();

// Get the left-side margin to remove it
let mut whitespace_margin = std::usize::MAX;
let mut whitespace_margin = usize::MAX;
for line_idx in 0..annotated_file.lines.len() {
let file = annotated_file.file.clone();
let line = &annotated_file.lines[line_idx];
Expand All @@ -1373,19 +1373,19 @@ impl EmitterWriter {
}
}
}
if whitespace_margin == std::usize::MAX {
if whitespace_margin == usize::MAX {
whitespace_margin = 0;
}

// Left-most column any visible span points at.
let mut span_left_margin = std::usize::MAX;
let mut span_left_margin = usize::MAX;
for line in &annotated_file.lines {
for ann in &line.annotations {
span_left_margin = min(span_left_margin, ann.start_col);
span_left_margin = min(span_left_margin, ann.end_col);
}
}
if span_left_margin == std::usize::MAX {
if span_left_margin == usize::MAX {
span_left_margin = 0;
}

Expand Down Expand Up @@ -1421,7 +1421,7 @@ impl EmitterWriter {
} else {
termize::dimensions()
.map(|(w, _)| w.saturating_sub(code_offset))
.unwrap_or(std::usize::MAX)
.unwrap_or(usize::MAX)
};

let margin = Margin::new(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_index/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<'a, T: Idx> BitIter<'a, T> {
// additional state about whether we have started.
BitIter {
word: 0,
offset: std::usize::MAX - (WORD_BITS - 1),
offset: usize::MAX - (WORD_BITS - 1),
iter: words.iter(),
marker: PhantomData,
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait AllocMap<K: Hash + Eq, V> {
where
K: Borrow<Q>;

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

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

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