From 9feb567399205879c80f9165ac8cdbcf547211da Mon Sep 17 00:00:00 2001 From: DevJPM Date: Sun, 25 Oct 2020 16:53:25 +0100 Subject: [PATCH 01/15] Updated the list of white-listed target features for x86 This PR both adds in-source documentation on what to look out for when adding a new (X86) feature set and adds all that are detectable at run-time in Rust stable as of 1.27.0. This should only enable the use of the corresponding LLVM intrinsics. Actual intrinsics need to be added separately in rust-lang/stdarch. It also re-orders the run-time-detect test statements to be more consistent with the actual list of intrinsics whitelisted and removes underscores not present in the actual names (which might be mistaken as being part of the name) --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 5 ++ .../rustc_codegen_ssa/src/target_features.rs | 13 ++++ library/std/tests/run-time-detect.rs | 63 +++++++++++-------- 3 files changed, 56 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 9c1e1b8fac06f..2cc2825cf32ef 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -137,6 +137,8 @@ pub fn time_trace_profiler_finish(file_name: &str) { // WARNING: the features after applying `to_llvm_feature` must be known // to LLVM or the feature detection code will walk past the end of the feature // array, leading to crashes. +// To find a list of LLVM's names, check llvm-project/llvm/include/llvm/Support/*TargetParser.def +// where the * matches the architecture's name pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str { let arch = if sess.target.arch == "x86_64" { "x86" } else { &*sess.target.arch }; match (arch, s) { @@ -144,6 +146,9 @@ pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str { ("x86", "rdrand") => "rdrnd", ("x86", "bmi1") => "bmi", ("x86", "cmpxchg16b") => "cx16", + ("x86", "avx512vaes") => "vaes", + ("x86", "avx512gfni") => "gfni", + ("x86", "avx512vpclmulqdq") => "vpclmulqdq", ("aarch64", "fp") => "fp-armv8", ("aarch64", "fp16") => "fullfp16", (_, s) => s, diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index a8d88a95f7a27..cef96620884ff 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -4,6 +4,11 @@ use rustc_session::Session; use rustc_span::symbol::sym; use rustc_span::symbol::Symbol; +// When adding features to the below lists +// check whether they're named already elsewhere in rust +// e.g. in stdarch and whether the given name matches LLVM's +// if it doesn't, to_llvm_feature in llvm_util in rustc_codegen_llvm needs to be adapted + const ARM_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("aclass", Some(sym::arm_target_feature)), ("mclass", Some(sym::arm_target_feature)), @@ -50,15 +55,23 @@ const X86_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("aes", None), ("avx", None), ("avx2", None), + ("avx512bf16", Some(sym::avx512_target_feature)), + ("avx512bitalg", Some(sym::avx512_target_feature)), ("avx512bw", Some(sym::avx512_target_feature)), ("avx512cd", Some(sym::avx512_target_feature)), ("avx512dq", Some(sym::avx512_target_feature)), ("avx512er", Some(sym::avx512_target_feature)), ("avx512f", Some(sym::avx512_target_feature)), + ("avx512gfni", Some(sym::avx512_target_feature)), ("avx512ifma", Some(sym::avx512_target_feature)), ("avx512pf", Some(sym::avx512_target_feature)), + ("avx512vaes", Some(sym::avx512_target_feature)), ("avx512vbmi", Some(sym::avx512_target_feature)), + ("avx512vbmi2", Some(sym::avx512_target_feature)), ("avx512vl", Some(sym::avx512_target_feature)), + ("avx512vnni", Some(sym::avx512_target_feature)), + ("avx512vp2intersect", Some(sym::avx512_target_feature)), + ("avx512vpclmulqdq", Some(sym::avx512_target_feature)), ("avx512vpopcntdq", Some(sym::avx512_target_feature)), ("bmi1", None), ("bmi2", None), diff --git a/library/std/tests/run-time-detect.rs b/library/std/tests/run-time-detect.rs index 8dd1a8ac0d2df..ffd9a04d8643a 100644 --- a/library/std/tests/run-time-detect.rs +++ b/library/std/tests/run-time-detect.rs @@ -54,42 +54,55 @@ fn powerpc64_linux() { #[test] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn x86_all() { + // the below is in alphabetical order and matches + // the order of X86_ALLOWED_FEATURES in rustc_codegen_ssa's target_features.rs + + println!("adx: {:?}", is_x86_feature_detected!("adx")); println!("aes: {:?}", is_x86_feature_detected!("aes")); - println!("pcmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq")); + println!("avx: {:?}", is_x86_feature_detected!("avx")); + println!("avx2: {:?}", is_x86_feature_detected!("avx2")); + println!("avx512bf16: {:?}", is_x86_feature_detected!("avx512bf16")); + println!("avx512bitalg: {:?}", is_x86_feature_detected!("avx512bitalg")); + println!("avx512bw: {:?}", is_x86_feature_detected!("avx512bw")); + println!("avx512cd: {:?}", is_x86_feature_detected!("avx512cd")); + println!("avx512dq: {:?}", is_x86_feature_detected!("avx512dq")); + println!("avx512er: {:?}", is_x86_feature_detected!("avx512er")); + println!("avx512f: {:?}", is_x86_feature_detected!("avx512f")); + println!("avx512gfni: {:?}", is_x86_feature_detected!("avx512gfni")); + println!("avx512ifma: {:?}", is_x86_feature_detected!("avx512ifma")); + println!("avx512pf: {:?}", is_x86_feature_detected!("avx512pf")); + println!("avx512vaes: {:?}", is_x86_feature_detected!("avx512vaes")); + println!("avx512vbmi: {:?}", is_x86_feature_detected!("avx512vbmi")); + println!("avx512vbmi2: {:?}", is_x86_feature_detected!("avx512vbmi2")); + println!("avx512vl: {:?}", is_x86_feature_detected!("avx512vl")); + println!("avx512vnni: {:?}", is_x86_feature_detected!("avx512vnni")); + println!("avx512vp2intersect: {:?}", is_x86_feature_detected!("avx512vp2intersect")); + println!("avx512vpclmulqdq: {:?}", is_x86_feature_detected!("avx512vpclmulqdq")); + println!("avx512vpopcntdq: {:?}", is_x86_feature_detected!("avx512vpopcntdq")); + println!("bmi1: {:?}", is_x86_feature_detected!("bmi1")); + println!("bmi2: {:?}", is_x86_feature_detected!("bmi2")); + println!("cmpxchg16b: {:?}", is_x86_feature_detected!("cmpxchg16b")); + println!("f16c: {:?}", is_x86_feature_detected!("f16c")); + println!("fma: {:?}", is_x86_feature_detected!("fma")); + println!("fxsr: {:?}", is_x86_feature_detected!("fxsr")); + println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt")); + println!("movbe: {:?}", is_x86_feature_detected!("movbe")); + println!("pclmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq")); + println!("popcnt: {:?}", is_x86_feature_detected!("popcnt")); println!("rdrand: {:?}", is_x86_feature_detected!("rdrand")); println!("rdseed: {:?}", is_x86_feature_detected!("rdseed")); - println!("tsc: {:?}", is_x86_feature_detected!("tsc")); - println!("mmx: {:?}", is_x86_feature_detected!("mmx")); + println!("rtm: {:?}", is_x86_feature_detected!("rtm")); + println!("sha: {:?}", is_x86_feature_detected!("sha")); println!("sse: {:?}", is_x86_feature_detected!("sse")); println!("sse2: {:?}", is_x86_feature_detected!("sse2")); println!("sse3: {:?}", is_x86_feature_detected!("sse3")); - println!("ssse3: {:?}", is_x86_feature_detected!("ssse3")); println!("sse4.1: {:?}", is_x86_feature_detected!("sse4.1")); println!("sse4.2: {:?}", is_x86_feature_detected!("sse4.2")); println!("sse4a: {:?}", is_x86_feature_detected!("sse4a")); - println!("sha: {:?}", is_x86_feature_detected!("sha")); - println!("avx: {:?}", is_x86_feature_detected!("avx")); - println!("avx2: {:?}", is_x86_feature_detected!("avx2")); - println!("avx512f {:?}", is_x86_feature_detected!("avx512f")); - println!("avx512cd {:?}", is_x86_feature_detected!("avx512cd")); - println!("avx512er {:?}", is_x86_feature_detected!("avx512er")); - println!("avx512pf {:?}", is_x86_feature_detected!("avx512pf")); - println!("avx512bw {:?}", is_x86_feature_detected!("avx512bw")); - println!("avx512dq {:?}", is_x86_feature_detected!("avx512dq")); - println!("avx512vl {:?}", is_x86_feature_detected!("avx512vl")); - println!("avx512_ifma {:?}", is_x86_feature_detected!("avx512ifma")); - println!("avx512_vbmi {:?}", is_x86_feature_detected!("avx512vbmi")); - println!("avx512_vpopcntdq {:?}", is_x86_feature_detected!("avx512vpopcntdq")); - println!("fma: {:?}", is_x86_feature_detected!("fma")); - println!("bmi1: {:?}", is_x86_feature_detected!("bmi1")); - println!("bmi2: {:?}", is_x86_feature_detected!("bmi2")); - println!("abm: {:?}", is_x86_feature_detected!("abm")); - println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt")); + println!("ssse3: {:?}", is_x86_feature_detected!("ssse3")); println!("tbm: {:?}", is_x86_feature_detected!("tbm")); - println!("popcnt: {:?}", is_x86_feature_detected!("popcnt")); - println!("fxsr: {:?}", is_x86_feature_detected!("fxsr")); println!("xsave: {:?}", is_x86_feature_detected!("xsave")); + println!("xsavec: {:?}", is_x86_feature_detected!("xsavec")); println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt")); println!("xsaves: {:?}", is_x86_feature_detected!("xsaves")); - println!("xsavec: {:?}", is_x86_feature_detected!("xsavec")); } From cd95e939bb9bef598be54067e93ac712d43fba71 Mon Sep 17 00:00:00 2001 From: DevJPM Date: Sun, 25 Oct 2020 17:27:22 +0100 Subject: [PATCH 02/15] Removed movbe from run-time-detect `movbe` seems to not be a run-time detectable feature on x86. It has thus been removed from the list. It was only commented out to ease comparison against the full list. --- library/std/tests/run-time-detect.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/tests/run-time-detect.rs b/library/std/tests/run-time-detect.rs index ffd9a04d8643a..04759d382a6fb 100644 --- a/library/std/tests/run-time-detect.rs +++ b/library/std/tests/run-time-detect.rs @@ -86,7 +86,7 @@ fn x86_all() { println!("fma: {:?}", is_x86_feature_detected!("fma")); println!("fxsr: {:?}", is_x86_feature_detected!("fxsr")); println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt")); - println!("movbe: {:?}", is_x86_feature_detected!("movbe")); + //println!("movbe: {:?}", is_x86_feature_detected!("movbe")); // movbe is unsupported as a target feature println!("pclmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq")); println!("popcnt: {:?}", is_x86_feature_detected!("popcnt")); println!("rdrand: {:?}", is_x86_feature_detected!("rdrand")); From 3daa93f555f4dab102da2a8d05cc38c4087166af Mon Sep 17 00:00:00 2001 From: DevJPM Date: Mon, 26 Oct 2020 08:15:23 +0100 Subject: [PATCH 03/15] Updated documentation, x86 feature detection testing, and removed LLVM 9 exclusive features Updated the added documentation in llvm_util.rs to note which copies of LLVM need to be inspected. Removed avx512bf16 and avx512vp2intersect because they are unsupported before LLVM 9 with the build with external LLVM 8 being supported Re-introduced detection testing previously removed for un-requestable features tsc and mmx --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 5 +++++ compiler/rustc_codegen_ssa/src/target_features.rs | 4 ++-- library/std/tests/run-time-detect.rs | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 2cc2825cf32ef..91686d27442c0 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -139,6 +139,11 @@ pub fn time_trace_profiler_finish(file_name: &str) { // array, leading to crashes. // To find a list of LLVM's names, check llvm-project/llvm/include/llvm/Support/*TargetParser.def // where the * matches the architecture's name +// Beware to not use the llvm github project for this, but check the git submodule +// found in src/llvm-project +// Though note that Rust can also be build with an external precompiled version of LLVM +// which might lead to failures if the oldest tested / supported LLVM version +// doesn't yet support the relevant intrinsics pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str { let arch = if sess.target.arch == "x86_64" { "x86" } else { &*sess.target.arch }; match (arch, s) { diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index cef96620884ff..e624768824bcb 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -55,7 +55,7 @@ const X86_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("aes", None), ("avx", None), ("avx2", None), - ("avx512bf16", Some(sym::avx512_target_feature)), + //("avx512bf16", Some(sym::avx512_target_feature)), // this seems to be unsupported by the supported build with external LLVM 8, LLVM 9 should be sufficient though ("avx512bitalg", Some(sym::avx512_target_feature)), ("avx512bw", Some(sym::avx512_target_feature)), ("avx512cd", Some(sym::avx512_target_feature)), @@ -70,7 +70,7 @@ const X86_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("avx512vbmi2", Some(sym::avx512_target_feature)), ("avx512vl", Some(sym::avx512_target_feature)), ("avx512vnni", Some(sym::avx512_target_feature)), - ("avx512vp2intersect", Some(sym::avx512_target_feature)), + //("avx512vp2intersect", Some(sym::avx512_target_feature)), // this seems to be unsupported by the supported build with external LLVM 8, LLVM 9 should be sufficient though ("avx512vpclmulqdq", Some(sym::avx512_target_feature)), ("avx512vpopcntdq", Some(sym::avx512_target_feature)), ("bmi1", None), diff --git a/library/std/tests/run-time-detect.rs b/library/std/tests/run-time-detect.rs index 04759d382a6fb..61a04c467224b 100644 --- a/library/std/tests/run-time-detect.rs +++ b/library/std/tests/run-time-detect.rs @@ -54,6 +54,13 @@ fn powerpc64_linux() { #[test] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn x86_all() { + // the below is the set of features we can test at runtime, but don't actually + // use to gate anything and are thus not part of the X86_ALLOWED_FEATURES list + + println!("abm: {:?}", is_x86_feature_detected!("abm")); // this is a synonym for lzcnt but we test it anyways + println!("mmx: {:?}", is_x86_feature_detected!("mmx")); + println!("tsc: {:?}", is_x86_feature_detected!("tsc")); + // the below is in alphabetical order and matches // the order of X86_ALLOWED_FEATURES in rustc_codegen_ssa's target_features.rs From 909c8945b172662494c0d0bd4cc89af618a41ffb Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 12 Nov 2020 22:29:52 +0300 Subject: [PATCH 04/15] stability: More precise location for deprecation lint on macros --- compiler/rustc_middle/src/middle/stability.rs | 5 +++-- compiler/rustc_resolve/src/macros.rs | 1 + src/test/ui/lint/expansion-time.rs | 10 ++++++++++ src/test/ui/lint/expansion-time.stderr | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 978f08927c6ef..47c140e0b1882 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -4,7 +4,7 @@ pub use self::StabilityLevel::*; use crate::ty::{self, TyCtxt}; -use rustc_ast::CRATE_NODE_ID; +use rustc_ast::NodeId; use rustc_attr::{self as attr, ConstStability, Deprecation, Stability}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{Applicability, DiagnosticBuilder}; @@ -211,13 +211,14 @@ pub fn early_report_deprecation( suggestion: Option, lint: &'static Lint, span: Span, + node_id: NodeId, ) { if span.in_derive_expansion() { return; } let diag = BuiltinLintDiagnostics::DeprecatedMacro(suggestion, span); - lint_buffer.buffer_lint_with_diagnostic(lint, CRATE_NODE_ID, span, message, diag); + lint_buffer.buffer_lint_with_diagnostic(lint, node_id, span, message, diag); } fn late_report_deprecation( diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index b5b281b93bcae..2fe2a499bcf20 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -1028,6 +1028,7 @@ impl<'a> Resolver<'a> { depr.suggestion, lint, span, + node_id, ); } } diff --git a/src/test/ui/lint/expansion-time.rs b/src/test/ui/lint/expansion-time.rs index c98ecc980dd3d..a9c7ac363b0b3 100644 --- a/src/test/ui/lint/expansion-time.rs +++ b/src/test/ui/lint/expansion-time.rs @@ -12,6 +12,16 @@ mod benches { fn foo() {} } +#[deprecated = "reason"] +macro_rules! deprecated { + () => {} +} + +#[allow(deprecated)] +mod deprecated { + deprecated!(); // No warning +} + #[warn(incomplete_include)] fn main() { // WARN see in the stderr file, the warning points to the included file. diff --git a/src/test/ui/lint/expansion-time.stderr b/src/test/ui/lint/expansion-time.stderr index bc48d64e7e6b7..24e2733064e48 100644 --- a/src/test/ui/lint/expansion-time.stderr +++ b/src/test/ui/lint/expansion-time.stderr @@ -33,7 +33,7 @@ LL | 2 | ^ | note: the lint level is defined here - --> $DIR/expansion-time.rs:15:8 + --> $DIR/expansion-time.rs:25:8 | LL | #[warn(incomplete_include)] | ^^^^^^^^^^^^^^^^^^ From 55d7f736d8c62cc0a03594302538001ef3f3411d Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Fri, 13 Nov 2020 19:15:51 -0800 Subject: [PATCH 05/15] Tighten the bounds on atomic Ordering in std::sys::unix::weak --- library/std/src/sys/unix/weak.rs | 46 +++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/library/std/src/sys/unix/weak.rs b/library/std/src/sys/unix/weak.rs index f4b33a00f7c85..cc3f8dbbce750 100644 --- a/library/std/src/sys/unix/weak.rs +++ b/library/std/src/sys/unix/weak.rs @@ -24,7 +24,7 @@ use crate::ffi::CStr; use crate::marker; use crate::mem; -use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::sync::atomic::{self, AtomicUsize, Ordering}; macro_rules! weak { (fn $name:ident($($t:ty),*) -> $ret:ty) => ( @@ -47,15 +47,49 @@ impl Weak { pub fn get(&self) -> Option { assert_eq!(mem::size_of::(), mem::size_of::()); unsafe { - if self.addr.load(Ordering::SeqCst) == 1 { - self.addr.store(fetch(self.name), Ordering::SeqCst); - } - match self.addr.load(Ordering::SeqCst) { + // Relaxed is fine here because we fence before reading through the + // pointer (see the comment below). + match self.addr.load(Ordering::Relaxed) { + 1 => self.initialize(), 0 => None, - addr => Some(mem::transmute_copy::(&addr)), + addr => { + let func = mem::transmute_copy::(&addr); + // The caller is presumably going to read through this value + // (by calling the function we've dlsymed). This means we'd + // need to have loaded it with at least C11's consume + // ordering in order to be guaranteed that the data we read + // from the pointer isn't from before the pointer was + // stored. Rust has no equivalent to memory_order_consume, + // so we use an acquire fence (sorry, ARM). + // + // Now, in practice this likely isn't needed even on CPUs + // where relaxed and consume mean different things. The + // symbols we're loading are probably present (or not) at + // init, and even if they aren't the runtime dynamic loader + // is extremely likely have sufficient barriers internally + // (possibly implicitly, for example the ones provided by + // invoking `mprotect`). + // + // That said, none of that's *guaranteed*, and so we fence. + atomic::fence(Ordering::Acquire); + Some(func) + } } } } + + // Cold because it should only happen during first-time initalization. + #[cold] + unsafe fn initialize(&self) -> Option { + let val = fetch(self.name); + // This synchronizes with the acquire fence in `get`. + self.addr.store(val, Ordering::Release); + + match val { + 0 => None, + addr => Some(mem::transmute_copy::(&addr)), + } + } } unsafe fn fetch(name: &str) -> usize { From 72b83af2ffadbc98fee52481c7168b0b644d73db Mon Sep 17 00:00:00 2001 From: DevJPM Date: Sun, 15 Nov 2020 11:34:08 +0100 Subject: [PATCH 06/15] Re-enable LLVM 9 target features with LLVM 9 being the minimum now With #78848 merged, the minimum supported LLVM version is now 9 which means we can actually use the target features introduced in LLVM 9 --- compiler/rustc_codegen_ssa/src/target_features.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index e624768824bcb..cef96620884ff 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -55,7 +55,7 @@ const X86_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("aes", None), ("avx", None), ("avx2", None), - //("avx512bf16", Some(sym::avx512_target_feature)), // this seems to be unsupported by the supported build with external LLVM 8, LLVM 9 should be sufficient though + ("avx512bf16", Some(sym::avx512_target_feature)), ("avx512bitalg", Some(sym::avx512_target_feature)), ("avx512bw", Some(sym::avx512_target_feature)), ("avx512cd", Some(sym::avx512_target_feature)), @@ -70,7 +70,7 @@ const X86_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("avx512vbmi2", Some(sym::avx512_target_feature)), ("avx512vl", Some(sym::avx512_target_feature)), ("avx512vnni", Some(sym::avx512_target_feature)), - //("avx512vp2intersect", Some(sym::avx512_target_feature)), // this seems to be unsupported by the supported build with external LLVM 8, LLVM 9 should be sufficient though + ("avx512vp2intersect", Some(sym::avx512_target_feature)), ("avx512vpclmulqdq", Some(sym::avx512_target_feature)), ("avx512vpopcntdq", Some(sym::avx512_target_feature)), ("bmi1", None), From c82a258ad40ca8877e91a12722097e79a42905c6 Mon Sep 17 00:00:00 2001 From: Camelid Date: Sun, 15 Nov 2020 12:36:28 -0800 Subject: [PATCH 07/15] Turn top-level comments into module docs in MIR visitor --- compiler/rustc_middle/src/mir/visit.rs | 124 ++++++++++++------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index d8d639ab73451..638dd8ce9706f 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -1,70 +1,70 @@ +//! # The MIR Visitor +//! +//! ## Overview +//! +//! There are two visitors, one for immutable and one for mutable references, +//! but both are generated by the following macro. The code is written according +//! to the following conventions: +//! +//! - introduce a `visit_foo` and a `super_foo` method for every MIR type +//! - `visit_foo`, by default, calls `super_foo` +//! - `super_foo`, by default, destructures the `foo` and calls `visit_foo` +//! +//! This allows you as a user to override `visit_foo` for types are +//! interested in, and invoke (within that method) call +//! `self.super_foo` to get the default behavior. Just as in an OO +//! language, you should never call `super` methods ordinarily except +//! in that circumstance. +//! +//! For the most part, we do not destructure things external to the +//! MIR, e.g., types, spans, etc, but simply visit them and stop. This +//! avoids duplication with other visitors like `TypeFoldable`. +//! +//! ## Updating +//! +//! The code is written in a very deliberate style intended to minimize +//! the chance of things being overlooked. You'll notice that we always +//! use pattern matching to reference fields and we ensure that all +//! matches are exhaustive. +//! +//! For example, the `super_basic_block_data` method begins like this: +//! +//! ```rust +//! fn super_basic_block_data(&mut self, +//! block: BasicBlock, +//! data: & $($mutability)? BasicBlockData<'tcx>) { +//! let BasicBlockData { +//! statements, +//! terminator, +//! is_cleanup: _ +//! } = *data; +//! +//! for statement in statements { +//! self.visit_statement(block, statement); +//! } +//! +//! ... +//! } +//! ``` +//! +//! Here we used `let BasicBlockData { } = *data` deliberately, +//! rather than writing `data.statements` in the body. This is because if one +//! adds a new field to `BasicBlockData`, one will be forced to revise this code, +//! and hence one will (hopefully) invoke the correct visit methods (if any). +//! +//! For this to work, ALL MATCHES MUST BE EXHAUSTIVE IN FIELDS AND VARIANTS. +//! That means you never write `..` to skip over fields, nor do you write `_` +//! to skip over variants in a `match`. +//! +//! The only place that `_` is acceptable is to match a field (or +//! variant argument) that does not require visiting, as in +//! `is_cleanup` above. + use crate::mir::*; use crate::ty::subst::SubstsRef; use crate::ty::{CanonicalUserTypeAnnotation, Ty}; use rustc_span::Span; -// # The MIR Visitor -// -// ## Overview -// -// There are two visitors, one for immutable and one for mutable references, -// but both are generated by the following macro. The code is written according -// to the following conventions: -// -// - introduce a `visit_foo` and a `super_foo` method for every MIR type -// - `visit_foo`, by default, calls `super_foo` -// - `super_foo`, by default, destructures the `foo` and calls `visit_foo` -// -// This allows you as a user to override `visit_foo` for types are -// interested in, and invoke (within that method) call -// `self.super_foo` to get the default behavior. Just as in an OO -// language, you should never call `super` methods ordinarily except -// in that circumstance. -// -// For the most part, we do not destructure things external to the -// MIR, e.g., types, spans, etc, but simply visit them and stop. This -// avoids duplication with other visitors like `TypeFoldable`. -// -// ## Updating -// -// The code is written in a very deliberate style intended to minimize -// the chance of things being overlooked. You'll notice that we always -// use pattern matching to reference fields and we ensure that all -// matches are exhaustive. -// -// For example, the `super_basic_block_data` method begins like this: -// -// ```rust -// fn super_basic_block_data(&mut self, -// block: BasicBlock, -// data: & $($mutability)? BasicBlockData<'tcx>) { -// let BasicBlockData { -// statements, -// terminator, -// is_cleanup: _ -// } = *data; -// -// for statement in statements { -// self.visit_statement(block, statement); -// } -// -// ... -// } -// ``` -// -// Here we used `let BasicBlockData { } = *data` deliberately, -// rather than writing `data.statements` in the body. This is because if one -// adds a new field to `BasicBlockData`, one will be forced to revise this code, -// and hence one will (hopefully) invoke the correct visit methods (if any). -// -// For this to work, ALL MATCHES MUST BE EXHAUSTIVE IN FIELDS AND VARIANTS. -// That means you never write `..` to skip over fields, nor do you write `_` -// to skip over variants in a `match`. -// -// The only place that `_` is acceptable is to match a field (or -// variant argument) that does not require visiting, as in -// `is_cleanup` above. - macro_rules! make_mir_visitor { ($visitor_trait_name:ident, $($mutability:ident)?) => { pub trait $visitor_trait_name<'tcx> { From dcc194ce2fb53555baf4bc16e5cacb3b5e1911b1 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Mon, 16 Nov 2020 10:48:31 +0100 Subject: [PATCH 08/15] instrument `QueryNormalizer::fold_ty` --- compiler/rustc_trait_selection/src/traits/query/normalize.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index 42a598ce3a008..bcd3d37ae6747 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -97,6 +97,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> { self.infcx.tcx } + #[instrument(skip(self))] fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { if !ty.has_projections() { return ty; From d701bf91feb4d6cd85455b5b38a8e7b5228af883 Mon Sep 17 00:00:00 2001 From: Mahmut Bulut Date: Tue, 17 Nov 2020 11:50:52 +0100 Subject: [PATCH 09/15] Enable AVX512 *epi64 variants by updating stdarch --- library/stdarch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/stdarch b/library/stdarch index 3c3664355ef46..777efaf564470 160000 --- a/library/stdarch +++ b/library/stdarch @@ -1 +1 @@ -Subproject commit 3c3664355ef46e788b53080e521d6542fbddfd84 +Subproject commit 777efaf5644706b36706a7a5c51edb63835e05ca From d17874ff601c53ac35f71e55f5629a5b8232d678 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Tue, 17 Nov 2020 12:52:21 +0100 Subject: [PATCH 10/15] bootstrap: use the same version number for rustc and cargo Historically the stable tarballs were named after the version number of the specific tool, instead of the version number of Rust. For example, both of the following tarballs were part of the same release: rustc-1.48.0-x86_64-unknown-linux-gnu.tar.xz cargo-0.49.0-x86_64-unknown-linux-gnu.tar.xz PR #77336 changed the dist code to instead use Rust's version number for all the tarballs, regardless of the tool they contain: rustc-1.48.0-x86_64-unknown-linux-gnu.tar.xz cargo-1.48.0-x86_64-unknown-linux-gnu.tar.xz Because of that there is no need anymore to have a separate `cargo` field in src/stage0.txt, as the Cargo version will always be the same as the rustc version. This PR removes the field, simplifying the code and the maintenance work required while producing releases. --- src/bootstrap/bootstrap.py | 29 ++++------------------------- src/stage0.txt | 11 +++++------ 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 54d0a23dec58d..4fb58034ce216 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -360,7 +360,6 @@ def output(filepath): class RustBuild(object): """Provide all the methods required to build Rust""" def __init__(self): - self.cargo_channel = '' self.date = '' self._download_url = '' self.rustc_channel = '' @@ -387,7 +386,6 @@ def download_stage0(self): will move all the content to the right place. """ rustc_channel = self.rustc_channel - cargo_channel = self.cargo_channel rustfmt_channel = self.rustfmt_channel if self.rustc().startswith(self.bin_root()) and \ @@ -400,12 +398,15 @@ def download_stage0(self): rustc_channel, self.build, tarball_suffix) pattern = "rust-std-{}".format(self.build) self._download_stage0_helper(filename, pattern, tarball_suffix) - filename = "rustc-{}-{}{}".format(rustc_channel, self.build, tarball_suffix) self._download_stage0_helper(filename, "rustc", tarball_suffix) + filename = "cargo-{}-{}{}".format(rustc_channel, self.build, + tarball_suffix) + self._download_stage0_helper(filename, "cargo", tarball_suffix) self.fix_bin_or_dylib("{}/bin/rustc".format(self.bin_root())) self.fix_bin_or_dylib("{}/bin/rustdoc".format(self.bin_root())) + self.fix_bin_or_dylib("{}/bin/cargo".format(self.bin_root())) lib_dir = "{}/lib".format(self.bin_root()) for lib in os.listdir(lib_dir): if lib.endswith(".so"): @@ -413,17 +414,6 @@ def download_stage0(self): with output(self.rustc_stamp()) as rust_stamp: rust_stamp.write(self.date) - if self.cargo().startswith(self.bin_root()) and \ - (not os.path.exists(self.cargo()) or - self.program_out_of_date(self.cargo_stamp())): - tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz' - filename = "cargo-{}-{}{}".format(cargo_channel, self.build, - tarball_suffix) - self._download_stage0_helper(filename, "cargo", tarball_suffix) - self.fix_bin_or_dylib("{}/bin/cargo".format(self.bin_root())) - with output(self.cargo_stamp()) as cargo_stamp: - cargo_stamp.write(self.date) - if self.rustfmt() and self.rustfmt().startswith(self.bin_root()) and ( not os.path.exists(self.rustfmt()) or self.program_out_of_date(self.rustfmt_stamp(), self.rustfmt_channel) @@ -601,16 +591,6 @@ def rustc_stamp(self): """ return os.path.join(self.bin_root(), '.rustc-stamp') - def cargo_stamp(self): - """Return the path for .cargo-stamp - - >>> rb = RustBuild() - >>> rb.build_dir = "build" - >>> rb.cargo_stamp() == os.path.join("build", "stage0", ".cargo-stamp") - True - """ - return os.path.join(self.bin_root(), '.cargo-stamp') - def rustfmt_stamp(self): """Return the path for .rustfmt-stamp @@ -1056,7 +1036,6 @@ def bootstrap(help_triggered): data = stage0_data(build.rust_root) build.date = data['date'] build.rustc_channel = data['rustc'] - build.cargo_channel = data['cargo'] if "rustfmt" in data: build.rustfmt_channel = data['rustfmt'] diff --git a/src/stage0.txt b/src/stage0.txt index 9eaa58dd43869..dae9d219b7b9b 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -1,6 +1,5 @@ # This file describes the stage0 compiler that's used to then bootstrap the Rust -# compiler itself. For the rustbuild build system, this also describes the -# relevant Cargo revision that we're using. +# compiler itself. # # Currently Rust always bootstraps from the previous stable release, and in our # train model this means that the master branch bootstraps from beta, beta @@ -8,13 +7,13 @@ # release. # # If you're looking at this file on the master branch, you'll likely see that -# rustc and cargo are configured to `beta`, whereas if you're looking at a -# source tarball for a stable release you'll likely see `1.x.0` for rustc and -# `0.(x+1).0` for Cargo where they were released on `date`. +# rustc is configured to `beta`, whereas if you're looking at a source tarball +# for a stable release you'll likely see `1.x.0` for rustc, with the previous +# stable release's version number. `date` is the date where the release we're +# bootstrapping off was released. date: 2020-10-16 rustc: beta -cargo: beta # We use a nightly rustfmt to format the source because it solves some # bootstrapping issues with use of new syntax in this repo. If you're looking at From 9bbc4c16d31ec0c89aa5943fc1bfca8d8fc6f281 Mon Sep 17 00:00:00 2001 From: Andreas Jonson Date: Tue, 17 Nov 2020 19:29:15 +0100 Subject: [PATCH 11/15] add trailing_zeros and leading_zeros to non zero types --- library/core/src/lib.rs | 1 + library/core/src/num/nonzero.rs | 74 +++++++++++++++++++++++ library/core/tests/lib.rs | 2 + library/core/tests/nonzero.rs | 102 +++++++++++++++++++++++++++++++- 4 files changed, 178 insertions(+), 1 deletion(-) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 41202546566a7..d67f9c15a1916 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -80,6 +80,7 @@ #![feature(const_mut_refs)] #![feature(const_int_pow)] #![feature(constctlz)] +#![feature(const_cttz)] #![feature(const_panic)] #![feature(const_pin)] #![feature(const_fn)] diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 5a9fd902c9ca1..716b4a90e5ec2 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -6,6 +6,7 @@ use crate::str::FromStr; use super::from_str_radix; use super::{IntErrorKind, ParseIntError}; +use crate::intrinsics; macro_rules! doc_comment { ($x:expr, $($tt:tt)*) => { @@ -189,3 +190,76 @@ macro_rules! from_str_radix_nzint_impl { from_str_radix_nzint_impl! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroI128 NonZeroIsize } + +macro_rules! nonzero_leading_trailing_zeros { + ( $( $Ty: ident($Uint: ty) , $LeadingTestExpr:expr ;)+ ) => { + $( + impl $Ty { + doc_comment! { + concat!("Returns the number of leading zeros in the binary representation of `self`. + +On many architectures, this function can perform better than `leading_zeros()` on the underlying integer type, as special handling of zero can be avoided. + +# Examples + +Basic usage: + +``` +#![feature(nonzero_leading_trailing_zeros)] +let n = std::num::", stringify!($Ty), "::new(", stringify!($LeadingTestExpr), ").unwrap(); + +assert_eq!(n.leading_zeros(), 0); +```"), + #[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] + #[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] + #[inline] + pub const fn leading_zeros(self) -> u32 { + // SAFETY: since `self` can not be zero it is safe to call ctlz_nonzero + unsafe { intrinsics::ctlz_nonzero(self.0 as $Uint) as u32 } + } + } + + doc_comment! { + concat!("Returns the number of trailing zeros in the binary representation +of `self`. + +On many architectures, this function can perform better than `trailing_zeros()` on the underlying integer type, as special handling of zero can be avoided. + +# Examples + +Basic usage: + +``` +#![feature(nonzero_leading_trailing_zeros)] +let n = std::num::", stringify!($Ty), "::new(0b0101000).unwrap(); + +assert_eq!(n.trailing_zeros(), 3); +```"), + #[unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] + #[rustc_const_unstable(feature = "nonzero_leading_trailing_zeros", issue = "79143")] + #[inline] + pub const fn trailing_zeros(self) -> u32 { + // SAFETY: since `self` can not be zero it is safe to call cttz_nonzero + unsafe { intrinsics::cttz_nonzero(self.0 as $Uint) as u32 } + } + } + + } + )+ + } +} + +nonzero_leading_trailing_zeros! { + NonZeroU8(u8), u8::MAX; + NonZeroU16(u16), u16::MAX; + NonZeroU32(u32), u32::MAX; + NonZeroU64(u64), u64::MAX; + NonZeroU128(u128), u128::MAX; + NonZeroUsize(usize), usize::MAX; + NonZeroI8(u8), -1i8; + NonZeroI16(u16), -1i16; + NonZeroI32(u32), -1i32; + NonZeroI64(u64), -1i64; + NonZeroI128(u128), -1i128; + NonZeroIsize(usize), -1isize; +} diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index c9f9b890c3938..14ef03fd53eba 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -60,6 +60,8 @@ #![feature(once_cell)] #![feature(unsafe_block_in_unsafe_fn)] #![feature(int_bits_const)] +#![feature(nonzero_leading_trailing_zeros)] +#![feature(const_option)] #![deny(unsafe_op_in_unsafe_fn)] extern crate test; diff --git a/library/core/tests/nonzero.rs b/library/core/tests/nonzero.rs index fb1293c99bba9..ca449b4350ede 100644 --- a/library/core/tests/nonzero.rs +++ b/library/core/tests/nonzero.rs @@ -1,5 +1,8 @@ use core::convert::TryFrom; -use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8}; +use core::num::{ + IntErrorKind, NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, + NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, +}; use core::option::Option::{self, None, Some}; use std::mem::size_of; @@ -212,3 +215,100 @@ fn nonzero_const() { const ONE: Option = NonZeroU8::new(1); assert!(ONE.is_some()); } + +#[test] +fn nonzero_leading_zeros() { + assert_eq!(NonZeroU8::new(1).unwrap().leading_zeros(), 7); + assert_eq!(NonZeroI8::new(1).unwrap().leading_zeros(), 7); + assert_eq!(NonZeroU16::new(1).unwrap().leading_zeros(), 15); + assert_eq!(NonZeroI16::new(1).unwrap().leading_zeros(), 15); + assert_eq!(NonZeroU32::new(1).unwrap().leading_zeros(), 31); + assert_eq!(NonZeroI32::new(1).unwrap().leading_zeros(), 31); + assert_eq!(NonZeroU64::new(1).unwrap().leading_zeros(), 63); + assert_eq!(NonZeroI64::new(1).unwrap().leading_zeros(), 63); + assert_eq!(NonZeroU128::new(1).unwrap().leading_zeros(), 127); + assert_eq!(NonZeroI128::new(1).unwrap().leading_zeros(), 127); + assert_eq!(NonZeroUsize::new(1).unwrap().leading_zeros(), usize::BITS - 1); + assert_eq!(NonZeroIsize::new(1).unwrap().leading_zeros(), usize::BITS - 1); + + assert_eq!(NonZeroU8::new(u8::MAX >> 2).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroI8::new((u8::MAX >> 2) as i8).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroU16::new(u16::MAX >> 2).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroI16::new((u16::MAX >> 2) as i16).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroU32::new(u32::MAX >> 2).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroI32::new((u32::MAX >> 2) as i32).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroU64::new(u64::MAX >> 2).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroI64::new((u64::MAX >> 2) as i64).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroU128::new(u128::MAX >> 2).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroI128::new((u128::MAX >> 2) as i128).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroUsize::new(usize::MAX >> 2).unwrap().leading_zeros(), 2); + assert_eq!(NonZeroIsize::new((usize::MAX >> 2) as isize).unwrap().leading_zeros(), 2); + + assert_eq!(NonZeroU8::new(u8::MAX).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroI8::new(-1i8).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroU16::new(u16::MAX).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroI16::new(-1i16).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroU32::new(u32::MAX).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroI32::new(-1i32).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroU64::new(u64::MAX).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroI64::new(-1i64).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroU128::new(u128::MAX).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroI128::new(-1i128).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroUsize::new(usize::MAX).unwrap().leading_zeros(), 0); + assert_eq!(NonZeroIsize::new(-1isize).unwrap().leading_zeros(), 0); + + const LEADING_ZEROS: u32 = NonZeroU16::new(1).unwrap().leading_zeros(); + assert_eq!(LEADING_ZEROS, 15); +} + +#[test] +fn nonzero_trailing_zeros() { + assert_eq!(NonZeroU8::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroI8::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroU16::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroI16::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroU32::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroI32::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroU64::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroI64::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroU128::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroI128::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroUsize::new(1).unwrap().trailing_zeros(), 0); + assert_eq!(NonZeroIsize::new(1).unwrap().trailing_zeros(), 0); + + assert_eq!(NonZeroU8::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroI8::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroU16::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroI16::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroU32::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroI32::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroU64::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroI64::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroU128::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroI128::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroUsize::new(1 << 2).unwrap().trailing_zeros(), 2); + assert_eq!(NonZeroIsize::new(1 << 2).unwrap().trailing_zeros(), 2); + + assert_eq!(NonZeroU8::new(1 << 7).unwrap().trailing_zeros(), 7); + assert_eq!(NonZeroI8::new(1 << 7).unwrap().trailing_zeros(), 7); + assert_eq!(NonZeroU16::new(1 << 15).unwrap().trailing_zeros(), 15); + assert_eq!(NonZeroI16::new(1 << 15).unwrap().trailing_zeros(), 15); + assert_eq!(NonZeroU32::new(1 << 31).unwrap().trailing_zeros(), 31); + assert_eq!(NonZeroI32::new(1 << 31).unwrap().trailing_zeros(), 31); + assert_eq!(NonZeroU64::new(1 << 63).unwrap().trailing_zeros(), 63); + assert_eq!(NonZeroI64::new(1 << 63).unwrap().trailing_zeros(), 63); + assert_eq!(NonZeroU128::new(1 << 127).unwrap().trailing_zeros(), 127); + assert_eq!(NonZeroI128::new(1 << 127).unwrap().trailing_zeros(), 127); + + assert_eq!( + NonZeroUsize::new(1 << (usize::BITS - 1)).unwrap().trailing_zeros(), + usize::BITS - 1 + ); + assert_eq!( + NonZeroIsize::new(1 << (usize::BITS - 1)).unwrap().trailing_zeros(), + usize::BITS - 1 + ); + + const TRAILING_ZEROS: u32 = NonZeroU16::new(1 << 2).unwrap().trailing_zeros(); + assert_eq!(TRAILING_ZEROS, 2); +} From 95eff664269adc18daca51b0de969b699a4ddb01 Mon Sep 17 00:00:00 2001 From: Camelid Date: Tue, 17 Nov 2020 12:16:15 -0800 Subject: [PATCH 12/15] Fix handling of panic calls This should make Clippy more resilient and will unblock #78343. This PR is made against rust-lang/rust to avoid the need for a subtree sync at @flip1995's suggestion in rust-lang/rust-clippy#6310. --- .../src/assertions_on_constants.rs | 5 +- src/tools/clippy/clippy_lints/src/attrs.rs | 4 +- .../clippy_lints/src/fallible_impl_from.rs | 9 ++-- .../clippy_lints/src/implicit_return.rs | 9 +--- .../clippy_lints/src/panic_unimplemented.rs | 44 ++++++++-------- .../clippy/clippy_lints/src/utils/mod.rs | 20 +++++++- .../clippy/clippy_lints/src/utils/paths.rs | 8 ++- src/tools/clippy/tests/ui/panicking_macros.rs | 11 ++++ .../clippy/tests/ui/panicking_macros.stderr | 50 ++++++++++++++----- 9 files changed, 106 insertions(+), 54 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs b/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs index 982d5ecf8d02f..a2ccb0369c4a4 100644 --- a/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs +++ b/src/tools/clippy/clippy_lints/src/assertions_on_constants.rs @@ -1,6 +1,5 @@ use crate::consts::{constant, Constant}; -use crate::utils::paths; -use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, snippet_opt, span_lint_and_help}; +use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call, snippet_opt, span_lint_and_help}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_hir::{Expr, ExprKind, PatKind, UnOp}; @@ -133,7 +132,7 @@ fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) if let ExprKind::Block(ref inner_block, _) = block_expr.kind; if let Some(begin_panic_call) = &inner_block.expr; // function call - if let Some(args) = match_function_call(cx, begin_panic_call, &paths::BEGIN_PANIC); + if let Some(args) = match_panic_call(cx, begin_panic_call); if args.len() == 1; // bind the second argument of the `assert!` macro if it exists if let panic_message = snippet_opt(cx, args[0].span); diff --git a/src/tools/clippy/clippy_lints/src/attrs.rs b/src/tools/clippy/clippy_lints/src/attrs.rs index 55904a0ec0a84..57702dafa6a0c 100644 --- a/src/tools/clippy/clippy_lints/src/attrs.rs +++ b/src/tools/clippy/clippy_lints/src/attrs.rs @@ -1,7 +1,7 @@ //! checks for attributes use crate::utils::{ - first_line_of_span, is_present_in_source, match_def_path, paths, snippet_opt, span_lint, span_lint_and_help, + first_line_of_span, is_present_in_source, match_panic_def_id, snippet_opt, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then, without_block_comments, }; use if_chain::if_chain; @@ -513,7 +513,7 @@ fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_> typeck_results .qpath_res(qpath, path_expr.hir_id) .opt_def_id() - .map_or(true, |fun_id| !match_def_path(cx, fun_id, &paths::BEGIN_PANIC)) + .map_or(true, |fun_id| !match_panic_def_id(cx, fun_id)) } else { true } diff --git a/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs b/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs index fe817fe94f2e4..509a4a4e15f62 100644 --- a/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs +++ b/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs @@ -1,5 +1,7 @@ -use crate::utils::paths::{BEGIN_PANIC, BEGIN_PANIC_FMT, FROM_TRAIT}; -use crate::utils::{is_expn_of, is_type_diagnostic_item, match_def_path, method_chain_args, span_lint_and_then}; +use crate::utils::paths::FROM_TRAIT; +use crate::utils::{ + is_expn_of, is_type_diagnostic_item, match_def_path, match_panic_def_id, method_chain_args, span_lint_and_then, +}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; @@ -84,8 +86,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h if let ExprKind::Call(ref func_expr, _) = expr.kind; if let ExprKind::Path(QPath::Resolved(_, ref path)) = func_expr.kind; if let Some(path_def_id) = path.res.opt_def_id(); - if match_def_path(self.lcx, path_def_id, &BEGIN_PANIC) || - match_def_path(self.lcx, path_def_id, &BEGIN_PANIC_FMT); + if match_panic_def_id(self.lcx, path_def_id); if is_expn_of(expr.span, "unreachable").is_none(); then { self.result.push(expr.span); diff --git a/src/tools/clippy/clippy_lints/src/implicit_return.rs b/src/tools/clippy/clippy_lints/src/implicit_return.rs index 22c4fef32a32b..ed7f3b9293dbf 100644 --- a/src/tools/clippy/clippy_lints/src/implicit_return.rs +++ b/src/tools/clippy/clippy_lints/src/implicit_return.rs @@ -1,8 +1,4 @@ -use crate::utils::{ - fn_has_unsatisfiable_preds, match_def_path, - paths::{BEGIN_PANIC, BEGIN_PANIC_FMT}, - snippet_opt, span_lint_and_then, -}; +use crate::utils::{fn_has_unsatisfiable_preds, match_panic_def_id, snippet_opt, span_lint_and_then}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::intravisit::FnKind; @@ -109,8 +105,7 @@ fn expr_match(cx: &LateContext<'_>, expr: &Expr<'_>) { if_chain! { if let ExprKind::Path(qpath) = &expr.kind; if let Some(path_def_id) = cx.qpath_res(qpath, expr.hir_id).opt_def_id(); - if match_def_path(cx, path_def_id, &BEGIN_PANIC) || - match_def_path(cx, path_def_id, &BEGIN_PANIC_FMT); + if match_panic_def_id(cx, path_def_id); then { } else { lint(cx, expr.span, expr.span, LINT_RETURN) diff --git a/src/tools/clippy/clippy_lints/src/panic_unimplemented.rs b/src/tools/clippy/clippy_lints/src/panic_unimplemented.rs index 6379dffd22e37..3d888fe732573 100644 --- a/src/tools/clippy/clippy_lints/src/panic_unimplemented.rs +++ b/src/tools/clippy/clippy_lints/src/panic_unimplemented.rs @@ -1,4 +1,4 @@ -use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, paths, span_lint}; +use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call, span_lint}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_hir::{Expr, ExprKind}; @@ -93,27 +93,27 @@ declare_lint_pass!(PanicUnimplemented => [PANIC_PARAMS, UNIMPLEMENTED, UNREACHAB impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - if_chain! { - if let ExprKind::Block(ref block, _) = expr.kind; - if let Some(ref ex) = block.expr; - if let Some(params) = match_function_call(cx, ex, &paths::BEGIN_PANIC) - .or_else(|| match_function_call(cx, ex, &paths::BEGIN_PANIC_FMT)); - then { - let span = get_outer_span(expr); - if is_expn_of(expr.span, "unimplemented").is_some() { - span_lint(cx, UNIMPLEMENTED, span, - "`unimplemented` should not be present in production code"); - } else if is_expn_of(expr.span, "todo").is_some() { - span_lint(cx, TODO, span, - "`todo` should not be present in production code"); - } else if is_expn_of(expr.span, "unreachable").is_some() { - span_lint(cx, UNREACHABLE, span, - "`unreachable` should not be present in production code"); - } else if is_expn_of(expr.span, "panic").is_some() { - span_lint(cx, PANIC, span, - "`panic` should not be present in production code"); - match_panic(params, expr, cx); - } + if let Some(params) = match_panic_call(cx, expr) { + let span = get_outer_span(expr); + if is_expn_of(expr.span, "unimplemented").is_some() { + span_lint( + cx, + UNIMPLEMENTED, + span, + "`unimplemented` should not be present in production code", + ); + } else if is_expn_of(expr.span, "todo").is_some() { + span_lint(cx, TODO, span, "`todo` should not be present in production code"); + } else if is_expn_of(expr.span, "unreachable").is_some() { + span_lint( + cx, + UNREACHABLE, + span, + "`unreachable` should not be present in production code", + ); + } else if is_expn_of(expr.span, "panic").is_some() { + span_lint(cx, PANIC, span, "`panic` should not be present in production code"); + match_panic(params, expr, cx); } } } diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index 0d43fd0392eb2..a68262d56c64d 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -1196,7 +1196,7 @@ pub fn has_iter_method(cx: &LateContext<'_>, probably_ref_ty: Ty<'_>) -> Option< /// Usage: /// /// ```rust,ignore -/// if let Some(args) = match_function_call(cx, begin_panic_call, &paths::BEGIN_PANIC); +/// if let Some(args) = match_function_call(cx, cmp_max_call, &paths::CMP_MAX); /// ``` pub fn match_function_call<'tcx>( cx: &LateContext<'tcx>, @@ -1231,6 +1231,24 @@ pub fn match_def_path<'tcx>(cx: &LateContext<'tcx>, did: DefId, syms: &[&str]) - cx.match_def_path(did, &syms) } +pub fn match_panic_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx [Expr<'tcx>]> { + match_function_call(cx, expr, &paths::BEGIN_PANIC) + .or_else(|| match_function_call(cx, expr, &paths::BEGIN_PANIC_FMT)) + .or_else(|| match_function_call(cx, expr, &paths::PANIC_ANY)) + .or_else(|| match_function_call(cx, expr, &paths::PANICKING_PANIC)) + .or_else(|| match_function_call(cx, expr, &paths::PANICKING_PANIC_FMT)) + .or_else(|| match_function_call(cx, expr, &paths::PANICKING_PANIC_STR)) +} + +pub fn match_panic_def_id(cx: &LateContext<'_>, did: DefId) -> bool { + match_def_path(cx, did, &paths::BEGIN_PANIC) + || match_def_path(cx, did, &paths::BEGIN_PANIC_FMT) + || match_def_path(cx, did, &paths::PANIC_ANY) + || match_def_path(cx, did, &paths::PANICKING_PANIC) + || match_def_path(cx, did, &paths::PANICKING_PANIC_FMT) + || match_def_path(cx, did, &paths::PANICKING_PANIC_STR) +} + /// Returns the list of condition expressions and the list of blocks in a /// sequence of `if/else`. /// E.g., this returns `([a, b], [c, d, e])` for the expression diff --git a/src/tools/clippy/clippy_lints/src/utils/paths.rs b/src/tools/clippy/clippy_lints/src/utils/paths.rs index 1ad8c6029860b..8f5fbfd9f846a 100644 --- a/src/tools/clippy/clippy_lints/src/utils/paths.rs +++ b/src/tools/clippy/clippy_lints/src/utils/paths.rs @@ -8,8 +8,8 @@ pub const ANY_TRAIT: [&str; 3] = ["std", "any", "Any"]; pub const ARC_PTR_EQ: [&str; 4] = ["alloc", "sync", "Arc", "ptr_eq"]; pub const ASMUT_TRAIT: [&str; 3] = ["core", "convert", "AsMut"]; pub const ASREF_TRAIT: [&str; 3] = ["core", "convert", "AsRef"]; -pub const BEGIN_PANIC: [&str; 3] = ["std", "panicking", "begin_panic"]; -pub const BEGIN_PANIC_FMT: [&str; 3] = ["std", "panicking", "begin_panic_fmt"]; +pub(super) const BEGIN_PANIC: [&str; 3] = ["std", "panicking", "begin_panic"]; +pub(super) const BEGIN_PANIC_FMT: [&str; 3] = ["std", "panicking", "begin_panic_fmt"]; pub const BINARY_HEAP: [&str; 4] = ["alloc", "collections", "binary_heap", "BinaryHeap"]; pub const BORROW_TRAIT: [&str; 3] = ["core", "borrow", "Borrow"]; pub const BOX: [&str; 3] = ["alloc", "boxed", "Box"]; @@ -78,6 +78,10 @@ pub const ORD: [&str; 3] = ["core", "cmp", "Ord"]; pub const OS_STRING: [&str; 4] = ["std", "ffi", "os_str", "OsString"]; pub const OS_STRING_AS_OS_STR: [&str; 5] = ["std", "ffi", "os_str", "OsString", "as_os_str"]; pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"]; +pub(super) const PANICKING_PANIC: [&str; 3] = ["core", "panicking", "panic"]; +pub(super) const PANICKING_PANIC_FMT: [&str; 3] = ["core", "panicking", "panic_fmt"]; +pub(super) const PANICKING_PANIC_STR: [&str; 3] = ["core", "panicking", "panic_str"]; +pub(super) const PANIC_ANY: [&str; 3] = ["std", "panic", "panic_any"]; pub const PARKING_LOT_MUTEX_GUARD: [&str; 2] = ["parking_lot", "MutexGuard"]; pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 2] = ["parking_lot", "RwLockReadGuard"]; pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 2] = ["parking_lot", "RwLockWriteGuard"]; diff --git a/src/tools/clippy/tests/ui/panicking_macros.rs b/src/tools/clippy/tests/ui/panicking_macros.rs index f91ccfaed743d..77fcb8dfd02fd 100644 --- a/src/tools/clippy/tests/ui/panicking_macros.rs +++ b/src/tools/clippy/tests/ui/panicking_macros.rs @@ -1,6 +1,8 @@ #![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)] #![allow(clippy::assertions_on_constants)] +extern crate core; + fn panic() { let a = 2; panic!(); @@ -33,9 +35,18 @@ fn unreachable() { let b = a + 2; } +fn core_versions() { + use core::{panic, todo, unimplemented, unreachable}; + panic!(); + todo!(); + unimplemented!(); + unreachable!(); +} + fn main() { panic(); todo(); unimplemented(); unreachable(); + core_versions(); } diff --git a/src/tools/clippy/tests/ui/panicking_macros.stderr b/src/tools/clippy/tests/ui/panicking_macros.stderr index 37c11d72a574a..83234c0ed92cc 100644 --- a/src/tools/clippy/tests/ui/panicking_macros.stderr +++ b/src/tools/clippy/tests/ui/panicking_macros.stderr @@ -1,5 +1,5 @@ error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:6:5 + --> $DIR/panicking_macros.rs:8:5 | LL | panic!(); | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | panic!(); = note: `-D clippy::panic` implied by `-D warnings` error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:7:5 + --> $DIR/panicking_macros.rs:9:5 | LL | panic!("message"); | ^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | panic!("message"); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:8:5 + --> $DIR/panicking_macros.rs:10:5 | LL | panic!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | panic!("{} {}", "panic with", "multiple arguments"); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:14:5 + --> $DIR/panicking_macros.rs:16:5 | LL | todo!(); | ^^^^^^^^ @@ -31,19 +31,19 @@ LL | todo!(); = note: `-D clippy::todo` implied by `-D warnings` error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:15:5 + --> $DIR/panicking_macros.rs:17:5 | LL | todo!("message"); | ^^^^^^^^^^^^^^^^^ error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:16:5 + --> $DIR/panicking_macros.rs:18:5 | LL | todo!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:22:5 + --> $DIR/panicking_macros.rs:24:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^^ @@ -51,19 +51,19 @@ LL | unimplemented!(); = note: `-D clippy::unimplemented` implied by `-D warnings` error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:23:5 + --> $DIR/panicking_macros.rs:25:5 | LL | unimplemented!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:24:5 + --> $DIR/panicking_macros.rs:26:5 | LL | unimplemented!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `unreachable` should not be present in production code - --> $DIR/panicking_macros.rs:30:5 + --> $DIR/panicking_macros.rs:32:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | unreachable!(); = note: `-D clippy::unreachable` implied by `-D warnings` error: `unreachable` should not be present in production code - --> $DIR/panicking_macros.rs:31:5 + --> $DIR/panicking_macros.rs:33:5 | LL | unreachable!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,10 +79,34 @@ LL | unreachable!("message"); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `unreachable` should not be present in production code - --> $DIR/panicking_macros.rs:32:5 + --> $DIR/panicking_macros.rs:34:5 | LL | unreachable!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors +error: `panic` should not be present in production code + --> $DIR/panicking_macros.rs:40:5 + | +LL | panic!(); + | ^^^^^^^^^ + +error: `todo` should not be present in production code + --> $DIR/panicking_macros.rs:41:5 + | +LL | todo!(); + | ^^^^^^^^ + +error: `unimplemented` should not be present in production code + --> $DIR/panicking_macros.rs:42:5 + | +LL | unimplemented!(); + | ^^^^^^^^^^^^^^^^^ + +error: `unreachable` should not be present in production code + --> $DIR/panicking_macros.rs:43:5 + | +LL | unreachable!(); + | ^^^^^^^^^^^^^^^ + +error: aborting due to 16 previous errors From bdaa76cfde64d06bb93c1f9102a0312d84cd0983 Mon Sep 17 00:00:00 2001 From: William Chargin Date: Tue, 17 Nov 2020 15:29:49 -0800 Subject: [PATCH 13/15] Fix typo in `std::io::Write` docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These referred to a “`Write`er”—extra *e*. Presumably a copy-paste holdover from “`Read`er”. Test Plan: Running ``git grep '`\?[Ww]rite`\?er'`` no longer finds any results. wchargin-branch: io-write-docs --- library/std/src/io/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 703c3755b6383..dfbf6c3f24443 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -1307,10 +1307,10 @@ pub trait Write { default_write_vectored(|b| self.write(b), bufs) } - /// Determines if this `Write`er has an efficient [`write_vectored`] + /// Determines if this `Write`r has an efficient [`write_vectored`] /// implementation. /// - /// If a `Write`er does not override the default [`write_vectored`] + /// If a `Write`r does not override the default [`write_vectored`] /// implementation, code using it may want to avoid the method all together /// and coalesce writes into a single buffer for higher performance. /// From 7edc4f23b20e3b6ce11795f0e9b7941a7162c3eb Mon Sep 17 00:00:00 2001 From: bstrie Date: Sat, 24 Oct 2020 19:21:40 -0400 Subject: [PATCH 14/15] Update tests to remove old numeric constants Part of #68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed. --- library/core/src/intrinsics.rs | 68 ++++++------- library/core/tests/num/nan.rs | 1 - src/test/codegen/enum-discriminant-value.rs | 8 +- src/test/codegen/issue-56927.rs | 1 - src/test/compile-fail/consts/issue-55878.rs | 2 +- src/test/rustdoc/reexport-check.rs | 1 + src/test/rustdoc/show-const-contents.rs | 1 + .../bounds-check-no-overflow.rs | 1 - ...20-assoc-const-arith-overflow.noopt.stderr | 16 ++-- ...9020-assoc-const-arith-overflow.opt.stderr | 16 ++-- ...h-overflow.opt_with_overflow_checks.stderr | 16 ++-- .../issue-69020-assoc-const-arith-overflow.rs | 2 - src/test/ui/big-literals.rs | 8 +- .../const_evaluatable_checked/fn_call.rs | 2 +- ...ue-72819-generic-in-const-eval.full.stderr | 6 +- ...sue-72819-generic-in-const-eval.min.stderr | 2 +- .../issue-72819-generic-in-const-eval.rs | 4 +- .../ui/const-generics/issues/issue-73260.rs | 4 +- .../const-generics/issues/issue-73260.stderr | 16 ++-- src/test/ui/consts/const-err-early.rs | 2 +- src/test/ui/consts/const-err-early.stderr | 4 +- src/test/ui/consts/const-err-multi.rs | 2 +- src/test/ui/consts/const-err-multi.stderr | 4 +- src/test/ui/consts/const-err2.noopt.stderr | 12 +-- src/test/ui/consts/const-err2.opt.stderr | 12 +-- ...const-err2.opt_with_overflow_checks.stderr | 12 +-- src/test/ui/consts/const-err2.rs | 6 +- .../const-eval/const-eval-overflow-3.rs | 2 - .../const-eval/const-eval-overflow-3.stderr | 2 +- .../const-eval/const-eval-overflow-3b.rs | 2 - .../const-eval/const-eval-overflow-3b.stderr | 4 +- .../const-eval/const-eval-overflow-4.rs | 2 - .../const-eval/const-eval-overflow-4.stderr | 2 +- .../const-eval/const-eval-overflow-4b.rs | 3 - .../const-eval/const-eval-overflow-4b.stderr | 6 +- .../consts/const-eval/const-eval-overflow2.rs | 2 - .../const-eval/const-eval-overflow2.stderr | 16 ++-- .../const-eval/const-eval-overflow2b.rs | 2 - .../const-eval/const-eval-overflow2b.stderr | 16 ++-- .../const-eval/const-eval-overflow2c.rs | 2 - .../const-eval/const-eval-overflow2c.stderr | 16 ++-- src/test/ui/consts/const-eval/dangling.rs | 2 +- src/test/ui/consts/const-int-arithmetic.rs | 2 - .../ui/consts/const-int-overflowing-rpass.rs | 2 +- src/test/ui/consts/const-negation.rs | 10 +- src/test/ui/consts/issue-63952.rs | 2 - src/test/ui/consts/issue-63952.stderr | 2 +- src/test/ui/consts/promote_fn_calls_std.rs | 1 + src/test/ui/consts/promotion.rs | 2 +- src/test/ui/discrim/discrim-ill-typed.rs | 2 - src/test/ui/discrim/discrim-ill-typed.stderr | 16 ++-- src/test/ui/discrim/discrim-overflow-2.rs | 2 - src/test/ui/discrim/discrim-overflow-2.stderr | 16 ++-- src/test/ui/discrim/discrim-overflow.rs | 2 - src/test/ui/discrim/discrim-overflow.stderr | 16 ++-- src/test/ui/drop/dynamic-drop-async.rs | 1 - src/test/ui/drop/dynamic-drop.rs | 1 - ...ture-gate-precise_pointer_size_matching.rs | 4 +- ...-gate-precise_pointer_size_matching.stderr | 4 +- .../half-open-range-pats-exhaustive-fail.rs | 64 ++++++------- ...alf-open-range-pats-exhaustive-fail.stderr | 24 ++--- .../half-open-range-pats-exhaustive-pass.rs | 20 ++-- .../half-open-range-pats-semantics.rs | 82 ++++++++-------- .../half-open-range-pats-thir-lower-empty.rs | 24 ++--- ...lf-open-range-pats-thir-lower-empty.stderr | 96 +++++++++---------- .../ui/hashmap/hashmap-capacity-overflow.rs | 1 - src/test/ui/issues/issue-20427.rs | 1 + src/test/ui/issues/issue-23833.rs | 2 - src/test/ui/issues/issue-37686.rs | 2 +- src/test/ui/issues/issue-41880.rs | 2 +- src/test/ui/issues/issue-48006.rs | 4 +- src/test/ui/issues/issue-50811.rs | 9 +- .../ui/issues/issue-68010-large-zst-consts.rs | 2 +- src/test/ui/issues/issue-6804.rs | 2 +- .../ui/issues/issue-8460-const.noopt.stderr | 48 +++++----- .../ui/issues/issue-8460-const.opt.stderr | 48 +++++----- ...8460-const.opt_with_overflow_checks.stderr | 48 +++++----- src/test/ui/issues/issue-8460-const.rs | 1 - .../ui/iterators/iter-count-overflow-debug.rs | 5 +- .../iterators/iter-count-overflow-ndebug.rs | 5 +- .../iterators/iter-position-overflow-debug.rs | 5 +- .../iter-position-overflow-ndebug.rs | 5 +- src/test/ui/macros/macro-first-set.rs | 2 +- ...type-move-out-of-closure-env-issue-1965.rs | 2 - ...-move-out-of-closure-env-issue-1965.stderr | 2 +- .../float-int-invalid-const-cast.rs | 2 - src/test/ui/numbers-arithmetic/float-nan.rs | 1 - .../ui/numbers-arithmetic/num-wrapping.rs | 3 +- .../ui/numbers-arithmetic/overflowing-neg.rs | 2 +- .../saturating-float-casts-impl.rs | 4 - .../ui/numbers-arithmetic/shift-near-oflo.rs | 20 ++-- src/test/ui/numbers-arithmetic/u128-as-f32.rs | 2 - .../usefulness/exhaustive_integer_patterns.rs | 2 +- ...non-exhaustive-pattern-pointer-size-int.rs | 2 - ...exhaustive-pattern-pointer-size-int.stderr | 6 +- src/test/ui/precise_pointer_size_matching.rs | 2 - .../ui/precise_pointer_size_matching.stderr | 4 +- .../ui/regions/regions-addr-of-upvar-self.rs | 2 - .../regions/regions-addr-of-upvar-self.stderr | 10 +- .../match-forbidden-without-eq.rs | 2 - .../match-forbidden-without-eq.stderr | 6 +- .../ui/simd/simd-intrinsic-float-minmax.rs | 4 +- .../simd/simd-intrinsic-generic-comparison.rs | 4 +- src/test/ui/sleep.rs | 1 - .../structs-enums/discrim-explicit-23030.rs | 2 - src/test/ui/symbol-names/const-generics.rs | 12 +-- src/test/ui/union/union-transmute.rs | 3 - src/test/ui/use-module-level-int-consts.rs | 1 + src/test/ui/wrapping-int-api.rs | 3 - src/tools/clippy/tests/ui/float_cmp_const.rs | 2 +- 110 files changed, 467 insertions(+), 534 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 433f0129306bd..d389781bb9daa 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1173,133 +1173,133 @@ extern "rust-intrinsic" { /// Returns the square root of an `f32` /// /// The stabilized version of this intrinsic is - /// [`std::f32::sqrt`](../../std/primitive.f32.html#method.sqrt) + /// [`f32::sqrt`](../../std/primitive.f32.html#method.sqrt) pub fn sqrtf32(x: f32) -> f32; /// Returns the square root of an `f64` /// /// The stabilized version of this intrinsic is - /// [`std::f64::sqrt`](../../std/primitive.f64.html#method.sqrt) + /// [`f64::sqrt`](../../std/primitive.f64.html#method.sqrt) pub fn sqrtf64(x: f64) -> f64; /// Raises an `f32` to an integer power. /// /// The stabilized version of this intrinsic is - /// [`std::f32::powi`](../../std/primitive.f32.html#method.powi) + /// [`f32::powi`](../../std/primitive.f32.html#method.powi) pub fn powif32(a: f32, x: i32) -> f32; /// Raises an `f64` to an integer power. /// /// The stabilized version of this intrinsic is - /// [`std::f64::powi`](../../std/primitive.f64.html#method.powi) + /// [`f64::powi`](../../std/primitive.f64.html#method.powi) pub fn powif64(a: f64, x: i32) -> f64; /// Returns the sine of an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::sin`](../../std/primitive.f32.html#method.sin) + /// [`f32::sin`](../../std/primitive.f32.html#method.sin) pub fn sinf32(x: f32) -> f32; /// Returns the sine of an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::sin`](../../std/primitive.f64.html#method.sin) + /// [`f64::sin`](../../std/primitive.f64.html#method.sin) pub fn sinf64(x: f64) -> f64; /// Returns the cosine of an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::cos`](../../std/primitive.f32.html#method.cos) + /// [`f32::cos`](../../std/primitive.f32.html#method.cos) pub fn cosf32(x: f32) -> f32; /// Returns the cosine of an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::cos`](../../std/primitive.f64.html#method.cos) + /// [`f64::cos`](../../std/primitive.f64.html#method.cos) pub fn cosf64(x: f64) -> f64; /// Raises an `f32` to an `f32` power. /// /// The stabilized version of this intrinsic is - /// [`std::f32::powf`](../../std/primitive.f32.html#method.powf) + /// [`f32::powf`](../../std/primitive.f32.html#method.powf) pub fn powf32(a: f32, x: f32) -> f32; /// Raises an `f64` to an `f64` power. /// /// The stabilized version of this intrinsic is - /// [`std::f64::powf`](../../std/primitive.f64.html#method.powf) + /// [`f64::powf`](../../std/primitive.f64.html#method.powf) pub fn powf64(a: f64, x: f64) -> f64; /// Returns the exponential of an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::exp`](../../std/primitive.f32.html#method.exp) + /// [`f32::exp`](../../std/primitive.f32.html#method.exp) pub fn expf32(x: f32) -> f32; /// Returns the exponential of an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::exp`](../../std/primitive.f64.html#method.exp) + /// [`f64::exp`](../../std/primitive.f64.html#method.exp) pub fn expf64(x: f64) -> f64; /// Returns 2 raised to the power of an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::exp2`](../../std/primitive.f32.html#method.exp2) + /// [`f32::exp2`](../../std/primitive.f32.html#method.exp2) pub fn exp2f32(x: f32) -> f32; /// Returns 2 raised to the power of an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::exp2`](../../std/primitive.f64.html#method.exp2) + /// [`f64::exp2`](../../std/primitive.f64.html#method.exp2) pub fn exp2f64(x: f64) -> f64; /// Returns the natural logarithm of an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::ln`](../../std/primitive.f32.html#method.ln) + /// [`f32::ln`](../../std/primitive.f32.html#method.ln) pub fn logf32(x: f32) -> f32; /// Returns the natural logarithm of an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::ln`](../../std/primitive.f64.html#method.ln) + /// [`f64::ln`](../../std/primitive.f64.html#method.ln) pub fn logf64(x: f64) -> f64; /// Returns the base 10 logarithm of an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::log10`](../../std/primitive.f32.html#method.log10) + /// [`f32::log10`](../../std/primitive.f32.html#method.log10) pub fn log10f32(x: f32) -> f32; /// Returns the base 10 logarithm of an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::log10`](../../std/primitive.f64.html#method.log10) + /// [`f64::log10`](../../std/primitive.f64.html#method.log10) pub fn log10f64(x: f64) -> f64; /// Returns the base 2 logarithm of an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::log2`](../../std/primitive.f32.html#method.log2) + /// [`f32::log2`](../../std/primitive.f32.html#method.log2) pub fn log2f32(x: f32) -> f32; /// Returns the base 2 logarithm of an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::log2`](../../std/primitive.f64.html#method.log2) + /// [`f64::log2`](../../std/primitive.f64.html#method.log2) pub fn log2f64(x: f64) -> f64; /// Returns `a * b + c` for `f32` values. /// /// The stabilized version of this intrinsic is - /// [`std::f32::mul_add`](../../std/primitive.f32.html#method.mul_add) + /// [`f32::mul_add`](../../std/primitive.f32.html#method.mul_add) pub fn fmaf32(a: f32, b: f32, c: f32) -> f32; /// Returns `a * b + c` for `f64` values. /// /// The stabilized version of this intrinsic is - /// [`std::f64::mul_add`](../../std/primitive.f64.html#method.mul_add) + /// [`f64::mul_add`](../../std/primitive.f64.html#method.mul_add) pub fn fmaf64(a: f64, b: f64, c: f64) -> f64; /// Returns the absolute value of an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::abs`](../../std/primitive.f32.html#method.abs) + /// [`f32::abs`](../../std/primitive.f32.html#method.abs) pub fn fabsf32(x: f32) -> f32; /// Returns the absolute value of an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::abs`](../../std/primitive.f64.html#method.abs) + /// [`f64::abs`](../../std/primitive.f64.html#method.abs) pub fn fabsf64(x: f64) -> f64; /// Returns the minimum of two `f32` values. @@ -1326,45 +1326,45 @@ extern "rust-intrinsic" { /// Copies the sign from `y` to `x` for `f32` values. /// /// The stabilized version of this intrinsic is - /// [`std::f32::copysign`](../../std/primitive.f32.html#method.copysign) + /// [`f32::copysign`](../../std/primitive.f32.html#method.copysign) pub fn copysignf32(x: f32, y: f32) -> f32; /// Copies the sign from `y` to `x` for `f64` values. /// /// The stabilized version of this intrinsic is - /// [`std::f64::copysign`](../../std/primitive.f64.html#method.copysign) + /// [`f64::copysign`](../../std/primitive.f64.html#method.copysign) pub fn copysignf64(x: f64, y: f64) -> f64; /// Returns the largest integer less than or equal to an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::floor`](../../std/primitive.f32.html#method.floor) + /// [`f32::floor`](../../std/primitive.f32.html#method.floor) pub fn floorf32(x: f32) -> f32; /// Returns the largest integer less than or equal to an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::floor`](../../std/primitive.f64.html#method.floor) + /// [`f64::floor`](../../std/primitive.f64.html#method.floor) pub fn floorf64(x: f64) -> f64; /// Returns the smallest integer greater than or equal to an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::ceil`](../../std/primitive.f32.html#method.ceil) + /// [`f32::ceil`](../../std/primitive.f32.html#method.ceil) pub fn ceilf32(x: f32) -> f32; /// Returns the smallest integer greater than or equal to an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::ceil`](../../std/primitive.f64.html#method.ceil) + /// [`f64::ceil`](../../std/primitive.f64.html#method.ceil) pub fn ceilf64(x: f64) -> f64; /// Returns the integer part of an `f32`. /// /// The stabilized version of this intrinsic is - /// [`std::f32::trunc`](../../std/primitive.f32.html#method.trunc) + /// [`f32::trunc`](../../std/primitive.f32.html#method.trunc) pub fn truncf32(x: f32) -> f32; /// Returns the integer part of an `f64`. /// /// The stabilized version of this intrinsic is - /// [`std::f64::trunc`](../../std/primitive.f64.html#method.trunc) + /// [`f64::trunc`](../../std/primitive.f64.html#method.trunc) pub fn truncf64(x: f64) -> f64; /// Returns the nearest integer to an `f32`. May raise an inexact floating-point exception @@ -1386,12 +1386,12 @@ extern "rust-intrinsic" { /// Returns the nearest integer to an `f32`. Rounds half-way cases away from zero. /// /// The stabilized version of this intrinsic is - /// [`std::f32::round`](../../std/primitive.f32.html#method.round) + /// [`f32::round`](../../std/primitive.f32.html#method.round) pub fn roundf32(x: f32) -> f32; /// Returns the nearest integer to an `f64`. Rounds half-way cases away from zero. /// /// The stabilized version of this intrinsic is - /// [`std::f64::round`](../../std/primitive.f64.html#method.round) + /// [`f64::round`](../../std/primitive.f64.html#method.round) pub fn roundf64(x: f64) -> f64; /// Float addition that allows optimizations based on algebraic rules. diff --git a/library/core/tests/num/nan.rs b/library/core/tests/num/nan.rs index 011ffa790beee..ef81988c9612f 100644 --- a/library/core/tests/num/nan.rs +++ b/library/core/tests/num/nan.rs @@ -1,6 +1,5 @@ #[test] fn test_nan() { - use core::f64; let x = "NaN".to_string(); assert_eq!(format!("{}", f64::NAN), x); assert_eq!(format!("{:e}", f64::NAN), x); diff --git a/src/test/codegen/enum-discriminant-value.rs b/src/test/codegen/enum-discriminant-value.rs index f9da987765f9c..cc14c21200253 100644 --- a/src/test/codegen/enum-discriminant-value.rs +++ b/src/test/codegen/enum-discriminant-value.rs @@ -4,14 +4,14 @@ #[repr(i64)] pub enum I64 { - I64Min = std::i64::MIN, - I64Max = std::i64::MAX, + I64Min = i64::MIN, + I64Max = i64::MAX, } #[repr(u64)] pub enum U64 { - U64Min = std::u64::MIN, - U64Max = std::u64::MAX, + U64Min = u64::MIN, + U64Max = u64::MAX, } fn main() { diff --git a/src/test/codegen/issue-56927.rs b/src/test/codegen/issue-56927.rs index d502673e2f880..2c84015d5e29a 100644 --- a/src/test/codegen/issue-56927.rs +++ b/src/test/codegen/issue-56927.rs @@ -1,7 +1,6 @@ // compile-flags: -C no-prepopulate-passes #![crate_type="rlib"] -use std::usize; #[repr(align(16))] pub struct S { diff --git a/src/test/compile-fail/consts/issue-55878.rs b/src/test/compile-fail/consts/issue-55878.rs index aa1dd58d2463d..9669cb8110d75 100644 --- a/src/test/compile-fail/consts/issue-55878.rs +++ b/src/test/compile-fail/consts/issue-55878.rs @@ -3,5 +3,5 @@ // error-pattern: is too big for the current architecture fn main() { - println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>()); + println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); } diff --git a/src/test/rustdoc/reexport-check.rs b/src/test/rustdoc/reexport-check.rs index 066b0cfe5e80e..841702987ef7c 100644 --- a/src/test/rustdoc/reexport-check.rs +++ b/src/test/rustdoc/reexport-check.rs @@ -6,6 +6,7 @@ extern crate reexport_check; // @!has 'foo/index.html' '//code' 'pub use self::i32;' // @has 'foo/index.html' '//tr[@class="module-item"]' 'i32' // @has 'foo/i32/index.html' +#[allow(deprecated, deprecated_in_future)] pub use std::i32; // @!has 'foo/index.html' '//code' 'pub use self::string::String;' // @has 'foo/index.html' '//tr[@class="module-item"]' 'String' diff --git a/src/test/rustdoc/show-const-contents.rs b/src/test/rustdoc/show-const-contents.rs index 814339e198f95..f5a356bcae6ac 100644 --- a/src/test/rustdoc/show-const-contents.rs +++ b/src/test/rustdoc/show-const-contents.rs @@ -52,6 +52,7 @@ pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); pub use std::f32::consts::PI; // @has show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' +#[allow(deprecated, deprecated_in_future)] pub use std::i32::MAX; macro_rules! int_module { diff --git a/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs b/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs index 3caf5f4499522..577853a4e9111 100644 --- a/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs +++ b/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs @@ -2,7 +2,6 @@ // error-pattern:index out of bounds // ignore-emscripten no processes -use std::usize; use std::mem::size_of; fn main() { diff --git a/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.noopt.stderr b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.noopt.stderr index f59287bce736b..0c35819007b7f 100644 --- a/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.noopt.stderr +++ b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.noopt.stderr @@ -1,5 +1,5 @@ error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:29:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:27:22 | LL | const NEG: i32 = -i32::MIN + T::NEG; | ^^^^^^^^^ attempt to negate `i32::MIN`, which would overflow @@ -7,25 +7,25 @@ LL | const NEG: i32 = -i32::MIN + T::NEG; = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:31:35 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:29:35 | LL | const NEG_REV: i32 = T::NEG + (-i32::MIN); | ^^^^^^^^^^^ attempt to negate `i32::MIN`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:34:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:32:22 | LL | const ADD: i32 = (i32::MAX+1) + T::ADD; | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:36:36 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:34:36 | LL | const ADD_REV: i32 = T::ADD + (i32::MAX+1); | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:39:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:37:22 | LL | const DIV: i32 = (1/0) + T::DIV; | ^^^^^ attempt to divide `1_i32` by zero @@ -33,19 +33,19 @@ LL | const DIV: i32 = (1/0) + T::DIV; = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:41:35 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:39:35 | LL | const DIV_REV: i32 = T::DIV + (1/0); | ^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:44:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:42:22 | LL | const OOB: i32 = [1][1] + T::OOB; | ^^^^^^ index out of bounds: the length is 1 but the index is 1 error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:46:35 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:44:35 | LL | const OOB_REV: i32 = T::OOB + [1][1]; | ^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt.stderr b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt.stderr index f59287bce736b..0c35819007b7f 100644 --- a/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt.stderr +++ b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt.stderr @@ -1,5 +1,5 @@ error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:29:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:27:22 | LL | const NEG: i32 = -i32::MIN + T::NEG; | ^^^^^^^^^ attempt to negate `i32::MIN`, which would overflow @@ -7,25 +7,25 @@ LL | const NEG: i32 = -i32::MIN + T::NEG; = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:31:35 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:29:35 | LL | const NEG_REV: i32 = T::NEG + (-i32::MIN); | ^^^^^^^^^^^ attempt to negate `i32::MIN`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:34:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:32:22 | LL | const ADD: i32 = (i32::MAX+1) + T::ADD; | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:36:36 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:34:36 | LL | const ADD_REV: i32 = T::ADD + (i32::MAX+1); | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:39:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:37:22 | LL | const DIV: i32 = (1/0) + T::DIV; | ^^^^^ attempt to divide `1_i32` by zero @@ -33,19 +33,19 @@ LL | const DIV: i32 = (1/0) + T::DIV; = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:41:35 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:39:35 | LL | const DIV_REV: i32 = T::DIV + (1/0); | ^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:44:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:42:22 | LL | const OOB: i32 = [1][1] + T::OOB; | ^^^^^^ index out of bounds: the length is 1 but the index is 1 error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:46:35 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:44:35 | LL | const OOB_REV: i32 = T::OOB + [1][1]; | ^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt_with_overflow_checks.stderr b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt_with_overflow_checks.stderr index f59287bce736b..0c35819007b7f 100644 --- a/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt_with_overflow_checks.stderr +++ b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt_with_overflow_checks.stderr @@ -1,5 +1,5 @@ error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:29:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:27:22 | LL | const NEG: i32 = -i32::MIN + T::NEG; | ^^^^^^^^^ attempt to negate `i32::MIN`, which would overflow @@ -7,25 +7,25 @@ LL | const NEG: i32 = -i32::MIN + T::NEG; = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:31:35 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:29:35 | LL | const NEG_REV: i32 = T::NEG + (-i32::MIN); | ^^^^^^^^^^^ attempt to negate `i32::MIN`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:34:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:32:22 | LL | const ADD: i32 = (i32::MAX+1) + T::ADD; | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:36:36 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:34:36 | LL | const ADD_REV: i32 = T::ADD + (i32::MAX+1); | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:39:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:37:22 | LL | const DIV: i32 = (1/0) + T::DIV; | ^^^^^ attempt to divide `1_i32` by zero @@ -33,19 +33,19 @@ LL | const DIV: i32 = (1/0) + T::DIV; = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:41:35 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:39:35 | LL | const DIV_REV: i32 = T::DIV + (1/0); | ^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:44:22 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:42:22 | LL | const OOB: i32 = [1][1] + T::OOB; | ^^^^^^ index out of bounds: the length is 1 but the index is 1 error: this operation will panic at runtime - --> $DIR/issue-69020-assoc-const-arith-overflow.rs:46:35 + --> $DIR/issue-69020-assoc-const-arith-overflow.rs:44:35 | LL | const OOB_REV: i32 = T::OOB + [1][1]; | ^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.rs b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.rs index 850f65ae9d183..d4af6e8641440 100644 --- a/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.rs +++ b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.rs @@ -5,8 +5,6 @@ #![crate_type="lib"] -use std::i32; - pub trait Foo { const NEG: i32; const NEG_REV: i32; diff --git a/src/test/ui/big-literals.rs b/src/test/ui/big-literals.rs index 131de5439b7d4..96ea115c877f0 100644 --- a/src/test/ui/big-literals.rs +++ b/src/test/ui/big-literals.rs @@ -10,8 +10,8 @@ pub fn main() { assert_eq!((-2147483648i32).wrapping_sub(1), 2147483647); - assert_eq!(-3.40282356e+38_f32, ::std::f32::MIN); - assert_eq!(3.40282356e+38_f32, ::std::f32::MAX); - assert_eq!(-1.7976931348623158e+308_f64, ::std::f64::MIN); - assert_eq!(1.7976931348623158e+308_f64, ::std::f64::MAX); + assert_eq!(-3.40282356e+38_f32, f32::MIN); + assert_eq!(3.40282356e+38_f32, f32::MAX); + assert_eq!(-1.7976931348623158e+308_f64, f64::MIN); + assert_eq!(1.7976931348623158e+308_f64, f64::MAX); } diff --git a/src/test/ui/const-generics/const_evaluatable_checked/fn_call.rs b/src/test/ui/const-generics/const_evaluatable_checked/fn_call.rs index 1b9ec0108b1e7..c182f5ef81b7d 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/fn_call.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/fn_call.rs @@ -6,7 +6,7 @@ const fn test_me(a: usize, b: usize) -> usize { if a < b { std::mem::size_of::() } else { - std::usize::MAX + usize::MAX } } diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr index e4105a3df1c88..b499400472153 100644 --- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr +++ b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr @@ -1,8 +1,8 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-72819-generic-in-const-eval.rs:9:47 + --> $DIR/issue-72819-generic-in-const-eval.rs:9:39 | -LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue, - | ^^^^^^ +LL | where Assert::<{N < usize::MAX / 2}>: IsTrue, + | ^^^^^^ | = note: this may fail depending on what value the parameter takes diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr index 9fec3eb946d83..08b1b01b65717 100644 --- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr +++ b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr @@ -1,7 +1,7 @@ error: generic parameters may not be used in const operations --> $DIR/issue-72819-generic-in-const-eval.rs:9:17 | -LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue, +LL | where Assert::<{N < usize::MAX / 2}>: IsTrue, | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs index 6182042bde781..4c0004795f0dc 100644 --- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs +++ b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs @@ -6,7 +6,7 @@ #![cfg_attr(min, feature(min_const_generics))] struct Arr -where Assert::<{N < usize::max_value() / 2}>: IsTrue, +where Assert::<{N < usize::MAX / 2}>: IsTrue, //[full]~^ ERROR constant expression depends on a generic parameter //[min]~^^ ERROR generic parameters may not be used in const operations { @@ -19,5 +19,5 @@ trait IsTrue {} impl IsTrue for Assert {} fn main() { - let x: Arr<{usize::max_value()}> = Arr {}; + let x: Arr<{usize::MAX}> = Arr {}; } diff --git a/src/test/ui/const-generics/issues/issue-73260.rs b/src/test/ui/const-generics/issues/issue-73260.rs index 351d6849af5db..04e4e9cd52b00 100644 --- a/src/test/ui/const-generics/issues/issue-73260.rs +++ b/src/test/ui/const-generics/issues/issue-73260.rs @@ -3,7 +3,7 @@ #![feature(const_generics)] #![allow(incomplete_features)] struct Arr -where Assert::<{N < usize::max_value() / 2}>: IsTrue, //~ ERROR constant expression +where Assert::<{N < usize::MAX / 2}>: IsTrue, //~ ERROR constant expression { } @@ -14,7 +14,7 @@ trait IsTrue {} impl IsTrue for Assert {} fn main() { - let x: Arr<{usize::max_value()}> = Arr {}; + let x: Arr<{usize::MAX}> = Arr {}; //~^ ERROR mismatched types //~| ERROR mismatched types } diff --git a/src/test/ui/const-generics/issues/issue-73260.stderr b/src/test/ui/const-generics/issues/issue-73260.stderr index e22612ed5ea63..6a912ffc3c01b 100644 --- a/src/test/ui/const-generics/issues/issue-73260.stderr +++ b/src/test/ui/const-generics/issues/issue-73260.stderr @@ -1,25 +1,25 @@ error: constant expression depends on a generic parameter - --> $DIR/issue-73260.rs:6:47 + --> $DIR/issue-73260.rs:6:39 | -LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue, - | ^^^^^^ +LL | where Assert::<{N < usize::MAX / 2}>: IsTrue, + | ^^^^^^ | = note: this may fail depending on what value the parameter takes error[E0308]: mismatched types --> $DIR/issue-73260.rs:17:12 | -LL | let x: Arr<{usize::max_value()}> = Arr {}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `false`, found `true` +LL | let x: Arr<{usize::MAX}> = Arr {}; + | ^^^^^^^^^^^^^^^^^ expected `false`, found `true` | = note: expected type `false` found type `true` error[E0308]: mismatched types - --> $DIR/issue-73260.rs:17:40 + --> $DIR/issue-73260.rs:17:32 | -LL | let x: Arr<{usize::max_value()}> = Arr {}; - | ^^^ expected `false`, found `true` +LL | let x: Arr<{usize::MAX}> = Arr {}; + | ^^^ expected `false`, found `true` | = note: expected type `false` found type `true` diff --git a/src/test/ui/consts/const-err-early.rs b/src/test/ui/consts/const-err-early.rs index bae2cd286e1c9..13dfe7fac9900 100644 --- a/src/test/ui/consts/const-err-early.rs +++ b/src/test/ui/consts/const-err-early.rs @@ -1,6 +1,6 @@ #![deny(const_err)] -pub const A: i8 = -std::i8::MIN; //~ ERROR const_err +pub const A: i8 = -i8::MIN; //~ ERROR const_err pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err pub const C: u8 = 200u8 * 4; //~ ERROR const_err pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err diff --git a/src/test/ui/consts/const-err-early.stderr b/src/test/ui/consts/const-err-early.stderr index 36b36db7c18bc..ec55139f17345 100644 --- a/src/test/ui/consts/const-err-early.stderr +++ b/src/test/ui/consts/const-err-early.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error --> $DIR/const-err-early.rs:3:19 | -LL | pub const A: i8 = -std::i8::MIN; - | ------------------^^^^^^^^^^^^^- +LL | pub const A: i8 = -i8::MIN; + | ------------------^^^^^^^^- | | | attempt to negate `i8::MIN`, which would overflow | diff --git a/src/test/ui/consts/const-err-multi.rs b/src/test/ui/consts/const-err-multi.rs index fa3ad832c60e2..ce74fae98162d 100644 --- a/src/test/ui/consts/const-err-multi.rs +++ b/src/test/ui/consts/const-err-multi.rs @@ -1,6 +1,6 @@ #![deny(const_err)] -pub const A: i8 = -std::i8::MIN; +pub const A: i8 = -i8::MIN; //~^ ERROR const_err pub const B: i8 = A; //~^ ERROR const_err diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr index 5b688d4c6d84c..b3123b4e35928 100644 --- a/src/test/ui/consts/const-err-multi.stderr +++ b/src/test/ui/consts/const-err-multi.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error --> $DIR/const-err-multi.rs:3:19 | -LL | pub const A: i8 = -std::i8::MIN; - | ------------------^^^^^^^^^^^^^- +LL | pub const A: i8 = -i8::MIN; + | ------------------^^^^^^^^- | | | attempt to negate `i8::MIN`, which would overflow | diff --git a/src/test/ui/consts/const-err2.noopt.stderr b/src/test/ui/consts/const-err2.noopt.stderr index 2473632cbc804..8b1688c4a8989 100644 --- a/src/test/ui/consts/const-err2.noopt.stderr +++ b/src/test/ui/consts/const-err2.noopt.stderr @@ -1,16 +1,16 @@ error: this arithmetic operation will overflow --> $DIR/const-err2.rs:19:13 | -LL | let a = -std::i8::MIN; - | ^^^^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow +LL | let a = -i8::MIN; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow | = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow --> $DIR/const-err2.rs:21:18 | -LL | let a_i128 = -std::i128::MIN; - | ^^^^^^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow +LL | let a_i128 = -i128::MIN; + | ^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow error: this arithmetic operation will overflow --> $DIR/const-err2.rs:23:13 @@ -21,8 +21,8 @@ LL | let b = 200u8 + 200u8 + 200u8; error: this arithmetic operation will overflow --> $DIR/const-err2.rs:25:18 | -LL | let b_i128 = std::i128::MIN - std::i128::MAX; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow +LL | let b_i128 = i128::MIN - i128::MAX; + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow error: this arithmetic operation will overflow --> $DIR/const-err2.rs:27:13 diff --git a/src/test/ui/consts/const-err2.opt.stderr b/src/test/ui/consts/const-err2.opt.stderr index 2473632cbc804..8b1688c4a8989 100644 --- a/src/test/ui/consts/const-err2.opt.stderr +++ b/src/test/ui/consts/const-err2.opt.stderr @@ -1,16 +1,16 @@ error: this arithmetic operation will overflow --> $DIR/const-err2.rs:19:13 | -LL | let a = -std::i8::MIN; - | ^^^^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow +LL | let a = -i8::MIN; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow | = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow --> $DIR/const-err2.rs:21:18 | -LL | let a_i128 = -std::i128::MIN; - | ^^^^^^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow +LL | let a_i128 = -i128::MIN; + | ^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow error: this arithmetic operation will overflow --> $DIR/const-err2.rs:23:13 @@ -21,8 +21,8 @@ LL | let b = 200u8 + 200u8 + 200u8; error: this arithmetic operation will overflow --> $DIR/const-err2.rs:25:18 | -LL | let b_i128 = std::i128::MIN - std::i128::MAX; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow +LL | let b_i128 = i128::MIN - i128::MAX; + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow error: this arithmetic operation will overflow --> $DIR/const-err2.rs:27:13 diff --git a/src/test/ui/consts/const-err2.opt_with_overflow_checks.stderr b/src/test/ui/consts/const-err2.opt_with_overflow_checks.stderr index 2473632cbc804..8b1688c4a8989 100644 --- a/src/test/ui/consts/const-err2.opt_with_overflow_checks.stderr +++ b/src/test/ui/consts/const-err2.opt_with_overflow_checks.stderr @@ -1,16 +1,16 @@ error: this arithmetic operation will overflow --> $DIR/const-err2.rs:19:13 | -LL | let a = -std::i8::MIN; - | ^^^^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow +LL | let a = -i8::MIN; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow | = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow --> $DIR/const-err2.rs:21:18 | -LL | let a_i128 = -std::i128::MIN; - | ^^^^^^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow +LL | let a_i128 = -i128::MIN; + | ^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow error: this arithmetic operation will overflow --> $DIR/const-err2.rs:23:13 @@ -21,8 +21,8 @@ LL | let b = 200u8 + 200u8 + 200u8; error: this arithmetic operation will overflow --> $DIR/const-err2.rs:25:18 | -LL | let b_i128 = std::i128::MIN - std::i128::MAX; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow +LL | let b_i128 = i128::MIN - i128::MAX; + | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow error: this arithmetic operation will overflow --> $DIR/const-err2.rs:27:13 diff --git a/src/test/ui/consts/const-err2.rs b/src/test/ui/consts/const-err2.rs index 2c6a987180bb1..db49ec25aaaeb 100644 --- a/src/test/ui/consts/const-err2.rs +++ b/src/test/ui/consts/const-err2.rs @@ -16,13 +16,13 @@ fn black_box(_: T) { } fn main() { - let a = -std::i8::MIN; + let a = -i8::MIN; //~^ ERROR arithmetic operation will overflow - let a_i128 = -std::i128::MIN; + let a_i128 = -i128::MIN; //~^ ERROR arithmetic operation will overflow let b = 200u8 + 200u8 + 200u8; //~^ ERROR arithmetic operation will overflow - let b_i128 = std::i128::MIN - std::i128::MAX; + let b_i128 = i128::MIN - i128::MAX; //~^ ERROR arithmetic operation will overflow let c = 200u8 * 4; //~^ ERROR arithmetic operation will overflow diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3.rs b/src/test/ui/consts/const-eval/const-eval-overflow-3.rs index 6fd8e9cbc806b..bcc966dc9621c 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3.rs @@ -12,8 +12,6 @@ #![allow(unused_imports)] use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; const A_I8_I : [u32; (i8::MAX as usize) + 1] diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3.stderr index 0ae51786b36a5..73f421b5b1465 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const-eval-overflow-3.rs:20:11 + --> $DIR/const-eval-overflow-3.rs:18:11 | LL | = [0; (i8::MAX + 1) as usize]; | ^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs b/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs index db6f17a671aea..480069e67fa28 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs @@ -10,8 +10,6 @@ #![allow(unused_imports)] use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; const A_I8_I : [u32; (i8::MAX as usize) + 1] diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr index 2696d5a0b32bb..2b96b66819286 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/const-eval-overflow-3b.rs:18:22 + --> $DIR/const-eval-overflow-3b.rs:16:22 | LL | = [0; (i8::MAX + 1u8) as usize]; | ^^^ expected `i8`, found `u8` error[E0277]: cannot add `u8` to `i8` - --> $DIR/const-eval-overflow-3b.rs:18:20 + --> $DIR/const-eval-overflow-3b.rs:16:20 | LL | = [0; (i8::MAX + 1u8) as usize]; | ^ no implementation for `i8 + u8` diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4.rs b/src/test/ui/consts/const-eval/const-eval-overflow-4.rs index 0b12a438f9662..762c7a968a8ff 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4.rs @@ -6,8 +6,6 @@ #![allow(unused_imports)] use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; const A_I8_T : [u32; (i8::MAX as i8 + 1i8) as usize] diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4.stderr index e548fc266c212..94f4193195c20 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const-eval-overflow-4.rs:13:13 + --> $DIR/const-eval-overflow-4.rs:11:13 | LL | : [u32; (i8::MAX as i8 + 1i8) as usize] | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.rs b/src/test/ui/consts/const-eval/const-eval-overflow-4b.rs index 2a4585faf1493..ce9c980de0dd2 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.rs @@ -5,9 +5,6 @@ #![allow(unused_imports)] -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; - const A_I8_T : [u32; (i8::MAX as i8 + 1u8) as usize] //~^ ERROR mismatched types diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr index e695e9f75feb5..1e181c465dba7 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/const-eval-overflow-4b.rs:12:30 + --> $DIR/const-eval-overflow-4b.rs:9:30 | LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^^^ expected `i8`, found `u8` error[E0277]: cannot add `u8` to `i8` - --> $DIR/const-eval-overflow-4b.rs:12:28 + --> $DIR/const-eval-overflow-4b.rs:9:28 | LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^ no implementation for `i8 + u8` @@ -13,7 +13,7 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] = help: the trait `Add` is not implemented for `i8` error[E0604]: only `u8` can be cast as `char`, not `i8` - --> $DIR/const-eval-overflow-4b.rs:25:13 + --> $DIR/const-eval-overflow-4b.rs:22:13 | LL | : [u32; 5i8 as char as usize] | ^^^^^^^^^^^ invalid cast diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.rs b/src/test/ui/consts/const-eval/const-eval-overflow2.rs index a0dbcc88cea8a..57a9dd55c8b55 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs @@ -8,8 +8,6 @@ #![deny(const_err)] use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; const VALS_I8: (i8,) = ( diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr index 51a810b8f3ba8..8864bc170f2ee 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,5 +1,5 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:16:6 + --> $DIR/const-eval-overflow2.rs:14:6 | LL | / const VALS_I8: (i8,) = LL | | ( @@ -15,7 +15,7 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:22:6 + --> $DIR/const-eval-overflow2.rs:20:6 | LL | / const VALS_I16: (i16,) = LL | | ( @@ -25,7 +25,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:28:6 + --> $DIR/const-eval-overflow2.rs:26:6 | LL | / const VALS_I32: (i32,) = LL | | ( @@ -35,7 +35,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:34:6 + --> $DIR/const-eval-overflow2.rs:32:6 | LL | / const VALS_I64: (i64,) = LL | | ( @@ -45,7 +45,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:40:6 + --> $DIR/const-eval-overflow2.rs:38:6 | LL | / const VALS_U8: (u8,) = LL | | ( @@ -55,7 +55,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:45:6 + --> $DIR/const-eval-overflow2.rs:43:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MIN - 1, @@ -64,7 +64,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:50:6 + --> $DIR/const-eval-overflow2.rs:48:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MIN - 1, @@ -73,7 +73,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:56:6 + --> $DIR/const-eval-overflow2.rs:54:6 | LL | / const VALS_U64: (u64,) = LL | | ( diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs index da883671a60a3..e87952ab0f438 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs @@ -8,8 +8,6 @@ #![deny(const_err)] use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; const VALS_I8: (i8,) = ( diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr index eec440fcb76a5..e66e80c8f1937 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,5 +1,5 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:16:6 + --> $DIR/const-eval-overflow2b.rs:14:6 | LL | / const VALS_I8: (i8,) = LL | | ( @@ -15,7 +15,7 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:22:6 + --> $DIR/const-eval-overflow2b.rs:20:6 | LL | / const VALS_I16: (i16,) = LL | | ( @@ -25,7 +25,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:28:6 + --> $DIR/const-eval-overflow2b.rs:26:6 | LL | / const VALS_I32: (i32,) = LL | | ( @@ -35,7 +35,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:34:6 + --> $DIR/const-eval-overflow2b.rs:32:6 | LL | / const VALS_I64: (i64,) = LL | | ( @@ -45,7 +45,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:40:6 + --> $DIR/const-eval-overflow2b.rs:38:6 | LL | / const VALS_U8: (u8,) = LL | | ( @@ -55,7 +55,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:45:6 + --> $DIR/const-eval-overflow2b.rs:43:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX + 1, @@ -64,7 +64,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:50:6 + --> $DIR/const-eval-overflow2b.rs:48:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX + 1, @@ -73,7 +73,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:56:6 + --> $DIR/const-eval-overflow2b.rs:54:6 | LL | / const VALS_U64: (u64,) = LL | | ( diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs index e87344405a103..84d3dd20a924e 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs @@ -8,8 +8,6 @@ #![deny(const_err)] use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; const VALS_I8: (i8,) = ( diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr index e44f94c202166..10e308938f3a1 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,5 +1,5 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:16:6 + --> $DIR/const-eval-overflow2c.rs:14:6 | LL | / const VALS_I8: (i8,) = LL | | ( @@ -15,7 +15,7 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:22:6 + --> $DIR/const-eval-overflow2c.rs:20:6 | LL | / const VALS_I16: (i16,) = LL | | ( @@ -25,7 +25,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:28:6 + --> $DIR/const-eval-overflow2c.rs:26:6 | LL | / const VALS_I32: (i32,) = LL | | ( @@ -35,7 +35,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:34:6 + --> $DIR/const-eval-overflow2c.rs:32:6 | LL | / const VALS_I64: (i64,) = LL | | ( @@ -45,7 +45,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:40:6 + --> $DIR/const-eval-overflow2c.rs:38:6 | LL | / const VALS_U8: (u8,) = LL | | ( @@ -55,7 +55,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:45:6 + --> $DIR/const-eval-overflow2c.rs:43:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX * 2, @@ -64,7 +64,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:50:6 + --> $DIR/const-eval-overflow2c.rs:48:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX * 2, @@ -73,7 +73,7 @@ LL | | ); | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:56:6 + --> $DIR/const-eval-overflow2c.rs:54:6 | LL | / const VALS_U64: (u64,) = LL | | ( diff --git a/src/test/ui/consts/const-eval/dangling.rs b/src/test/ui/consts/const-eval/dangling.rs index 78cf000db03d1..72e97c03220fc 100644 --- a/src/test/ui/consts/const-eval/dangling.rs +++ b/src/test/ui/consts/const-eval/dangling.rs @@ -1,6 +1,6 @@ #![feature(const_raw_ptr_deref)] -use std::{mem, usize}; +use std::mem; // Make sure we error with the right kind of error on a too large slice. const TEST: () = { unsafe { //~ NOTE diff --git a/src/test/ui/consts/const-int-arithmetic.rs b/src/test/ui/consts/const-int-arithmetic.rs index 9b2e30961aae6..e0d722ede94e3 100644 --- a/src/test/ui/consts/const-int-arithmetic.rs +++ b/src/test/ui/consts/const-int-arithmetic.rs @@ -5,8 +5,6 @@ #![feature(const_overflowing_int_methods)] #![feature(const_wrapping_int_methods)] -use std::{i8, i128}; - macro_rules! suite { ($( $fn:ident -> $ty:ty { $( $label:ident : $expr:expr, $result:expr; )* } diff --git a/src/test/ui/consts/const-int-overflowing-rpass.rs b/src/test/ui/consts/const-int-overflowing-rpass.rs index eecb88becabca..75e77fdf1be17 100644 --- a/src/test/ui/consts/const-int-overflowing-rpass.rs +++ b/src/test/ui/consts/const-int-overflowing-rpass.rs @@ -16,7 +16,7 @@ const SHR_A: (u32, bool) = 0x10u32.overflowing_shr(4); const SHR_B: (u32, bool) = 0x10u32.overflowing_shr(132); const NEG_A: (u32, bool) = 0u32.overflowing_neg(); -const NEG_B: (u32, bool) = core::u32::MAX.overflowing_neg(); +const NEG_B: (u32, bool) = u32::MAX.overflowing_neg(); const ABS_POS: (i32, bool) = 10i32.overflowing_abs(); const ABS_NEG: (i32, bool) = (-10i32).overflowing_abs(); diff --git a/src/test/ui/consts/const-negation.rs b/src/test/ui/consts/const-negation.rs index 1c8e27ae6172a..26c3c0b836bec 100644 --- a/src/test/ui/consts/const-negation.rs +++ b/src/test/ui/consts/const-negation.rs @@ -8,19 +8,19 @@ fn main() { const I: isize = -2147483648isize; #[cfg(target_pointer_width = "64")] const I: isize = -9223372036854775808isize; - assert_eq!(::std::i32::MIN as u64, 0xffffffff80000000); + assert_eq!(i32::MIN as u64, 0xffffffff80000000); assert_eq!(-2147483648isize as u64, 0xffffffff80000000); assert_eq!(-2147483648i32 as u64, 0xffffffff80000000); - assert_eq!(::std::i64::MIN as u64, 0x8000000000000000); + assert_eq!(i64::MIN as u64, 0x8000000000000000); #[cfg(target_pointer_width = "64")] assert_eq!(-9223372036854775808isize as u64, 0x8000000000000000); #[cfg(target_pointer_width = "32")] assert_eq!(-9223372036854775808isize as u64, 0); assert_eq!(-9223372036854775808i32 as u64, 0); - const J: usize = ::std::i32::MAX as usize; + const J: usize = i32::MAX as usize; const K: usize = -1i32 as u32 as usize; - const L: usize = ::std::i32::MIN as usize; - const M: usize = ::std::i64::MIN as usize; + const L: usize = i32::MIN as usize; + const M: usize = i64::MIN as usize; match 5 { J => {}, K => {}, diff --git a/src/test/ui/consts/issue-63952.rs b/src/test/ui/consts/issue-63952.rs index 35cbc7003f095..f50e1e51f612f 100644 --- a/src/test/ui/consts/issue-63952.rs +++ b/src/test/ui/consts/issue-63952.rs @@ -1,7 +1,5 @@ // Regression test for #63952, shouldn't hang. -use std::usize; - #[repr(C)] #[derive(Copy, Clone)] struct SliceRepr { diff --git a/src/test/ui/consts/issue-63952.stderr b/src/test/ui/consts/issue-63952.stderr index 5e85be45b1647..503c5706fa24e 100644 --- a/src/test/ui/consts/issue-63952.stderr +++ b/src/test/ui/consts/issue-63952.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/issue-63952.rs:18:1 + --> $DIR/issue-63952.rs:16:1 | LL | / const SLICE_WAY_TOO_LONG: &[u8] = unsafe { LL | | SliceTransmute { diff --git a/src/test/ui/consts/promote_fn_calls_std.rs b/src/test/ui/consts/promote_fn_calls_std.rs index bdb472f3a9cce..557f6a434f4cd 100644 --- a/src/test/ui/consts/promote_fn_calls_std.rs +++ b/src/test/ui/consts/promote_fn_calls_std.rs @@ -1,3 +1,4 @@ +#![allow(deprecated, deprecated_in_future)] // can be removed if different fns are chosen // build-pass (FIXME(62277): could be check-pass?) fn main() { diff --git a/src/test/ui/consts/promotion.rs b/src/test/ui/consts/promotion.rs index 5f84030a9e96b..e6f5c3d27ca99 100644 --- a/src/test/ui/consts/promotion.rs +++ b/src/test/ui/consts/promotion.rs @@ -13,5 +13,5 @@ fn main() { // make sure that these do not cause trouble despite overflowing baz_u32(&(0-1)); - baz_i32(&-std::i32::MIN); + baz_i32(&-i32::MIN); } diff --git a/src/test/ui/discrim/discrim-ill-typed.rs b/src/test/ui/discrim/discrim-ill-typed.rs index 98c90f0ea6828..3cf0ea0e6b997 100644 --- a/src/test/ui/discrim/discrim-ill-typed.rs +++ b/src/test/ui/discrim/discrim-ill-typed.rs @@ -7,8 +7,6 @@ #![allow(dead_code, unused_variables, unused_imports)] -use std::{i8,u8,i16,u16,i32,u32,i64, u64}; - fn f_i8() { #[repr(i8)] enum A { diff --git a/src/test/ui/discrim/discrim-ill-typed.stderr b/src/test/ui/discrim/discrim-ill-typed.stderr index 7b9f086151a84..9a695a8987a37 100644 --- a/src/test/ui/discrim/discrim-ill-typed.stderr +++ b/src/test/ui/discrim/discrim-ill-typed.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:17:16 + --> $DIR/discrim-ill-typed.rs:15:16 | LL | OhNo = 0_u8, | ^^^^ expected `i8`, found `u8` @@ -10,7 +10,7 @@ LL | OhNo = 0_i8, | ^^^^ error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:30:16 + --> $DIR/discrim-ill-typed.rs:28:16 | LL | OhNo = 0_i8, | ^^^^ expected `u8`, found `i8` @@ -21,7 +21,7 @@ LL | OhNo = 0_u8, | ^^^^ error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:43:16 + --> $DIR/discrim-ill-typed.rs:41:16 | LL | OhNo = 0_u16, | ^^^^^ expected `i16`, found `u16` @@ -32,7 +32,7 @@ LL | OhNo = 0_i16, | ^^^^^ error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:56:16 + --> $DIR/discrim-ill-typed.rs:54:16 | LL | OhNo = 0_i16, | ^^^^^ expected `u16`, found `i16` @@ -43,7 +43,7 @@ LL | OhNo = 0_u16, | ^^^^^ error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:69:16 + --> $DIR/discrim-ill-typed.rs:67:16 | LL | OhNo = 0_u32, | ^^^^^ expected `i32`, found `u32` @@ -54,7 +54,7 @@ LL | OhNo = 0_i32, | ^^^^^ error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:82:16 + --> $DIR/discrim-ill-typed.rs:80:16 | LL | OhNo = 0_i32, | ^^^^^ expected `u32`, found `i32` @@ -65,7 +65,7 @@ LL | OhNo = 0_u32, | ^^^^^ error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:95:16 + --> $DIR/discrim-ill-typed.rs:93:16 | LL | OhNo = 0_u64, | ^^^^^ expected `i64`, found `u64` @@ -76,7 +76,7 @@ LL | OhNo = 0_i64, | ^^^^^ error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:108:16 + --> $DIR/discrim-ill-typed.rs:106:16 | LL | OhNo = 0_i64, | ^^^^^ expected `u64`, found `i64` diff --git a/src/test/ui/discrim/discrim-overflow-2.rs b/src/test/ui/discrim/discrim-overflow-2.rs index f8f565f4d9c14..ca24317c54dc2 100644 --- a/src/test/ui/discrim/discrim-overflow-2.rs +++ b/src/test/ui/discrim/discrim-overflow-2.rs @@ -5,8 +5,6 @@ // See also run-pass/discrim-explicit-23030.rs where the suggested // workaround is tested. -use std::{i8,u8,i16,u16,i32,u32,i64, u64}; - fn f_i8() { #[repr(i8)] enum A { diff --git a/src/test/ui/discrim/discrim-overflow-2.stderr b/src/test/ui/discrim/discrim-overflow-2.stderr index 198ebe9eb51f9..3ca84c6675357 100644 --- a/src/test/ui/discrim/discrim-overflow-2.stderr +++ b/src/test/ui/discrim/discrim-overflow-2.stderr @@ -1,5 +1,5 @@ error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:15:9 + --> $DIR/discrim-overflow-2.rs:13:9 | LL | OhNo, | ^^^^ overflowed on value after 127 @@ -7,7 +7,7 @@ LL | OhNo, = note: explicitly set `OhNo = -128` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:24:9 + --> $DIR/discrim-overflow-2.rs:22:9 | LL | OhNo, | ^^^^ overflowed on value after 255 @@ -15,7 +15,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:33:9 + --> $DIR/discrim-overflow-2.rs:31:9 | LL | OhNo, | ^^^^ overflowed on value after 32767 @@ -23,7 +23,7 @@ LL | OhNo, = note: explicitly set `OhNo = -32768` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:42:9 + --> $DIR/discrim-overflow-2.rs:40:9 | LL | OhNo, | ^^^^ overflowed on value after 65535 @@ -31,7 +31,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:51:9 + --> $DIR/discrim-overflow-2.rs:49:9 | LL | OhNo, | ^^^^ overflowed on value after 2147483647 @@ -39,7 +39,7 @@ LL | OhNo, = note: explicitly set `OhNo = -2147483648` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:60:9 + --> $DIR/discrim-overflow-2.rs:58:9 | LL | OhNo, | ^^^^ overflowed on value after 4294967295 @@ -47,7 +47,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:69:9 + --> $DIR/discrim-overflow-2.rs:67:9 | LL | OhNo, | ^^^^ overflowed on value after 9223372036854775807 @@ -55,7 +55,7 @@ LL | OhNo, = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:78:9 + --> $DIR/discrim-overflow-2.rs:76:9 | LL | OhNo, | ^^^^ overflowed on value after 18446744073709551615 diff --git a/src/test/ui/discrim/discrim-overflow.rs b/src/test/ui/discrim/discrim-overflow.rs index d8a9dacfa5180..774ced93c1723 100644 --- a/src/test/ui/discrim/discrim-overflow.rs +++ b/src/test/ui/discrim/discrim-overflow.rs @@ -3,8 +3,6 @@ // See also run-pass/discrim-explicit-23030.rs where the suggested // workaround is tested. -use std::{i8,u8,i16,u16,i32,u32,i64, u64}; - fn f_i8() { #[repr(i8)] enum A { diff --git a/src/test/ui/discrim/discrim-overflow.stderr b/src/test/ui/discrim/discrim-overflow.stderr index a2ae4863f9f79..1b331bb1b8d98 100644 --- a/src/test/ui/discrim/discrim-overflow.stderr +++ b/src/test/ui/discrim/discrim-overflow.stderr @@ -1,5 +1,5 @@ error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:13:9 + --> $DIR/discrim-overflow.rs:11:9 | LL | OhNo, | ^^^^ overflowed on value after 127 @@ -7,7 +7,7 @@ LL | OhNo, = note: explicitly set `OhNo = -128` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:24:9 + --> $DIR/discrim-overflow.rs:22:9 | LL | OhNo, | ^^^^ overflowed on value after 255 @@ -15,7 +15,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:35:9 + --> $DIR/discrim-overflow.rs:33:9 | LL | OhNo, | ^^^^ overflowed on value after 32767 @@ -23,7 +23,7 @@ LL | OhNo, = note: explicitly set `OhNo = -32768` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:46:9 + --> $DIR/discrim-overflow.rs:44:9 | LL | OhNo, | ^^^^ overflowed on value after 65535 @@ -31,7 +31,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:58:9 + --> $DIR/discrim-overflow.rs:56:9 | LL | OhNo, | ^^^^ overflowed on value after 2147483647 @@ -39,7 +39,7 @@ LL | OhNo, = note: explicitly set `OhNo = -2147483648` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:70:9 + --> $DIR/discrim-overflow.rs:68:9 | LL | OhNo, | ^^^^ overflowed on value after 4294967295 @@ -47,7 +47,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:82:9 + --> $DIR/discrim-overflow.rs:80:9 | LL | OhNo, | ^^^^ overflowed on value after 9223372036854775807 @@ -55,7 +55,7 @@ LL | OhNo, = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:94:9 + --> $DIR/discrim-overflow.rs:92:9 | LL | OhNo, | ^^^^ overflowed on value after 18446744073709551615 diff --git a/src/test/ui/drop/dynamic-drop-async.rs b/src/test/ui/drop/dynamic-drop-async.rs index b027faa9d7c3a..c4f7c3786168b 100644 --- a/src/test/ui/drop/dynamic-drop-async.rs +++ b/src/test/ui/drop/dynamic-drop-async.rs @@ -18,7 +18,6 @@ use std::{ ptr, rc::Rc, task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - usize, }; struct InjectedFailure; diff --git a/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs index 6d0cd101dbc80..88f557055f371 100644 --- a/src/test/ui/drop/dynamic-drop.rs +++ b/src/test/ui/drop/dynamic-drop.rs @@ -12,7 +12,6 @@ use std::mem::ManuallyDrop; use std::ops::Generator; use std::panic; use std::pin::Pin; -use std::usize; struct InjectedFailure; diff --git a/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs b/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs index 1208552d25637..54d0e49c8c58e 100644 --- a/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs +++ b/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs @@ -1,10 +1,8 @@ #![feature(exclusive_range_pattern)] -use std::usize::MAX; - fn main() { match 0usize { //~ERROR non-exhaustive patterns: `_` not covered - 0..=MAX => {} + 0..=usize::MAX => {} } match 0isize { //~ERROR non-exhaustive patterns: `_` not covered diff --git a/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr b/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr index c7a63e5d50252..2cc5d1396ced7 100644 --- a/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr +++ b/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/feature-gate-precise_pointer_size_matching.rs:6:11 + --> $DIR/feature-gate-precise_pointer_size_matching.rs:4:11 | LL | match 0usize { | ^^^^^^ pattern `_` not covered @@ -10,7 +10,7 @@ LL | match 0usize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/feature-gate-precise_pointer_size_matching.rs:10:11 + --> $DIR/feature-gate-precise_pointer_size_matching.rs:8:11 | LL | match 0isize { | ^^^^^^ pattern `_` not covered diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.rs index b135891d0b82f..be225359bffab 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.rs +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.rs @@ -13,8 +13,8 @@ macro_rules! m { } fn floats() { - m!(0f32, core::f32::NEG_INFINITY..); //~ ERROR non-exhaustive patterns: `_` not covered - m!(0f32, ..core::f32::INFINITY); //~ ERROR non-exhaustive patterns: `_` not covered + m!(0f32, f32::NEG_INFINITY..); //~ ERROR non-exhaustive patterns: `_` not covered + m!(0f32, ..f32::INFINITY); //~ ERROR non-exhaustive patterns: `_` not covered } fn khar() { @@ -33,12 +33,12 @@ fn khar() { mod unsigned { fn u8() { - const ALMOST_MAX: u8 = core::u8::MAX - 1; - const ALMOST_MIN: u8 = core::u8::MIN + 1; + const ALMOST_MAX: u8 = u8::MAX - 1; + const ALMOST_MIN: u8 = u8::MIN + 1; const VAL: u8 = 42; const VAL_1: u8 = VAL + 1; const VAL_2: u8 = VAL + 2; - m!(0, ..core::u8::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..u8::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns @@ -46,12 +46,12 @@ mod unsigned { m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns } fn u16() { - const ALMOST_MAX: u16 = core::u16::MAX - 1; - const ALMOST_MIN: u16 = core::u16::MIN + 1; + const ALMOST_MAX: u16 = u16::MAX - 1; + const ALMOST_MIN: u16 = u16::MIN + 1; const VAL: u16 = 42; const VAL_1: u16 = VAL + 1; const VAL_2: u16 = VAL + 2; - m!(0, ..core::u16::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..u16::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns @@ -59,12 +59,12 @@ mod unsigned { m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns } fn u32() { - const ALMOST_MAX: u32 = core::u32::MAX - 1; - const ALMOST_MIN: u32 = core::u32::MIN + 1; + const ALMOST_MAX: u32 = u32::MAX - 1; + const ALMOST_MIN: u32 = u32::MIN + 1; const VAL: u32 = 42; const VAL_1: u32 = VAL + 1; const VAL_2: u32 = VAL + 2; - m!(0, ..core::u32::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..u32::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns @@ -72,12 +72,12 @@ mod unsigned { m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns } fn u64() { - const ALMOST_MAX: u64 = core::u64::MAX - 1; - const ALMOST_MIN: u64 = core::u64::MIN + 1; + const ALMOST_MAX: u64 = u64::MAX - 1; + const ALMOST_MIN: u64 = u64::MIN + 1; const VAL: u64 = 42; const VAL_1: u64 = VAL + 1; const VAL_2: u64 = VAL + 2; - m!(0, ..core::u64::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..u64::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns @@ -85,12 +85,12 @@ mod unsigned { m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns } fn u128() { - const ALMOST_MAX: u128 = core::u128::MAX - 1; - const ALMOST_MIN: u128 = core::u128::MIN + 1; + const ALMOST_MAX: u128 = u128::MAX - 1; + const ALMOST_MIN: u128 = u128::MIN + 1; const VAL: u128 = 42; const VAL_1: u128 = VAL + 1; const VAL_2: u128 = VAL + 2; - m!(0, ..core::u128::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..u128::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns @@ -101,12 +101,12 @@ mod unsigned { mod signed { fn i8() { - const ALMOST_MAX: i8 = core::i8::MAX - 1; - const ALMOST_MIN: i8 = core::i8::MIN + 1; + const ALMOST_MAX: i8 = i8::MAX - 1; + const ALMOST_MIN: i8 = i8::MIN + 1; const VAL: i8 = 42; const VAL_1: i8 = VAL + 1; const VAL_2: i8 = VAL + 2; - m!(0, ..core::i8::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..i8::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns @@ -114,12 +114,12 @@ mod signed { m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns } fn i16() { - const ALMOST_MAX: i16 = core::i16::MAX - 1; - const ALMOST_MIN: i16 = core::i16::MIN + 1; + const ALMOST_MAX: i16 = i16::MAX - 1; + const ALMOST_MIN: i16 = i16::MIN + 1; const VAL: i16 = 42; const VAL_1: i16 = VAL + 1; const VAL_2: i16 = VAL + 2; - m!(0, ..core::i16::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..i16::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns @@ -127,12 +127,12 @@ mod signed { m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns } fn i32() { - const ALMOST_MAX: i32 = core::i32::MAX - 1; - const ALMOST_MIN: i32 = core::i32::MIN + 1; + const ALMOST_MAX: i32 = i32::MAX - 1; + const ALMOST_MIN: i32 = i32::MIN + 1; const VAL: i32 = 42; const VAL_1: i32 = VAL + 1; const VAL_2: i32 = VAL + 2; - m!(0, ..core::i32::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..i32::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns @@ -140,12 +140,12 @@ mod signed { m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns } fn i64() { - const ALMOST_MAX: i64 = core::i64::MAX - 1; - const ALMOST_MIN: i64 = core::i64::MIN + 1; + const ALMOST_MAX: i64 = i64::MAX - 1; + const ALMOST_MIN: i64 = i64::MIN + 1; const VAL: i64 = 42; const VAL_1: i64 = VAL + 1; const VAL_2: i64 = VAL + 2; - m!(0, ..core::i64::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..i64::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns @@ -153,12 +153,12 @@ mod signed { m!(0, ..VAL_1 | VAL_2..); //~ ERROR non-exhaustive patterns } fn i128() { - const ALMOST_MAX: i128 = core::i128::MAX - 1; - const ALMOST_MIN: i128 = core::i128::MIN + 1; + const ALMOST_MAX: i128 = i128::MAX - 1; + const ALMOST_MIN: i128 = i128::MIN + 1; const VAL: i128 = 42; const VAL_1: i128 = VAL + 1; const VAL_2: i128 = VAL + 2; - m!(0, ..core::i128::MAX); //~ ERROR non-exhaustive patterns + m!(0, ..i128::MAX); //~ ERROR non-exhaustive patterns m!(0, ..ALMOST_MAX); //~ ERROR non-exhaustive patterns m!(0, ALMOST_MIN..); //~ ERROR non-exhaustive patterns m!(0, ..=ALMOST_MAX); //~ ERROR non-exhaustive patterns diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr index 5744232235dd1..14dbca60b78f2 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr @@ -1,7 +1,7 @@ error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:16:8 | -LL | m!(0f32, core::f32::NEG_INFINITY..); +LL | m!(0f32, f32::NEG_INFINITY..); | ^^^^ pattern `_` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -10,7 +10,7 @@ LL | m!(0f32, core::f32::NEG_INFINITY..); error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:17:8 | -LL | m!(0f32, ..core::f32::INFINITY); +LL | m!(0f32, ..f32::INFINITY); | ^^^^ pattern `_` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -73,7 +73,7 @@ LL | m!('a', ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `u8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:41:12 | -LL | m!(0, ..core::u8::MAX); +LL | m!(0, ..u8::MAX); | ^ pattern `u8::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -127,7 +127,7 @@ LL | m!(0, ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `u16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:54:12 | -LL | m!(0, ..core::u16::MAX); +LL | m!(0, ..u16::MAX); | ^ pattern `u16::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -181,7 +181,7 @@ LL | m!(0, ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `u32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:67:12 | -LL | m!(0, ..core::u32::MAX); +LL | m!(0, ..u32::MAX); | ^ pattern `u32::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -235,7 +235,7 @@ LL | m!(0, ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `u64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:80:12 | -LL | m!(0, ..core::u64::MAX); +LL | m!(0, ..u64::MAX); | ^ pattern `u64::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -289,7 +289,7 @@ LL | m!(0, ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `u128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:93:12 | -LL | m!(0, ..core::u128::MAX); +LL | m!(0, ..u128::MAX); | ^ pattern `u128::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -343,7 +343,7 @@ LL | m!(0, ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `i8::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:109:12 | -LL | m!(0, ..core::i8::MAX); +LL | m!(0, ..i8::MAX); | ^ pattern `i8::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -397,7 +397,7 @@ LL | m!(0, ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `i16::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:122:12 | -LL | m!(0, ..core::i16::MAX); +LL | m!(0, ..i16::MAX); | ^ pattern `i16::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -451,7 +451,7 @@ LL | m!(0, ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `i32::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:135:12 | -LL | m!(0, ..core::i32::MAX); +LL | m!(0, ..i32::MAX); | ^ pattern `i32::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -505,7 +505,7 @@ LL | m!(0, ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `i64::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:148:12 | -LL | m!(0, ..core::i64::MAX); +LL | m!(0, ..i64::MAX); | ^ pattern `i64::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms @@ -559,7 +559,7 @@ LL | m!(0, ..VAL_1 | VAL_2..); error[E0004]: non-exhaustive patterns: `i128::MAX` not covered --> $DIR/half-open-range-pats-exhaustive-fail.rs:161:12 | -LL | m!(0, ..core::i128::MAX); +LL | m!(0, ..i128::MAX); | ^ pattern `i128::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-pass.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-pass.rs index efac0df2a430d..d3a59e4dffcd6 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-pass.rs +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-pass.rs @@ -26,19 +26,19 @@ macro_rules! test_int { } fn unsigned_int() { - test_int!(0u8, core::u8::MIN, core::u8::MAX); - test_int!(0u16, core::u16::MIN, core::u16::MAX); - test_int!(0u32, core::u32::MIN, core::u32::MAX); - test_int!(0u64, core::u64::MIN, core::u64::MAX); - test_int!(0u128, core::u128::MIN, core::u128::MAX); + test_int!(0u8, u8::MIN, u8::MAX); + test_int!(0u16, u16::MIN, u16::MAX); + test_int!(0u32, u32::MIN, u32::MAX); + test_int!(0u64, u64::MIN, u64::MAX); + test_int!(0u128, u128::MIN, u128::MAX); } fn signed_int() { - test_int!(0i8, core::i8::MIN, core::i8::MAX); - test_int!(0i16, core::i16::MIN, core::i16::MAX); - test_int!(0i32, core::i32::MIN, core::i32::MAX); - test_int!(0i64, core::i64::MIN, core::i64::MAX); - test_int!(0i128, core::i128::MIN, core::i128::MAX); + test_int!(0i8, i8::MIN, i8::MAX); + test_int!(0i16, i16::MIN, i16::MAX); + test_int!(0i32, i32::MIN, i32::MAX); + test_int!(0i64, i64::MIN, i64::MAX); + test_int!(0i128, i128::MIN, i128::MAX); } fn khar() { diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-semantics.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-semantics.rs index 416c59af3fd3e..ae532d935df82 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-semantics.rs +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-semantics.rs @@ -24,15 +24,15 @@ fn range_to_inclusive() { //--------------------------------------- // u8; `..=X` - assert!(yes!(core::u8::MIN, ..=core::u8::MIN)); - assert!(yes!(core::u8::MIN, ..=5)); + assert!(yes!(u8::MIN, ..=u8::MIN)); + assert!(yes!(u8::MIN, ..=5)); assert!(yes!(5u8, ..=5)); assert!(!yes!(6u8, ..=5)); // i16; `..=X` - assert!(yes!(core::i16::MIN, ..=core::i16::MIN)); - assert!(yes!(core::i16::MIN, ..=0)); - assert!(yes!(core::i16::MIN, ..=-5)); + assert!(yes!(i16::MIN, ..=i16::MIN)); + assert!(yes!(i16::MIN, ..=0)); + assert!(yes!(i16::MIN, ..=-5)); assert!(yes!(-5, ..=-5)); assert!(!yes!(-4, ..=-5)); @@ -43,14 +43,14 @@ fn range_to_inclusive() { assert!(!yes!('b', ..='a')); // f32; `..=X` - assert!(yes!(core::f32::NEG_INFINITY, ..=core::f32::NEG_INFINITY)); - assert!(yes!(core::f32::NEG_INFINITY, ..=1.0f32)); + assert!(yes!(f32::NEG_INFINITY, ..=f32::NEG_INFINITY)); + assert!(yes!(f32::NEG_INFINITY, ..=1.0f32)); assert!(yes!(1.5f32, ..=1.5f32)); assert!(!yes!(1.6f32, ..=-1.5f32)); // f64; `..=X` - assert!(yes!(core::f64::NEG_INFINITY, ..=core::f64::NEG_INFINITY)); - assert!(yes!(core::f64::NEG_INFINITY, ..=1.0f64)); + assert!(yes!(f64::NEG_INFINITY, ..=f64::NEG_INFINITY)); + assert!(yes!(f64::NEG_INFINITY, ..=1.0f64)); assert!(yes!(1.5f64, ..=1.5f64)); assert!(!yes!(1.6f64, ..=-1.5f64)); } @@ -66,16 +66,16 @@ fn range_to() { assert!(!yes!(6u8, ..5)); // u8; `..X` - const NU8: u8 = core::u8::MIN + 1; - assert!(yes!(core::u8::MIN, ..NU8)); + const NU8: u8 = u8::MIN + 1; + assert!(yes!(u8::MIN, ..NU8)); assert!(yes!(0u8, ..5)); assert!(!yes!(5u8, ..5)); assert!(!yes!(6u8, ..5)); // i16; `..X` - const NI16: i16 = core::i16::MIN + 1; - assert!(yes!(core::i16::MIN, ..NI16)); - assert!(yes!(core::i16::MIN, ..5)); + const NI16: i16 = i16::MIN + 1; + assert!(yes!(i16::MIN, ..NI16)); + assert!(yes!(i16::MIN, ..5)); assert!(yes!(-6, ..-5)); assert!(!yes!(-5, ..-5)); @@ -87,16 +87,16 @@ fn range_to() { assert!(!yes!('b', ..'a')); // f32; `..X` - assert!(yes!(core::f32::NEG_INFINITY, ..1.0f32)); + assert!(yes!(f32::NEG_INFINITY, ..1.0f32)); assert!(!yes!(1.5f32, ..1.5f32)); - const E32: f32 = 1.5f32 + core::f32::EPSILON; + const E32: f32 = 1.5f32 + f32::EPSILON; assert!(yes!(1.5f32, ..E32)); assert!(!yes!(1.6f32, ..1.5f32)); // f64; `..X` - assert!(yes!(core::f64::NEG_INFINITY, ..1.0f64)); + assert!(yes!(f64::NEG_INFINITY, ..1.0f64)); assert!(!yes!(1.5f64, ..1.5f64)); - const E64: f64 = 1.5f64 + core::f64::EPSILON; + const E64: f64 = 1.5f64 + f64::EPSILON; assert!(yes!(1.5f64, ..E64)); assert!(!yes!(1.6f64, ..1.5f64)); } @@ -106,23 +106,23 @@ fn range_from() { //-------------------------------- // u8; `X..` - assert!(yes!(core::u8::MIN, core::u8::MIN..)); - assert!(yes!(core::u8::MAX, core::u8::MIN..)); - assert!(!yes!(core::u8::MIN, 1..)); + assert!(yes!(u8::MIN, u8::MIN..)); + assert!(yes!(u8::MAX, u8::MIN..)); + assert!(!yes!(u8::MIN, 1..)); assert!(!yes!(4, 5..)); assert!(yes!(5, 5..)); assert!(yes!(6, 5..)); - assert!(yes!(core::u8::MAX, core::u8::MAX..)); + assert!(yes!(u8::MAX, u8::MAX..)); // i16; `X..` - assert!(yes!(core::i16::MIN, core::i16::MIN..)); - assert!(yes!(core::i16::MAX, core::i16::MIN..)); - const NI16: i16 = core::i16::MIN + 1; - assert!(!yes!(core::i16::MIN, NI16..)); + assert!(yes!(i16::MIN, i16::MIN..)); + assert!(yes!(i16::MAX, i16::MIN..)); + const NI16: i16 = i16::MIN + 1; + assert!(!yes!(i16::MIN, NI16..)); assert!(!yes!(-4, 5..)); assert!(yes!(-4, -4..)); assert!(yes!(-3, -4..)); - assert!(yes!(core::i16::MAX, core::i16::MAX..)); + assert!(yes!(i16::MAX, i16::MAX..)); // char; `X..` assert!(yes!('\u{0}', '\u{0}'..)); @@ -133,24 +133,24 @@ fn range_from() { assert!(yes!(core::char::MAX, core::char::MAX..)); // f32; `X..` - assert!(yes!(core::f32::NEG_INFINITY, core::f32::NEG_INFINITY..)); - assert!(yes!(core::f32::INFINITY, core::f32::NEG_INFINITY..)); - assert!(!yes!(core::f32::NEG_INFINITY, 1.0f32..)); - assert!(yes!(core::f32::INFINITY, 1.0f32..)); - assert!(!yes!(1.0f32 - core::f32::EPSILON, 1.0f32..)); + assert!(yes!(f32::NEG_INFINITY, f32::NEG_INFINITY..)); + assert!(yes!(f32::INFINITY, f32::NEG_INFINITY..)); + assert!(!yes!(f32::NEG_INFINITY, 1.0f32..)); + assert!(yes!(f32::INFINITY, 1.0f32..)); + assert!(!yes!(1.0f32 - f32::EPSILON, 1.0f32..)); assert!(yes!(1.0f32, 1.0f32..)); - assert!(yes!(core::f32::INFINITY, 1.0f32..)); - assert!(yes!(core::f32::INFINITY, core::f32::INFINITY..)); + assert!(yes!(f32::INFINITY, 1.0f32..)); + assert!(yes!(f32::INFINITY, f32::INFINITY..)); // f64; `X..` - assert!(yes!(core::f64::NEG_INFINITY, core::f64::NEG_INFINITY..)); - assert!(yes!(core::f64::INFINITY, core::f64::NEG_INFINITY..)); - assert!(!yes!(core::f64::NEG_INFINITY, 1.0f64..)); - assert!(yes!(core::f64::INFINITY, 1.0f64..)); - assert!(!yes!(1.0f64 - core::f64::EPSILON, 1.0f64..)); + assert!(yes!(f64::NEG_INFINITY, f64::NEG_INFINITY..)); + assert!(yes!(f64::INFINITY, f64::NEG_INFINITY..)); + assert!(!yes!(f64::NEG_INFINITY, 1.0f64..)); + assert!(yes!(f64::INFINITY, 1.0f64..)); + assert!(!yes!(1.0f64 - f64::EPSILON, 1.0f64..)); assert!(yes!(1.0f64, 1.0f64..)); - assert!(yes!(core::f64::INFINITY, 1.0f64..)); - assert!(yes!(core::f64::INFINITY, core::f64::INFINITY..)); + assert!(yes!(f64::INFINITY, 1.0f64..)); + assert!(yes!(f64::INFINITY, f64::INFINITY..)); } fn main() { diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs index 904efda903c69..2c8e554b229c8 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs @@ -9,42 +9,42 @@ macro_rules! m { } fn main() { - m!(0, ..core::u8::MIN); + m!(0, ..u8::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0, ..core::u16::MIN); + m!(0, ..u16::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0, ..core::u32::MIN); + m!(0, ..u32::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0, ..core::u64::MIN); + m!(0, ..u64::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0, ..core::u128::MIN); + m!(0, ..u128::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0, ..core::i8::MIN); + m!(0, ..i8::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0, ..core::i16::MIN); + m!(0, ..i16::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0, ..core::i32::MIN); + m!(0, ..i32::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0, ..core::i64::MIN); + m!(0, ..i64::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0, ..core::i128::MIN); + m!(0, ..i128::MIN); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0f32, ..core::f32::NEG_INFINITY); + m!(0f32, ..f32::NEG_INFINITY); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper - m!(0f64, ..core::f64::NEG_INFINITY); + m!(0f64, ..f64::NEG_INFINITY); //~^ ERROR lower range bound must be less than upper //~| ERROR lower range bound must be less than upper diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr index 12ad86429613b..4931ddfac71c9 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr @@ -1,74 +1,74 @@ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:12:11 | -LL | m!(0, ..core::u8::MIN); - | ^^^^^^^^^^^^^^^ +LL | m!(0, ..u8::MIN); + | ^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:15:11 | -LL | m!(0, ..core::u16::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..u16::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:18:11 | -LL | m!(0, ..core::u32::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..u32::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:21:11 | -LL | m!(0, ..core::u64::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..u64::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:24:11 | -LL | m!(0, ..core::u128::MIN); - | ^^^^^^^^^^^^^^^^^ +LL | m!(0, ..u128::MIN); + | ^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:28:11 | -LL | m!(0, ..core::i8::MIN); - | ^^^^^^^^^^^^^^^ +LL | m!(0, ..i8::MIN); + | ^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:31:11 | -LL | m!(0, ..core::i16::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..i16::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:34:11 | -LL | m!(0, ..core::i32::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..i32::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:37:11 | -LL | m!(0, ..core::i64::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..i64::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:40:11 | -LL | m!(0, ..core::i128::MIN); - | ^^^^^^^^^^^^^^^^^ +LL | m!(0, ..i128::MIN); + | ^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:44:14 | -LL | m!(0f32, ..core::f32::NEG_INFINITY); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | m!(0f32, ..f32::NEG_INFINITY); + | ^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:47:14 | -LL | m!(0f64, ..core::f64::NEG_INFINITY); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | m!(0f64, ..f64::NEG_INFINITY); + | ^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:51:13 @@ -79,74 +79,74 @@ LL | m!('a', ..'\u{0}'); error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:12:11 | -LL | m!(0, ..core::u8::MIN); - | ^^^^^^^^^^^^^^^ +LL | m!(0, ..u8::MIN); + | ^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:15:11 | -LL | m!(0, ..core::u16::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..u16::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:18:11 | -LL | m!(0, ..core::u32::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..u32::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:21:11 | -LL | m!(0, ..core::u64::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..u64::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:24:11 | -LL | m!(0, ..core::u128::MIN); - | ^^^^^^^^^^^^^^^^^ +LL | m!(0, ..u128::MIN); + | ^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:28:11 | -LL | m!(0, ..core::i8::MIN); - | ^^^^^^^^^^^^^^^ +LL | m!(0, ..i8::MIN); + | ^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:31:11 | -LL | m!(0, ..core::i16::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..i16::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:34:11 | -LL | m!(0, ..core::i32::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..i32::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:37:11 | -LL | m!(0, ..core::i64::MIN); - | ^^^^^^^^^^^^^^^^ +LL | m!(0, ..i64::MIN); + | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:40:11 | -LL | m!(0, ..core::i128::MIN); - | ^^^^^^^^^^^^^^^^^ +LL | m!(0, ..i128::MIN); + | ^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:44:14 | -LL | m!(0f32, ..core::f32::NEG_INFINITY); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | m!(0f32, ..f32::NEG_INFINITY); + | ^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:47:14 | -LL | m!(0f64, ..core::f64::NEG_INFINITY); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | m!(0f64, ..f64::NEG_INFINITY); + | ^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:51:13 diff --git a/src/test/ui/hashmap/hashmap-capacity-overflow.rs b/src/test/ui/hashmap/hashmap-capacity-overflow.rs index 5f88683f4adfc..2988af06556d9 100644 --- a/src/test/ui/hashmap/hashmap-capacity-overflow.rs +++ b/src/test/ui/hashmap/hashmap-capacity-overflow.rs @@ -3,7 +3,6 @@ // ignore-emscripten no processes use std::collections::hash_map::HashMap; -use std::usize; use std::mem::size_of; fn main() { diff --git a/src/test/ui/issues/issue-20427.rs b/src/test/ui/issues/issue-20427.rs index fa2ea6cf592af..41922c6229351 100644 --- a/src/test/ui/issues/issue-20427.rs +++ b/src/test/ui/issues/issue-20427.rs @@ -4,6 +4,7 @@ #![allow(unused_imports)] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] +#![allow(deprecated, deprecated_in_future)] // aux-build:i8.rs // ignore-pretty issue #37201 diff --git a/src/test/ui/issues/issue-23833.rs b/src/test/ui/issues/issue-23833.rs index 77dc5c50d7aba..d4128fa54e3da 100644 --- a/src/test/ui/issues/issue-23833.rs +++ b/src/test/ui/issues/issue-23833.rs @@ -1,8 +1,6 @@ // run-pass #![allow(unused_imports)] use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; const A_I8_T : [u32; (i8::MAX as i8 - 1i8) as usize] diff --git a/src/test/ui/issues/issue-37686.rs b/src/test/ui/issues/issue-37686.rs index 8c3762514494a..ba58e9e9d8976 100644 --- a/src/test/ui/issues/issue-37686.rs +++ b/src/test/ui/issues/issue-37686.rs @@ -1,7 +1,7 @@ // run-pass fn main() { match (0, 0) { - (std::usize::MIN, std::usize::MAX) => {} + (usize::MIN, usize::MAX) => {} _ => {} } } diff --git a/src/test/ui/issues/issue-41880.rs b/src/test/ui/issues/issue-41880.rs index 10cde21abd766..977c43b71fb71 100644 --- a/src/test/ui/issues/issue-41880.rs +++ b/src/test/ui/issues/issue-41880.rs @@ -19,7 +19,7 @@ impl Iterator for Iterate where F: Fn(&T) -> T { Some(self.state.clone()) } #[inline] - fn size_hint(&self) -> (usize, Option) { (std::usize::MAX, None) } + fn size_hint(&self) -> (usize, Option) { (usize::MAX, None) } } fn main() { diff --git a/src/test/ui/issues/issue-48006.rs b/src/test/ui/issues/issue-48006.rs index 3a862ace55ecc..cfef270e5a67c 100644 --- a/src/test/ui/issues/issue-48006.rs +++ b/src/test/ui/issues/issue-48006.rs @@ -6,10 +6,10 @@ use std::iter::Step; #[cfg(target_pointer_width = "16")] fn main() { - assert!(Step::steps_between(&0u32, &::std::u32::MAX).is_none()); + assert!(Step::steps_between(&0u32, &u32::MAX).is_none()); } #[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] fn main() { - assert!(Step::steps_between(&0u32, &::std::u32::MAX).is_some()); + assert!(Step::steps_between(&0u32, &u32::MAX).is_some()); } diff --git a/src/test/ui/issues/issue-50811.rs b/src/test/ui/issues/issue-50811.rs index 63d87e03c4899..683c856049fdc 100644 --- a/src/test/ui/issues/issue-50811.rs +++ b/src/test/ui/issues/issue-50811.rs @@ -3,7 +3,6 @@ extern crate test; -use std::f64::{NAN, NEG_INFINITY, INFINITY, MAX}; use std::mem::size_of; use test::black_box; @@ -12,7 +11,7 @@ use test::black_box; macro_rules! compare { ($op:tt) => { compare!( - [NEG_INFINITY, -MAX, -1.0, -0.0, 0.0, 1.0, MAX, INFINITY, NAN], + [f64::NEG_INFINITY, -f64::MAX, -1.0, -0.0, 0.0, 1.0, f64::MAX, f64::INFINITY, f64::NAN], $op ); }; @@ -20,7 +19,7 @@ macro_rules! compare { $(compare!( $lhs, $op, - [NEG_INFINITY, -MAX, -1.0, -0.0, 0.0, 1.0, MAX, INFINITY, NAN] + [f64::NEG_INFINITY, -f64::MAX, -1.0, -0.0, 0.0, 1.0, f64::MAX, f64::INFINITY, f64::NAN] );)+ }; ($lhs:expr, $op:tt, [$($rhs:expr),+]) => { @@ -44,8 +43,8 @@ macro_rules! compare { fn main() { assert_eq!(0.0/0.0 < 0.0/0.0, false); assert_eq!(0.0/0.0 > 0.0/0.0, false); - assert_eq!(NAN < NAN, false); - assert_eq!(NAN > NAN, false); + assert_eq!(f64::NAN < f64::NAN, false); + assert_eq!(f64::NAN > f64::NAN, false); compare!(==); compare!(!=); diff --git a/src/test/ui/issues/issue-68010-large-zst-consts.rs b/src/test/ui/issues/issue-68010-large-zst-consts.rs index 4f1bd45e90a19..3277df69c0285 100644 --- a/src/test/ui/issues/issue-68010-large-zst-consts.rs +++ b/src/test/ui/issues/issue-68010-large-zst-consts.rs @@ -1,5 +1,5 @@ // build-pass fn main() { - println!("{}", [(); std::usize::MAX].len()); + println!("{}", [(); usize::MAX].len()); } diff --git a/src/test/ui/issues/issue-6804.rs b/src/test/ui/issues/issue-6804.rs index 325137327b269..6d950c424e381 100644 --- a/src/test/ui/issues/issue-6804.rs +++ b/src/test/ui/issues/issue-6804.rs @@ -3,7 +3,7 @@ #![allow(unused)] #![deny(illegal_floating_point_literal_pattern)] -use std::f64::NAN; +const NAN: f64 = f64::NAN; fn main() { let x = NAN; diff --git a/src/test/ui/issues/issue-8460-const.noopt.stderr b/src/test/ui/issues/issue-8460-const.noopt.stderr index 739b5468743b2..d94c7742de301 100644 --- a/src/test/ui/issues/issue-8460-const.noopt.stderr +++ b/src/test/ui/issues/issue-8460-const.noopt.stderr @@ -1,5 +1,5 @@ error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:14:36 + --> $DIR/issue-8460-const.rs:13:36 | LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow @@ -7,37 +7,37 @@ LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:16:36 + --> $DIR/issue-8460-const.rs:15:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:18:36 + --> $DIR/issue-8460-const.rs:17:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:20:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:21:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:24:36 + --> $DIR/issue-8460-const.rs:23:36 | LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:26:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide `1_isize` by zero @@ -45,103 +45,103 @@ LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:27:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:30:36 + --> $DIR/issue-8460-const.rs:29:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:32:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:33:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:36:36 + --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:38:36 + --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `isize::MIN % -1_isize`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:40:36 + --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute the remainder of `i8::MIN % -1_i8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:42:36 + --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute the remainder of `i16::MIN % -1_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:44:36 + --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:46:36 + --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:48:36 + --> $DIR/issue-8460-const.rs:47:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute the remainder of `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:50:36 + --> $DIR/issue-8460-const.rs:49:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:52:36 + --> $DIR/issue-8460-const.rs:51:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:54:36 + --> $DIR/issue-8460-const.rs:53:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:56:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:58:36 + --> $DIR/issue-8460-const.rs:57:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:60:36 + --> $DIR/issue-8460-const.rs:59:36 | LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero diff --git a/src/test/ui/issues/issue-8460-const.opt.stderr b/src/test/ui/issues/issue-8460-const.opt.stderr index 739b5468743b2..d94c7742de301 100644 --- a/src/test/ui/issues/issue-8460-const.opt.stderr +++ b/src/test/ui/issues/issue-8460-const.opt.stderr @@ -1,5 +1,5 @@ error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:14:36 + --> $DIR/issue-8460-const.rs:13:36 | LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow @@ -7,37 +7,37 @@ LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:16:36 + --> $DIR/issue-8460-const.rs:15:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:18:36 + --> $DIR/issue-8460-const.rs:17:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:20:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:21:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:24:36 + --> $DIR/issue-8460-const.rs:23:36 | LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:26:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide `1_isize` by zero @@ -45,103 +45,103 @@ LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:27:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:30:36 + --> $DIR/issue-8460-const.rs:29:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:32:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:33:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:36:36 + --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:38:36 + --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `isize::MIN % -1_isize`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:40:36 + --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute the remainder of `i8::MIN % -1_i8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:42:36 + --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute the remainder of `i16::MIN % -1_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:44:36 + --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:46:36 + --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:48:36 + --> $DIR/issue-8460-const.rs:47:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute the remainder of `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:50:36 + --> $DIR/issue-8460-const.rs:49:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:52:36 + --> $DIR/issue-8460-const.rs:51:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:54:36 + --> $DIR/issue-8460-const.rs:53:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:56:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:58:36 + --> $DIR/issue-8460-const.rs:57:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:60:36 + --> $DIR/issue-8460-const.rs:59:36 | LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero diff --git a/src/test/ui/issues/issue-8460-const.opt_with_overflow_checks.stderr b/src/test/ui/issues/issue-8460-const.opt_with_overflow_checks.stderr index 739b5468743b2..d94c7742de301 100644 --- a/src/test/ui/issues/issue-8460-const.opt_with_overflow_checks.stderr +++ b/src/test/ui/issues/issue-8460-const.opt_with_overflow_checks.stderr @@ -1,5 +1,5 @@ error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:14:36 + --> $DIR/issue-8460-const.rs:13:36 | LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow @@ -7,37 +7,37 @@ LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:16:36 + --> $DIR/issue-8460-const.rs:15:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:18:36 + --> $DIR/issue-8460-const.rs:17:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:20:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:21:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:24:36 + --> $DIR/issue-8460-const.rs:23:36 | LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:26:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide `1_isize` by zero @@ -45,103 +45,103 @@ LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:27:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:30:36 + --> $DIR/issue-8460-const.rs:29:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:32:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:33:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:36:36 + --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:38:36 + --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `isize::MIN % -1_isize`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:40:36 + --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute the remainder of `i8::MIN % -1_i8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:42:36 + --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute the remainder of `i16::MIN % -1_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:44:36 + --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:46:36 + --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/issue-8460-const.rs:48:36 + --> $DIR/issue-8460-const.rs:47:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute the remainder of `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:50:36 + --> $DIR/issue-8460-const.rs:49:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:52:36 + --> $DIR/issue-8460-const.rs:51:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:54:36 + --> $DIR/issue-8460-const.rs:53:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:56:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:58:36 + --> $DIR/issue-8460-const.rs:57:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:60:36 + --> $DIR/issue-8460-const.rs:59:36 | LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero diff --git a/src/test/ui/issues/issue-8460-const.rs b/src/test/ui/issues/issue-8460-const.rs index 53005e46d2f47..dc754666c8e1f 100644 --- a/src/test/ui/issues/issue-8460-const.rs +++ b/src/test/ui/issues/issue-8460-const.rs @@ -7,7 +7,6 @@ #![deny(const_err)] -use std::{isize, i8, i16, i32, i64, i128}; use std::thread; fn main() { diff --git a/src/test/ui/iterators/iter-count-overflow-debug.rs b/src/test/ui/iterators/iter-count-overflow-debug.rs index d661203575083..5a0394ae760e9 100644 --- a/src/test/ui/iterators/iter-count-overflow-debug.rs +++ b/src/test/ui/iterators/iter-count-overflow-debug.rs @@ -4,13 +4,12 @@ // compile-flags: -C debug_assertions=yes -C opt-level=3 use std::panic; -use std::usize::MAX; fn main() { - assert_eq!((0..MAX).by_ref().count(), MAX); + assert_eq!((0..usize::MAX).by_ref().count(), usize::MAX); let r = panic::catch_unwind(|| { - (0..=MAX).by_ref().count() + (0..=usize::MAX).by_ref().count() }); assert!(r.is_err()); } diff --git a/src/test/ui/iterators/iter-count-overflow-ndebug.rs b/src/test/ui/iterators/iter-count-overflow-ndebug.rs index b755bb554f441..2ecf5096bf819 100644 --- a/src/test/ui/iterators/iter-count-overflow-ndebug.rs +++ b/src/test/ui/iterators/iter-count-overflow-ndebug.rs @@ -3,9 +3,8 @@ // compile-flags: -C debug_assertions=no -C opt-level=3 use std::panic; -use std::usize::MAX; fn main() { - assert_eq!((0..MAX).by_ref().count(), MAX); - assert_eq!((0..=MAX).by_ref().count(), 0); + assert_eq!((0..usize::MAX).by_ref().count(), usize::MAX); + assert_eq!((0..=usize::MAX).by_ref().count(), 0); } diff --git a/src/test/ui/iterators/iter-position-overflow-debug.rs b/src/test/ui/iterators/iter-position-overflow-debug.rs index f1eded31702c4..733ee0c46cc3d 100644 --- a/src/test/ui/iterators/iter-position-overflow-debug.rs +++ b/src/test/ui/iterators/iter-position-overflow-debug.rs @@ -4,11 +4,10 @@ // compile-flags: -C debug_assertions=yes -C opt-level=3 use std::panic; -use std::usize::MAX; fn main() { - let n = MAX as u64; - assert_eq!((0..).by_ref().position(|i| i >= n), Some(MAX)); + let n = usize::MAX as u64; + assert_eq!((0..).by_ref().position(|i| i >= n), Some(usize::MAX)); let r = panic::catch_unwind(|| { (0..).by_ref().position(|i| i > n) diff --git a/src/test/ui/iterators/iter-position-overflow-ndebug.rs b/src/test/ui/iterators/iter-position-overflow-ndebug.rs index 368f9c0c02b07..d4532ee8f59e8 100644 --- a/src/test/ui/iterators/iter-position-overflow-ndebug.rs +++ b/src/test/ui/iterators/iter-position-overflow-ndebug.rs @@ -3,11 +3,10 @@ // compile-flags: -C debug_assertions=no -C opt-level=3 use std::panic; -use std::usize::MAX; fn main() { - let n = MAX as u64; - assert_eq!((0..).by_ref().position(|i| i >= n), Some(MAX)); + let n = usize::MAX as u64; + assert_eq!((0..).by_ref().position(|i| i >= n), Some(usize::MAX)); assert_eq!((0..).by_ref().position(|i| i > n), Some(0)); assert_eq!((0..=n + 1).by_ref().position(|_| false), None); } diff --git a/src/test/ui/macros/macro-first-set.rs b/src/test/ui/macros/macro-first-set.rs index eb2504d4bfdb7..f85376dabcb5d 100644 --- a/src/test/ui/macros/macro-first-set.rs +++ b/src/test/ui/macros/macro-first-set.rs @@ -249,7 +249,7 @@ macro_rules! test_path { test_path!(); test_path!(,); test_path!(::std); -test_path!(std::u8,); +test_path!(std::ops,); test_path!(any, super, super::super::self::path, X::Z<'a, T=U>); macro_rules! test_lifetime { diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs index 5fcd3392d33e3..52a5103865123 100644 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs +++ b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs @@ -1,7 +1,5 @@ #![feature(box_syntax, unboxed_closures)] -use std::usize; - fn to_fn>(f: F) -> F { f } fn test(_x: Box) {} diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr index 462bbd7be58a2..9427ba546a9c1 100644 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr +++ b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `i`, a captured variable in an `Fn` closure - --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:11:28 + --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:9:28 | LL | let i = box 3; | - captured outer variable diff --git a/src/test/ui/numbers-arithmetic/float-int-invalid-const-cast.rs b/src/test/ui/numbers-arithmetic/float-int-invalid-const-cast.rs index ced3c61ec162a..7691149602bc6 100644 --- a/src/test/ui/numbers-arithmetic/float-int-invalid-const-cast.rs +++ b/src/test/ui/numbers-arithmetic/float-int-invalid-const-cast.rs @@ -2,8 +2,6 @@ #![deny(const_err)] -use std::{f32, f64}; - // Forces evaluation of constants, triggering hard error fn force(_: T) {} diff --git a/src/test/ui/numbers-arithmetic/float-nan.rs b/src/test/ui/numbers-arithmetic/float-nan.rs index ee87b8cccfe40..0cc6473e5c48c 100644 --- a/src/test/ui/numbers-arithmetic/float-nan.rs +++ b/src/test/ui/numbers-arithmetic/float-nan.rs @@ -1,5 +1,4 @@ // run-pass -use std::f64; pub fn main() { let nan: f64 = f64::NAN; diff --git a/src/test/ui/numbers-arithmetic/num-wrapping.rs b/src/test/ui/numbers-arithmetic/num-wrapping.rs index 9a01549ecd24e..43b1059f944ee 100644 --- a/src/test/ui/numbers-arithmetic/num-wrapping.rs +++ b/src/test/ui/numbers-arithmetic/num-wrapping.rs @@ -21,7 +21,8 @@ macro_rules! int_modules { ($(($name:ident, $size:expr),)*) => ($( mod $name { pub const BITS: usize = $size; - pub use std::$name::*; + pub const MAX: $name = $name::MAX; + pub const MIN: $name = $name::MIN; } )*) } diff --git a/src/test/ui/numbers-arithmetic/overflowing-neg.rs b/src/test/ui/numbers-arithmetic/overflowing-neg.rs index fe77544641cc1..df1198053036d 100644 --- a/src/test/ui/numbers-arithmetic/overflowing-neg.rs +++ b/src/test/ui/numbers-arithmetic/overflowing-neg.rs @@ -6,5 +6,5 @@ #![allow(arithmetic_overflow)] fn main() { - let _x = -std::i8::MIN; + let _x = -i8::MIN; } diff --git a/src/test/ui/numbers-arithmetic/saturating-float-casts-impl.rs b/src/test/ui/numbers-arithmetic/saturating-float-casts-impl.rs index 6c3e503693c3c..4c6929d6627a8 100644 --- a/src/test/ui/numbers-arithmetic/saturating-float-casts-impl.rs +++ b/src/test/ui/numbers-arithmetic/saturating-float-casts-impl.rs @@ -11,10 +11,6 @@ extern crate test; use self::test::black_box; -use std::{f32, f64}; -#[cfg(not(target_os = "emscripten"))] -use std::{i128, u128}; -use std::{i16, i32, i64, i8, u16, u32, u64, u8}; macro_rules! test { ($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => ( diff --git a/src/test/ui/numbers-arithmetic/shift-near-oflo.rs b/src/test/ui/numbers-arithmetic/shift-near-oflo.rs index 939eb9746121f..55006a1134297 100644 --- a/src/test/ui/numbers-arithmetic/shift-near-oflo.rs +++ b/src/test/ui/numbers-arithmetic/shift-near-oflo.rs @@ -47,21 +47,21 @@ fn test_left_shift() { let x = 1_u8 << id(0); assert_eq!(x, 1); let x = 1_i8 << id(7); - assert_eq!(x, std::i8::MIN); + assert_eq!(x, i8::MIN); let x = 1_u8 << id(7); assert_eq!(x, 0x80); // high-order bits on LHS are silently discarded without panic. let x = 3_i8 << id(7); - assert_eq!(x, std::i8::MIN); + assert_eq!(x, i8::MIN); let x = 3_u8 << id(7); assert_eq!(x, 0x80); // above is (approximately) expanded from: - tests!(i8, u8, 7, std::i8::MIN, 0x80_u8); + tests!(i8, u8, 7, i8::MIN, 0x80_u8); - tests!(i16, u16, 15, std::i16::MIN, 0x8000_u16); - tests!(i32, u32, 31, std::i32::MIN, 0x8000_0000_u32); - tests!(i64, u64, 63, std::i64::MIN, 0x8000_0000_0000_0000_u64); + tests!(i16, u16, 15, i16::MIN, 0x8000_u16); + tests!(i32, u32, 31, i32::MIN, 0x8000_0000_u32); + tests!(i64, u64, 63, i64::MIN, 0x8000_0000_0000_0000_u64); } fn test_right_shift() { @@ -92,9 +92,9 @@ fn test_right_shift() { } } } - tests!(i8, u8, 7, std::i8::MIN, 0x40_i8, 0x80_u8); - tests!(i16, u16, 15, std::i16::MIN, 0x4000_u16, 0x8000_u16); - tests!(i32, u32, 31, std::i32::MIN, 0x4000_0000_u32, 0x8000_0000_u32); - tests!(i64, u64, 63, std::i64::MIN, + tests!(i8, u8, 7, i8::MIN, 0x40_i8, 0x80_u8); + tests!(i16, u16, 15, i16::MIN, 0x4000_u16, 0x8000_u16); + tests!(i32, u32, 31, i32::MIN, 0x4000_0000_u32, 0x8000_0000_u32); + tests!(i64, u64, 63, i64::MIN, 0x4000_0000_0000_0000_u64, 0x8000_0000_0000_0000_u64); } diff --git a/src/test/ui/numbers-arithmetic/u128-as-f32.rs b/src/test/ui/numbers-arithmetic/u128-as-f32.rs index 2671a267f4a87..839ce932d9e76 100644 --- a/src/test/ui/numbers-arithmetic/u128-as-f32.rs +++ b/src/test/ui/numbers-arithmetic/u128-as-f32.rs @@ -4,8 +4,6 @@ #![deny(overflowing_literals)] extern crate test; -use std::f32; -use std::u128; use test::black_box; macro_rules! test { diff --git a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs index 78cc0d28fb037..0b68ef01fa6b8 100644 --- a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs +++ b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs @@ -3,7 +3,7 @@ #![deny(unreachable_patterns)] #![deny(overlapping_patterns)] -use std::{char, u8, u16, u32, u64, u128, i8, i16, i32, i64, i128}; +use std::char; fn main() { let x: u8 = 0; diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-pattern-pointer-size-int.rs b/src/test/ui/pattern/usefulness/non-exhaustive-pattern-pointer-size-int.rs index 0c52876e21f95..e65fffd0d962c 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-pattern-pointer-size-int.rs +++ b/src/test/ui/pattern/usefulness/non-exhaustive-pattern-pointer-size-int.rs @@ -1,5 +1,3 @@ -use std::{usize, isize}; - fn main() { match 0usize { //~^ ERROR non-exhaustive patterns diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-pattern-pointer-size-int.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-pattern-pointer-size-int.stderr index d0aa452fd3861..dd2da1b7e66ff 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-pattern-pointer-size-int.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-pattern-pointer-size-int.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/non-exhaustive-pattern-pointer-size-int.rs:4:11 + --> $DIR/non-exhaustive-pattern-pointer-size-int.rs:2:11 | LL | match 0usize { | ^^^^^^ pattern `_` not covered @@ -10,7 +10,7 @@ LL | match 0usize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/non-exhaustive-pattern-pointer-size-int.rs:12:11 + --> $DIR/non-exhaustive-pattern-pointer-size-int.rs:10:11 | LL | match 0isize { | ^^^^^^ pattern `_` not covered @@ -21,7 +21,7 @@ LL | match 0isize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching error[E0004]: non-exhaustive patterns: type `usize` is non-empty - --> $DIR/non-exhaustive-pattern-pointer-size-int.rs:20:11 + --> $DIR/non-exhaustive-pattern-pointer-size-int.rs:18:11 | LL | match 7usize {} | ^^^^^^ diff --git a/src/test/ui/precise_pointer_size_matching.rs b/src/test/ui/precise_pointer_size_matching.rs index 54aeb8616d959..4b40eb5bcfe68 100644 --- a/src/test/ui/precise_pointer_size_matching.rs +++ b/src/test/ui/precise_pointer_size_matching.rs @@ -10,8 +10,6 @@ #![deny(unreachable_patterns, overlapping_patterns)] -use std::{usize, isize}; - fn main() { match 0isize { isize::MIN ..= isize::MAX => {} // ok diff --git a/src/test/ui/precise_pointer_size_matching.stderr b/src/test/ui/precise_pointer_size_matching.stderr index 9a34171a391c4..a4c15b2cd4b9c 100644 --- a/src/test/ui/precise_pointer_size_matching.stderr +++ b/src/test/ui/precise_pointer_size_matching.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `isize::MIN..=-6_isize` and `21_isize..=isize::MAX` not covered - --> $DIR/precise_pointer_size_matching.rs:24:11 + --> $DIR/precise_pointer_size_matching.rs:22:11 | LL | match 0isize { | ^^^^^^ patterns `isize::MIN..=-6_isize` and `21_isize..=isize::MAX` not covered @@ -8,7 +8,7 @@ LL | match 0isize { = note: the matched value is of type `isize` error[E0004]: non-exhaustive patterns: `0_usize` and `21_usize..=usize::MAX` not covered - --> $DIR/precise_pointer_size_matching.rs:29:11 + --> $DIR/precise_pointer_size_matching.rs:27:11 | LL | match 0usize { | ^^^^^^ patterns `0_usize` and `21_usize..=usize::MAX` not covered diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.rs b/src/test/ui/regions/regions-addr-of-upvar-self.rs index 1f8fe9a4439b9..6159ab02d3d95 100644 --- a/src/test/ui/regions/regions-addr-of-upvar-self.rs +++ b/src/test/ui/regions/regions-addr-of-upvar-self.rs @@ -1,5 +1,3 @@ -use std::usize; - struct Dog { food: usize, } diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.stderr b/src/test/ui/regions/regions-addr-of-upvar-self.stderr index 005800d50a457..62e9058365f11 100644 --- a/src/test/ui/regions/regions-addr-of-upvar-self.stderr +++ b/src/test/ui/regions/regions-addr-of-upvar-self.stderr @@ -1,22 +1,22 @@ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements - --> $DIR/regions-addr-of-upvar-self.rs:10:41 + --> $DIR/regions-addr-of-upvar-self.rs:8:41 | LL | let p: &'static mut usize = &mut self.food; | ^^^^^^^^^^^^^^ | -note: first, the lifetime cannot outlive the lifetime `'_` as defined on the body at 9:18... - --> $DIR/regions-addr-of-upvar-self.rs:9:18 +note: first, the lifetime cannot outlive the lifetime `'_` as defined on the body at 7:18... + --> $DIR/regions-addr-of-upvar-self.rs:7:18 | LL | let _f = || { | ^^ note: ...so that closure can access `self` - --> $DIR/regions-addr-of-upvar-self.rs:10:41 + --> $DIR/regions-addr-of-upvar-self.rs:8:41 | LL | let p: &'static mut usize = &mut self.food; | ^^^^^^^^^^^^^^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that reference does not outlive borrowed content - --> $DIR/regions-addr-of-upvar-self.rs:10:41 + --> $DIR/regions-addr-of-upvar-self.rs:8:41 | LL | let p: &'static mut usize = &mut self.food; | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs index 1cca27520618d..fa5630837b9ad 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs +++ b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs @@ -1,5 +1,3 @@ -use std::f32; - #[derive(PartialEq)] struct Foo { x: u32 diff --git a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr index 02fa23981894a..9a5d57d411832 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr +++ b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr @@ -1,11 +1,11 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/match-forbidden-without-eq.rs:13:9 + --> $DIR/match-forbidden-without-eq.rs:11:9 | LL | FOO => { } | ^^^ warning: floating-point types cannot be used in patterns - --> $DIR/match-forbidden-without-eq.rs:20:9 + --> $DIR/match-forbidden-without-eq.rs:18:9 | LL | f32::INFINITY => { } | ^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | f32::INFINITY => { } = note: for more information, see issue #41620 warning: floating-point types cannot be used in patterns - --> $DIR/match-forbidden-without-eq.rs:20:9 + --> $DIR/match-forbidden-without-eq.rs:18:9 | LL | f32::INFINITY => { } | ^^^^^^^^^^^^^ diff --git a/src/test/ui/simd/simd-intrinsic-float-minmax.rs b/src/test/ui/simd/simd-intrinsic-float-minmax.rs index 5f0aa11af5fb8..d79be61f90995 100644 --- a/src/test/ui/simd/simd-intrinsic-float-minmax.rs +++ b/src/test/ui/simd/simd-intrinsic-float-minmax.rs @@ -20,11 +20,11 @@ fn main() { let y = f32x4(2.0, 1.0, 4.0, 3.0); #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] - let nan = ::std::f32::NAN; + let nan = f32::NAN; // MIPS hardware treats f32::NAN as SNAN. Clear the signaling bit. // See https://github.com/rust-lang/rust/issues/52746. #[cfg(any(target_arch = "mips", target_arch = "mips64"))] - let nan = f32::from_bits(::std::f32::NAN.to_bits() - 1); + let nan = f32::from_bits(f32::NAN.to_bits() - 1); let n = f32x4(nan, nan, nan, nan); diff --git a/src/test/ui/simd/simd-intrinsic-generic-comparison.rs b/src/test/ui/simd/simd-intrinsic-generic-comparison.rs index 2b593e1c9b804..103132c18ae2f 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-comparison.rs +++ b/src/test/ui/simd/simd-intrinsic-generic-comparison.rs @@ -4,8 +4,6 @@ #![feature(repr_simd, platform_intrinsics, concat_idents)] #![allow(non_camel_case_types)] -use std::f32::NAN; - #[repr(simd)] #[derive(Copy, Clone)] struct i32x4(i32, i32, i32, i32); @@ -94,7 +92,7 @@ fn main() { // NAN comparisons are special: // -11 (*) 13 // -5 -100 (*) - let f4 = f32x4(NAN, f1.1, NAN, f2.3); + let f4 = f32x4(f32::NAN, f1.1, f32::NAN, f2.3); unsafe { tests! { diff --git a/src/test/ui/sleep.rs b/src/test/ui/sleep.rs index 3b3a4a4f3250c..f3f8d7259c44e 100644 --- a/src/test/ui/sleep.rs +++ b/src/test/ui/sleep.rs @@ -4,7 +4,6 @@ use std::thread::{self, sleep}; use std::time::Duration; use std::sync::{Arc, Mutex}; -use std::u64; fn main() { let finished = Arc::new(Mutex::new(false)); diff --git a/src/test/ui/structs-enums/discrim-explicit-23030.rs b/src/test/ui/structs-enums/discrim-explicit-23030.rs index 211ca7e4e8feb..af7ab865e3222 100644 --- a/src/test/ui/structs-enums/discrim-explicit-23030.rs +++ b/src/test/ui/structs-enums/discrim-explicit-23030.rs @@ -5,8 +5,6 @@ // See also compile-fail/overflow-discrim.rs, which shows what // happens if you leave the OhNo explicit cases out here. -use std::{i8,u8,i16,u16,i32,u32,i64,u64,isize,usize}; - fn f_i8() { #[repr(i8)] enum A { diff --git a/src/test/ui/symbol-names/const-generics.rs b/src/test/ui/symbol-names/const-generics.rs index ad87000228d04..823995e5be3af 100644 --- a/src/test/ui/symbol-names/const-generics.rs +++ b/src/test/ui/symbol-names/const-generics.rs @@ -19,11 +19,11 @@ // `i8` pub struct I8; - impl I8<{std::i8::MIN}> { + impl I8<{i8::MIN}> { pub fn foo() {} } - impl I8<{std::i8::MAX}> { + impl I8<{i8::MAX}> { pub fn foo() {} } @@ -34,7 +34,7 @@ // `i16` pub struct I16; - impl I16<{std::i16::MIN}> { + impl I16<{i16::MIN}> { pub fn foo() {} } @@ -45,7 +45,7 @@ // `i32` pub struct I32; - impl I32<{std::i32::MIN}> { + impl I32<{i32::MIN}> { pub fn foo() {} } @@ -56,7 +56,7 @@ // `i64` pub struct I64; - impl I64<{std::i64::MIN}> { + impl I64<{i64::MIN}> { pub fn foo() {} } @@ -67,7 +67,7 @@ // `i128` pub struct I128; - impl I128<{std::i128::MIN}> { + impl I128<{i128::MIN}> { pub fn foo() {} } diff --git a/src/test/ui/union/union-transmute.rs b/src/test/ui/union/union-transmute.rs index ac7dede98a3a3..be8062f6276fd 100644 --- a/src/test/ui/union/union-transmute.rs +++ b/src/test/ui/union/union-transmute.rs @@ -1,8 +1,5 @@ // run-pass -extern crate core; -use core::f32; - union U { a: (u8, u8), b: u16, diff --git a/src/test/ui/use-module-level-int-consts.rs b/src/test/ui/use-module-level-int-consts.rs index 758fb414eadf2..200f742d771f5 100644 --- a/src/test/ui/use-module-level-int-consts.rs +++ b/src/test/ui/use-module-level-int-consts.rs @@ -2,6 +2,7 @@ // Make sure the module level constants are still there and accessible even after // the corresponding associated constants have been added, and later stabilized. +#![allow(deprecated, deprecated_in_future)] use std::{u16, f32}; fn main() { diff --git a/src/test/ui/wrapping-int-api.rs b/src/test/ui/wrapping-int-api.rs index ecdd742fb4e08..6e2fc7f80b9c4 100644 --- a/src/test/ui/wrapping-int-api.rs +++ b/src/test/ui/wrapping-int-api.rs @@ -4,9 +4,6 @@ // Don't warn about overflowing ops on 32-bit platforms #![cfg_attr(target_pointer_width = "32", allow(const_err))] -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; - fn main() { assert_eq!( i8::MAX.wrapping_add(1), i8::MIN); assert_eq!( i16::MAX.wrapping_add(1), i16::MIN); diff --git a/src/tools/clippy/tests/ui/float_cmp_const.rs b/src/tools/clippy/tests/ui/float_cmp_const.rs index dfc025558a2f4..263d9a7b92ddb 100644 --- a/src/tools/clippy/tests/ui/float_cmp_const.rs +++ b/src/tools/clippy/tests/ui/float_cmp_const.rs @@ -48,7 +48,7 @@ fn main() { v != 1.0; const ZERO_ARRAY: [f32; 3] = [0.0, 0.0, 0.0]; - const ZERO_INF_ARRAY: [f32; 3] = [0.0, ::std::f32::INFINITY, ::std::f32::NEG_INFINITY]; + const ZERO_INF_ARRAY: [f32; 3] = [0.0, f32::INFINITY, f32::NEG_INFINITY]; const NON_ZERO_ARRAY: [f32; 3] = [0.0, 0.1, 0.2]; const NON_ZERO_ARRAY2: [f32; 3] = [0.2, 0.1, 0.0]; From 88584d5800247f4040a45637a88034ddaadb1a9a Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Wed, 18 Nov 2020 10:42:49 +0100 Subject: [PATCH 15/15] change error for `LayoutErr::SizeOverflow` --- compiler/rustc_middle/src/ty/layout.rs | 2 +- src/test/compile-fail/consts/issue-55878.rs | 2 +- src/test/ui/huge-array-simple-32.stderr | 2 +- src/test/ui/huge-array-simple-64.stderr | 2 +- src/test/ui/huge-array.rs | 2 +- src/test/ui/huge-array.stderr | 2 +- src/test/ui/huge-enum.rs | 2 +- src/test/ui/huge-enum.stderr | 2 +- src/test/ui/huge-struct.rs | 2 +- src/test/ui/huge-struct.stderr | 2 +- src/test/ui/issues/issue-15919-32.stderr | 2 +- src/test/ui/issues/issue-15919-64.stderr | 2 +- src/test/ui/issues/issue-17913.stderr | 2 +- src/test/ui/issues/issue-56762.rs | 4 ++-- src/test/ui/issues/issue-56762.stderr | 4 ++-- src/test/ui/layout/big-type-no-err.rs | 13 +++++++++++++ .../ui/lint/issue-69485-var-size-diffs-too-large.rs | 2 +- .../issue-69485-var-size-diffs-too-large.stderr | 2 +- 18 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 src/test/ui/layout/big-type-no-err.rs diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 1e93c3650b890..64264ff157c60 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -176,7 +176,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> { match *self { LayoutError::Unknown(ty) => write!(f, "the type `{}` has an unknown layout", ty), LayoutError::SizeOverflow(ty) => { - write!(f, "the type `{}` is too big for the current architecture", ty) + write!(f, "values of the type `{}` are too big for the current architecture", ty) } } } diff --git a/src/test/compile-fail/consts/issue-55878.rs b/src/test/compile-fail/consts/issue-55878.rs index aa1dd58d2463d..541befa7b1310 100644 --- a/src/test/compile-fail/consts/issue-55878.rs +++ b/src/test/compile-fail/consts/issue-55878.rs @@ -1,7 +1,7 @@ // normalize-stderr-64bit "18446744073709551615" -> "SIZE" // normalize-stderr-32bit "4294967295" -> "SIZE" -// error-pattern: is too big for the current architecture +// error-pattern: are too big for the current architecture fn main() { println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>()); } diff --git a/src/test/ui/huge-array-simple-32.stderr b/src/test/ui/huge-array-simple-32.stderr index d734a9689e05c..31e120df626de 100644 --- a/src/test/ui/huge-array-simple-32.stderr +++ b/src/test/ui/huge-array-simple-32.stderr @@ -1,4 +1,4 @@ -error: the type `[u8; 2147516416]` is too big for the current architecture +error: values of the type `[u8; 2147516416]` are too big for the current architecture --> $DIR/huge-array-simple-32.rs:10:9 | LL | let _fat: [u8; (1<<31)+(1<<15)] = diff --git a/src/test/ui/huge-array-simple-64.stderr b/src/test/ui/huge-array-simple-64.stderr index 791baa8468747..c5d3fe85d0d83 100644 --- a/src/test/ui/huge-array-simple-64.stderr +++ b/src/test/ui/huge-array-simple-64.stderr @@ -1,4 +1,4 @@ -error: the type `[u8; 2305843011361177600]` is too big for the current architecture +error: values of the type `[u8; 2305843011361177600]` are too big for the current architecture --> $DIR/huge-array-simple-64.rs:10:9 | LL | let _fat: [u8; (1<<61)+(1<<31)] = diff --git a/src/test/ui/huge-array.rs b/src/test/ui/huge-array.rs index 846380586a009..3070801f86576 100644 --- a/src/test/ui/huge-array.rs +++ b/src/test/ui/huge-array.rs @@ -6,7 +6,7 @@ fn generic(t: T) { let s: [T; 1518600000] = [t; 1518600000]; - //~^ ERROR the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture + //~^ ERROR values of the type `[[u8; 1518599999]; 1518600000]` are too big } fn main() { diff --git a/src/test/ui/huge-array.stderr b/src/test/ui/huge-array.stderr index 23d9e87ae0054..817458b73e47b 100644 --- a/src/test/ui/huge-array.stderr +++ b/src/test/ui/huge-array.stderr @@ -1,4 +1,4 @@ -error: the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture +error: values of the type `[[u8; 1518599999]; 1518600000]` are too big for the current architecture --> $DIR/huge-array.rs:8:9 | LL | let s: [T; 1518600000] = [t; 1518600000]; diff --git a/src/test/ui/huge-enum.rs b/src/test/ui/huge-enum.rs index 8a713c3a26eda..39ea6e11b1ff7 100644 --- a/src/test/ui/huge-enum.rs +++ b/src/test/ui/huge-enum.rs @@ -14,5 +14,5 @@ type BIG = Option<[u32; (1<<45)-1]>; fn main() { let big: BIG = None; - //~^ ERROR is too big for the current architecture + //~^ ERROR are too big for the current architecture } diff --git a/src/test/ui/huge-enum.stderr b/src/test/ui/huge-enum.stderr index a069c37b80a21..a1456e1a8ab0a 100644 --- a/src/test/ui/huge-enum.stderr +++ b/src/test/ui/huge-enum.stderr @@ -1,4 +1,4 @@ -error: the type `Option` is too big for the current architecture +error: values of the type `Option` are too big for the current architecture --> $DIR/huge-enum.rs:16:9 | LL | let big: BIG = None; diff --git a/src/test/ui/huge-struct.rs b/src/test/ui/huge-struct.rs index 71169a1104798..02f38d860b496 100644 --- a/src/test/ui/huge-struct.rs +++ b/src/test/ui/huge-struct.rs @@ -48,6 +48,6 @@ struct S1M { val: S1k> } fn main() { let fat: Option>>> = None; - //~^ ERROR is too big for the current architecture + //~^ ERROR are too big for the current architecture } diff --git a/src/test/ui/huge-struct.stderr b/src/test/ui/huge-struct.stderr index 72e32a8593b18..f0ee88e595539 100644 --- a/src/test/ui/huge-struct.stderr +++ b/src/test/ui/huge-struct.stderr @@ -1,4 +1,4 @@ -error: the type `SXX>>` is too big for the current architecture +error: values of the type `SXX>>` are too big for the current architecture --> $DIR/huge-struct.rs:50:9 | LL | let fat: Option>>> = None; diff --git a/src/test/ui/issues/issue-15919-32.stderr b/src/test/ui/issues/issue-15919-32.stderr index 8411313fc81b3..133637f9a058b 100644 --- a/src/test/ui/issues/issue-15919-32.stderr +++ b/src/test/ui/issues/issue-15919-32.stderr @@ -1,4 +1,4 @@ -error: the type `[usize; 4294967295]` is too big for the current architecture +error: values of the type `[usize; 4294967295]` are too big for the current architecture --> $DIR/issue-15919-32.rs:9:9 | LL | let x = [0usize; 0xffff_ffff]; diff --git a/src/test/ui/issues/issue-15919-64.stderr b/src/test/ui/issues/issue-15919-64.stderr index f624c96ce84da..193b823035c09 100644 --- a/src/test/ui/issues/issue-15919-64.stderr +++ b/src/test/ui/issues/issue-15919-64.stderr @@ -1,4 +1,4 @@ -error: the type `[usize; 18446744073709551615]` is too big for the current architecture +error: values of the type `[usize; 18446744073709551615]` are too big for the current architecture --> $DIR/issue-15919-64.rs:9:9 | LL | let x = [0usize; 0xffff_ffff_ffff_ffff]; diff --git a/src/test/ui/issues/issue-17913.stderr b/src/test/ui/issues/issue-17913.stderr index ae388c4d491df..9a6431d447004 100644 --- a/src/test/ui/issues/issue-17913.stderr +++ b/src/test/ui/issues/issue-17913.stderr @@ -1,4 +1,4 @@ -error: the type `[&usize; N]` is too big for the current architecture +error: values of the type `[&usize; N]` are too big for the current architecture error: aborting due to previous error diff --git a/src/test/ui/issues/issue-56762.rs b/src/test/ui/issues/issue-56762.rs index 5ba5b9847d085..fb0a270f18bef 100644 --- a/src/test/ui/issues/issue-56762.rs +++ b/src/test/ui/issues/issue-56762.rs @@ -17,8 +17,8 @@ impl TooBigArray { } static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); -//~^ ERROR the type `[u8; 2305843009213693951]` is too big for the current architecture +//~^ ERROR values of the type `[u8; 2305843009213693951]` are too big static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; -//~^ ERROR the type `[u8; 2305843009213693951]` is too big for the current architecture +//~^ ERROR values of the type `[u8; 2305843009213693951]` are too big fn main() { } diff --git a/src/test/ui/issues/issue-56762.stderr b/src/test/ui/issues/issue-56762.stderr index 69626d4bc7a9e..f26ef280b20b7 100644 --- a/src/test/ui/issues/issue-56762.stderr +++ b/src/test/ui/issues/issue-56762.stderr @@ -1,10 +1,10 @@ -error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture +error[E0080]: values of the type `[u8; 2305843009213693951]` are too big for the current architecture --> $DIR/issue-56762.rs:19:1 | LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture +error[E0080]: values of the type `[u8; 2305843009213693951]` are too big for the current architecture --> $DIR/issue-56762.rs:21:1 | LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; diff --git a/src/test/ui/layout/big-type-no-err.rs b/src/test/ui/layout/big-type-no-err.rs new file mode 100644 index 0000000000000..af8191a9cb919 --- /dev/null +++ b/src/test/ui/layout/big-type-no-err.rs @@ -0,0 +1,13 @@ +// Enormous types are allowed if they are never actually instantiated. +// run-pass +trait Foo { + type Assoc; +} + +impl Foo for [u16; usize::MAX] { + type Assoc = u32; +} + +fn main() { + let _a: Option<<[u16; usize::MAX] as Foo>::Assoc> = None; +} diff --git a/src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs index 0895f4c18e387..2560ffe168be5 100644 --- a/src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs +++ b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs @@ -3,7 +3,7 @@ // compile-flags: -Zmir-opt-level=0 fn main() { - Bug::V([0; !0]); //~ ERROR is too big for the current + Bug::V([0; !0]); //~ ERROR are too big for the current } enum Bug { diff --git a/src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr index 51eac95afb9ce..c229458da47da 100644 --- a/src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr +++ b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr @@ -1,4 +1,4 @@ -error: the type `[u8; 18446744073709551615]` is too big for the current architecture +error: values of the type `[u8; 18446744073709551615]` are too big for the current architecture --> $DIR/issue-69485-var-size-diffs-too-large.rs:6:12 | LL | Bug::V([0; !0]);