diff --git a/Cargo.lock b/Cargo.lock index ab6731e4d433d..070858cd185ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1138,19 +1138,12 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "compiler_builtins 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-alloc 1.0.0", "rustc-std-workspace-core 1.0.0", -] - -[[package]] -name = "hashbrown" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3534,7 +3527,7 @@ dependencies = [ "core 0.0.0", "dlmalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "panic_abort 0.0.0", "panic_unwind 0.0.0", @@ -4450,7 +4443,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum globset 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef4feaabe24a0a658fd9cf4a9acf6ed284f045c77df0f49020ba3245cfb7b454" "checksum h2 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "a539b63339fbbb00e081e84b6e11bd1d9634a82d91da2984a18ac74a8823f392" "checksum handlebars 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "df044dd42cdb7e32f28557b661406fc0f2494be75199779998810dbc35030e0d" -"checksum hashbrown 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9529213c67695ca2d146e6f263b7b72df8fa973368beadf767e8ed80c03f2f36" "checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs index c58a98bac3678..a4cb81d3d1b1b 100644 --- a/src/bootstrap/cc_detect.rs +++ b/src/bootstrap/cc_detect.rs @@ -46,7 +46,7 @@ fn cc2ar(cc: &Path, target: &str) -> Option { } else if target.contains("openbsd") { Some(PathBuf::from("ar")) } else if target.contains("vxworks") { - Some(PathBuf::from("vx-ar")) + Some(PathBuf::from("wr-ar")) } else { let parent = cc.parent().unwrap(); let file = cc.file_name().unwrap().to_str().unwrap(); diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in index 73d6fe532c8b3..e0a1f46078d32 100644 --- a/src/bootstrap/mk/Makefile.in +++ b/src/bootstrap/mk/Makefile.in @@ -81,5 +81,14 @@ ci-subset-1: ci-subset-2: $(Q)$(BOOTSTRAP) test $(TESTS_IN_2) +TESTS_IN_MINGW_2 := \ + src/test/ui \ + src/test/compile-fail + +ci-mingw-subset-1: + $(Q)$(BOOTSTRAP) test $(TESTS_IN_MINGW_2:%=--exclude %) +ci-mingw-subset-2: + $(Q)$(BOOTSTRAP) test $(TESTS_IN_MINGW_2) + .PHONY: dist diff --git a/src/ci/azure-pipelines/auto.yml b/src/ci/azure-pipelines/auto.yml index 06fa3bd9f4347..77c9cda58b8e6 100644 --- a/src/ci/azure-pipelines/auto.yml +++ b/src/ci/azure-pipelines/auto.yml @@ -272,7 +272,7 @@ jobs: i686-mingw-1: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu - SCRIPT: make ci-subset-1 + SCRIPT: make ci-mingw-subset-1 MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 @@ -282,13 +282,13 @@ jobs: i686-mingw-2: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu - SCRIPT: make ci-subset-2 + SCRIPT: make ci-mingw-subset-2 MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 x86_64-mingw-1: MSYS_BITS: 64 - SCRIPT: make ci-subset-1 + SCRIPT: make ci-mingw-subset-1 RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z @@ -298,7 +298,7 @@ jobs: NO_LLVM_ASSERTIONS: 1 x86_64-mingw-2: MSYS_BITS: 64 - SCRIPT: make ci-subset-2 + SCRIPT: make ci-mingw-subset-2 RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu MINGW_URL: https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z diff --git a/src/ci/azure-pipelines/steps/run.yml b/src/ci/azure-pipelines/steps/run.yml index ca32888b74c34..ac6b344a45e66 100644 --- a/src/ci/azure-pipelines/steps/run.yml +++ b/src/ci/azure-pipelines/steps/run.yml @@ -199,7 +199,7 @@ steps: # Upload CPU usage statistics that we've been gathering this whole time. Always # execute this step in case we want to inspect failed builds, but don't let # errors here ever fail the build since this is just informational. -- bash: aws s3 cp --acl public-read cpu-usage.csv s3://$DEPLOY_BUCKET/rustc-builds/$BUILD_SOURCEVERSION/cpu-$SYSTEM_JOBNAME.csv +- bash: aws s3 cp --acl public-read cpu-usage.csv s3://$DEPLOY_BUCKET/rustc-builds/$BUILD_SOURCEVERSION/cpu-$CI_JOB_NAME.csv env: AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) condition: variables['AWS_SECRET_ACCESS_KEY'] diff --git a/src/liballoc/collections/mod.rs b/src/liballoc/collections/mod.rs index 5a33ddc14f004..f1f22fe48c58a 100644 --- a/src/liballoc/collections/mod.rs +++ b/src/liballoc/collections/mod.rs @@ -41,32 +41,35 @@ pub use linked_list::LinkedList; #[doc(no_inline)] pub use vec_deque::VecDeque; -use crate::alloc::{AllocErr, LayoutErr}; +use crate::alloc::{Layout, LayoutErr}; -/// Augments `AllocErr` with a CapacityOverflow variant. +/// The error type for `try_reserve` methods. #[derive(Clone, PartialEq, Eq, Debug)] #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] -pub enum CollectionAllocErr { +pub enum TryReserveError { /// Error due to the computed capacity exceeding the collection's maximum /// (usually `isize::MAX` bytes). CapacityOverflow, - /// Error due to the allocator (see the `AllocErr` type's docs). - AllocErr, -} -#[unstable(feature = "try_reserve", reason = "new API", issue="48043")] -impl From for CollectionAllocErr { - #[inline] - fn from(AllocErr: AllocErr) -> Self { - CollectionAllocErr::AllocErr - } + /// The memory allocator returned an error + AllocError { + /// The layout of allocation request that failed + layout: Layout, + + #[doc(hidden)] + #[unstable(feature = "container_error_extra", issue = "0", reason = "\ + Enable exposing the allocator’s custom error value \ + if an associated type is added in the future: \ + https://github.com/rust-lang/wg-allocators/issues/23")] + non_exhaustive: (), + }, } #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] -impl From for CollectionAllocErr { +impl From for TryReserveError { #[inline] fn from(_: LayoutErr) -> Self { - CollectionAllocErr::CapacityOverflow + TryReserveError::CapacityOverflow } } diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 9240346ace931..2fc87413367ad 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -18,7 +18,7 @@ use core::ptr::{self, NonNull}; use core::slice; use core::hash::{Hash, Hasher}; -use crate::collections::CollectionAllocErr; +use crate::collections::TryReserveError; use crate::raw_vec::RawVec; use crate::vec::Vec; @@ -576,10 +576,10 @@ impl VecDeque { /// /// ``` /// #![feature(try_reserve)] - /// use std::collections::CollectionAllocErr; + /// use std::collections::TryReserveError; /// use std::collections::VecDeque; /// - /// fn process_data(data: &[u32]) -> Result, CollectionAllocErr> { + /// fn process_data(data: &[u32]) -> Result, TryReserveError> { /// let mut output = VecDeque::new(); /// /// // Pre-reserve the memory, exiting if we can't @@ -595,7 +595,7 @@ impl VecDeque { /// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?"); /// ``` #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] - pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> { + pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> { self.try_reserve(additional) } @@ -614,10 +614,10 @@ impl VecDeque { /// /// ``` /// #![feature(try_reserve)] - /// use std::collections::CollectionAllocErr; + /// use std::collections::TryReserveError; /// use std::collections::VecDeque; /// - /// fn process_data(data: &[u32]) -> Result, CollectionAllocErr> { + /// fn process_data(data: &[u32]) -> Result, TryReserveError> { /// let mut output = VecDeque::new(); /// /// // Pre-reserve the memory, exiting if we can't @@ -633,12 +633,12 @@ impl VecDeque { /// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?"); /// ``` #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] - pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> { + pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { let old_cap = self.cap(); let used_cap = self.len() + 1; let new_cap = used_cap.checked_add(additional) .and_then(|needed_cap| needed_cap.checked_next_power_of_two()) - .ok_or(CollectionAllocErr::CapacityOverflow)?; + .ok_or(TryReserveError::CapacityOverflow)?; if new_cap > old_cap { self.buf.try_reserve_exact(used_cap, new_cap - used_cap)?; diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 7421beddd9574..4a48945adc37a 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -87,6 +87,7 @@ #![feature(const_in_array_repeat_expressions)] #![feature(dispatch_from_dyn)] #![feature(core_intrinsics)] +#![feature(container_error_extra)] #![feature(dropck_eyepatch)] #![feature(exact_size_is_empty)] #![feature(fmt_internals)] diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index 250c419c531f8..0b5e186d4c77b 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -98,5 +98,5 @@ macro_rules! vec { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! format { - ($($arg:tt)*) => ($crate::fmt::format(format_args!($($arg)*))) + ($($arg:tt)*) => ($crate::fmt::format(::core::format_args!($($arg)*))) } diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 0abab45e920cc..bc8a38f6b3aad 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -7,8 +7,8 @@ use core::ops::Drop; use core::ptr::{self, NonNull, Unique}; use core::slice; -use crate::alloc::{Alloc, Layout, Global, handle_alloc_error}; -use crate::collections::CollectionAllocErr::{self, *}; +use crate::alloc::{Alloc, Layout, Global, AllocErr, handle_alloc_error}; +use crate::collections::TryReserveError::{self, *}; use crate::boxed::Box; #[cfg(test)] @@ -385,7 +385,7 @@ impl RawVec { /// The same as `reserve_exact`, but returns on errors instead of panicking or aborting. pub fn try_reserve_exact(&mut self, used_capacity: usize, needed_extra_capacity: usize) - -> Result<(), CollectionAllocErr> { + -> Result<(), TryReserveError> { self.reserve_internal(used_capacity, needed_extra_capacity, Fallible, Exact) } @@ -413,7 +413,7 @@ impl RawVec { pub fn reserve_exact(&mut self, used_capacity: usize, needed_extra_capacity: usize) { match self.reserve_internal(used_capacity, needed_extra_capacity, Infallible, Exact) { Err(CapacityOverflow) => capacity_overflow(), - Err(AllocErr) => unreachable!(), + Err(AllocError { .. }) => unreachable!(), Ok(()) => { /* yay */ } } } @@ -422,7 +422,7 @@ impl RawVec { /// needed_extra_capacity` elements. This logic is used in amortized reserve methods. /// Returns `(new_capacity, new_alloc_size)`. fn amortized_new_size(&self, used_capacity: usize, needed_extra_capacity: usize) - -> Result { + -> Result { // Nothing we can really do about these checks :( let required_cap = used_capacity.checked_add(needed_extra_capacity) @@ -435,7 +435,7 @@ impl RawVec { /// The same as `reserve`, but returns on errors instead of panicking or aborting. pub fn try_reserve(&mut self, used_capacity: usize, needed_extra_capacity: usize) - -> Result<(), CollectionAllocErr> { + -> Result<(), TryReserveError> { self.reserve_internal(used_capacity, needed_extra_capacity, Fallible, Amortized) } @@ -494,7 +494,7 @@ impl RawVec { pub fn reserve(&mut self, used_capacity: usize, needed_extra_capacity: usize) { match self.reserve_internal(used_capacity, needed_extra_capacity, Infallible, Amortized) { Err(CapacityOverflow) => capacity_overflow(), - Err(AllocErr) => unreachable!(), + Err(AllocError { .. }) => unreachable!(), Ok(()) => { /* yay */ } } } @@ -640,10 +640,8 @@ impl RawVec { needed_extra_capacity: usize, fallibility: Fallibility, strategy: ReserveStrategy, - ) -> Result<(), CollectionAllocErr> { + ) -> Result<(), TryReserveError> { unsafe { - use crate::alloc::AllocErr; - // NOTE: we don't early branch on ZSTs here because we want this // to actually catch "asking for more than usize::MAX" in that case. // If we make it past the first branch then we are guaranteed to @@ -672,12 +670,16 @@ impl RawVec { None => self.a.alloc(new_layout), }; - match (&res, fallibility) { + let ptr = match (res, fallibility) { (Err(AllocErr), Infallible) => handle_alloc_error(new_layout), - _ => {} - } + (Err(AllocErr), Fallible) => return Err(TryReserveError::AllocError { + layout: new_layout, + non_exhaustive: (), + }), + (Ok(ptr), _) => ptr, + }; - self.ptr = res?.cast().into(); + self.ptr = ptr.cast().into(); self.cap = new_cap; Ok(()) @@ -737,7 +739,7 @@ unsafe impl<#[may_dangle] T, A: Alloc> Drop for RawVec { // all 4GB in user-space. e.g., PAE or x32 #[inline] -fn alloc_guard(alloc_size: usize) -> Result<(), CollectionAllocErr> { +fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> { if mem::size_of::() < 8 && alloc_size > core::isize::MAX as usize { Err(CapacityOverflow) } else { diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index eca726cd41032..b65f191836e9d 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -56,7 +56,7 @@ use core::ptr; use core::str::{pattern::Pattern, lossy}; use crate::borrow::{Cow, ToOwned}; -use crate::collections::CollectionAllocErr; +use crate::collections::TryReserveError; use crate::boxed::Box; use crate::str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars}; use crate::vec::Vec; @@ -937,9 +937,9 @@ impl String { /// /// ``` /// #![feature(try_reserve)] - /// use std::collections::CollectionAllocErr; + /// use std::collections::TryReserveError; /// - /// fn process_data(data: &str) -> Result { + /// fn process_data(data: &str) -> Result { /// let mut output = String::new(); /// /// // Pre-reserve the memory, exiting if we can't @@ -953,7 +953,7 @@ impl String { /// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?"); /// ``` #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] - pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> { + pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { self.vec.try_reserve(additional) } @@ -975,9 +975,9 @@ impl String { /// /// ``` /// #![feature(try_reserve)] - /// use std::collections::CollectionAllocErr; + /// use std::collections::TryReserveError; /// - /// fn process_data(data: &str) -> Result { + /// fn process_data(data: &str) -> Result { /// let mut output = String::new(); /// /// // Pre-reserve the memory, exiting if we can't @@ -991,7 +991,7 @@ impl String { /// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?"); /// ``` #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] - pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> { + pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> { self.vec.try_reserve_exact(additional) } diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index 765210e5aa6b3..55edf56345b59 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -1,5 +1,5 @@ use std::borrow::Cow; -use std::collections::CollectionAllocErr::*; +use std::collections::TryReserveError::*; use std::mem::size_of; use std::{usize, isize}; @@ -566,11 +566,11 @@ fn test_try_reserve() { } else { panic!("usize::MAX should trigger an overflow!") } } else { // Check isize::MAX + 1 is an OOM - if let Err(AllocErr) = empty_string.try_reserve(MAX_CAP + 1) { + if let Err(AllocError { .. }) = empty_string.try_reserve(MAX_CAP + 1) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } // Check usize::MAX is an OOM - if let Err(AllocErr) = empty_string.try_reserve(MAX_USIZE) { + if let Err(AllocError { .. }) = empty_string.try_reserve(MAX_USIZE) { } else { panic!("usize::MAX should trigger an OOM!") } } } @@ -590,7 +590,7 @@ fn test_try_reserve() { if let Err(CapacityOverflow) = ten_bytes.try_reserve(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_bytes.try_reserve(MAX_CAP - 9) { + if let Err(AllocError { .. }) = ten_bytes.try_reserve(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } // Should always overflow in the add-to-len @@ -629,10 +629,10 @@ fn test_try_reserve_exact() { if let Err(CapacityOverflow) = empty_string.try_reserve_exact(MAX_USIZE) { } else { panic!("usize::MAX should trigger an overflow!") } } else { - if let Err(AllocErr) = empty_string.try_reserve_exact(MAX_CAP + 1) { + if let Err(AllocError { .. }) = empty_string.try_reserve_exact(MAX_CAP + 1) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } - if let Err(AllocErr) = empty_string.try_reserve_exact(MAX_USIZE) { + if let Err(AllocError { .. }) = empty_string.try_reserve_exact(MAX_USIZE) { } else { panic!("usize::MAX should trigger an OOM!") } } } @@ -651,7 +651,7 @@ fn test_try_reserve_exact() { if let Err(CapacityOverflow) = ten_bytes.try_reserve_exact(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_bytes.try_reserve_exact(MAX_CAP - 9) { + if let Err(AllocError { .. }) = ten_bytes.try_reserve_exact(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } if let Err(CapacityOverflow) = ten_bytes.try_reserve_exact(MAX_USIZE) { diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 6e8ffe18522a0..29a22aa0315b0 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use std::mem::size_of; use std::{usize, isize}; use std::vec::{Drain, IntoIter}; -use std::collections::CollectionAllocErr::*; +use std::collections::TryReserveError::*; struct DropCounter<'a> { count: &'a mut u32, @@ -1121,11 +1121,11 @@ fn test_try_reserve() { } else { panic!("usize::MAX should trigger an overflow!") } } else { // Check isize::MAX + 1 is an OOM - if let Err(AllocErr) = empty_bytes.try_reserve(MAX_CAP + 1) { + if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_CAP + 1) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } // Check usize::MAX is an OOM - if let Err(AllocErr) = empty_bytes.try_reserve(MAX_USIZE) { + if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_USIZE) { } else { panic!("usize::MAX should trigger an OOM!") } } } @@ -1145,7 +1145,7 @@ fn test_try_reserve() { if let Err(CapacityOverflow) = ten_bytes.try_reserve(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_bytes.try_reserve(MAX_CAP - 9) { + if let Err(AllocError { .. }) = ten_bytes.try_reserve(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } // Should always overflow in the add-to-len @@ -1168,7 +1168,7 @@ fn test_try_reserve() { if let Err(CapacityOverflow) = ten_u32s.try_reserve(MAX_CAP/4 - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_u32s.try_reserve(MAX_CAP/4 - 9) { + if let Err(AllocError { .. }) = ten_u32s.try_reserve(MAX_CAP/4 - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } // Should fail in the mul-by-size @@ -1209,10 +1209,10 @@ fn test_try_reserve_exact() { if let Err(CapacityOverflow) = empty_bytes.try_reserve_exact(MAX_USIZE) { } else { panic!("usize::MAX should trigger an overflow!") } } else { - if let Err(AllocErr) = empty_bytes.try_reserve_exact(MAX_CAP + 1) { + if let Err(AllocError { .. }) = empty_bytes.try_reserve_exact(MAX_CAP + 1) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } - if let Err(AllocErr) = empty_bytes.try_reserve_exact(MAX_USIZE) { + if let Err(AllocError { .. }) = empty_bytes.try_reserve_exact(MAX_USIZE) { } else { panic!("usize::MAX should trigger an OOM!") } } } @@ -1231,7 +1231,7 @@ fn test_try_reserve_exact() { if let Err(CapacityOverflow) = ten_bytes.try_reserve_exact(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_bytes.try_reserve_exact(MAX_CAP - 9) { + if let Err(AllocError { .. }) = ten_bytes.try_reserve_exact(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } if let Err(CapacityOverflow) = ten_bytes.try_reserve_exact(MAX_USIZE) { @@ -1252,7 +1252,7 @@ fn test_try_reserve_exact() { if let Err(CapacityOverflow) = ten_u32s.try_reserve_exact(MAX_CAP/4 - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_u32s.try_reserve_exact(MAX_CAP/4 - 9) { + if let Err(AllocError { .. }) = ten_u32s.try_reserve_exact(MAX_CAP/4 - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } if let Err(CapacityOverflow) = ten_u32s.try_reserve_exact(MAX_USIZE - 20) { diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index 1bbcca97b3c78..d49b553fc0217 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -1,6 +1,6 @@ use std::fmt::Debug; use std::collections::{VecDeque, vec_deque::Drain}; -use std::collections::CollectionAllocErr::*; +use std::collections::TryReserveError::*; use std::mem::size_of; use std::{usize, isize}; @@ -1168,7 +1168,7 @@ fn test_try_reserve() { // VecDeque starts with capacity 7, always adds 1 to the capacity // and also rounds the number to next power of 2 so this is the // furthest we can go without triggering CapacityOverflow - if let Err(AllocErr) = empty_bytes.try_reserve(MAX_CAP) { + if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_CAP) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } } @@ -1188,7 +1188,7 @@ fn test_try_reserve() { if let Err(CapacityOverflow) = ten_bytes.try_reserve(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_bytes.try_reserve(MAX_CAP - 9) { + if let Err(AllocError { .. }) = ten_bytes.try_reserve(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } // Should always overflow in the add-to-len @@ -1211,7 +1211,7 @@ fn test_try_reserve() { if let Err(CapacityOverflow) = ten_u32s.try_reserve(MAX_CAP/4 - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_u32s.try_reserve(MAX_CAP/4 - 9) { + if let Err(AllocError { .. }) = ten_u32s.try_reserve(MAX_CAP/4 - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } // Should fail in the mul-by-size @@ -1256,7 +1256,7 @@ fn test_try_reserve_exact() { // VecDeque starts with capacity 7, always adds 1 to the capacity // and also rounds the number to next power of 2 so this is the // furthest we can go without triggering CapacityOverflow - if let Err(AllocErr) = empty_bytes.try_reserve_exact(MAX_CAP) { + if let Err(AllocError { .. }) = empty_bytes.try_reserve_exact(MAX_CAP) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } } @@ -1275,7 +1275,7 @@ fn test_try_reserve_exact() { if let Err(CapacityOverflow) = ten_bytes.try_reserve_exact(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_bytes.try_reserve_exact(MAX_CAP - 9) { + if let Err(AllocError { .. }) = ten_bytes.try_reserve_exact(MAX_CAP - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } if let Err(CapacityOverflow) = ten_bytes.try_reserve_exact(MAX_USIZE) { @@ -1296,7 +1296,7 @@ fn test_try_reserve_exact() { if let Err(CapacityOverflow) = ten_u32s.try_reserve_exact(MAX_CAP/4 - 9) { } else { panic!("isize::MAX + 1 should trigger an overflow!"); } } else { - if let Err(AllocErr) = ten_u32s.try_reserve_exact(MAX_CAP/4 - 9) { + if let Err(AllocError { .. }) = ten_u32s.try_reserve_exact(MAX_CAP/4 - 9) { } else { panic!("isize::MAX + 1 should trigger an OOM!") } } if let Err(CapacityOverflow) = ten_u32s.try_reserve_exact(MAX_USIZE - 20) { diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index dac04e4e62403..d2798955c46a9 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -70,7 +70,7 @@ use core::ptr::{self, NonNull}; use core::slice::{self, SliceIndex}; use crate::borrow::{ToOwned, Cow}; -use crate::collections::CollectionAllocErr; +use crate::collections::TryReserveError; use crate::boxed::Box; use crate::raw_vec::RawVec; @@ -498,9 +498,9 @@ impl Vec { /// /// ``` /// #![feature(try_reserve)] - /// use std::collections::CollectionAllocErr; + /// use std::collections::TryReserveError; /// - /// fn process_data(data: &[u32]) -> Result, CollectionAllocErr> { + /// fn process_data(data: &[u32]) -> Result, TryReserveError> { /// let mut output = Vec::new(); /// /// // Pre-reserve the memory, exiting if we can't @@ -516,7 +516,7 @@ impl Vec { /// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?"); /// ``` #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] - pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> { + pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { self.buf.try_reserve(self.len, additional) } @@ -538,9 +538,9 @@ impl Vec { /// /// ``` /// #![feature(try_reserve)] - /// use std::collections::CollectionAllocErr; + /// use std::collections::TryReserveError; /// - /// fn process_data(data: &[u32]) -> Result, CollectionAllocErr> { + /// fn process_data(data: &[u32]) -> Result, TryReserveError> { /// let mut output = Vec::new(); /// /// // Pre-reserve the memory, exiting if we can't @@ -556,7 +556,7 @@ impl Vec { /// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?"); /// ``` #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] - pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> { + pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> { self.buf.try_reserve_exact(self.len, additional) } diff --git a/src/libcore/iter/adapters/chain.rs b/src/libcore/iter/adapters/chain.rs index 76239ebc0abaf..0b9f7f6b609e7 100644 --- a/src/libcore/iter/adapters/chain.rs +++ b/src/libcore/iter/adapters/chain.rs @@ -207,6 +207,29 @@ impl DoubleEndedIterator for Chain where } } + #[inline] + fn nth_back(&mut self, mut n: usize) -> Option { + match self.state { + ChainState::Both | ChainState::Back => { + for x in self.b.by_ref().rev() { + if n == 0 { + return Some(x) + } + n -= 1; + } + if let ChainState::Both = self.state { + self.state = ChainState::Front; + } + } + ChainState::Front => {} + } + if let ChainState::Front = self.state { + self.a.nth_back(n) + } else { + None + } + } + fn try_rfold(&mut self, init: Acc, mut f: F) -> R where Self: Sized, F: FnMut(Acc, Self::Item) -> R, R: Try { diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index bbed95167161d..e114f3af0c515 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -2,21 +2,21 @@ /// /// For details, see `std::macros`. #[macro_export] -#[allow_internal_unstable(core_panic, __rust_unstable_column)] +#[allow_internal_unstable(core_panic)] #[stable(feature = "core", since = "1.6.0")] macro_rules! panic { () => ( $crate::panic!("explicit panic") ); ($msg:expr) => ({ - $crate::panicking::panic(&($msg, file!(), line!(), __rust_unstable_column!())) + $crate::panicking::panic(&($msg, $crate::file!(), $crate::line!(), $crate::column!())) }); ($msg:expr,) => ( $crate::panic!($msg) ); ($fmt:expr, $($arg:tt)+) => ({ - $crate::panicking::panic_fmt(format_args!($fmt, $($arg)+), - &(file!(), line!(), __rust_unstable_column!())) + $crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+), + &($crate::file!(), $crate::line!(), $crate::column!())) }); } @@ -70,7 +70,7 @@ macro_rules! assert_eq { panic!(r#"assertion failed: `(left == right)` left: `{:?}`, right: `{:?}`: {}"#, &*left_val, &*right_val, - format_args!($($arg)+)) + $crate::format_args!($($arg)+)) } } } @@ -127,7 +127,7 @@ macro_rules! assert_ne { panic!(r#"assertion failed: `(left != right)` left: `{:?}`, right: `{:?}`: {}"#, &*left_val, &*right_val, - format_args!($($arg)+)) + $crate::format_args!($($arg)+)) } } } @@ -181,7 +181,7 @@ macro_rules! assert_ne { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! debug_assert { - ($($arg:tt)*) => (if cfg!(debug_assertions) { assert!($($arg)*); }) + ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert!($($arg)*); }) } /// Asserts that two expressions are equal to each other. @@ -208,7 +208,7 @@ macro_rules! debug_assert { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! debug_assert_eq { - ($($arg:tt)*) => (if cfg!(debug_assertions) { $crate::assert_eq!($($arg)*); }) + ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_eq!($($arg)*); }) } /// Asserts that two expressions are not equal to each other. @@ -235,7 +235,7 @@ macro_rules! debug_assert_eq { #[macro_export] #[stable(feature = "assert_ne", since = "1.13.0")] macro_rules! debug_assert_ne { - ($($arg:tt)*) => (if cfg!(debug_assertions) { $crate::assert_ne!($($arg)*); }) + ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_ne!($($arg)*); }) } /// Unwraps a result or propagates its error. @@ -386,7 +386,7 @@ macro_rules! r#try { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! write { - ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*))) + ($dst:expr, $($arg:tt)*) => ($dst.write_fmt($crate::format_args!($($arg)*))) } /// Write formatted data into a buffer, with a newline appended. @@ -446,7 +446,7 @@ macro_rules! writeln { $crate::writeln!($dst) ); ($dst:expr, $($arg:tt)*) => ( - $dst.write_fmt(format_args_nl!($($arg)*)) + $dst.write_fmt($crate::format_args_nl!($($arg)*)) ); } @@ -515,7 +515,7 @@ macro_rules! unreachable { $crate::unreachable!($msg) }); ($fmt:expr, $($arg:tt)*) => ({ - panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*) + panic!($crate::concat!("internal error: entered unreachable code: ", $fmt), $($arg)*) }); } @@ -573,7 +573,7 @@ macro_rules! unreachable { #[stable(feature = "rust1", since = "1.0.0")] macro_rules! unimplemented { () => (panic!("not yet implemented")); - ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)+))); + ($($arg:tt)+) => (panic!("not yet implemented: {}", $crate::format_args!($($arg)+))); } /// Indicates unfinished code. @@ -632,7 +632,7 @@ macro_rules! unimplemented { #[unstable(feature = "todo_macro", issue = "59277")] macro_rules! todo { () => (panic!("not yet implemented")); - ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)+))); + ($($arg:tt)+) => (panic!("not yet implemented: {}", $crate::format_args!($($arg)+))); } /// Definitions of built-in macros. @@ -927,13 +927,6 @@ pub(crate) mod builtin { #[macro_export] macro_rules! column { () => { /* compiler built-in */ } } - /// Same as `column`, but less likely to be shadowed. - #[unstable(feature = "__rust_unstable_column", issue = "0", - reason = "internal implementation detail of the `panic` macro")] - #[rustc_builtin_macro] - #[macro_export] - macro_rules! __rust_unstable_column { () => { /* compiler built-in */ } } - /// Expands to the file name in which it was invoked. /// /// With [`line!`] and [`column!`], these macros provide debugging information for diff --git a/src/libcore/prelude/v1.rs b/src/libcore/prelude/v1.rs index 762403790403d..7cc279a9ef2ec 100644 --- a/src/libcore/prelude/v1.rs +++ b/src/libcore/prelude/v1.rs @@ -56,7 +56,6 @@ pub use crate::hash::macros::Hash; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use crate::{ - __rust_unstable_column, asm, assert, cfg, diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 3615fab791505..bff7813730463 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -103,6 +103,22 @@ fn test_iterator_chain_nth() { assert_eq!(it.next(), None); } +#[test] +fn test_iterator_chain_nth_back() { + let xs = [0, 1, 2, 3, 4, 5]; + let ys = [30, 40, 50, 60]; + let zs = []; + let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60]; + for (i, x) in expected.iter().rev().enumerate() { + assert_eq!(Some(x), xs.iter().chain(&ys).nth_back(i)); + } + assert_eq!(zs.iter().chain(&xs).nth_back(0), Some(&5)); + + let mut it = xs.iter().chain(&zs); + assert_eq!(it.nth_back(5), Some(&0)); + assert_eq!(it.next(), None); +} + #[test] fn test_iterator_chain_last() { let xs = [0, 1, 2, 3, 4, 5]; diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index d37b2367ae77e..de84fcd7160df 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -178,8 +178,7 @@ pub trait MetadataLoader { -> Result; } -/// A store of Rust crates, through with their metadata -/// can be accessed. +/// A store of Rust crates, through which their metadata can be accessed. /// /// Note that this trait should probably not be expanding today. All new /// functionality should be driven through queries instead! diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 1e2ec08301cf9..11701a6637744 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2197,7 +2197,6 @@ impl<'tcx> Operand<'tcx> { let ty = tcx.type_of(def_id).subst(tcx, substs); Operand::Constant(box Constant { span, - ty, user_ty: None, literal: ty::Const::zero_sized(tcx, ty), }) @@ -2476,7 +2475,6 @@ impl<'tcx> Debug for Rvalue<'tcx> { #[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)] pub struct Constant<'tcx> { pub span: Span, - pub ty: Ty<'tcx>, /// Optional user-given type: for something like /// `collect::>`, this would be present and would @@ -3385,12 +3383,11 @@ impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> { fn super_fold_with>(&self, folder: &mut F) -> Self { Constant { span: self.span.clone(), - ty: self.ty.fold_with(folder), user_ty: self.user_ty.fold_with(folder), literal: self.literal.fold_with(folder), } } fn super_visit_with>(&self, visitor: &mut V) -> bool { - self.ty.visit_with(visitor) || self.literal.visit_with(visitor) + self.literal.visit_with(visitor) } } diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index f8889380b2abf..e9f7636ba85ae 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -252,7 +252,7 @@ impl<'tcx> Operand<'tcx> { match self { &Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty, - &Operand::Constant(ref c) => c.ty, + &Operand::Constant(ref c) => c.literal.ty, } } } diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index ee4ecb6762c96..2d16e7bcc8371 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -782,13 +782,11 @@ macro_rules! make_mir_visitor { location: Location) { let Constant { span, - ty, user_ty, literal, } = constant; self.visit_span(span); - self.visit_ty(ty, TyContext::Location(location)); drop(user_ty); // no visit method for this self.visit_const(literal, location); } diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index cc0c733c22410..e63f1b91dd7d5 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -221,7 +221,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> mir::TerminatorKind::Call { func: mir::Operand::Constant(ref c), ref args, .. - } => match c.ty.sty { + } => match c.literal.ty.sty { ty::FnDef(did, _) => Some((did, args)), _ => None, }, diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index ce98979cc0c64..dbce5ce4896a7 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -651,7 +651,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let (llval, ty) = self.simd_shuffle_indices( &bx, constant.span, - constant.ty, + constant.literal.ty, c, ); return OperandRef { diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 5e5804b72657b..254b73da44261 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -466,7 +466,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } mir::Operand::Constant(ref constant) => { - let ty = self.monomorphize(&constant.ty); self.eval_mir_constant(constant) .map(|c| OperandRef::from_const(bx, c)) .unwrap_or_else(|err| { @@ -481,6 +480,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // the above error (or silence it under some conditions) will not cause UB bx.abort(); // We've errored, so we don't have to produce working code. + let ty = self.monomorphize(&constant.literal.ty); let layout = bx.cx().layout_of(ty); bx.load_operand(PlaceRef::new_sized( bx.cx().const_undef(bx.cx().type_ptr_to(bx.cx().backend_type(layout))), diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 16cdbb7dd4d39..8391822bb7579 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -250,8 +250,11 @@ fn main() { let llvm_use_libcxx = env::var_os("LLVM_USE_LIBCXX"); let stdcppname = if target.contains("openbsd") { - // llvm-config on OpenBSD doesn't mention stdlib=libc++ - "c++" + if target.contains("sparc64") { + "estdc++" + } else { + "c++" + } } else if target.contains("freebsd") { "c++" } else if target.contains("darwin") { diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 5d8fabc7e69ae..4ac0a5b94c0d8 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -70,7 +70,7 @@ pub struct CrateMetadata { // whichever `TyCtxt` is being used to decode those values. pub root: schema::CrateRoot<'static>, - /// For each public item in this crate, we encode a key. When the + /// For each definition in this crate, we encode a key. When the /// crate is loaded, we read all the keys and put them in this /// hashmap, which gives the reverse mapping. This allows us to /// quickly retrace a `DefPath`, which is needed for incremental diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 70d6c15d8e2a7..9ff0c6ca6a546 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -272,12 +272,11 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) { self.super_constant(constant, location); - self.sanitize_constant(constant, location); - self.sanitize_type(constant, constant.ty); + self.sanitize_type(constant, constant.literal.ty); if let Some(annotation_index) = constant.user_ty { if let Err(terr) = self.cx.relate_type_and_user_type( - constant.ty, + constant.literal.ty, ty::Variance::Invariant, &UserTypeProjection { base: annotation_index, projs: vec![], }, location.to_locations(), @@ -289,7 +288,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { constant, "bad constant user type {:?} vs {:?}: {:?}", annotation, - constant.ty, + constant.literal.ty, terr, ); } @@ -299,7 +298,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { location.to_locations(), ConstraintCategory::Boring, self.cx.param_env.and(type_op::ascribe_user_type::AscribeUserType::new( - constant.ty, def_id, UserSubsts { substs, user_self_ty: None }, + constant.literal.ty, def_id, UserSubsts { substs, user_self_ty: None }, )), ) { span_mirbug!( @@ -403,41 +402,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { } } - /// Checks that the constant's `ty` field matches up with what would be - /// expected from its literal. Unevaluated constants and well-formed - /// constraints are checked by `visit_constant`. - fn sanitize_constant(&mut self, constant: &Constant<'tcx>, location: Location) { - debug!( - "sanitize_constant(constant={:?}, location={:?})", - constant, location - ); - - let literal = constant.literal; - - if let ConstValue::Unevaluated(..) = literal.val { - return; - } - - debug!("sanitize_constant: expected_ty={:?}", literal.ty); - - if let Err(terr) = self.cx.eq_types( - literal.ty, - constant.ty, - location.to_locations(), - ConstraintCategory::Boring, - ) { - span_mirbug!( - self, - constant, - "constant {:?} should have type {:?} but has {:?} ({:?})", - constant, - literal.ty, - constant.ty, - terr, - ); - } - } - /// Checks that the types internal to the `place` match up with /// what would be expected. fn sanitize_place( diff --git a/src/librustc_mir/build/expr/as_constant.rs b/src/librustc_mir/build/expr/as_constant.rs index 5197981a85cb8..39bdc871d83c6 100644 --- a/src/librustc_mir/build/expr/as_constant.rs +++ b/src/librustc_mir/build/expr/as_constant.rs @@ -38,9 +38,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { inferred_ty: ty, }) }); + assert_eq!(literal.ty, ty); Constant { span, - ty, user_ty, literal, } diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index ec061e7453577..1a186fa932ddb 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -591,7 +591,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let n = (!0u128) >> (128 - bits); let literal = ty::Const::from_bits(self.hir.tcx(), n, param_ty); - self.literal_operand(span, ty, literal) + self.literal_operand(span, literal) } // Helper to get the minimum value of the appropriate type @@ -602,6 +602,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let n = 1 << (bits - 1); let literal = ty::Const::from_bits(self.hir.tcx(), n, param_ty); - self.literal_operand(span, ty, literal) + self.literal_operand(span, literal) } } diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 02ab53fe8c1b1..889861b856748 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -114,7 +114,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { destination, Constant { span: expr_span, - ty: this.hir.bool_ty(), user_ty: None, literal: this.hir.true_literal(), }, @@ -126,7 +125,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { destination, Constant { span: expr_span, - ty: this.hir.bool_ty(), user_ty: None, literal: this.hir.false_literal(), }, diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index d9b748f71f011..3473155a3ea3e 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -108,8 +108,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Err(match_pair) } - PatternKind::Range(PatternRange { lo, hi, ty, end }) => { - let (range, bias) = match ty.sty { + PatternKind::Range(PatternRange { lo, hi, end }) => { + let (range, bias) = match lo.ty.sty { ty::Char => { (Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32))), 0) } diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 1c93abd40ded2..65e92d422b022 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -63,7 +63,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } PatternKind::Range(range) => { - assert!(range.ty == match_pair.pattern.ty); + assert_eq!(range.lo.ty, match_pair.pattern.ty); + assert_eq!(range.hi.ty, match_pair.pattern.ty); Test { span: match_pair.pattern.span, kind: TestKind::Range(range), @@ -270,8 +271,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ); } else { if let [success, fail] = *make_target_blocks(self) { + assert_eq!(value.ty, ty); + let expect = self.literal_operand(test.span, value); let val = Operand::Copy(place.clone()); - let expect = self.literal_operand(test.span, ty, value); self.compare(block, success, fail, source_info, BinOp::Eq, expect, val); } else { bug!("`TestKind::Eq` should have two target blocks"); @@ -279,13 +281,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - TestKind::Range(PatternRange { ref lo, ref hi, ty, ref end }) => { + TestKind::Range(PatternRange { ref lo, ref hi, ref end }) => { let lower_bound_success = self.cfg.start_new_block(); let target_blocks = make_target_blocks(self); // Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons. - let lo = self.literal_operand(test.span, ty, lo); - let hi = self.literal_operand(test.span, ty, hi); + let lo = self.literal_operand(test.span, lo); + let hi = self.literal_operand(test.span, hi); let val = Operand::Copy(place.clone()); if let [success, fail] = *target_blocks { @@ -387,7 +389,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) { use rustc::middle::lang_items::EqTraitLangItem; - let mut expect = self.literal_operand(source_info.span, value.ty, value); + let mut expect = self.literal_operand(source_info.span, value); let mut val = Operand::Copy(place.clone()); // If we're using `b"..."` as a pattern, we need to insert an @@ -440,7 +442,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }; let eq_def_id = self.hir.tcx().require_lang_item(EqTraitLangItem); - let (mty, method) = self.hir.trait_method(eq_def_id, sym::eq, deref_ty, &[deref_ty.into()]); + let method = self.hir.trait_method(eq_def_id, sym::eq, deref_ty, &[deref_ty.into()]); let bool_ty = self.hir.bool_ty(); let eq_result = self.temp(bool_ty, source_info.span); @@ -449,7 +451,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.cfg.terminate(block, source_info, TerminatorKind::Call { func: Operand::Constant(box Constant { span: source_info.span, - ty: mty, // FIXME(#54571): This constant comes from user input (a // constant in a pattern). Are there forms where users can add @@ -656,8 +657,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let tcx = self.hir.tcx(); - let lo = compare_const_vals(tcx, test.lo, pat.hi, self.hir.param_env, test.ty)?; - let hi = compare_const_vals(tcx, test.hi, pat.lo, self.hir.param_env, test.ty)?; + let test_ty = test.lo.ty; + let lo = compare_const_vals(tcx, test.lo, pat.hi, self.hir.param_env, test_ty)?; + let hi = compare_const_vals(tcx, test.hi, pat.lo, self.hir.param_env, test_ty)?; match (test.end, pat.end, lo, hi) { // pat < test @@ -774,8 +776,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let tcx = self.hir.tcx(); - let a = compare_const_vals(tcx, range.lo, value, self.hir.param_env, range.ty)?; - let b = compare_const_vals(tcx, value, range.hi, self.hir.param_env, range.ty)?; + let a = compare_const_vals(tcx, range.lo, value, self.hir.param_env, range.lo.ty)?; + let b = compare_const_vals(tcx, value, range.hi, self.hir.param_env, range.lo.ty)?; match (b, range.end) { (Less, _) | diff --git a/src/librustc_mir/build/misc.rs b/src/librustc_mir/build/misc.rs index 56025eeaaa922..d038310dd4454 100644 --- a/src/librustc_mir/build/misc.rs +++ b/src/librustc_mir/build/misc.rs @@ -26,12 +26,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// without any user type annotation. pub fn literal_operand(&mut self, span: Span, - ty: Ty<'tcx>, literal: &'tcx ty::Const<'tcx>) -> Operand<'tcx> { let constant = box Constant { span, - ty, user_ty: None, literal, }; @@ -47,7 +45,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pub fn zero_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> { let literal = ty::Const::from_bits(self.hir.tcx(), 0, ty::ParamEnv::empty().and(ty)); - self.literal_operand(span, ty, literal) + self.literal_operand(span, literal) } pub fn push_usize(&mut self, @@ -61,7 +59,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block, source_info, &temp, Constant { span: source_info.span, - ty: self.hir.usize_ty(), user_ty: None, literal: self.hir.usize_literal(value), }); diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 1c6a743155ee4..a33d7207ed4e1 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -927,7 +927,7 @@ fn convert_path_expr<'a, 'tcx>( ExprKind::Literal { literal: cx.tcx.mk_const(ty::Const { val: ConstValue::Unevaluated(def_id, substs), - ty: cx.tcx.type_of(def_id), + ty: cx.tables().node_type(expr.hir_id), }), user_ty, } diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 3d9349df5bedb..740dc2011cab1 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -170,13 +170,13 @@ impl<'a, 'tcx> Cx<'a, 'tcx> { method_name: Symbol, self_ty: Ty<'tcx>, params: &[Kind<'tcx>]) - -> (Ty<'tcx>, &'tcx ty::Const<'tcx>) { + -> &'tcx ty::Const<'tcx> { let substs = self.tcx.mk_substs_trait(self_ty, params); for item in self.tcx.associated_items(trait_def_id) { if item.kind == ty::AssocKind::Method && item.ident.name == method_name { let method_ty = self.tcx.type_of(item.def_id); let method_ty = method_ty.subst(self.tcx, substs); - return (method_ty, ty::Const::zero_sized(self.tcx, method_ty)); + return ty::Const::zero_sized(self.tcx, method_ty); } } diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 8a3d904e77579..1833ee30624bb 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -609,7 +609,6 @@ impl<'tcx> Witness<'tcx> { ConstantRange(lo, hi, ty, end) => PatternKind::Range(PatternRange { lo: ty::Const::from_bits(cx.tcx, lo, ty::ParamEnv::empty().and(ty)), hi: ty::Const::from_bits(cx.tcx, hi, ty::ParamEnv::empty().and(ty)), - ty, end, }), _ => PatternKind::Wild, @@ -880,10 +879,10 @@ impl<'tcx> IntRange<'tcx> { let range = loop { match pat.kind { box PatternKind::Constant { value } => break ConstantValue(value), - box PatternKind::Range(PatternRange { lo, hi, ty, end }) => break ConstantRange( - lo.eval_bits(tcx, param_env, ty), - hi.eval_bits(tcx, param_env, ty), - ty, + box PatternKind::Range(PatternRange { lo, hi, end }) => break ConstantRange( + lo.eval_bits(tcx, param_env, lo.ty), + hi.eval_bits(tcx, param_env, hi.ty), + lo.ty, end, ), box PatternKind::AscribeUserType { ref subpattern, .. } => { @@ -1339,11 +1338,11 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>, Some(vec![Variant(adt_def.variants[variant_index].def_id)]) } PatternKind::Constant { value } => Some(vec![ConstantValue(value)]), - PatternKind::Range(PatternRange { lo, hi, ty, end }) => + PatternKind::Range(PatternRange { lo, hi, end }) => Some(vec![ConstantRange( - lo.eval_bits(cx.tcx, cx.param_env, ty), - hi.eval_bits(cx.tcx, cx.param_env, ty), - ty, + lo.eval_bits(cx.tcx, cx.param_env, lo.ty), + hi.eval_bits(cx.tcx, cx.param_env, hi.ty), + lo.ty, end, )]), PatternKind::Array { .. } => match pcx.ty.sty { @@ -1656,7 +1655,7 @@ fn constructor_covered_by_range<'tcx>( ) -> Result { let (from, to, end, ty) = match pat.kind { box PatternKind::Constant { value } => (value, value, RangeEnd::Included, value.ty), - box PatternKind::Range(PatternRange { lo, hi, end, ty }) => (lo, hi, end, ty), + box PatternKind::Range(PatternRange { lo, hi, end }) => (lo, hi, end, lo.ty), _ => bug!("`constructor_covered_by_range` called with {:?}", pat), }; trace!("constructor_covered_by_range {:#?}, {:#?}, {:#?}, {}", ctor, from, to, ty); diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 10223151f5c3b..bebb0719af808 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -181,7 +181,6 @@ pub enum PatternKind<'tcx> { pub struct PatternRange<'tcx> { pub lo: &'tcx ty::Const<'tcx>, pub hi: &'tcx ty::Const<'tcx>, - pub ty: Ty<'tcx>, pub end: RangeEnd, } @@ -296,7 +295,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { PatternKind::Constant { value } => { write!(f, "{}", value) } - PatternKind::Range(PatternRange { lo, hi, ty: _, end }) => { + PatternKind::Range(PatternRange { lo, hi, end }) => { write!(f, "{}", lo)?; match end { RangeEnd::Included => write!(f, "..=")?, @@ -442,6 +441,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { let mut kind = match (lo, hi) { (PatternKind::Constant { value: lo }, PatternKind::Constant { value: hi }) => { + assert_eq!(lo.ty, ty); + assert_eq!(hi.ty, ty); let cmp = compare_const_vals( self.tcx, lo, @@ -451,7 +452,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ); match (end, cmp) { (RangeEnd::Excluded, Some(Ordering::Less)) => - PatternKind::Range(PatternRange { lo, hi, ty, end }), + PatternKind::Range(PatternRange { lo, hi, end }), (RangeEnd::Excluded, _) => { span_err!( self.tcx.sess, @@ -465,7 +466,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { PatternKind::Constant { value: lo } } (RangeEnd::Included, Some(Ordering::Less)) => { - PatternKind::Range(PatternRange { lo, hi, ty, end }) + PatternKind::Range(PatternRange { lo, hi, end }) } (RangeEnd::Included, _) => { let mut err = struct_span_err!( @@ -1416,17 +1417,7 @@ impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> { } => PatternKind::Constant { value, }, - PatternKind::Range(PatternRange { - lo, - hi, - ty, - end, - }) => PatternKind::Range(PatternRange { - lo, - hi, - ty: ty.fold_with(folder), - end, - }), + PatternKind::Range(range) => PatternKind::Range(range), PatternKind::Slice { ref prefix, ref slice, diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 33447eba7492a..063e779637158 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -445,7 +445,6 @@ impl CloneShimBuilder<'tcx> { let func_ty = tcx.mk_fn_def(self.def_id, substs); let func = Operand::Constant(box Constant { span: self.span, - ty: func_ty, user_ty: None, literal: ty::Const::zero_sized(tcx, func_ty), }); @@ -505,7 +504,6 @@ impl CloneShimBuilder<'tcx> { fn make_usize(&self, value: u64) -> Box> { box Constant { span: self.span, - ty: self.tcx.types.usize, user_ty: None, literal: ty::Const::from_usize(self.tcx, value), } @@ -745,7 +743,6 @@ fn build_call_shim<'tcx>( let ty = tcx.type_of(def_id); (Operand::Constant(box Constant { span, - ty, user_ty: None, literal: ty::Const::zero_sized(tcx, ty), }), diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 38d26d0ba50a4..c3c432d606644 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -539,7 +539,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { Operand::Constant(Box::new( Constant { span, - ty, user_ty: None, literal: self.tcx.mk_const(*ty::Const::from_scalar( self.tcx, diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 0a021d9b8fa06..4480d1e0a05b8 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -527,7 +527,6 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { fn constant_bool(&self, span: Span, val: bool) -> Rvalue<'tcx> { Rvalue::Use(Operand::Constant(Box::new(Constant { span, - ty: self.tcx.types.bool, user_ty: None, literal: ty::Const::from_bool(self.tcx, val), }))) diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 94bb70e10aa53..f694188024031 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -975,7 +975,6 @@ fn insert_panic_block<'tcx>( let term = TerminatorKind::Assert { cond: Operand::Constant(box Constant { span: body.span, - ty: tcx.types.bool, user_ty: None, literal: ty::Const::from_bool(tcx, false), }), diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 40cb1fbdc57fa..bc7bd39be488e 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -328,7 +328,7 @@ impl Inliner<'tcx> { } TerminatorKind::Call {func: Operand::Constant(ref f), .. } => { - if let ty::FnDef(def_id, _) = f.ty.sty { + if let ty::FnDef(def_id, _) = f.literal.ty.sty { // Don't give intrinsics the extra penalty for calls let f = tcx.fn_sig(def_id); if f.abi() == Abi::RustIntrinsic || f.abi() == Abi::PlatformIntrinsic { diff --git a/src/librustc_mir/transform/instcombine.rs b/src/librustc_mir/transform/instcombine.rs index 5542926503693..b2d063a1f4e10 100644 --- a/src/librustc_mir/transform/instcombine.rs +++ b/src/librustc_mir/transform/instcombine.rs @@ -97,8 +97,7 @@ impl Visitor<'tcx> for OptimizationFinder<'b, 'tcx> { let place_ty = place.ty(&self.body.local_decls, self.tcx).ty; if let ty::Array(_, len) = place_ty.sty { let span = self.body.source_info(location).span; - let ty = self.tcx.types.usize; - let constant = Constant { span, ty, literal: len, user_ty: None }; + let constant = Constant { span, literal: len, user_ty: None }; self.optimizations.arrays_lengths.insert(location, constant); } } diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index dcfc80968f31c..0eed43b10868e 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -249,7 +249,7 @@ trait Qualif { if let ConstValue::Unevaluated(def_id, _) = constant.literal.val { // Don't peek inside trait associated constants. if cx.tcx.trait_of_item(def_id).is_some() { - Self::in_any_value_of_ty(cx, constant.ty).unwrap_or(false) + Self::in_any_value_of_ty(cx, constant.literal.ty).unwrap_or(false) } else { let (bits, _) = cx.tcx.at(constant.span).mir_const_qualif(def_id); @@ -258,7 +258,7 @@ trait Qualif { // Just in case the type is more specific than // the definition, e.g., impl associated const // with type parameters, take it into account. - qualif && Self::mask_for_ty(cx, constant.ty) + qualif && Self::mask_for_ty(cx, constant.literal.ty) } } else { false diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 7fe8480c819e6..598de3a77e61c 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -224,7 +224,7 @@ fn is_rustc_peek<'a, 'tcx>( if let Some(mir::Terminator { ref kind, source_info, .. }) = *terminator { if let mir::TerminatorKind::Call { func: ref oper, ref args, .. } = *kind { if let mir::Operand::Constant(ref func) = *oper { - if let ty::FnDef(def_id, _) = func.ty.sty { + if let ty::FnDef(def_id, _) = func.literal.ty.sty { let abi = tcx.fn_sig(def_id).abi(); let name = tcx.item_name(def_id); if abi == Abi::RustIntrinsic && name == sym::rustc_peek { diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 52fd645e38e22..c5561a1ae0d15 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -970,7 +970,6 @@ where fn constant_usize(&self, val: u16) -> Operand<'tcx> { Operand::Constant(box Constant { span: self.source_info.span, - ty: self.tcx().types.usize, user_ty: None, literal: ty::Const::from_usize(self.tcx(), val.into()), }) diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 68880fc345ae2..ac2701971dfd5 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -397,10 +397,9 @@ impl ExtraComments<'tcx> { impl Visitor<'tcx> for ExtraComments<'tcx> { fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) { self.super_constant(constant, location); - let Constant { span, ty, user_ty, literal } = constant; + let Constant { span, user_ty, literal } = constant; self.push("mir::Constant"); self.push(&format!("+ span: {:?}", span)); - self.push(&format!("+ ty: {:?}", ty)); if let Some(user_ty) = user_ty { self.push(&format!("+ user_ty: {:?}", user_ty)); } diff --git a/src/librustc_target/spec/aarch64_wrs_vxworks.rs b/src/librustc_target/spec/aarch64_wrs_vxworks.rs index 6ad6632341ce3..65caeac5ed1ad 100644 --- a/src/librustc_target/spec/aarch64_wrs_vxworks.rs +++ b/src/librustc_target/spec/aarch64_wrs_vxworks.rs @@ -9,15 +9,14 @@ pub fn target() -> TargetResult { target_endian: "little".to_string(), target_pointer_width: "64".to_string(), target_c_int_width: "32".to_string(), - target_env: "gnu".to_string(), data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), arch: "aarch64".to_string(), target_os: "vxworks".to_string(), - target_vendor: "unknown".to_string(), + target_env: "gnu".to_string(), + target_vendor: "wrs".to_string(), linker_flavor: LinkerFlavor::Gcc, options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), - target_mcount: "\u{1}_mcount".to_string(), .. base }, }) diff --git a/src/librustc_target/spec/arm_wrs_vxworks_sf.rs b/src/librustc_target/spec/arm_wrs_vxworks_sf.rs deleted file mode 100644 index bde903de10221..0000000000000 --- a/src/librustc_target/spec/arm_wrs_vxworks_sf.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; - -pub fn target() -> TargetResult { - let mut base = super::vxworks_base::opts(); - base.max_atomic_width = Some(64); - Ok(Target { - llvm_target: "arm-unknown-linux-gnueabi".to_string(), - target_endian: "little".to_string(), - target_pointer_width: "32".to_string(), - target_c_int_width: "32".to_string(), - data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), - target_os: "vxworks".to_string(), - target_env: "gnu".to_string(), - target_vendor: "unknown".to_string(), - linker_flavor: LinkerFlavor::Gcc, - - options: TargetOptions { - features: "+strict-align,+v6".to_string(), - abi_blacklist: super::arm_base::abi_blacklist(), - target_mcount: "\u{1}__gnu_mcount_nc".to_string(), - .. base - }, - }) -} diff --git a/src/librustc_target/spec/armv7_wrs_vxworks.rs b/src/librustc_target/spec/armv7_wrs_vxworks.rs deleted file mode 100644 index 06c51ae61068f..0000000000000 --- a/src/librustc_target/spec/armv7_wrs_vxworks.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; - -// This target is for glibc Linux on ARMv7 without NEON or -// thumb-mode. See the thumbv7neon variant for enabling both. - -pub fn target() -> TargetResult { - let base = super::vxworks_base::opts(); - Ok(Target { - llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), - target_endian: "little".to_string(), - target_pointer_width: "32".to_string(), - target_c_int_width: "32".to_string(), - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), - target_os: "vxworks".to_string(), - target_env: "gnu".to_string(), - target_vendor: "unknown".to_string(), - linker_flavor: LinkerFlavor::Gcc, - - options: TargetOptions { - // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), - cpu: "generic".to_string(), - max_atomic_width: Some(64), - abi_blacklist: super::arm_base::abi_blacklist(), - target_mcount: "\u{1}__gnu_mcount_nc".to_string(), - position_independent_executables: false, - .. base - } - }) -} diff --git a/src/librustc_target/spec/arm_wrs_vxworks.rs b/src/librustc_target/spec/armv7_wrs_vxworks_eabihf.rs similarity index 77% rename from src/librustc_target/spec/arm_wrs_vxworks.rs rename to src/librustc_target/spec/armv7_wrs_vxworks_eabihf.rs index 06c51ae61068f..9e3b24dd327dc 100644 --- a/src/librustc_target/spec/arm_wrs_vxworks.rs +++ b/src/librustc_target/spec/armv7_wrs_vxworks_eabihf.rs @@ -1,8 +1,5 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; -// This target is for glibc Linux on ARMv7 without NEON or -// thumb-mode. See the thumbv7neon variant for enabling both. - pub fn target() -> TargetResult { let base = super::vxworks_base::opts(); Ok(Target { @@ -14,17 +11,14 @@ pub fn target() -> TargetResult { arch: "arm".to_string(), target_os: "vxworks".to_string(), target_env: "gnu".to_string(), - target_vendor: "unknown".to_string(), + target_vendor: "wrs".to_string(), linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { // Info about features at https://wiki.debian.org/ArmHardFloatPort features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), abi_blacklist: super::arm_base::abi_blacklist(), - target_mcount: "\u{1}__gnu_mcount_nc".to_string(), - position_independent_executables: false, .. base } }) diff --git a/src/librustc_target/spec/i586_wrs_vxworks.rs b/src/librustc_target/spec/i586_wrs_vxworks.rs deleted file mode 100644 index 355250e6eca7f..0000000000000 --- a/src/librustc_target/spec/i586_wrs_vxworks.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::spec::TargetResult; - -pub fn target() -> TargetResult { - let mut base = super::i686_wrs_vxworks::target()?; - base.options.cpu = "pentium".to_string(); - base.llvm_target = "i586-unknown-linux-gnu".to_string(); - Ok(base) -} diff --git a/src/librustc_target/spec/i686_wrs_vxworks.rs b/src/librustc_target/spec/i686_wrs_vxworks.rs index 4b1ff5ccbe8aa..c5f9583a35856 100644 --- a/src/librustc_target/spec/i686_wrs_vxworks.rs +++ b/src/librustc_target/spec/i686_wrs_vxworks.rs @@ -16,7 +16,7 @@ pub fn target() -> TargetResult { arch: "x86".to_string(), target_os: "vxworks".to_string(), target_env: "gnu".to_string(), - target_vendor: "unknown".to_string(), + target_vendor: "wrs".to_string(), linker_flavor: LinkerFlavor::Gcc, options: base, }) diff --git a/src/librustc_target/spec/i686_wrs_vxworks_gnu.rs b/src/librustc_target/spec/i686_wrs_vxworks_gnu.rs deleted file mode 100644 index 4b1ff5ccbe8aa..0000000000000 --- a/src/librustc_target/spec/i686_wrs_vxworks_gnu.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::spec::{LinkerFlavor, Target, TargetResult}; - -pub fn target() -> TargetResult { - let mut base = super::vxworks_base::opts(); - base.cpu = "pentium4".to_string(); - base.max_atomic_width = Some(64); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string()); - base.stack_probes = true; - - Ok(Target { - llvm_target: "i686-unknown-linux-gnu".to_string(), - target_endian: "little".to_string(), - target_pointer_width: "32".to_string(), - target_c_int_width: "32".to_string(), - data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(), - arch: "x86".to_string(), - target_os: "vxworks".to_string(), - target_env: "gnu".to_string(), - target_vendor: "unknown".to_string(), - linker_flavor: LinkerFlavor::Gcc, - options: base, - }) -} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 9a009ca68eee3..539e28f7088e3 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -398,6 +398,7 @@ supported_targets! { ("aarch64-unknown-openbsd", aarch64_unknown_openbsd), ("i686-unknown-openbsd", i686_unknown_openbsd), + ("sparc64-unknown-openbsd", sparc64_unknown_openbsd), ("x86_64-unknown-openbsd", x86_64_unknown_openbsd), ("aarch64-unknown-netbsd", aarch64_unknown_netbsd), @@ -492,10 +493,9 @@ supported_targets! { ("nvptx64-nvidia-cuda", nvptx64_nvidia_cuda), - ("x86_64-wrs-vxworks", x86_64_wrs_vxworks), ("i686-wrs-vxworks", i686_wrs_vxworks), - ("i586-wrs-vxworks", i586_wrs_vxworks), - ("armv7-wrs-vxworks", armv7_wrs_vxworks), + ("x86_64-wrs-vxworks", x86_64_wrs_vxworks), + ("armv7-wrs-vxworks-eabihf", armv7_wrs_vxworks_eabihf), ("aarch64-wrs-vxworks", aarch64_wrs_vxworks), ("powerpc-wrs-vxworks", powerpc_wrs_vxworks), ("powerpc-wrs-vxworks-spe", powerpc_wrs_vxworks_spe), diff --git a/src/librustc_target/spec/powerpc64_wrs_vxworks.rs b/src/librustc_target/spec/powerpc64_wrs_vxworks.rs index a9520709e6656..27a84b953dd07 100644 --- a/src/librustc_target/spec/powerpc64_wrs_vxworks.rs +++ b/src/librustc_target/spec/powerpc64_wrs_vxworks.rs @@ -15,10 +15,9 @@ pub fn target() -> TargetResult { arch: "powerpc64".to_string(), target_os: "vxworks".to_string(), target_env: "gnu".to_string(), - target_vendor: "unknown".to_string(), + target_vendor: "wrs".to_string(), linker_flavor: LinkerFlavor::Gcc, options: TargetOptions { - target_mcount: "_mcount".to_string(), .. base }, }) diff --git a/src/librustc_target/spec/powerpc64_wrs_vxworks_gnusf.rs b/src/librustc_target/spec/powerpc64_wrs_vxworks_gnusf.rs deleted file mode 100644 index c2dae8535a287..0000000000000 --- a/src/librustc_target/spec/powerpc64_wrs_vxworks_gnusf.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; - -pub fn target() -> TargetResult { - let mut base = super::vxworks_base::opts(); - base.cpu = "ppc64".to_string(); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); - base.max_atomic_width = Some(64); - - Ok(Target { - llvm_target: "powerpc64-unknown-linux-gnu".to_string(), - target_endian: "big".to_string(), - target_pointer_width: "64".to_string(), - target_c_int_width: "32".to_string(), - data_layout: "E-m:e-i64:64-n32:64".to_string(), - arch: "powerpc64".to_string(), - target_os: "vxworks".to_string(), - target_env: "gnu".to_string(), - target_vendor: "unknown".to_string(), - linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { - features: "-hard-float".to_string(), - target_mcount: "_mcount".to_string(), - .. base - }, - }) -} diff --git a/src/librustc_target/spec/powerpc_wrs_vxworks.rs b/src/librustc_target/spec/powerpc_wrs_vxworks.rs index 2e833ee1d487b..a4d2897f89228 100644 --- a/src/librustc_target/spec/powerpc_wrs_vxworks.rs +++ b/src/librustc_target/spec/powerpc_wrs_vxworks.rs @@ -19,7 +19,6 @@ pub fn target() -> TargetResult { linker_flavor: LinkerFlavor::Gcc, options: TargetOptions { features: "+secure-plt".to_string(), - target_mcount: "_mcount".to_string(), .. base }, }) diff --git a/src/librustc_target/spec/powerpc_wrs_vxworks_gnusf.rs b/src/librustc_target/spec/powerpc_wrs_vxworks_gnusf.rs deleted file mode 100644 index 43723ea7c0cc8..0000000000000 --- a/src/librustc_target/spec/powerpc_wrs_vxworks_gnusf.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; - -pub fn target() -> TargetResult { - let mut base = super::vxworks_base::opts(); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string()); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("--secure-plt".to_string()); - base.max_atomic_width = Some(32); - - Ok(Target { - llvm_target: "powerpc-unknown-linux-gnu".to_string(), - target_endian: "big".to_string(), - target_pointer_width: "32".to_string(), - target_c_int_width: "32".to_string(), - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), - target_os: "vxworks".to_string(), - target_env: "gnu".to_string(), - target_vendor: "wrs".to_string(), - linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { - features: "+secure-plt,-hard-float".to_string(), - target_mcount: "_mcount".to_string(), - .. base - }, - }) -} diff --git a/src/librustc_target/spec/powerpc_wrs_vxworks_gnuspesf.rs b/src/librustc_target/spec/powerpc_wrs_vxworks_gnuspesf.rs deleted file mode 100644 index 8f236235867e5..0000000000000 --- a/src/librustc_target/spec/powerpc_wrs_vxworks_gnuspesf.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult}; - -pub fn target() -> TargetResult { - let mut base = super::vxworks_base::opts(); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-mspe".to_string()); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("--secure-plt".to_string()); - base.max_atomic_width = Some(32); - - Ok(Target { - llvm_target: "powerpc-unknown-linux-gnuspe".to_string(), - target_endian: "big".to_string(), - target_pointer_width: "32".to_string(), - target_c_int_width: "32".to_string(), - data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(), - arch: "powerpc".to_string(), - target_os: "vxworks".to_string(), - target_env: "gnu".to_string(), - target_vendor: "wrs".to_string(), - linker_flavor: LinkerFlavor::Gcc, - options: TargetOptions { - // feature msync would disable instruction 'fsync' which is not supported by fsl_p1p2 - features: "+secure-plt,+msync,-hard-float".to_string(), - target_mcount: "_mcount".to_string(), - .. base - }, - }) -} diff --git a/src/librustc_target/spec/powerpc_wrs_vxworks_spe.rs b/src/librustc_target/spec/powerpc_wrs_vxworks_spe.rs index 2305b4b7ab84c..90118a1485242 100644 --- a/src/librustc_target/spec/powerpc_wrs_vxworks_spe.rs +++ b/src/librustc_target/spec/powerpc_wrs_vxworks_spe.rs @@ -20,7 +20,6 @@ pub fn target() -> TargetResult { options: TargetOptions { // feature msync would disable instruction 'fsync' which is not supported by fsl_p1p2 features: "+secure-plt,+msync".to_string(), - target_mcount: "_mcount".to_string(), .. base }, }) diff --git a/src/librustc_target/spec/sparc64_unknown_openbsd.rs b/src/librustc_target/spec/sparc64_unknown_openbsd.rs new file mode 100644 index 0000000000000..229e0621e0dc1 --- /dev/null +++ b/src/librustc_target/spec/sparc64_unknown_openbsd.rs @@ -0,0 +1,22 @@ +use crate::spec::{LinkerFlavor, Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::openbsd_base::opts(); + base.cpu = "v9".to_string(); + base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); + base.max_atomic_width = Some(64); + + Ok(Target { + llvm_target: "sparc64-unknown-openbsd".to_string(), + target_endian: "big".to_string(), + target_pointer_width: "64".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "E-m:e-i64:64-n32:64-S128".to_string(), + arch: "sparc64".to_string(), + target_os: "openbsd".to_string(), + target_env: String::new(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} diff --git a/src/librustc_target/spec/vxworks_base.rs b/src/librustc_target/spec/vxworks_base.rs index 6db56c553a9d8..16acd411dca81 100644 --- a/src/librustc_target/spec/vxworks_base.rs +++ b/src/librustc_target/spec/vxworks_base.rs @@ -1,7 +1,11 @@ -use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel}; +use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions}; use std::default::Default; pub fn opts() -> TargetOptions { + let mut args_crt = LinkArgs::new(); + args_crt.insert(LinkerFlavor::Gcc, vec![ + "--static-crt".to_string(), + ]); let mut args = LinkArgs::new(); args.insert(LinkerFlavor::Gcc, vec![ // We want to be able to strip as much executable code as possible @@ -12,30 +16,25 @@ pub fn opts() -> TargetOptions { // following libraries so we're sure to pass it as one of the first // arguments. "-Wl,--as-needed".to_string(), - - // Always enable NX protection when it is available - "-Wl,-z,noexecstack".to_string(), - ]); - - let mut late_lk_args = LinkArgs::new(); - late_lk_args.insert(LinkerFlavor::Gcc, vec![ - "-lnet".to_string(), - "-lunix".to_string(), ]); TargetOptions { - linker: Some("vx-cxx".to_string()), + linker: Some("wr-c++".to_string()), exe_suffix: ".vxe".to_string(), - late_link_args: late_lk_args, dynamic_linking: true, executables: true, target_family: Some("unix".to_string()), linker_is_gnu: true, has_rpath: true, pre_link_args: args, - position_independent_executables: true, - relro_level: RelroLevel::Full, + position_independent_executables: false, has_elf_tls: true, + pre_link_args_crt: args_crt, + crt_static_default: true, + crt_static_respected: true, + crt_static_allows_dylibs: true, + // VxWorks needs to implement this to support profiling + target_mcount: "_mcount".to_string(), .. Default::default() } } diff --git a/src/librustc_target/spec/x86_64_wrs_vxworks.rs b/src/librustc_target/spec/x86_64_wrs_vxworks.rs index eac7cd7502d46..1ab2f3a47c481 100644 --- a/src/librustc_target/spec/x86_64_wrs_vxworks.rs +++ b/src/librustc_target/spec/x86_64_wrs_vxworks.rs @@ -6,6 +6,7 @@ pub fn target() -> TargetResult { base.max_atomic_width = Some(64); base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); base.stack_probes = true; + base.disable_redzone = true; Ok(Target { llvm_target: "x86_64-unknown-linux-gnu".to_string(), diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 5334c4dfc68cc..3288d0b4df2ee 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -23,7 +23,7 @@ libc = { version = "0.2.51", default-features = false, features = ['rustc-dep-of compiler_builtins = { version = "0.1.16" } profiler_builtins = { path = "../libprofiler_builtins", optional = true } unwind = { path = "../libunwind" } -hashbrown = { version = "0.4.0", features = ['rustc-dep-of-std'] } +hashbrown = { version = "0.5.0", features = ['rustc-dep-of-std'] } [dependencies.backtrace] version = "0.3.34" diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 1e28ee8da26b4..a0538986a2242 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -6,7 +6,7 @@ use hashbrown::hash_map as base; use crate::borrow::Borrow; use crate::cell::Cell; -use crate::collections::CollectionAllocErr; +use crate::collections::TryReserveError; use crate::fmt::{self, Debug}; #[allow(deprecated)] use crate::hash::{BuildHasher, Hash, Hasher, SipHasher13}; @@ -588,7 +588,7 @@ where /// ``` #[inline] #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")] - pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> { + pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { self.base .try_reserve(additional) .map_err(map_collection_alloc_err) @@ -2542,10 +2542,13 @@ fn map_entry<'a, K: 'a, V: 'a>(raw: base::RustcEntry<'a, K, V>) -> Entry<'a, K, } #[inline] -fn map_collection_alloc_err(err: hashbrown::CollectionAllocErr) -> CollectionAllocErr { +fn map_collection_alloc_err(err: hashbrown::CollectionAllocErr) -> TryReserveError { match err { - hashbrown::CollectionAllocErr::CapacityOverflow => CollectionAllocErr::CapacityOverflow, - hashbrown::CollectionAllocErr::AllocErr => CollectionAllocErr::AllocErr, + hashbrown::CollectionAllocErr::CapacityOverflow => TryReserveError::CapacityOverflow, + hashbrown::CollectionAllocErr::AllocErr { layout } => TryReserveError::AllocError { + layout, + non_exhaustive: (), + }, } } @@ -2605,7 +2608,7 @@ mod test_map { use super::RandomState; use crate::cell::RefCell; use rand::{thread_rng, Rng}; - use realstd::collections::CollectionAllocErr::*; + use realstd::collections::TryReserveError::*; use realstd::usize; // https://github.com/rust-lang/rust/issues/62301 @@ -3405,7 +3408,7 @@ mod test_map { panic!("usize::MAX should trigger an overflow!"); } - if let Err(AllocErr) = empty_bytes.try_reserve(MAX_USIZE / 8) { + if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_USIZE / 8) { } else { panic!("usize::MAX / 8 should trigger an OOM!") } diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index d243412405a79..26db651ef8911 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -1,5 +1,5 @@ use crate::borrow::Borrow; -use crate::collections::CollectionAllocErr; +use crate::collections::TryReserveError; use crate::fmt; use crate::hash::{Hash, BuildHasher}; use crate::iter::{Chain, FromIterator, FusedIterator}; @@ -383,7 +383,7 @@ impl HashSet /// ``` #[inline] #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] - pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> { + pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { self.map.try_reserve(additional) } diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs index 15c2532f8b4e0..f5957466be841 100644 --- a/src/libstd/collections/mod.rs +++ b/src/libstd/collections/mod.rs @@ -427,7 +427,7 @@ pub use self::hash_map::HashMap; pub use self::hash_set::HashSet; #[unstable(feature = "try_reserve", reason = "new API", issue="48043")] -pub use alloc_crate::collections::CollectionAllocErr; +pub use alloc_crate::collections::TryReserveError; mod hash; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 1f48315d3f8db..c3882bacf87eb 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -228,7 +228,6 @@ // std is implemented with unstable features, many of which are internal // compiler details that will never be stable // NB: the following list is sorted to minimize merge conflicts. -#![feature(__rust_unstable_column)] #![feature(alloc_error_handler)] #![feature(alloc_layout_extra)] #![feature(allocator_api)] @@ -251,6 +250,7 @@ #![feature(concat_idents)] #![feature(const_cstr_unchecked)] #![feature(const_raw_ptr_deref)] +#![feature(container_error_extra)] #![feature(core_intrinsics)] #![feature(custom_test_frameworks)] #![feature(doc_alias)] @@ -550,7 +550,6 @@ pub use core::{ option_env, stringify, // Unstable - __rust_unstable_column, asm, concat_idents, format_args_nl, diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index f2000936b9a21..cbeaf20b13adc 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -53,20 +53,20 @@ /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[allow_internal_unstable(__rust_unstable_column, libstd_sys_internals)] +#[allow_internal_unstable(libstd_sys_internals)] macro_rules! panic { () => ({ $crate::panic!("explicit panic") }); ($msg:expr) => ({ - $crate::rt::begin_panic($msg, &(file!(), line!(), __rust_unstable_column!())) + $crate::rt::begin_panic($msg, &($crate::file!(), $crate::line!(), $crate::column!())) }); ($msg:expr,) => ({ $crate::panic!($msg) }); ($fmt:expr, $($arg:tt)+) => ({ - $crate::rt::begin_panic_fmt(&format_args!($fmt, $($arg)+), - &(file!(), line!(), __rust_unstable_column!())) + $crate::rt::begin_panic_fmt(&$crate::format_args!($fmt, $($arg)+), + &($crate::file!(), $crate::line!(), $crate::column!())) }); } @@ -113,7 +113,7 @@ macro_rules! panic { #[stable(feature = "rust1", since = "1.0.0")] #[allow_internal_unstable(print_internals)] macro_rules! print { - ($($arg:tt)*) => ($crate::io::_print(format_args!($($arg)*))); + ($($arg:tt)*) => ($crate::io::_print($crate::format_args!($($arg)*))); } /// Prints to the standard output, with a newline. @@ -147,7 +147,7 @@ macro_rules! print { macro_rules! println { () => ($crate::print!("\n")); ($($arg:tt)*) => ({ - $crate::io::_print(format_args_nl!($($arg)*)); + $crate::io::_print($crate::format_args_nl!($($arg)*)); }) } @@ -176,7 +176,7 @@ macro_rules! println { #[stable(feature = "eprint", since = "1.19.0")] #[allow_internal_unstable(print_internals)] macro_rules! eprint { - ($($arg:tt)*) => ($crate::io::_eprint(format_args!($($arg)*))); + ($($arg:tt)*) => ($crate::io::_eprint($crate::format_args!($($arg)*))); } /// Prints to the standard error, with a newline. @@ -206,7 +206,7 @@ macro_rules! eprint { macro_rules! eprintln { () => ($crate::eprint!("\n")); ($($arg:tt)*) => ({ - $crate::io::_eprint(format_args_nl!($($arg)*)); + $crate::io::_eprint($crate::format_args_nl!($($arg)*)); }) } @@ -337,7 +337,7 @@ macro_rules! eprintln { #[stable(feature = "dbg_macro", since = "1.32.0")] macro_rules! dbg { () => { - $crate::eprintln!("[{}:{}]", file!(), line!()); + $crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!()); }; ($val:expr) => { // Use of `match` here is intentional because it affects the lifetimes @@ -345,7 +345,7 @@ macro_rules! dbg { match $val { tmp => { $crate::eprintln!("[{}:{}] {} = {:#?}", - file!(), line!(), stringify!($val), &tmp); + $crate::file!(), $crate::line!(), $crate::stringify!($val), &tmp); tmp } } diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs index 752c6202ee489..3e4cf91127fc5 100644 --- a/src/libstd/prelude/v1.rs +++ b/src/libstd/prelude/v1.rs @@ -40,7 +40,6 @@ pub use crate::result::Result::{self, Ok, Err}; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use core::prelude::v1::{ - __rust_unstable_column, asm, assert, cfg, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e7deadbc9a043..dac402921b95c 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -25,7 +25,6 @@ use syntax_pos::{Span, DUMMY_SP, FileName}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; -use std::fs; use std::io::ErrorKind; use std::{iter, mem}; use std::ops::DerefMut; @@ -1241,13 +1240,11 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } let filename = self.cx.resolve_path(&*file.as_str(), it.span()); - match fs::read_to_string(&filename) { - Ok(src) => { - let src_interned = Symbol::intern(&src); - - // Add this input file to the code map to make it available as - // dependency information - self.cx.source_map().new_source_file(filename.into(), src); + match self.cx.source_map().load_file(&filename) { + Ok(source_file) => { + let src = source_file.src.as_ref() + .expect("freshly loaded file should have a source"); + let src_interned = Symbol::intern(src.as_str()); let include_info = vec![ ast::NestedMetaItem::MetaItem( diff --git a/src/libsyntax/source_map.rs b/src/libsyntax/source_map.rs index 940687cb5d4e4..7190cfd72a959 100644 --- a/src/libsyntax/source_map.rs +++ b/src/libsyntax/source_map.rs @@ -171,6 +171,26 @@ impl SourceMap { Ok(self.new_source_file(filename, src)) } + /// Loads source file as a binary blob. + /// + /// Unlike `load_file`, guarantees that no normalization like BOM-removal + /// takes place. + pub fn load_binary_file(&self, path: &Path) -> io::Result> { + // Ideally, this should use `self.file_loader`, but it can't + // deal with binary files yet. + let bytes = fs::read(path)?; + + // We need to add file to the `SourceMap`, so that it is present + // in dep-info. There's also an edge case that file might be both + // loaded as a binary via `include_bytes!` and as proper `SourceFile` + // via `mod`, so we try to use real file contents and not just an + // empty string. + let text = std::str::from_utf8(&bytes).unwrap_or("") + .to_string(); + self.new_source_file(path.to_owned().into(), text); + Ok(bytes) + } + pub fn files(&self) -> MappedLockGuard<'_, Vec>> { LockGuard::map(self.files.borrow(), |files| &mut files.source_files) } diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 3ded808bb358a..4add2261c6cda 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -57,7 +57,6 @@ pub fn register_builtin_macros(resolver: &mut dyn syntax::ext::base::Resolver, e } register_bang! { - __rust_unstable_column: source_util::expand_column, asm: asm::expand_asm, assert: assert::expand_assert, cfg: cfg::expand_cfg, diff --git a/src/libsyntax_ext/source_util.rs b/src/libsyntax_ext/source_util.rs index cbc01b48afd03..e008ed710e4d0 100644 --- a/src/libsyntax_ext/source_util.rs +++ b/src/libsyntax_ext/source_util.rs @@ -9,8 +9,6 @@ use syntax::tokenstream; use smallvec::SmallVec; use syntax_pos::{self, Pos, Span}; -use std::fs; -use std::io::ErrorKind; use rustc_data_structures::sync::Lrc; // These macros all relate to the file system; they either return @@ -114,20 +112,17 @@ pub fn expand_include_str(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::To None => return DummyResult::any(sp) }; let file = cx.resolve_path(file, sp); - match fs::read_to_string(&file) { - Ok(src) => { - let interned_src = Symbol::intern(&src); - - // Add this input file to the code map to make it available as - // dependency information - cx.source_map().new_source_file(file.into(), src); - - base::MacEager::expr(cx.expr_str(sp, interned_src)) + match cx.source_map().load_binary_file(&file) { + Ok(bytes) => match std::str::from_utf8(&bytes) { + Ok(src) => { + let interned_src = Symbol::intern(&src); + base::MacEager::expr(cx.expr_str(sp, interned_src)) + } + Err(_) => { + cx.span_err(sp, &format!("{} wasn't a utf-8 file", file.display())); + DummyResult::any(sp) + } }, - Err(ref e) if e.kind() == ErrorKind::InvalidData => { - cx.span_err(sp, &format!("{} wasn't a utf-8 file", file.display())); - DummyResult::any(sp) - } Err(e) => { cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e)); DummyResult::any(sp) @@ -142,18 +137,8 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream:: None => return DummyResult::any(sp) }; let file = cx.resolve_path(file, sp); - match fs::read(&file) { + match cx.source_map().load_binary_file(&file) { Ok(bytes) => { - // Add the contents to the source map if it contains UTF-8. - let (contents, bytes) = match String::from_utf8(bytes) { - Ok(s) => { - let bytes = s.as_bytes().to_owned(); - (s, bytes) - }, - Err(e) => (String::new(), e.into_bytes()), - }; - cx.source_map().new_source_file(file.into(), contents); - base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Lrc::new(bytes)))) }, Err(e) => { diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index e2d1635f31216..27fc66d3b09e6 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -609,7 +609,6 @@ symbols! { rust_eh_personality, rust_eh_unwind_resume, rust_oom, - __rust_unstable_column, rvalue_static_promotion, sanitizer_runtime, _Self, diff --git a/src/libunwind/build.rs b/src/libunwind/build.rs index a266407c60294..f24d957d67b75 100644 --- a/src/libunwind/build.rs +++ b/src/libunwind/build.rs @@ -23,7 +23,11 @@ fn main() { } else if target.contains("netbsd") { println!("cargo:rustc-link-lib=gcc_s"); } else if target.contains("openbsd") { - println!("cargo:rustc-link-lib=c++abi"); + if target.contains("sparc64") { + println!("cargo:rustc-link-lib=gcc"); + } else { + println!("cargo:rustc-link-lib=c++abi"); + } } else if target.contains("solaris") { println!("cargo:rustc-link-lib=gcc_s"); } else if target.contains("dragonfly") { diff --git a/src/test/ui/.gitattributes b/src/test/ui/.gitattributes index b62ade73aa993..489dc8ad1118c 100644 --- a/src/test/ui/.gitattributes +++ b/src/test/ui/.gitattributes @@ -1,2 +1,3 @@ lexer-crlf-line-endings-string-literal-doc-comment.rs -text trailing-carriage-return-in-string.rs -text +*.bin -text diff --git a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr index fab5892dae183..64fd1a4a78d96 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | ) -> &dyn Foo | ^^^^^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#27r + = note: hidden type `impl std::future::Future` captures lifetime '_#22r error: lifetime may not live long enough --> $DIR/issue-63388-1.rs:15:5 diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr index 1e779208e58a5..dc3fbed593b79 100644 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr +++ b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr @@ -2,7 +2,7 @@ error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:111:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` + | -------- cast requires that `o2` is borrowed for `'static` LL | o1.set0(&o2); | ^^^ borrowed value does not live long enough ... @@ -13,7 +13,7 @@ error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:112:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` + | -------- cast requires that `o3` is borrowed for `'static` LL | o1.set0(&o2); LL | o1.set1(&o3); | ^^^ borrowed value does not live long enough @@ -37,7 +37,7 @@ error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:114:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` + | -------- cast requires that `o3` is borrowed for `'static` ... LL | o2.set1(&o3); | ^^^ borrowed value does not live long enough @@ -49,7 +49,7 @@ error[E0597]: `o1` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:115:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o1` is borrowed for `'static` + | -------- cast requires that `o1` is borrowed for `'static` ... LL | o3.set0(&o1); | ^^^ borrowed value does not live long enough @@ -61,7 +61,7 @@ error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:116:13 | LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` + | -------- cast requires that `o2` is borrowed for `'static` ... LL | o3.set1(&o2); | ^^^ borrowed value does not live long enough diff --git a/src/test/ui/include-macros/data.bin b/src/test/ui/include-macros/data.bin new file mode 100644 index 0000000000000..ce4e0b8311a31 --- /dev/null +++ b/src/test/ui/include-macros/data.bin @@ -0,0 +1,2 @@ +This file starts with BOM. +Lines are separated by \r\n. diff --git a/src/test/ui/include-macros/normalization.rs b/src/test/ui/include-macros/normalization.rs new file mode 100644 index 0000000000000..889f08e606ec9 --- /dev/null +++ b/src/test/ui/include-macros/normalization.rs @@ -0,0 +1,12 @@ +// run-pass + +fn main() { + assert_eq!( + &include_bytes!("data.bin")[..], + &b"\xEF\xBB\xBFThis file starts with BOM.\r\nLines are separated by \\r\\n.\r\n"[..], + ); + assert_eq!( + include_str!("data.bin"), + "\u{FEFF}This file starts with BOM.\r\nLines are separated by \\r\\n.\r\n", + ); +} diff --git a/src/test/ui/macros/trace-macro.stderr b/src/test/ui/macros/trace-macro.stderr index 287f7b297d5c6..202a9235adbac 100644 --- a/src/test/ui/macros/trace-macro.stderr +++ b/src/test/ui/macros/trace-macro.stderr @@ -5,5 +5,5 @@ LL | println!("Hello, World!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expanding `println! { "Hello, World!" }` - = note: to `{ $crate :: io :: _print (format_args_nl ! ("Hello, World!")) ; }` + = note: to `{ $crate :: io :: _print ($crate :: format_args_nl ! ("Hello, World!")) ; }` diff --git a/src/test/ui/rust-unstable-column-gated.rs b/src/test/ui/rust-unstable-column-gated.rs deleted file mode 100644 index 053806ead2d12..0000000000000 --- a/src/test/ui/rust-unstable-column-gated.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - println!("{}", __rust_unstable_column!()); - //~^ ERROR use of unstable library feature '__rust_unstable_column' -} diff --git a/src/test/ui/rust-unstable-column-gated.stderr b/src/test/ui/rust-unstable-column-gated.stderr deleted file mode 100644 index 7db1b01fb0e63..0000000000000 --- a/src/test/ui/rust-unstable-column-gated.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: use of unstable library feature '__rust_unstable_column': internal implementation detail of the `panic` macro - --> $DIR/rust-unstable-column-gated.rs:2:20 - | -LL | println!("{}", __rust_unstable_column!()); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(__rust_unstable_column)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr index 94646c2cfe0c3..e33001b9244da 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:10:50 @@ -30,7 +30,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | ^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:19:62 diff --git a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr index 779b21e21a097..3e58c97301975 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn ref_self(&self, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#28r + = note: hidden type `impl std::future::Future` captures lifetime '_#23r error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:15:47 @@ -24,7 +24,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#28r + = note: hidden type `impl std::future::Future` captures lifetime '_#23r error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:21:53 @@ -44,7 +44,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#28r + = note: hidden type `impl std::future::Future` captures lifetime '_#23r error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:25:62 @@ -64,7 +64,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#28r + = note: hidden type `impl std::future::Future` captures lifetime '_#23r error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:29:62 @@ -84,7 +84,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#28r + = note: hidden type `impl std::future::Future` captures lifetime '_#23r error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:33:71 @@ -104,7 +104,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#28r + = note: hidden type `impl std::future::Future` captures lifetime '_#23r error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:37:67 diff --git a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr index cfe91dde37354..b8a538088109f 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn ref_self(&mut self, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:15:51 @@ -24,7 +24,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:21:57 @@ -44,7 +44,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:25:66 @@ -64,7 +64,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:29:66 @@ -84,7 +84,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:33:75 @@ -104,7 +104,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:37:75 diff --git a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr index 98fa5e2545186..cee008de6671f 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:15:61 @@ -24,7 +24,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:19:70 @@ -44,7 +44,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:23:70 @@ -64,7 +64,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:27:79 @@ -84,7 +84,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:31:79 diff --git a/src/test/ui/self/elision/ref-self-async.nll.stderr b/src/test/ui/self/elision/ref-self-async.nll.stderr index f991f6d9f7fa1..c3c15485b229c 100644 --- a/src/test/ui/self/elision/ref-self-async.nll.stderr +++ b/src/test/ui/self/elision/ref-self-async.nll.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn ref_self(&self, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-self-async.rs:24:47 @@ -24,7 +24,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-self-async.rs:30:53 @@ -44,7 +44,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-self-async.rs:34:62 @@ -64,7 +64,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-self-async.rs:38:62 @@ -84,7 +84,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-self-async.rs:42:71 @@ -104,7 +104,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-self-async.rs:46:71 @@ -124,7 +124,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | ^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-self-async.rs:50:73 diff --git a/src/test/ui/self/elision/ref-struct-async.nll.stderr b/src/test/ui/self/elision/ref-struct-async.nll.stderr index 437d403e044ed..ff50f6825bc6b 100644 --- a/src/test/ui/self/elision/ref-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-struct-async.nll.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:15:57 @@ -24,7 +24,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:19:66 @@ -44,7 +44,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:23:66 @@ -64,7 +64,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:27:75 @@ -84,7 +84,7 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { | ^^^^ | - = note: hidden type `impl std::future::Future` captures lifetime '_#18r + = note: hidden type `impl std::future::Future` captures lifetime '_#15r error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:31:71 diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 05cfdf1ce53bf..3da6be74129f4 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1659,10 +1659,10 @@ impl<'test> TestCx<'test> { _ if self.config.target.contains("vxworks") => { let aux_dir = self.aux_output_dir_name(); let ProcArgs { prog, args } = self.make_run_args(); - let mut vx_run = Command::new("vx-run"); - vx_run.args(&[&prog]).args(args).envs(env.clone()); + let mut wr_run = Command::new("wr-run"); + wr_run.args(&[&prog]).args(args).envs(env.clone()); self.compose_and_run( - vx_run, + wr_run, self.config.run_lib_path.to_str().unwrap(), Some(aux_dir.to_str().unwrap()), None,