Rollup merge of #70777 - faern:use-assoc-int-consts2, r=dtolnay
Don't import integer and float modules, use assoc consts Stop importing the standard library integer and float modules to reach the `MIN`, `MAX` and other constants. They are available directly on the primitive types now. This PR is a follow up of #69860 which made sure we use the new constants in documentation. This type of change touches a lot of files, and previously all my assoc int consts PRs had collisions and were accepted only after a long delay. So I'd prefer to do it in smaller steps now. Just removing these imports seem like a good next step. r? @dtolnay
This commit is contained in:
commit
c2595539e7
|
@ -1,7 +1,6 @@
|
|||
mod _common;
|
||||
|
||||
use _common::validate;
|
||||
use std::u64;
|
||||
|
||||
fn main() {
|
||||
for exp in 19..64 {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use core::intrinsics::{self, min_align_of_val, size_of_val};
|
||||
use core::ptr::{NonNull, Unique};
|
||||
use core::usize;
|
||||
|
||||
#[stable(feature = "alloc_module", since = "1.28.0")]
|
||||
#[doc(inline)]
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
//! ```
|
||||
//! use std::cmp::Ordering;
|
||||
//! use std::collections::BinaryHeap;
|
||||
//! use std::usize;
|
||||
//!
|
||||
//! #[derive(Copy, Clone, Eq, PartialEq)]
|
||||
//! struct State {
|
||||
|
|
|
@ -250,7 +250,6 @@ use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver};
|
|||
use core::pin::Pin;
|
||||
use core::ptr::{self, NonNull};
|
||||
use core::slice::{self, from_raw_parts_mut};
|
||||
use core::usize;
|
||||
|
||||
use crate::alloc::{box_free, handle_alloc_error, AllocInit, AllocRef, Global, Layout};
|
||||
use crate::string::String;
|
||||
|
|
|
@ -90,7 +90,6 @@ use core::borrow::{Borrow, BorrowMut};
|
|||
use core::cmp::Ordering::{self, Less};
|
||||
use core::mem::{self, size_of};
|
||||
use core::ptr;
|
||||
use core::{u16, u32, u8};
|
||||
|
||||
use crate::borrow::ToOwned;
|
||||
use crate::boxed::Box;
|
||||
|
|
|
@ -23,7 +23,6 @@ use core::ptr::{self, NonNull};
|
|||
use core::slice::{self, from_raw_parts_mut};
|
||||
use core::sync::atomic;
|
||||
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst};
|
||||
use core::{isize, usize};
|
||||
|
||||
use crate::alloc::{box_free, handle_alloc_error, AllocInit, AllocRef, Global, Layout};
|
||||
use crate::boxed::Box;
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
use core::any::Any;
|
||||
use core::clone::Clone;
|
||||
use core::convert::TryInto;
|
||||
use core::f64;
|
||||
use core::i64;
|
||||
use core::ops::Deref;
|
||||
use core::result::Result::{Err, Ok};
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::borrow::Cow;
|
||||
use std::collections::TryReserveError::*;
|
||||
use std::mem::size_of;
|
||||
use std::{isize, usize};
|
||||
|
||||
pub trait IntoCow<'a, B: ?Sized>
|
||||
where
|
||||
|
|
|
@ -3,7 +3,6 @@ use std::collections::TryReserveError::*;
|
|||
use std::mem::size_of;
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
use std::vec::{Drain, IntoIter};
|
||||
use std::{isize, usize};
|
||||
|
||||
struct DropCounter<'a> {
|
||||
count: &'a mut u32,
|
||||
|
|
|
@ -3,7 +3,6 @@ use std::collections::{vec_deque::Drain, VecDeque};
|
|||
use std::fmt::Debug;
|
||||
use std::mem::size_of;
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
use std::{isize, usize};
|
||||
|
||||
use crate::hash;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use super::super::*;
|
||||
use core::num::flt2dec::strategy::dragon::*;
|
||||
use std::{f64, i16};
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use super::super::*;
|
||||
use core::num::flt2dec::strategy::grisu::*;
|
||||
use std::{f64, i16};
|
||||
use test::Bencher;
|
||||
|
||||
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
|
||||
|
|
|
@ -104,7 +104,6 @@ fn test_format_int() {
|
|||
|
||||
#[test]
|
||||
fn test_format_int_exp_limits() {
|
||||
use core::{i128, i16, i32, i64, i8, u128, u16, u32, u64, u8};
|
||||
assert_eq!(format!("{:e}", i8::MIN), "-1.28e2");
|
||||
assert_eq!(format!("{:e}", i8::MAX), "1.27e2");
|
||||
assert_eq!(format!("{:e}", i16::MIN), "-3.2768e4");
|
||||
|
@ -125,8 +124,6 @@ fn test_format_int_exp_limits() {
|
|||
|
||||
#[test]
|
||||
fn test_format_int_exp_precision() {
|
||||
use core::{i128, i16, i32, i64, i8};
|
||||
|
||||
//test that float and integer match
|
||||
let big_int: u32 = 314_159_265;
|
||||
assert_eq!(format!("{:.1e}", big_int), format!("{:.1e}", f64::from(big_int)));
|
||||
|
@ -214,7 +211,6 @@ fn test_format_int_sign_padding() {
|
|||
|
||||
#[test]
|
||||
fn test_format_int_twos_complement() {
|
||||
use core::{i16, i32, i64, i8};
|
||||
assert_eq!(format!("{}", i8::MIN), "-128");
|
||||
assert_eq!(format!("{}", i16::MIN), "-32768");
|
||||
assert_eq!(format!("{}", i32::MIN), "-2147483648");
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
use core::cell::Cell;
|
||||
use core::convert::TryFrom;
|
||||
use core::iter::*;
|
||||
use core::usize;
|
||||
use core::{i16, i8, isize};
|
||||
|
||||
#[test]
|
||||
fn test_lt() {
|
||||
|
@ -2251,62 +2249,58 @@ fn test_range_inclusive_folds() {
|
|||
|
||||
#[test]
|
||||
fn test_range_size_hint() {
|
||||
use core::usize::MAX as UMAX;
|
||||
assert_eq!((0..0usize).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..100usize).size_hint(), (100, Some(100)));
|
||||
assert_eq!((0..UMAX).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((0..usize::MAX).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
|
||||
let umax = u128::try_from(UMAX).unwrap();
|
||||
let umax = u128::try_from(usize::MAX).unwrap();
|
||||
assert_eq!((0..0u128).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..100u128).size_hint(), (100, Some(100)));
|
||||
assert_eq!((0..umax).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((0..umax + 1).size_hint(), (UMAX, None));
|
||||
assert_eq!((0..umax).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((0..umax + 1).size_hint(), (usize::MAX, None));
|
||||
|
||||
use core::isize::{MAX as IMAX, MIN as IMIN};
|
||||
assert_eq!((0..0isize).size_hint(), (0, Some(0)));
|
||||
assert_eq!((-100..100isize).size_hint(), (200, Some(200)));
|
||||
assert_eq!((IMIN..IMAX).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((isize::MIN..isize::MAX).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
|
||||
let imin = i128::try_from(IMIN).unwrap();
|
||||
let imax = i128::try_from(IMAX).unwrap();
|
||||
let imin = i128::try_from(isize::MIN).unwrap();
|
||||
let imax = i128::try_from(isize::MAX).unwrap();
|
||||
assert_eq!((0..0i128).size_hint(), (0, Some(0)));
|
||||
assert_eq!((-100..100i128).size_hint(), (200, Some(200)));
|
||||
assert_eq!((imin..imax).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((imin..imax + 1).size_hint(), (UMAX, None));
|
||||
assert_eq!((imin..imax).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((imin..imax + 1).size_hint(), (usize::MAX, None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_range_inclusive_size_hint() {
|
||||
use core::usize::MAX as UMAX;
|
||||
assert_eq!((1..=0usize).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..=0usize).size_hint(), (1, Some(1)));
|
||||
assert_eq!((0..=100usize).size_hint(), (101, Some(101)));
|
||||
assert_eq!((0..=UMAX - 1).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((0..=UMAX).size_hint(), (UMAX, None));
|
||||
assert_eq!((0..=usize::MAX - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((0..=usize::MAX).size_hint(), (usize::MAX, None));
|
||||
|
||||
let umax = u128::try_from(UMAX).unwrap();
|
||||
let umax = u128::try_from(usize::MAX).unwrap();
|
||||
assert_eq!((1..=0u128).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..=0u128).size_hint(), (1, Some(1)));
|
||||
assert_eq!((0..=100u128).size_hint(), (101, Some(101)));
|
||||
assert_eq!((0..=umax - 1).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((0..=umax).size_hint(), (UMAX, None));
|
||||
assert_eq!((0..=umax + 1).size_hint(), (UMAX, None));
|
||||
assert_eq!((0..=umax - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((0..=umax).size_hint(), (usize::MAX, None));
|
||||
assert_eq!((0..=umax + 1).size_hint(), (usize::MAX, None));
|
||||
|
||||
use core::isize::{MAX as IMAX, MIN as IMIN};
|
||||
assert_eq!((0..=-1isize).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..=0isize).size_hint(), (1, Some(1)));
|
||||
assert_eq!((-100..=100isize).size_hint(), (201, Some(201)));
|
||||
assert_eq!((IMIN..=IMAX - 1).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((IMIN..=IMAX).size_hint(), (UMAX, None));
|
||||
assert_eq!((isize::MIN..=isize::MAX - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((isize::MIN..=isize::MAX).size_hint(), (usize::MAX, None));
|
||||
|
||||
let imin = i128::try_from(IMIN).unwrap();
|
||||
let imax = i128::try_from(IMAX).unwrap();
|
||||
let imin = i128::try_from(isize::MIN).unwrap();
|
||||
let imax = i128::try_from(isize::MAX).unwrap();
|
||||
assert_eq!((0..=-1i128).size_hint(), (0, Some(0)));
|
||||
assert_eq!((0..=0i128).size_hint(), (1, Some(1)));
|
||||
assert_eq!((-100..=100i128).size_hint(), (201, Some(201)));
|
||||
assert_eq!((imin..=imax - 1).size_hint(), (UMAX, Some(UMAX)));
|
||||
assert_eq!((imin..=imax).size_hint(), (UMAX, None));
|
||||
assert_eq!((imin..=imax + 1).size_hint(), (UMAX, None));
|
||||
assert_eq!((imin..=imax - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
|
||||
assert_eq!((imin..=imax).size_hint(), (usize::MAX, None));
|
||||
assert_eq!((imin..=imax + 1).size_hint(), (usize::MAX, None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#![allow(overflowing_literals)]
|
||||
|
||||
use std::{f32, f64, i64};
|
||||
|
||||
mod parse;
|
||||
mod rawfp;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{f32, f64, fmt, i16, str};
|
||||
use std::{fmt, str};
|
||||
|
||||
use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded};
|
||||
use core::num::flt2dec::{round_up, Formatted, Part, Sign, MAX_SIG_DIGITS};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#![cfg(not(target_arch = "wasm32"))]
|
||||
|
||||
use std::i16;
|
||||
use std::str;
|
||||
|
||||
use core::num::flt2dec::strategy::grisu::format_exact_opt;
|
||||
|
|
|
@ -2,7 +2,6 @@ macro_rules! int_module {
|
|||
($T:ident, $T_i:ident) => {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use core::isize;
|
||||
use core::mem;
|
||||
use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
|
||||
use core::$T_i::*;
|
||||
|
|
|
@ -5,7 +5,6 @@ use rustc_span::source_map::SourceMap;
|
|||
use rustc_span::{BytePos, CharPos, FileName, Pos};
|
||||
|
||||
use log::debug;
|
||||
use std::usize;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
|
|
@ -25,7 +25,7 @@ use rustc_span::Span;
|
|||
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive};
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::{i128, iter, u128};
|
||||
use std::iter;
|
||||
|
||||
fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: &str) -> Option<&'ll Value> {
|
||||
let llvm_name = match name {
|
||||
|
|
|
@ -17,8 +17,6 @@ use rustc_span::source_map::{Span, DUMMY_SP};
|
|||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::{Abi, Int, LayoutOf, Variants};
|
||||
|
||||
use std::{i128, u128};
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
pub fn codegen_rvalue(
|
||||
&mut self,
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
use crate::snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use std::fmt::Debug;
|
||||
use std::usize;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
|
|
@ -93,7 +93,6 @@ use std::path::Path;
|
|||
use std::process;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::u32;
|
||||
|
||||
use measureme::{EventId, EventIdBuilder, SerializableString, StringId};
|
||||
use parking_lot::RwLock;
|
||||
|
|
|
@ -7,7 +7,6 @@ use std::iter::{self, FromIterator};
|
|||
use std::marker::PhantomData;
|
||||
use std::ops::{Index, IndexMut, Range, RangeBounds};
|
||||
use std::slice;
|
||||
use std::u32;
|
||||
use std::vec;
|
||||
|
||||
/// Represents some newtyped `usize` wrapper.
|
||||
|
|
|
@ -8,7 +8,6 @@ use rustc_data_structures::unify as ut;
|
|||
use std::cmp;
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::Range;
|
||||
use std::u32;
|
||||
|
||||
pub struct TypeVariableTable<'tcx> {
|
||||
values: sv::SnapshotVec<Delegate>,
|
||||
|
|
|
@ -21,7 +21,6 @@ use rustc_target::spec::abi::Abi;
|
|||
|
||||
use log::debug;
|
||||
use std::cmp;
|
||||
use std::{f32, f64, i16, i32, i64, i8, u16, u32, u64, u8};
|
||||
|
||||
declare_lint! {
|
||||
UNUSED_COMPARISONS,
|
||||
|
|
|
@ -42,7 +42,6 @@ use std::io;
|
|||
use std::mem;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::path::Path;
|
||||
use std::u32;
|
||||
|
||||
pub use cstore_impl::{provide, provide_extern};
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ use rustc_target::abi::VariantIdx;
|
|||
use std::hash::Hash;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::path::Path;
|
||||
use std::u32;
|
||||
|
||||
struct EncodeContext<'tcx> {
|
||||
opaque: opaque::Encoder,
|
||||
|
|
|
@ -33,7 +33,7 @@ use std::borrow::Cow;
|
|||
use std::fmt::{self, Debug, Display, Formatter, Write};
|
||||
use std::ops::Index;
|
||||
use std::slice;
|
||||
use std::{iter, mem, option, u32};
|
||||
use std::{iter, mem, option};
|
||||
|
||||
pub use self::cache::{BodyAndCache, ReadOnlyBodyAndCache};
|
||||
pub use self::query::*;
|
||||
|
|
|
@ -27,7 +27,7 @@ use rustc_index::vec::{Idx, IndexVec};
|
|||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::{cmp, iter, mem, usize};
|
||||
use std::{cmp, iter, mem};
|
||||
|
||||
use crate::const_eval::{is_const_fn, is_unstable_const_fn};
|
||||
use crate::transform::check_consts::{is_lang_panic_fn, qualifs, ConstKind, Item};
|
||||
|
|
|
@ -5,7 +5,6 @@ use rustc_middle::mir::*;
|
|||
use rustc_middle::ty;
|
||||
use smallvec::SmallVec;
|
||||
use std::convert::TryInto;
|
||||
use std::u32;
|
||||
|
||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
crate fn field_match_pairs<'pat>(
|
||||
|
|
|
@ -17,7 +17,6 @@ use rustc_span::symbol::kw;
|
|||
use rustc_span::Span;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
use std::u32;
|
||||
|
||||
use super::lints;
|
||||
|
||||
|
|
|
@ -256,7 +256,6 @@ use std::convert::TryInto;
|
|||
use std::fmt;
|
||||
use std::iter::{FromIterator, IntoIterator};
|
||||
use std::ops::RangeInclusive;
|
||||
use std::u128;
|
||||
|
||||
crate fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pat<'tcx>) -> Pat<'tcx> {
|
||||
LiteralExpander { tcx: cx.tcx, param_env: cx.param_env }.fold_pattern(&pat)
|
||||
|
|
|
@ -112,10 +112,10 @@ use rustc_span::symbol::sym;
|
|||
use rustc_span::Span;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
use std::rc::Rc;
|
||||
use std::{fmt, u32};
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
struct Variable(u32);
|
||||
|
|
|
@ -7,7 +7,6 @@ use rustc_macros::HashStable_Generic;
|
|||
use rustc_serialize::{Decoder, Encoder};
|
||||
use std::borrow::Borrow;
|
||||
use std::fmt;
|
||||
use std::{u32, u64};
|
||||
|
||||
rustc_index::newtype_index! {
|
||||
pub struct CrateId {
|
||||
|
|
|
@ -32,7 +32,6 @@ use std::collections::hash_map::Entry;
|
|||
use std::default::Default;
|
||||
use std::hash::Hash;
|
||||
use std::rc::Rc;
|
||||
use std::u32;
|
||||
use std::{mem, vec};
|
||||
|
||||
use crate::core::{self, DocContext, ImplTraitParam};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::cmp;
|
||||
use std::string::String;
|
||||
use std::usize;
|
||||
|
||||
use crate::clean::{self, DocFragment, Item};
|
||||
use crate::core::DocContext;
|
||||
|
|
|
@ -17,7 +17,6 @@ use rustc_serialize::{Decodable, Encodable};
|
|||
use std::collections::BTreeMap;
|
||||
use std::io::prelude::*;
|
||||
use std::string;
|
||||
use std::{f32, f64, i64, u64};
|
||||
use Animal::*;
|
||||
|
||||
#[derive(RustcDecodable, Eq, PartialEq, Debug)]
|
||||
|
|
|
@ -12,7 +12,6 @@ use self::StartResult::*;
|
|||
|
||||
use core::cmp;
|
||||
use core::intrinsics::abort;
|
||||
use core::isize;
|
||||
|
||||
use crate::cell::UnsafeCell;
|
||||
use crate::ptr;
|
||||
|
|
|
@ -11,7 +11,6 @@ use self::Message::*;
|
|||
pub use self::UpgradeResult::*;
|
||||
|
||||
use core::cmp;
|
||||
use core::isize;
|
||||
|
||||
use crate::cell::UnsafeCell;
|
||||
use crate::ptr;
|
||||
|
|
|
@ -26,7 +26,6 @@ use self::Blocker::*;
|
|||
pub use self::Failure::*;
|
||||
|
||||
use core::intrinsics::abort;
|
||||
use core::isize;
|
||||
use core::mem;
|
||||
use core::ptr;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::io;
|
|||
use crate::mem;
|
||||
use crate::sys::hermit::abi;
|
||||
use crate::time::Duration;
|
||||
use core::u32;
|
||||
|
||||
pub type Tid = abi::Tid;
|
||||
|
||||
|
|
Loading…
Reference in New Issue