Auto merge of #63640 - Centril:rollup-yeb8o66, r=Centril
Rollup of 10 pull requests Successful merges: - #60492 (Add custom nth_back for Chain) - #61780 (Finalize the error type for `try_reserve`) - #63495 ( Remove redundant `ty` fields from `mir::Constant` and `hair::pattern::PatternRange`.) - #63525 (Make sure that all file loading happens via SourceMap) - #63595 (add sparc64-unknown-openbsd target) - #63604 (Some update for vxWorks) - #63613 (Hygienize use of built-in macros in the standard library) - #63632 (A couple of comment fixes.) - #63634 (ci: properly set the job name in CPU stats) - #63636 (ci: move linkcheck from mingw-2 to mingw-1) Failed merges: r? @ghost
This commit is contained in:
commit
bdfd698f37
94 changed files with 378 additions and 550 deletions
12
Cargo.lock
12
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"
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ fn cc2ar(cc: &Path, target: &str) -> Option<PathBuf> {
|
|||
} 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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
||||
/// 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<AllocErr> for CollectionAllocErr {
|
||||
#[inline]
|
||||
fn from(AllocErr: AllocErr) -> Self {
|
||||
CollectionAllocErr::AllocErr
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
|
||||
impl From<LayoutErr> for CollectionAllocErr {
|
||||
impl From<LayoutErr> for TryReserveError {
|
||||
#[inline]
|
||||
fn from(_: LayoutErr) -> Self {
|
||||
CollectionAllocErr::CapacityOverflow
|
||||
TryReserveError::CapacityOverflow
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T> VecDeque<T> {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(try_reserve)]
|
||||
/// use std::collections::CollectionAllocErr;
|
||||
/// use std::collections::TryReserveError;
|
||||
/// use std::collections::VecDeque;
|
||||
///
|
||||
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, CollectionAllocErr> {
|
||||
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, TryReserveError> {
|
||||
/// let mut output = VecDeque::new();
|
||||
///
|
||||
/// // Pre-reserve the memory, exiting if we can't
|
||||
|
|
@ -595,7 +595,7 @@ impl<T> VecDeque<T> {
|
|||
/// # 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<T> VecDeque<T> {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(try_reserve)]
|
||||
/// use std::collections::CollectionAllocErr;
|
||||
/// use std::collections::TryReserveError;
|
||||
/// use std::collections::VecDeque;
|
||||
///
|
||||
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, CollectionAllocErr> {
|
||||
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, TryReserveError> {
|
||||
/// let mut output = VecDeque::new();
|
||||
///
|
||||
/// // Pre-reserve the memory, exiting if we can't
|
||||
|
|
@ -633,12 +633,12 @@ impl<T> VecDeque<T> {
|
|||
/// # 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)?;
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)*)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<T, A: Alloc> RawVec<T, A> {
|
|||
|
||||
/// 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<T, A: Alloc> RawVec<T, A> {
|
|||
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<T, A: Alloc> RawVec<T, A> {
|
|||
/// 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<usize, CollectionAllocErr> {
|
||||
-> Result<usize, TryReserveError> {
|
||||
|
||||
// Nothing we can really do about these checks :(
|
||||
let required_cap = used_capacity.checked_add(needed_extra_capacity)
|
||||
|
|
@ -435,7 +435,7 @@ impl<T, A: Alloc> RawVec<T, A> {
|
|||
|
||||
/// 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<T, A: Alloc> RawVec<T, A> {
|
|||
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<T, A: Alloc> RawVec<T, A> {
|
|||
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<T, A: Alloc> RawVec<T, A> {
|
|||
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<T, A> {
|
|||
// 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::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
|
||||
Err(CapacityOverflow)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -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<String, CollectionAllocErr> {
|
||||
/// fn process_data(data: &str) -> Result<String, TryReserveError> {
|
||||
/// 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<String, CollectionAllocErr> {
|
||||
/// fn process_data(data: &str) -> Result<String, TryReserveError> {
|
||||
/// 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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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<T> Vec<T> {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(try_reserve)]
|
||||
/// use std::collections::CollectionAllocErr;
|
||||
/// use std::collections::TryReserveError;
|
||||
///
|
||||
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, CollectionAllocErr> {
|
||||
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
|
||||
/// let mut output = Vec::new();
|
||||
///
|
||||
/// // Pre-reserve the memory, exiting if we can't
|
||||
|
|
@ -516,7 +516,7 @@ impl<T> Vec<T> {
|
|||
/// # 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<T> Vec<T> {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(try_reserve)]
|
||||
/// use std::collections::CollectionAllocErr;
|
||||
/// use std::collections::TryReserveError;
|
||||
///
|
||||
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, CollectionAllocErr> {
|
||||
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
|
||||
/// let mut output = Vec::new();
|
||||
///
|
||||
/// // Pre-reserve the memory, exiting if we can't
|
||||
|
|
@ -556,7 +556,7 @@ impl<T> Vec<T> {
|
|||
/// # 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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -207,6 +207,29 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn nth_back(&mut self, mut n: usize) -> Option<A::Item> {
|
||||
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<Acc, F, R>(&mut self, init: Acc, mut f: F) -> R where
|
||||
Self: Sized, F: FnMut(Acc, Self::Item) -> R, R: Try<Ok=Acc>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -178,8 +178,7 @@ pub trait MetadataLoader {
|
|||
-> Result<MetadataRef, String>;
|
||||
}
|
||||
|
||||
/// 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!
|
||||
|
|
|
|||
|
|
@ -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::<Vec<_>>`, this would be present and would
|
||||
|
|
@ -3385,12 +3383,11 @@ impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
|
|||
fn super_fold_with<F: TypeFolder<'tcx>>(&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<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
||||
self.ty.visit_with(visitor) || self.literal.visit_with(visitor)
|
||||
self.literal.visit_with(visitor)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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))),
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
inferred_ty: ty,
|
||||
})
|
||||
});
|
||||
assert_eq!(literal.ty, ty);
|
||||
Constant {
|
||||
span,
|
||||
ty,
|
||||
user_ty,
|
||||
literal,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, _) |
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<bool, ErrorReported> {
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<Constant<'tcx>> {
|
||||
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),
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
})))
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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()),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
})
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -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
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -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
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -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
|
||||
},
|
||||
})
|
||||
|
|
|
|||
22
src/librustc_target/spec/sparc64_unknown_openbsd.rs
Normal file
22
src/librustc_target/spec/sparc64_unknown_openbsd.rs
Normal file
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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!")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<T, S> HashSet<T, S>
|
|||
/// ```
|
||||
#[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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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<Vec<u8>> {
|
||||
// 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<Lrc<SourceFile>>> {
|
||||
LockGuard::map(self.files.borrow(), |files| &mut files.source_files)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -609,7 +609,6 @@ symbols! {
|
|||
rust_eh_personality,
|
||||
rust_eh_unwind_resume,
|
||||
rust_oom,
|
||||
__rust_unstable_column,
|
||||
rvalue_static_promotion,
|
||||
sanitizer_runtime,
|
||||
_Self,
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
|
|
|
|||
1
src/test/ui/.gitattributes
vendored
1
src/test/ui/.gitattributes
vendored
|
|
@ -1,2 +1,3 @@
|
|||
lexer-crlf-line-endings-string-literal-doc-comment.rs -text
|
||||
trailing-carriage-return-in-string.rs -text
|
||||
*.bin -text
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (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
|
||||
|
|
|
|||
2
src/test/ui/include-macros/data.bin
Normal file
2
src/test/ui/include-macros/data.bin
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
This file starts with BOM.
|
||||
Lines are separated by \r\n.
|
||||
12
src/test/ui/include-macros/normalization.rs
Normal file
12
src/test/ui/include-macros/normalization.rs
Normal file
|
|
@ -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",
|
||||
);
|
||||
}
|
||||
|
|
@ -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!")) ; }`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
fn main() {
|
||||
println!("{}", __rust_unstable_column!());
|
||||
//~^ ERROR use of unstable library feature '__rust_unstable_column'
|
||||
}
|
||||
|
|
@ -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`.
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<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: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<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:37:67
|
||||
|
|
|
|||
|
|
@ -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<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: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<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:37:75
|
||||
|
|
|
|||
|
|
@ -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<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: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<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:31:79
|
||||
|
|
|
|||
|
|
@ -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<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: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<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: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
|
||||
|
|
|
|||
|
|
@ -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<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: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<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:31:71
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue