diff --git a/Cargo.lock b/Cargo.lock index db2a5f9ec7c34..94cb7f50882e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,7 +17,7 @@ dependencies = [ name = "alloc" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -106,7 +106,7 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -463,7 +463,7 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -748,7 +748,7 @@ name = "dlmalloc" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -906,7 +906,7 @@ name = "fortanix-sgx-abi" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -1739,7 +1739,7 @@ dependencies = [ name = "panic_abort" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1749,7 +1749,7 @@ name = "panic_unwind" version = "0.0.0" dependencies = [ "alloc 0.0.0", - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", "unwind 0.0.0", @@ -1954,7 +1954,7 @@ name = "profiler_builtins" version = "0.0.0" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2485,7 +2485,7 @@ name = "rustc-demangle" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -2585,7 +2585,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2813,7 +2813,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2874,7 +2874,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2990,7 +2990,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -3262,7 +3262,7 @@ dependencies = [ "alloc 0.0.0", "backtrace-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "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)", @@ -3832,7 +3832,7 @@ dependencies = [ name = "unwind" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4028,7 +4028,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc" "checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007" "checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2" -"checksum compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6711d51cb46744dd8305293cc3fbc392aaff7a8f5095a7c4fae1e5113ef07c96" +"checksum compiler_builtins 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d7be038c8f003625c494e97c09bbcef65582b73f6aa86975f5273d8eba4c9d4c" "checksum compiletest_rs 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "56c799b1f7142badf3b047b4c1f2074cc96b6b784fb2432f2ed9c87da0a03749" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887" diff --git a/appveyor.yml b/appveyor.yml index d70ad54b1c812..2abf723de496e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,7 @@ environment: + # This is required for at least an AArch64 compiler in one image, and is also + # going to soon be required for compiling LLVM. + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Preview # By default schannel checks revocation of certificates unlike some other SSL # backends, but we've historically had problems on CI where a revocation @@ -81,7 +84,6 @@ environment: DIST_REQUIRE_ALL_TOOLS: 1 DEPLOY: 1 CI_JOB_NAME: dist-x86_64-msvc - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Preview - RUST_CONFIGURE_ARGS: > --build=i686-pc-windows-msvc --target=i586-pc-windows-msvc diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 74325a69e15ef..9bce142b483f2 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -489,7 +489,7 @@ impl From> for Pin> { } #[stable(feature = "box_from_slice", since = "1.17.0")] -impl<'a, T: Copy> From<&'a [T]> for Box<[T]> { +impl From<&[T]> for Box<[T]> { /// Converts a `&[T]` into a `Box<[T]>` /// /// This conversion allocates on the heap @@ -503,7 +503,7 @@ impl<'a, T: Copy> From<&'a [T]> for Box<[T]> { /// /// println!("{:?}", boxed_slice); /// ``` - fn from(slice: &'a [T]) -> Box<[T]> { + fn from(slice: &[T]) -> Box<[T]> { let mut boxed = unsafe { RawVec::with_capacity(slice.len()).into_box() }; boxed.copy_from_slice(slice); boxed @@ -511,7 +511,7 @@ impl<'a, T: Copy> From<&'a [T]> for Box<[T]> { } #[stable(feature = "box_from_slice", since = "1.17.0")] -impl<'a> From<&'a str> for Box { +impl From<&str> for Box { /// Converts a `&str` into a `Box` /// /// This conversion allocates on the heap @@ -523,7 +523,7 @@ impl<'a> From<&'a str> for Box { /// println!("{}", boxed); /// ``` #[inline] - fn from(s: &'a str) -> Box { + fn from(s: &str) -> Box { unsafe { from_boxed_utf8_unchecked(Box::from(s.as_bytes())) } } } diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 12f75d84211e6..68eecd97ea11a 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1145,7 +1145,7 @@ impl From for Rc { } #[stable(feature = "shared_from_slice", since = "1.21.0")] -impl<'a, T: Clone> From<&'a [T]> for Rc<[T]> { +impl From<&[T]> for Rc<[T]> { #[inline] fn from(v: &[T]) -> Rc<[T]> { >::from_slice(v) @@ -1153,7 +1153,7 @@ impl<'a, T: Clone> From<&'a [T]> for Rc<[T]> { } #[stable(feature = "shared_from_slice", since = "1.21.0")] -impl<'a> From<&'a str> for Rc { +impl From<&str> for Rc { #[inline] fn from(v: &str) -> Rc { let rc = Rc::<[u8]>::from(v.as_bytes()); diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index b714df5d36b6a..a3e2098695f70 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2172,9 +2172,9 @@ impl AsRef<[u8]> for String { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a str> for String { +impl From<&str> for String { #[inline] - fn from(s: &'a str) -> String { + fn from(s: &str) -> String { s.to_owned() } } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index adcd3d84f4832..cd62c3e05244c 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -2182,25 +2182,25 @@ impl AsMut<[T]> for Vec { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: Clone> From<&'a [T]> for Vec { +impl From<&[T]> for Vec { #[cfg(not(test))] - fn from(s: &'a [T]) -> Vec { + fn from(s: &[T]) -> Vec { s.to_vec() } #[cfg(test)] - fn from(s: &'a [T]) -> Vec { + fn from(s: &[T]) -> Vec { crate::slice::to_vec(s) } } #[stable(feature = "vec_from_mut", since = "1.19.0")] -impl<'a, T: Clone> From<&'a mut [T]> for Vec { +impl From<&mut [T]> for Vec { #[cfg(not(test))] - fn from(s: &'a mut [T]) -> Vec { + fn from(s: &mut [T]) -> Vec { s.to_vec() } #[cfg(test)] - fn from(s: &'a mut [T]) -> Vec { + fn from(s: &mut [T]) -> Vec { crate::slice::to_vec(s) } } @@ -2231,8 +2231,8 @@ impl From> for Box<[T]> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a str> for Vec { - fn from(s: &'a str) -> Vec { +impl From<&str> for Vec { + fn from(s: &str) -> Vec { From::from(s.as_bytes()) } } diff --git a/src/libcore/array.rs b/src/libcore/array.rs index 9c6ecc4350246..dcd9ce6dad756 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -139,7 +139,7 @@ macro_rules! array_impls { } #[stable(feature = "try_from", since = "1.34.0")] - impl<'a, T> TryFrom<&'a [T]> for [T; $N] where T: Copy { + impl TryFrom<&[T]> for [T; $N] where T: Copy { type Error = TryFromSliceError; fn try_from(slice: &[T]) -> Result<[T; $N], TryFromSliceError> { diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 81fcdeee12d29..94bed3708369a 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -1004,26 +1004,26 @@ mod impls { // & pointers #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b B> for &'a A where A: PartialEq { + impl PartialEq<&B> for &A where A: PartialEq { #[inline] - fn eq(&self, other: & &'b B) -> bool { PartialEq::eq(*self, *other) } + fn eq(&self, other: & &B) -> bool { PartialEq::eq(*self, *other) } #[inline] - fn ne(&self, other: & &'b B) -> bool { PartialEq::ne(*self, *other) } + fn ne(&self, other: & &B) -> bool { PartialEq::ne(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, 'b, A: ?Sized, B: ?Sized> PartialOrd<&'b B> for &'a A where A: PartialOrd { + impl PartialOrd<&B> for &A where A: PartialOrd { #[inline] - fn partial_cmp(&self, other: &&'b B) -> Option { + fn partial_cmp(&self, other: &&B) -> Option { PartialOrd::partial_cmp(*self, *other) } #[inline] - fn lt(&self, other: & &'b B) -> bool { PartialOrd::lt(*self, *other) } + fn lt(&self, other: & &B) -> bool { PartialOrd::lt(*self, *other) } #[inline] - fn le(&self, other: & &'b B) -> bool { PartialOrd::le(*self, *other) } + fn le(&self, other: & &B) -> bool { PartialOrd::le(*self, *other) } #[inline] - fn ge(&self, other: & &'b B) -> bool { PartialOrd::ge(*self, *other) } + fn ge(&self, other: & &B) -> bool { PartialOrd::ge(*self, *other) } #[inline] - fn gt(&self, other: & &'b B) -> bool { PartialOrd::gt(*self, *other) } + fn gt(&self, other: & &B) -> bool { PartialOrd::gt(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] impl Ord for &A where A: Ord { @@ -1036,26 +1036,26 @@ mod impls { // &mut pointers #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq { + impl PartialEq<&mut B> for &mut A where A: PartialEq { #[inline] - fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) } + fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) } #[inline] - fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) } + fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, 'b, A: ?Sized, B: ?Sized> PartialOrd<&'b mut B> for &'a mut A where A: PartialOrd { + impl PartialOrd<&mut B> for &mut A where A: PartialOrd { #[inline] - fn partial_cmp(&self, other: &&'b mut B) -> Option { + fn partial_cmp(&self, other: &&mut B) -> Option { PartialOrd::partial_cmp(*self, *other) } #[inline] - fn lt(&self, other: &&'b mut B) -> bool { PartialOrd::lt(*self, *other) } + fn lt(&self, other: &&mut B) -> bool { PartialOrd::lt(*self, *other) } #[inline] - fn le(&self, other: &&'b mut B) -> bool { PartialOrd::le(*self, *other) } + fn le(&self, other: &&mut B) -> bool { PartialOrd::le(*self, *other) } #[inline] - fn ge(&self, other: &&'b mut B) -> bool { PartialOrd::ge(*self, *other) } + fn ge(&self, other: &&mut B) -> bool { PartialOrd::ge(*self, *other) } #[inline] - fn gt(&self, other: &&'b mut B) -> bool { PartialOrd::gt(*self, *other) } + fn gt(&self, other: &&mut B) -> bool { PartialOrd::gt(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] impl Ord for &mut A where A: Ord { @@ -1066,18 +1066,18 @@ mod impls { impl Eq for &mut A where A: Eq {} #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a A where A: PartialEq { + impl PartialEq<&mut B> for &A where A: PartialEq { #[inline] - fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) } + fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) } #[inline] - fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) } + fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b B> for &'a mut A where A: PartialEq { + impl PartialEq<&B> for &mut A where A: PartialEq { #[inline] - fn eq(&self, other: &&'b B) -> bool { PartialEq::eq(*self, *other) } + fn eq(&self, other: &&B) -> bool { PartialEq::eq(*self, *other) } #[inline] - fn ne(&self, other: &&'b B) -> bool { PartialEq::ne(*self, *other) } + fn ne(&self, other: &&B) -> bool { PartialEq::ne(*self, *other) } } } diff --git a/src/libcore/internal_macros.rs b/src/libcore/internal_macros.rs index faca785e488c3..b5c20582986b2 100644 --- a/src/libcore/internal_macros.rs +++ b/src/libcore/internal_macros.rs @@ -37,21 +37,21 @@ macro_rules! forward_ref_binop { } #[$attr] - impl<'a> $imp<&'a $u> for $t { + impl $imp<&$u> for $t { type Output = <$t as $imp<$u>>::Output; #[inline] - fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output { + fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output { $imp::$method(self, *other) } } #[$attr] - impl<'a, 'b> $imp<&'a $u> for &'b $t { + impl $imp<&$u> for &$t { type Output = <$t as $imp<$u>>::Output; #[inline] - fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output { + fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output { $imp::$method(*self, *other) } } @@ -67,9 +67,9 @@ macro_rules! forward_ref_op_assign { }; (impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => { #[$attr] - impl<'a> $imp<&'a $u> for $t { + impl $imp<&$u> for $t { #[inline] - fn $method(&mut self, other: &'a $u) { + fn $method(&mut self, other: &$u) { $imp::$method(self, *other); } } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 98b5fcd3ee4f0..92688db7c15bc 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1979,10 +1979,10 @@ When starting from a slice rather than an array, fallible conversion APIs can be ``` use std::convert::TryInto; -fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " { +fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " { let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">()); *input = rest; - ", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap()) + ", stringify!($SelfT), "::from_le_bytes(int_bytes.try_into().unwrap()) } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] @@ -2020,10 +2020,10 @@ When starting from a slice rather than an array, fallible conversion APIs can be ``` use std::convert::TryInto; -fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " { +fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " { let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">()); *input = rest; - ", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap()) + ", stringify!($SelfT), "::from_ne_bytes(int_bytes.try_into().unwrap()) } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] @@ -3695,10 +3695,10 @@ When starting from a slice rather than an array, fallible conversion APIs can be ``` use std::convert::TryInto; -fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " { +fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " { let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">()); *input = rest; - ", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap()) + ", stringify!($SelfT), "::from_le_bytes(int_bytes.try_into().unwrap()) } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] @@ -3736,10 +3736,10 @@ When starting from a slice rather than an array, fallible conversion APIs can be ``` use std::convert::TryInto; -fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " { +fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " { let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">()); *input = rest; - ", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap()) + ", stringify!($SelfT), "::from_ne_bytes(int_bytes.try_into().unwrap()) } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 53d4197603068..a9a029d606d6f 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2837,15 +2837,15 @@ impl fmt::Pointer for Unique { } #[unstable(feature = "ptr_internals", issue = "0")] -impl<'a, T: ?Sized> From<&'a mut T> for Unique { - fn from(reference: &'a mut T) -> Self { +impl From<&mut T> for Unique { + fn from(reference: &mut T) -> Self { unsafe { Unique { pointer: reference as *mut T, _marker: PhantomData } } } } #[unstable(feature = "ptr_internals", issue = "0")] -impl<'a, T: ?Sized> From<&'a T> for Unique { - fn from(reference: &'a T) -> Self { +impl From<&T> for Unique { + fn from(reference: &T) -> Self { unsafe { Unique { pointer: reference as *const T, _marker: PhantomData } } } } @@ -2874,6 +2874,16 @@ impl<'a, T: ?Sized> From> for Unique { /// Usually this won't be necessary; covariance is correct for most safe abstractions, /// such as Box, Rc, Arc, Vec, and LinkedList. This is the case because they /// provide a public API that follows the normal shared XOR mutable rules of Rust. +/// +/// Notice that `NonNull` has a `From` instance for `&T`. However, this does +/// not change the fact that mutating through a (pointer derived from a) shared +/// reference is undefined behavior unless the mutation happens inside an +/// [`UnsafeCell`]. The same goes for creating a mutable reference from a shared +/// reference. When using this `From` instance without an `UnsafeCell`, +/// it is your responsibility to ensure that `as_mut` is never called, and `as_ptr` +/// is never used for mutation. +/// +/// [`UnsafeCell`]: ../cell/struct.UnsafeCell.html #[stable(feature = "nonnull", since = "1.25.0")] #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(1)] @@ -3049,17 +3059,17 @@ impl From> for NonNull { } #[stable(feature = "nonnull", since = "1.25.0")] -impl<'a, T: ?Sized> From<&'a mut T> for NonNull { +impl From<&mut T> for NonNull { #[inline] - fn from(reference: &'a mut T) -> Self { + fn from(reference: &mut T) -> Self { unsafe { NonNull { pointer: reference as *mut T } } } } #[stable(feature = "nonnull", since = "1.25.0")] -impl<'a, T: ?Sized> From<&'a T> for NonNull { +impl From<&T> for NonNull { #[inline] - fn from(reference: &'a T) -> Self { + fn from(reference: &T) -> Self { unsafe { NonNull { pointer: reference as *const T } } } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 92d29f6ee8a30..2bd6b536301e8 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -1200,7 +1200,7 @@ impl> FromIterator> for Result { /// let res: Result, &'static str> = v.iter().map(|x: &u32| /// x.checked_add(1).ok_or("Overflow!") /// ).collect(); - /// assert!(res == Ok(vec![2, 3])); + /// assert_eq!(res, Ok(vec![2, 3])); /// ``` #[inline] fn from_iter>>(iter: I) -> Result { diff --git a/src/libcore/tests/fmt/num.rs b/src/libcore/tests/fmt/num.rs index 6d9494ec289aa..10fcf8b76ccb4 100644 --- a/src/libcore/tests/fmt/num.rs +++ b/src/libcore/tests/fmt/num.rs @@ -3,146 +3,146 @@ fn test_format_int() { // Formatting integers should select the right implementation based off // the type of the argument. Also, hex/octal/binary should be defined // for integers, but they shouldn't emit the negative sign. - assert!(format!("{}", 1isize) == "1"); - assert!(format!("{}", 1i8) == "1"); - assert!(format!("{}", 1i16) == "1"); - assert!(format!("{}", 1i32) == "1"); - assert!(format!("{}", 1i64) == "1"); - assert!(format!("{}", -1isize) == "-1"); - assert!(format!("{}", -1i8) == "-1"); - assert!(format!("{}", -1i16) == "-1"); - assert!(format!("{}", -1i32) == "-1"); - assert!(format!("{}", -1i64) == "-1"); - assert!(format!("{:?}", 1isize) == "1"); - assert!(format!("{:?}", 1i8) == "1"); - assert!(format!("{:?}", 1i16) == "1"); - assert!(format!("{:?}", 1i32) == "1"); - assert!(format!("{:?}", 1i64) == "1"); - assert!(format!("{:b}", 1isize) == "1"); - assert!(format!("{:b}", 1i8) == "1"); - assert!(format!("{:b}", 1i16) == "1"); - assert!(format!("{:b}", 1i32) == "1"); - assert!(format!("{:b}", 1i64) == "1"); - assert!(format!("{:x}", 1isize) == "1"); - assert!(format!("{:x}", 1i8) == "1"); - assert!(format!("{:x}", 1i16) == "1"); - assert!(format!("{:x}", 1i32) == "1"); - assert!(format!("{:x}", 1i64) == "1"); - assert!(format!("{:X}", 1isize) == "1"); - assert!(format!("{:X}", 1i8) == "1"); - assert!(format!("{:X}", 1i16) == "1"); - assert!(format!("{:X}", 1i32) == "1"); - assert!(format!("{:X}", 1i64) == "1"); - assert!(format!("{:o}", 1isize) == "1"); - assert!(format!("{:o}", 1i8) == "1"); - assert!(format!("{:o}", 1i16) == "1"); - assert!(format!("{:o}", 1i32) == "1"); - assert!(format!("{:o}", 1i64) == "1"); + assert_eq!(format!("{}", 1isize), "1"); + assert_eq!(format!("{}", 1i8), "1"); + assert_eq!(format!("{}", 1i16), "1"); + assert_eq!(format!("{}", 1i32), "1"); + assert_eq!(format!("{}", 1i64), "1"); + assert_eq!(format!("{}", -1isize), "-1"); + assert_eq!(format!("{}", -1i8), "-1"); + assert_eq!(format!("{}", -1i16), "-1"); + assert_eq!(format!("{}", -1i32), "-1"); + assert_eq!(format!("{}", -1i64), "-1"); + assert_eq!(format!("{:?}", 1isize), "1"); + assert_eq!(format!("{:?}", 1i8), "1"); + assert_eq!(format!("{:?}", 1i16), "1"); + assert_eq!(format!("{:?}", 1i32), "1"); + assert_eq!(format!("{:?}", 1i64), "1"); + assert_eq!(format!("{:b}", 1isize), "1"); + assert_eq!(format!("{:b}", 1i8), "1"); + assert_eq!(format!("{:b}", 1i16), "1"); + assert_eq!(format!("{:b}", 1i32), "1"); + assert_eq!(format!("{:b}", 1i64), "1"); + assert_eq!(format!("{:x}", 1isize), "1"); + assert_eq!(format!("{:x}", 1i8), "1"); + assert_eq!(format!("{:x}", 1i16), "1"); + assert_eq!(format!("{:x}", 1i32), "1"); + assert_eq!(format!("{:x}", 1i64), "1"); + assert_eq!(format!("{:X}", 1isize), "1"); + assert_eq!(format!("{:X}", 1i8), "1"); + assert_eq!(format!("{:X}", 1i16), "1"); + assert_eq!(format!("{:X}", 1i32), "1"); + assert_eq!(format!("{:X}", 1i64), "1"); + assert_eq!(format!("{:o}", 1isize), "1"); + assert_eq!(format!("{:o}", 1i8), "1"); + assert_eq!(format!("{:o}", 1i16), "1"); + assert_eq!(format!("{:o}", 1i32), "1"); + assert_eq!(format!("{:o}", 1i64), "1"); - assert!(format!("{}", 1usize) == "1"); - assert!(format!("{}", 1u8) == "1"); - assert!(format!("{}", 1u16) == "1"); - assert!(format!("{}", 1u32) == "1"); - assert!(format!("{}", 1u64) == "1"); - assert!(format!("{:?}", 1usize) == "1"); - assert!(format!("{:?}", 1u8) == "1"); - assert!(format!("{:?}", 1u16) == "1"); - assert!(format!("{:?}", 1u32) == "1"); - assert!(format!("{:?}", 1u64) == "1"); - assert!(format!("{:b}", 1usize) == "1"); - assert!(format!("{:b}", 1u8) == "1"); - assert!(format!("{:b}", 1u16) == "1"); - assert!(format!("{:b}", 1u32) == "1"); - assert!(format!("{:b}", 1u64) == "1"); - assert!(format!("{:x}", 1usize) == "1"); - assert!(format!("{:x}", 1u8) == "1"); - assert!(format!("{:x}", 1u16) == "1"); - assert!(format!("{:x}", 1u32) == "1"); - assert!(format!("{:x}", 1u64) == "1"); - assert!(format!("{:X}", 1usize) == "1"); - assert!(format!("{:X}", 1u8) == "1"); - assert!(format!("{:X}", 1u16) == "1"); - assert!(format!("{:X}", 1u32) == "1"); - assert!(format!("{:X}", 1u64) == "1"); - assert!(format!("{:o}", 1usize) == "1"); - assert!(format!("{:o}", 1u8) == "1"); - assert!(format!("{:o}", 1u16) == "1"); - assert!(format!("{:o}", 1u32) == "1"); - assert!(format!("{:o}", 1u64) == "1"); + assert_eq!(format!("{}", 1usize), "1"); + assert_eq!(format!("{}", 1u8), "1"); + assert_eq!(format!("{}", 1u16), "1"); + assert_eq!(format!("{}", 1u32), "1"); + assert_eq!(format!("{}", 1u64), "1"); + assert_eq!(format!("{:?}", 1usize), "1"); + assert_eq!(format!("{:?}", 1u8), "1"); + assert_eq!(format!("{:?}", 1u16), "1"); + assert_eq!(format!("{:?}", 1u32), "1"); + assert_eq!(format!("{:?}", 1u64), "1"); + assert_eq!(format!("{:b}", 1usize), "1"); + assert_eq!(format!("{:b}", 1u8), "1"); + assert_eq!(format!("{:b}", 1u16), "1"); + assert_eq!(format!("{:b}", 1u32), "1"); + assert_eq!(format!("{:b}", 1u64), "1"); + assert_eq!(format!("{:x}", 1usize), "1"); + assert_eq!(format!("{:x}", 1u8), "1"); + assert_eq!(format!("{:x}", 1u16), "1"); + assert_eq!(format!("{:x}", 1u32), "1"); + assert_eq!(format!("{:x}", 1u64), "1"); + assert_eq!(format!("{:X}", 1usize), "1"); + assert_eq!(format!("{:X}", 1u8), "1"); + assert_eq!(format!("{:X}", 1u16), "1"); + assert_eq!(format!("{:X}", 1u32), "1"); + assert_eq!(format!("{:X}", 1u64), "1"); + assert_eq!(format!("{:o}", 1usize), "1"); + assert_eq!(format!("{:o}", 1u8), "1"); + assert_eq!(format!("{:o}", 1u16), "1"); + assert_eq!(format!("{:o}", 1u32), "1"); + assert_eq!(format!("{:o}", 1u64), "1"); // Test a larger number - assert!(format!("{:b}", 55) == "110111"); - assert!(format!("{:o}", 55) == "67"); - assert!(format!("{}", 55) == "55"); - assert!(format!("{:x}", 55) == "37"); - assert!(format!("{:X}", 55) == "37"); + assert_eq!(format!("{:b}", 55), "110111"); + assert_eq!(format!("{:o}", 55), "67"); + assert_eq!(format!("{}", 55), "55"); + assert_eq!(format!("{:x}", 55), "37"); + assert_eq!(format!("{:X}", 55), "37"); } #[test] fn test_format_int_zero() { - assert!(format!("{}", 0) == "0"); - assert!(format!("{:?}", 0) == "0"); - assert!(format!("{:b}", 0) == "0"); - assert!(format!("{:o}", 0) == "0"); - assert!(format!("{:x}", 0) == "0"); - assert!(format!("{:X}", 0) == "0"); + assert_eq!(format!("{}", 0), "0"); + assert_eq!(format!("{:?}", 0), "0"); + assert_eq!(format!("{:b}", 0), "0"); + assert_eq!(format!("{:o}", 0), "0"); + assert_eq!(format!("{:x}", 0), "0"); + assert_eq!(format!("{:X}", 0), "0"); - assert!(format!("{}", 0u32) == "0"); - assert!(format!("{:?}", 0u32) == "0"); - assert!(format!("{:b}", 0u32) == "0"); - assert!(format!("{:o}", 0u32) == "0"); - assert!(format!("{:x}", 0u32) == "0"); - assert!(format!("{:X}", 0u32) == "0"); + assert_eq!(format!("{}", 0u32), "0"); + assert_eq!(format!("{:?}", 0u32), "0"); + assert_eq!(format!("{:b}", 0u32), "0"); + assert_eq!(format!("{:o}", 0u32), "0"); + assert_eq!(format!("{:x}", 0u32), "0"); + assert_eq!(format!("{:X}", 0u32), "0"); } #[test] fn test_format_int_flags() { - assert!(format!("{:3}", 1) == " 1"); - assert!(format!("{:>3}", 1) == " 1"); - assert!(format!("{:>+3}", 1) == " +1"); - assert!(format!("{:<3}", 1) == "1 "); - assert!(format!("{:#}", 1) == "1"); - assert!(format!("{:#x}", 10) == "0xa"); - assert!(format!("{:#X}", 10) == "0xA"); - assert!(format!("{:#5x}", 10) == " 0xa"); - assert!(format!("{:#o}", 10) == "0o12"); - assert!(format!("{:08x}", 10) == "0000000a"); - assert!(format!("{:8x}", 10) == " a"); - assert!(format!("{:<8x}", 10) == "a "); - assert!(format!("{:>8x}", 10) == " a"); - assert!(format!("{:#08x}", 10) == "0x00000a"); - assert!(format!("{:08}", -10) == "-0000010"); - assert!(format!("{:x}", !0u8) == "ff"); - assert!(format!("{:X}", !0u8) == "FF"); - assert!(format!("{:b}", !0u8) == "11111111"); - assert!(format!("{:o}", !0u8) == "377"); - assert!(format!("{:#x}", !0u8) == "0xff"); - assert!(format!("{:#X}", !0u8) == "0xFF"); - assert!(format!("{:#b}", !0u8) == "0b11111111"); - assert!(format!("{:#o}", !0u8) == "0o377"); + assert_eq!(format!("{:3}", 1), " 1"); + assert_eq!(format!("{:>3}", 1), " 1"); + assert_eq!(format!("{:>+3}", 1), " +1"); + assert_eq!(format!("{:<3}", 1), "1 "); + assert_eq!(format!("{:#}", 1), "1"); + assert_eq!(format!("{:#x}", 10), "0xa"); + assert_eq!(format!("{:#X}", 10), "0xA"); + assert_eq!(format!("{:#5x}", 10), " 0xa"); + assert_eq!(format!("{:#o}", 10), "0o12"); + assert_eq!(format!("{:08x}", 10), "0000000a"); + assert_eq!(format!("{:8x}", 10), " a"); + assert_eq!(format!("{:<8x}", 10), "a "); + assert_eq!(format!("{:>8x}", 10), " a"); + assert_eq!(format!("{:#08x}", 10), "0x00000a"); + assert_eq!(format!("{:08}", -10), "-0000010"); + assert_eq!(format!("{:x}", !0u8), "ff"); + assert_eq!(format!("{:X}", !0u8), "FF"); + assert_eq!(format!("{:b}", !0u8), "11111111"); + assert_eq!(format!("{:o}", !0u8), "377"); + assert_eq!(format!("{:#x}", !0u8), "0xff"); + assert_eq!(format!("{:#X}", !0u8), "0xFF"); + assert_eq!(format!("{:#b}", !0u8), "0b11111111"); + assert_eq!(format!("{:#o}", !0u8), "0o377"); } #[test] fn test_format_int_sign_padding() { - assert!(format!("{:+5}", 1) == " +1"); - assert!(format!("{:+5}", -1) == " -1"); - assert!(format!("{:05}", 1) == "00001"); - assert!(format!("{:05}", -1) == "-0001"); - assert!(format!("{:+05}", 1) == "+0001"); - assert!(format!("{:+05}", -1) == "-0001"); + assert_eq!(format!("{:+5}", 1), " +1"); + assert_eq!(format!("{:+5}", -1), " -1"); + assert_eq!(format!("{:05}", 1), "00001"); + assert_eq!(format!("{:05}", -1), "-0001"); + assert_eq!(format!("{:+05}", 1), "+0001"); + assert_eq!(format!("{:+05}", -1), "-0001"); } #[test] fn test_format_int_twos_complement() { - use core::{i8, i16, i32, i64}; - assert!(format!("{}", i8::MIN) == "-128"); - assert!(format!("{}", i16::MIN) == "-32768"); - assert!(format!("{}", i32::MIN) == "-2147483648"); - assert!(format!("{}", i64::MIN) == "-9223372036854775808"); + use core::{i16, i32, i64, i8}; + assert_eq!(format!("{}", i8::MIN), "-128"); + assert_eq!(format!("{}", i16::MIN), "-32768"); + assert_eq!(format!("{}", i32::MIN), "-2147483648"); + assert_eq!(format!("{}", i64::MIN), "-9223372036854775808"); } #[test] fn test_format_debug_hex() { - assert!(format!("{:02x?}", b"Foo\0") == "[46, 6f, 6f, 00]"); - assert!(format!("{:02X?}", b"Foo\0") == "[46, 6F, 6F, 00]"); + assert_eq!(format!("{:02x?}", b"Foo\0"), "[46, 6f, 6f, 00]"); + assert_eq!(format!("{:02X?}", b"Foo\0"), "[46, 6F, 6F, 00]"); } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index b705968ce8aed..08b595c5eaa5a 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1443,16 +1443,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - // This method exercises the `in_scope_traits_map` query for all possible - // values so that we have their fingerprints available in the DepGraph. - // This is only required as long as we still use the old dependency tracking - // which needs to have the fingerprints of all input nodes beforehand. - pub fn precompute_in_scope_traits_hashes(self) { - for &def_index in self.trait_map.keys() { - self.in_scope_traits_map(def_index); - } - } - pub fn serialize_query_result_cache(self, encoder: &mut E) -> Result<(), E::Error> diff --git a/src/librustc_codegen_llvm/debuginfo/doc.rs b/src/librustc_codegen_llvm/debuginfo/doc.rs index cf18b995b61da..daccfc9b242f9 100644 --- a/src/librustc_codegen_llvm/debuginfo/doc.rs +++ b/src/librustc_codegen_llvm/debuginfo/doc.rs @@ -1,13 +1,13 @@ //! # Debug Info Module //! //! This module serves the purpose of generating debug symbols. We use LLVM's -//! [source level debugging](http://!llvm.org/docs/SourceLevelDebugging.html) +//! [source level debugging](https://llvm.org/docs/SourceLevelDebugging.html) //! features for generating the debug information. The general principle is //! this: //! //! Given the right metadata in the LLVM IR, the LLVM code generator is able to //! create DWARF debug symbols for the given code. The -//! [metadata](http://!llvm.org/docs/LangRef.html#metadata-type) is structured +//! [metadata](https://llvm.org/docs/LangRef.html#metadata-type) is structured //! much like DWARF *debugging information entries* (DIE), representing type //! information such as datatype layout, function signatures, block layout, //! variable location and scope information, etc. It is the purpose of this @@ -15,7 +15,7 @@ //! //! As the exact format of metadata trees may change between different LLVM //! versions, we now use LLVM -//! [DIBuilder](http://!llvm.org/docs/doxygen/html/classllvm_1_1DIBuilder.html) +//! [DIBuilder](https://llvm.org/docs/doxygen/html/classllvm_1_1DIBuilder.html) //! to create metadata where possible. This will hopefully ease the adaption of //! this module to future LLVM versions. //! diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index 4295034692958..255a3899d1183 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -21,7 +21,6 @@ pub fn dep_graph_tcx_init<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { } tcx.allocate_metadata_dep_nodes(); - tcx.precompute_in_scope_traits_hashes(); } type WorkProductMap = FxHashMap; diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index 01f8cbfbe8e2b..d60a0941b5979 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -19,6 +19,7 @@ use rustc::ty; use rustc::ty::layout::{Integer, IntegerExt, Size}; use syntax::attr::{SignedInt, UnsignedInt}; use rustc::hir::RangeEnd; +use rustc::mir::interpret::truncate; use std::mem; @@ -115,14 +116,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ty::Int(ity) => { // FIXME(49937): refactor these bit manipulations into interpret. let size = Integer::from_attr(&tcx, SignedInt(ity)).size(); - let max = !0u128 >> (128 - size.bits()); + let max = truncate(u128::max_value(), size); let bias = 1u128 << (size.bits() - 1); (Some((0, max, size)), bias) } ty::Uint(uty) => { // FIXME(49937): refactor these bit manipulations into interpret. let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size(); - let max = !0u128 >> (128 - size.bits()); + let max = truncate(u128::max_value(), size); (Some((0, max, size)), 0) } _ => (None, 0), diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 8a599c11b2095..f2111f2d9e028 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -850,7 +850,7 @@ impl Default for HashSet } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, T, S> BitOr<&'b HashSet> for &'a HashSet +impl BitOr<&HashSet> for &HashSet where T: Eq + Hash + Clone, S: BuildHasher + Default { @@ -882,7 +882,7 @@ impl<'a, 'b, T, S> BitOr<&'b HashSet> for &'a HashSet } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, T, S> BitAnd<&'b HashSet> for &'a HashSet +impl BitAnd<&HashSet> for &HashSet where T: Eq + Hash + Clone, S: BuildHasher + Default { @@ -914,7 +914,7 @@ impl<'a, 'b, T, S> BitAnd<&'b HashSet> for &'a HashSet } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, T, S> BitXor<&'b HashSet> for &'a HashSet +impl BitXor<&HashSet> for &HashSet where T: Eq + Hash + Clone, S: BuildHasher + Default { @@ -946,7 +946,7 @@ impl<'a, 'b, T, S> BitXor<&'b HashSet> for &'a HashSet } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, T, S> Sub<&'b HashSet> for &'a HashSet +impl Sub<&HashSet> for &HashSet where T: Eq + Hash + Clone, S: BuildHasher + Default { diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 2858308e8f8d5..3eb289501cb0f 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -337,7 +337,7 @@ impl From for Box { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b> From<&'b str> for Box { +impl<'a> From<&str> for Box { /// Converts a [`str`] into a box of dyn [`Error`] + [`Send`] + [`Sync`]. /// /// # Examples @@ -351,13 +351,13 @@ impl<'a, 'b> From<&'b str> for Box { /// assert!( /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` - fn from(err: &'b str) -> Box { + fn from(err: &str) -> Box { From::from(String::from(err)) } } #[stable(feature = "string_box_error", since = "1.6.0")] -impl<'a> From<&'a str> for Box { +impl From<&str> for Box { /// Converts a [`str`] into a box of dyn [`Error`]. /// /// # Examples @@ -370,7 +370,7 @@ impl<'a> From<&'a str> for Box { /// let a_boxed_error = Box::::from(a_str_error); /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` - fn from(err: &'a str) -> Box { + fn from(err: &str) -> Box { From::from(String::from(err)) } } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 139680e526fd6..ad3f45bfadaf4 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -690,8 +690,8 @@ impl<'a> From> for CString { } #[stable(feature = "box_from_c_str", since = "1.17.0")] -impl<'a> From<&'a CStr> for Box { - fn from(s: &'a CStr) -> Box { +impl From<&CStr> for Box { + fn from(s: &CStr) -> Box { let boxed: Box<[u8]> = Box::from(s.to_bytes_with_nul()); unsafe { Box::from_raw(Box::into_raw(boxed) as *mut CStr) } } @@ -767,7 +767,7 @@ impl From for Arc { } #[stable(feature = "shared_from_slice2", since = "1.24.0")] -impl<'a> From<&'a CStr> for Arc { +impl From<&CStr> for Arc { #[inline] fn from(s: &CStr) -> Arc { let arc: Arc<[u8]> = Arc::from(s.to_bytes_with_nul()); @@ -789,7 +789,7 @@ impl From for Rc { } #[stable(feature = "shared_from_slice2", since = "1.24.0")] -impl<'a> From<&'a CStr> for Rc { +impl From<&CStr> for Rc { #[inline] fn from(s: &CStr) -> Rc { let rc: Rc<[u8]> = Rc::from(s.to_bytes_with_nul()); @@ -1268,8 +1268,8 @@ impl ToOwned for CStr { } #[stable(feature = "cstring_asref", since = "1.7.0")] -impl<'a> From<&'a CStr> for CString { - fn from(s: &'a CStr) -> CString { +impl From<&CStr> for CString { + fn from(s: &CStr) -> CString { s.to_owned() } } diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index f68eaeb9c7e1f..3a0590021c917 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -357,8 +357,8 @@ impl From for OsString { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized + AsRef> From<&'a T> for OsString { - fn from(s: &'a T) -> OsString { +impl> From<&T> for OsString { + fn from(s: &T) -> OsString { s.as_ref().to_os_string() } } @@ -421,8 +421,8 @@ impl PartialEq for str { } #[stable(feature = "os_str_str_ref_eq", since = "1.29.0")] -impl<'a> PartialEq<&'a str> for OsString { - fn eq(&self, other: &&'a str) -> bool { +impl PartialEq<&str> for OsString { + fn eq(&self, other: &&str) -> bool { **self == **other } } @@ -656,8 +656,8 @@ impl OsStr { } #[stable(feature = "box_from_os_str", since = "1.17.0")] -impl<'a> From<&'a OsStr> for Box { - fn from(s: &'a OsStr) -> Box { +impl From<&OsStr> for Box { + fn from(s: &OsStr) -> Box { let rw = Box::into_raw(s.inner.into_box()) as *mut OsStr; unsafe { Box::from_raw(rw) } } @@ -707,7 +707,7 @@ impl From for Arc { } #[stable(feature = "shared_from_slice2", since = "1.24.0")] -impl<'a> From<&'a OsStr> for Arc { +impl From<&OsStr> for Arc { #[inline] fn from(s: &OsStr) -> Arc { let arc = s.inner.into_arc(); @@ -729,7 +729,7 @@ impl From for Rc { } #[stable(feature = "shared_from_slice2", since = "1.24.0")] -impl<'a> From<&'a OsStr> for Rc { +impl From<&OsStr> for Rc { #[inline] fn from(s: &OsStr) -> Rc { let rc = s.inner.into_rc(); diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 858a5778b8161..ea3fcd8ce2859 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1456,8 +1456,8 @@ impl PathBuf { } #[stable(feature = "box_from_path", since = "1.17.0")] -impl<'a> From<&'a Path> for Box { - fn from(path: &'a Path) -> Box { +impl From<&Path> for Box { + fn from(path: &Path) -> Box { let boxed: Box = path.inner.into(); let rw = Box::into_raw(boxed) as *mut Path; unsafe { Box::from_raw(rw) } @@ -1494,8 +1494,8 @@ impl Clone for Box { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized + AsRef> From<&'a T> for PathBuf { - fn from(s: &'a T) -> PathBuf { +impl> From<&T> for PathBuf { + fn from(s: &T) -> PathBuf { PathBuf::from(s.as_ref().to_os_string()) } } @@ -1630,7 +1630,7 @@ impl From for Arc { } #[stable(feature = "shared_from_slice2", since = "1.24.0")] -impl<'a> From<&'a Path> for Arc { +impl From<&Path> for Arc { /// Converts a Path into a Rc by copying the Path data into a new Rc buffer. #[inline] fn from(s: &Path) -> Arc { @@ -1650,7 +1650,7 @@ impl From for Rc { } #[stable(feature = "shared_from_slice2", since = "1.24.0")] -impl<'a> From<&'a Path> for Rc { +impl From<&Path> for Rc { /// Converts a Path into a Rc by copying the Path data into a new Rc buffer. #[inline] fn from(s: &Path) -> Rc { diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs index 50d72dc7b240b..6d2a4962ab444 100644 --- a/src/libstd/sys/cloudabi/shims/net.rs +++ b/src/libstd/sys/cloudabi/shims/net.rs @@ -297,10 +297,10 @@ impl Iterator for LookupHost { } } -impl<'a> TryFrom<&'a str> for LookupHost { +impl TryFrom<&str> for LookupHost { type Error = io::Error; - fn try_from(_v: &'a str) -> io::Result { + fn try_from(_v: &str) -> io::Result { unsupported() } } diff --git a/src/libstd/sys/redox/net/mod.rs b/src/libstd/sys/redox/net/mod.rs index a172763f61313..dbaa140ed8a0f 100644 --- a/src/libstd/sys/redox/net/mod.rs +++ b/src/libstd/sys/redox/net/mod.rs @@ -35,7 +35,7 @@ impl Iterator for LookupHost { } } -impl<'a> TryFrom<&'a str> for LookupHost { +impl TryFrom<&str> for LookupHost { type Error = io::Error; fn try_from(s: &str) -> io::Result { diff --git a/src/libstd/sys/sgx/net.rs b/src/libstd/sys/sgx/net.rs index ab8b2681393f8..e5e42e3d0b048 100644 --- a/src/libstd/sys/sgx/net.rs +++ b/src/libstd/sys/sgx/net.rs @@ -420,10 +420,10 @@ impl Iterator for LookupHost { } } -impl<'a> TryFrom<&'a str> for LookupHost { +impl TryFrom<&str> for LookupHost { type Error = io::Error; - fn try_from(v: &'a str) -> io::Result { + fn try_from(v: &str) -> io::Result { LookupHost::new(v.to_owned()) } } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 3b80b475a93db..06d1a9cf02dd0 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -827,27 +827,51 @@ pub fn canonicalize(p: &Path) -> io::Result { Ok(PathBuf::from(OsString::from_vec(buf))) } +fn open_and_set_permissions( + from: &Path, + to: &Path, +) -> io::Result<(crate::fs::File, crate::fs::File, u64)> { + use crate::fs::{File, OpenOptions}; + use crate::os::unix::fs::{OpenOptionsExt, PermissionsExt}; + + let reader = File::open(from)?; + let (perm, len) = { + let metadata = reader.metadata()?; + if !metadata.is_file() { + return Err(Error::new( + ErrorKind::InvalidInput, + "the source path is not an existing regular file", + )); + } + (metadata.permissions(), metadata.len()) + }; + let writer = OpenOptions::new() + // create the file with the correct mode right away + .mode(perm.mode()) + .write(true) + .create(true) + .truncate(true) + .open(to)?; + let writer_metadata = writer.metadata()?; + if writer_metadata.is_file() { + // Set the correct file permissions, in case the file already existed. + // Don't set the permissions on already existing non-files like + // pipes/FIFOs or device nodes. + writer.set_permissions(perm)?; + } + Ok((reader, writer, len)) +} + #[cfg(not(any(target_os = "linux", target_os = "android")))] pub fn copy(from: &Path, to: &Path) -> io::Result { - use crate::fs::File; - if !from.is_file() { - return Err(Error::new(ErrorKind::InvalidInput, - "the source path is not an existing regular file")) - } + let (mut reader, mut writer, _) = open_and_set_permissions(from, to)?; - let mut reader = File::open(from)?; - let mut writer = File::create(to)?; - let perm = reader.metadata()?.permissions(); - - let ret = io::copy(&mut reader, &mut writer)?; - writer.set_permissions(perm)?; - Ok(ret) + io::copy(&mut reader, &mut writer) } #[cfg(any(target_os = "linux", target_os = "android"))] pub fn copy(from: &Path, to: &Path) -> io::Result { use crate::cmp; - use crate::fs::File; use crate::sync::atomic::{AtomicBool, Ordering}; // Kernel prior to 4.5 don't have copy_file_range @@ -873,17 +897,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { ) } - if !from.is_file() { - return Err(Error::new(ErrorKind::InvalidInput, - "the source path is not an existing regular file")) - } - - let mut reader = File::open(from)?; - let mut writer = File::create(to)?; - let (perm, len) = { - let metadata = reader.metadata()?; - (metadata.permissions(), metadata.size()) - }; + let (mut reader, mut writer, len) = open_and_set_permissions(from, to)?; let has_copy_file_range = HAS_COPY_FILE_RANGE.load(Ordering::Relaxed); let mut written = 0u64; @@ -893,13 +907,14 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { let copy_result = unsafe { // We actually don't have to adjust the offsets, // because copy_file_range adjusts the file offset automatically - cvt(copy_file_range(reader.as_raw_fd(), - ptr::null_mut(), - writer.as_raw_fd(), - ptr::null_mut(), - bytes_to_copy, - 0) - ) + cvt(copy_file_range( + reader.as_raw_fd(), + ptr::null_mut(), + writer.as_raw_fd(), + ptr::null_mut(), + bytes_to_copy, + 0, + )) }; if let Err(ref copy_err) = copy_result { match copy_err.raw_os_error() { @@ -917,23 +932,24 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { Ok(ret) => written += ret as u64, Err(err) => { match err.raw_os_error() { - Some(os_err) if os_err == libc::ENOSYS - || os_err == libc::EXDEV - || os_err == libc::EPERM => { - // Try fallback io::copy if either: - // - Kernel version is < 4.5 (ENOSYS) - // - Files are mounted on different fs (EXDEV) - // - copy_file_range is disallowed, for example by seccomp (EPERM) - assert_eq!(written, 0); - let ret = io::copy(&mut reader, &mut writer)?; - writer.set_permissions(perm)?; - return Ok(ret) - }, + Some(os_err) + if os_err == libc::ENOSYS + || os_err == libc::EXDEV + || os_err == libc::EINVAL + || os_err == libc::EPERM => + { + // Try fallback io::copy if either: + // - Kernel version is < 4.5 (ENOSYS) + // - Files are mounted on different fs (EXDEV) + // - copy_file_range is disallowed, for example by seccomp (EPERM) + // - copy_file_range cannot be used with pipes or device nodes (EINVAL) + assert_eq!(written, 0); + return io::copy(&mut reader, &mut writer); + } _ => return Err(err), } } } } - writer.set_permissions(perm)?; Ok(written) } diff --git a/src/libstd/sys/unix/l4re.rs b/src/libstd/sys/unix/l4re.rs index b6e8cc738946b..b9e725371a36e 100644 --- a/src/libstd/sys/unix/l4re.rs +++ b/src/libstd/sys/unix/l4re.rs @@ -447,10 +447,10 @@ pub mod net { unsafe impl Send for LookupHost {} - impl<'a> TryFrom<&'a str> for LookupHost { + impl TryFrom<&str> for LookupHost { type Error = io::Error; - fn try_from(_v: &'a str) -> io::Result { + fn try_from(_v: &str) -> io::Result { unimpl!(); } } diff --git a/src/libstd/sys/wasm/net.rs b/src/libstd/sys/wasm/net.rs index 1249832fb09d2..a2ea2dfbbc032 100644 --- a/src/libstd/sys/wasm/net.rs +++ b/src/libstd/sys/wasm/net.rs @@ -298,10 +298,10 @@ impl Iterator for LookupHost { } } -impl<'a> TryFrom<&'a str> for LookupHost { +impl TryFrom<&str> for LookupHost { type Error = io::Error; - fn try_from(_v: &'a str) -> io::Result { + fn try_from(_v: &str) -> io::Result { unsupported() } } diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index 36721171b1733..b9505aaa69ba5 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -157,7 +157,7 @@ impl Drop for LookupHost { } } -impl<'a> TryFrom<&'a str> for LookupHost { +impl TryFrom<&str> for LookupHost { type Error = io::Error; fn try_from(s: &str) -> io::Result { diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index db5b8dcda4eab..01e3b29290318 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1423,15 +1423,17 @@ impl<'a> StringReader<'a> { // If the character is an ident start not followed by another single // quote, then this is a lifetime name: - if ident_start(Some(c2)) && !self.ch_is('\'') { + if (ident_start(Some(c2)) || c2.is_numeric()) && !self.ch_is('\'') { while ident_continue(self.ch) { self.bump(); } // lifetimes shouldn't end with a single quote // if we find one, then this is an invalid character literal if self.ch_is('\'') { - self.err_span_(start_with_quote, self.next_pos, - "character literal may only contain one codepoint"); + self.err_span_( + start_with_quote, + self.next_pos, + "character literal may only contain one codepoint"); self.bump(); return Ok(token::Literal(token::Err(Symbol::intern("??")), None)) @@ -1444,6 +1446,15 @@ impl<'a> StringReader<'a> { self.mk_ident(&format!("'{}", lifetime_name)) }); + if c2.is_numeric() { + // this is a recovered lifetime written `'1`, error but accept it + self.err_span_( + start_with_quote, + self.pos, + "lifetimes cannot start with a number", + ); + } + return Ok(token::Lifetime(ident)); } @@ -1873,6 +1884,7 @@ fn is_block_doc_comment(s: &str) -> bool { res } +/// Determine whether `c` is a valid start for an ident. fn ident_start(c: Option) -> bool { let c = match c { Some(c) => c, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fe31311094b89..22af7d47fd0a1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5116,12 +5116,8 @@ impl<'a> Parser<'a> { let ident = self.parse_ident()?; let (delim, tokens) = self.expect_delimited_token_tree()?; - if delim != MacDelimiter::Brace { - if !self.eat(&token::Semi) { - let msg = "macros that expand to items must either \ - be surrounded with braces or followed by a semicolon"; - self.span_err(self.prev_span, msg); - } + if delim != MacDelimiter::Brace && !self.eat(&token::Semi) { + self.report_invalid_macro_expansion_item(); } (ident, ast::MacroDef { tokens: tokens, legacy: true }) @@ -5264,13 +5260,8 @@ impl<'a> Parser<'a> { // if it has a special ident, it's definitely an item // // Require a semicolon or braces. - if style != MacStmtStyle::Braces { - if !self.eat(&token::Semi) { - self.span_err(self.prev_span, - "macros that expand to items must \ - either be surrounded with braces or \ - followed by a semicolon"); - } + if style != MacStmtStyle::Braces && !self.eat(&token::Semi) { + self.report_invalid_macro_expansion_item(); } let span = lo.to(hi); Stmt { @@ -8360,13 +8351,8 @@ impl<'a> Parser<'a> { }; // eat a matched-delimiter token tree: let (delim, tts) = self.expect_delimited_token_tree()?; - if delim != MacDelimiter::Brace { - if !self.eat(&token::Semi) { - self.span_err(self.prev_span, - "macros that expand to items must either \ - be surrounded with braces or followed by \ - a semicolon"); - } + if delim != MacDelimiter::Brace && !self.eat(&token::Semi) { + self.report_invalid_macro_expansion_item(); } let hi = self.prev_span; @@ -8597,6 +8583,25 @@ impl<'a> Parser<'a> { } } } + + fn report_invalid_macro_expansion_item(&self) { + self.struct_span_err( + self.prev_span, + "macros that expand to items must be delimited with braces or followed by a semicolon", + ).multipart_suggestion( + "change the delimiters to curly braces", + vec![ + (self.prev_span.with_hi(self.prev_span.lo() + BytePos(1)), String::from(" {")), + (self.prev_span.with_lo(self.prev_span.hi() - BytePos(1)), '}'.to_string()), + ], + Applicability::MaybeIncorrect, + ).span_suggestion( + self.sess.source_map.next_point(self.prev_span), + "add a semicolon", + ';'.to_string(), + Applicability::MaybeIncorrect, + ).emit(); + } } pub fn emit_unclosed_delims(unclosed_delims: &mut Vec, handler: &errors::Handler) { diff --git a/src/llvm-project b/src/llvm-project index 38ad31bde8ff6..4fc9fb8245abe 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 38ad31bde8ff681d862dc0f96930a5dd9b7a472e +Subproject commit 4fc9fb8245abe24680192535870c4522644a4212 diff --git a/src/test/ui/block-expression-remove-semicolon.rs b/src/test/ui/block-expression-remove-semicolon.rs new file mode 100644 index 0000000000000..afa10b38b9144 --- /dev/null +++ b/src/test/ui/block-expression-remove-semicolon.rs @@ -0,0 +1,10 @@ +fn foo() -> i32 { + 0 +} + +fn main() { + let x: i32 = { + //~^ ERROR mismatched types + foo(); //~ HELP consider removing this semicolon + }; +} diff --git a/src/test/ui/block-expression-remove-semicolon.stderr b/src/test/ui/block-expression-remove-semicolon.stderr new file mode 100644 index 0000000000000..51942f3d920f5 --- /dev/null +++ b/src/test/ui/block-expression-remove-semicolon.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/block-expression-remove-semicolon.rs:6:18 + | +LL | let x: i32 = { + | __________________^ +LL | | +LL | | foo(); + | | - help: consider removing this semicolon +LL | | }; + | |_____^ expected i32, found () + | + = note: expected type `i32` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/borrowck/issue-10876.rs b/src/test/ui/borrowck/issue-10876.rs new file mode 100644 index 0000000000000..d8fff5f17760a --- /dev/null +++ b/src/test/ui/borrowck/issue-10876.rs @@ -0,0 +1,19 @@ +// run-pass + +#![feature(nll)] + +enum Nat { + S(Box), + Z +} +fn test(x: &mut Nat) { + let mut p = &mut *x; + loop { + match p { + &mut Nat::Z => break, + &mut Nat::S(ref mut n) => p = &mut *n + } + } +} + +fn main() {} diff --git a/src/test/ui/issues/issue-10536.rs b/src/test/ui/issues/issue-10536.rs index 95c8c2b0585b6..ceb44ecf7f583 100644 --- a/src/test/ui/issues/issue-10536.rs +++ b/src/test/ui/issues/issue-10536.rs @@ -12,7 +12,7 @@ pub fn main() { foo!(); assert!({one! two()}); - //~^ ERROR macros that expand to items must either be surrounded with braces or followed by a + //~^ ERROR macros that expand to items //~| ERROR cannot find macro `one!` in this scope //~| ERROR mismatched types diff --git a/src/test/ui/issues/issue-10536.stderr b/src/test/ui/issues/issue-10536.stderr index d5caf777cd45e..584cdf43a8f4b 100644 --- a/src/test/ui/issues/issue-10536.stderr +++ b/src/test/ui/issues/issue-10536.stderr @@ -1,8 +1,16 @@ -error: macros that expand to items must either be surrounded with braces or followed by a semicolon +error: macros that expand to items must be delimited with braces or followed by a semicolon --> $DIR/issue-10536.rs:14:22 | LL | assert!({one! two()}); | ^^ +help: change the delimiters to curly braces + | +LL | assert!({one! two {}}); + | ^^ +help: add a semicolon + | +LL | assert!({one! two();}); + | ^ error: expected `(` or `{`, found `}` --> $DIR/issue-10536.rs:21:22 diff --git a/src/test/ui/issues/issue-26448-1.rs b/src/test/ui/issues/issue-26448-1.rs new file mode 100644 index 0000000000000..7d2d75bf2e878 --- /dev/null +++ b/src/test/ui/issues/issue-26448-1.rs @@ -0,0 +1,13 @@ +// run-pass + +pub trait Foo { + fn foo(self) -> T; +} + +impl<'a, T> Foo for &'a str where &'a str: Into { + fn foo(self) -> T { + panic!(); + } +} + +fn main() {} diff --git a/src/test/ui/issues/issue-26448-2.rs b/src/test/ui/issues/issue-26448-2.rs new file mode 100644 index 0000000000000..17e7c1f977a6d --- /dev/null +++ b/src/test/ui/issues/issue-26448-2.rs @@ -0,0 +1,21 @@ +// run-pass + +pub struct Bar { + items: Vec<&'static str>, + inner: T, +} + +pub trait IntoBar { + fn into_bar(self) -> Bar; +} + +impl<'a, T> IntoBar for &'a str where &'a str: Into { + fn into_bar(self) -> Bar { + Bar { + items: Vec::new(), + inner: self.into(), + } + } +} + +fn main() {} diff --git a/src/test/ui/issues/issue-26448-3.rs b/src/test/ui/issues/issue-26448-3.rs new file mode 100644 index 0000000000000..e57352e57f4fc --- /dev/null +++ b/src/test/ui/issues/issue-26448-3.rs @@ -0,0 +1,25 @@ +// run-pass + +pub struct Item { + _inner: &'static str, +} + +pub struct Bar { + items: Vec, + inner: T, +} + +pub trait IntoBar { + fn into_bar(self) -> Bar; +} + +impl<'a, T> IntoBar for &'a str where &'a str: Into { + fn into_bar(self) -> Bar { + Bar { + items: Vec::new(), + inner: self.into(), + } + } +} + +fn main() {} diff --git a/src/test/ui/issues/issue-26619.nll.stderr b/src/test/ui/issues/issue-26619.nll.stderr new file mode 100644 index 0000000000000..d1157cda92bf8 --- /dev/null +++ b/src/test/ui/issues/issue-26619.nll.stderr @@ -0,0 +1,11 @@ +error[E0515]: cannot return value referencing function parameter + --> $DIR/issue-26619.rs:7:76 + | +LL | for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) { + | -------- ^^^^^^^^^^^^^^^^^^^^^ returns a value referencing data owned by the current function + | | + | function parameter borrowed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-26619.rs b/src/test/ui/issues/issue-26619.rs new file mode 100644 index 0000000000000..cd89c674e4996 --- /dev/null +++ b/src/test/ui/issues/issue-26619.rs @@ -0,0 +1,24 @@ +#![feature(slice_patterns)] + +pub struct History<'a> { pub _s: &'a str } + +impl<'a> History<'a> { + pub fn get_page(&self) { + for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) { + //~^ ERROR borrowed value does not live long enough + println!("{:?}", s); + } + } + + fn make_entry(&self, s: &'a String) -> Option<&str> { + let parts: Vec<_> = s.split('|').collect(); + println!("{:?} -> {:?}", s, parts); + + if let [commit, ..] = &parts[..] { Some(commit) } else { None } + } +} + +fn main() { + let h = History{ _s: "" }; + h.get_page(); +} diff --git a/src/test/ui/issues/issue-26619.stderr b/src/test/ui/issues/issue-26619.stderr new file mode 100644 index 0000000000000..3ac6c4e308d21 --- /dev/null +++ b/src/test/ui/issues/issue-26619.stderr @@ -0,0 +1,12 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/issue-26619.rs:7:66 + | +LL | for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) { + | ^^^^^^^^ -- temporary value needs to live until here + | | | + | | temporary value dropped here while still borrowed + | temporary value does not live long enough + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-44127.rs b/src/test/ui/issues/issue-44127.rs new file mode 100644 index 0000000000000..21b2e68264a14 --- /dev/null +++ b/src/test/ui/issues/issue-44127.rs @@ -0,0 +1,17 @@ +// run-pass + +#![feature(decl_macro)] + +pub struct Foo { + bar: u32, +} +pub macro pattern($a:pat) { + Foo { bar: $a } +} + +fn main() { + match (Foo { bar: 3 }) { + pattern!(3) => println!("Test OK"), + _ => unreachable!(), + } +} diff --git a/src/test/ui/issues/issue-44255.rs b/src/test/ui/issues/issue-44255.rs new file mode 100644 index 0000000000000..2245032043257 --- /dev/null +++ b/src/test/ui/issues/issue-44255.rs @@ -0,0 +1,29 @@ +// run-pass + +use std::marker::PhantomData; + +fn main() { + let _arr = [1; >::VAL]; +} + +trait TypeVal { + const VAL: T; +} + +struct Five; + +impl TypeVal for Five { + const VAL: usize = 5; +} + +struct Multiply { + _n: PhantomData, + _m: PhantomData, +} + +impl TypeVal for Multiply + where N: TypeVal, + M: TypeVal, +{ + const VAL: usize = N::VAL * M::VAL; +} diff --git a/src/test/ui/issues/issue-46101.rs b/src/test/ui/issues/issue-46101.rs new file mode 100644 index 0000000000000..2d9111e9b3a98 --- /dev/null +++ b/src/test/ui/issues/issue-46101.rs @@ -0,0 +1,4 @@ +#![feature(use_extern_macros)] +trait Foo {} +#[derive(Foo::Anything)] //~ ERROR failed to resolve: partially resolved path in a derive macro +struct S; diff --git a/src/test/ui/issues/issue-46101.stderr b/src/test/ui/issues/issue-46101.stderr new file mode 100644 index 0000000000000..3ad5383294a53 --- /dev/null +++ b/src/test/ui/issues/issue-46101.stderr @@ -0,0 +1,14 @@ +error[E0433]: failed to resolve: partially resolved path in a derive macro + --> $DIR/issue-46101.rs:3:10 + | +LL | #[derive(Foo::Anything)] + | ^^^^^^^^^^^^^ partially resolved path in a derive macro + +error[E0601]: `main` function not found in crate `issue_46101` + | + = note: consider adding a `main` function to `$DIR/issue-46101.rs` + +error: aborting due to 2 previous errors + +Some errors occurred: E0433, E0601. +For more information about an error, try `rustc --explain E0433`. diff --git a/src/test/ui/issues/issue-55731.rs b/src/test/ui/issues/issue-55731.rs new file mode 100644 index 0000000000000..7b4f4e2cd3b40 --- /dev/null +++ b/src/test/ui/issues/issue-55731.rs @@ -0,0 +1,52 @@ +use std::marker::PhantomData; + +trait DistributedIterator { + fn reduce(self) + where + Self: Sized, + { + unreachable!() + } +} + +trait DistributedIteratorMulti { + type Item; +} + +struct Connect(PhantomData); +impl DistributedIteratorMulti<&'a ()>> DistributedIterator for Connect where {} + +struct Cloned(PhantomData); +impl<'a, Source> DistributedIteratorMulti<&'a Source> for Cloned<&'a Source> { + type Item = (); +} + +struct Map { + i: I, + f: F, +} +impl, F, Source> DistributedIteratorMulti for Map +where + F: A<>::Item>, +{ + type Item = (); +} + +trait A {} + +struct X; +impl A<()> for X {} + +fn multi(_reducer: I) +where + I: for<'a> DistributedIteratorMulti<&'a ()>, +{ + DistributedIterator::reduce(Connect::(PhantomData)) +} + +fn main() { + multi(Map { //~ ERROR implementation of `DistributedIteratorMulti` is not general enough + i: Cloned(PhantomData), + f: X, + }); +} diff --git a/src/test/ui/issues/issue-55731.stderr b/src/test/ui/issues/issue-55731.stderr new file mode 100644 index 0000000000000..f25e18e5d90cb --- /dev/null +++ b/src/test/ui/issues/issue-55731.stderr @@ -0,0 +1,11 @@ +error: implementation of `DistributedIteratorMulti` is not general enough + --> $DIR/issue-55731.rs:48:5 + | +LL | multi(Map { + | ^^^^^ + | + = note: `DistributedIteratorMulti<&'0 ()>` would have to be implemented for the type `Cloned<&()>`, for any lifetime `'0` + = note: but `DistributedIteratorMulti<&'1 ()>` is actually implemented for the type `Cloned<&'1 ()>`, for some specific lifetime `'1` + +error: aborting due to previous error + diff --git a/src/test/ui/issues/issue-57781.rs b/src/test/ui/issues/issue-57781.rs new file mode 100644 index 0000000000000..f5015aaf5d81f --- /dev/null +++ b/src/test/ui/issues/issue-57781.rs @@ -0,0 +1,20 @@ +// run-pass + +use std::cell::UnsafeCell; +use std::collections::HashMap; + +struct OnceCell { + _value: UnsafeCell>, +} + +impl OnceCell { + const INIT: OnceCell = OnceCell { + _value: UnsafeCell::new(None), + }; +} + +pub fn crash() { + let _ = OnceCell::>::INIT; +} + +fn main() {} diff --git a/src/test/ui/parser/macros-no-semicolon-items.rs b/src/test/ui/parser/macros-no-semicolon-items.rs index a727cafcab023..3afc275d61a2b 100644 --- a/src/test/ui/parser/macros-no-semicolon-items.rs +++ b/src/test/ui/parser/macros-no-semicolon-items.rs @@ -1,4 +1,15 @@ macro_rules! foo() //~ ERROR semicolon + //~| ERROR unexpected end of macro + +macro_rules! bar { + ($($tokens:tt)*) => {} +} + +bar!( //~ ERROR semicolon + blah + blah + blah +) fn main() { } diff --git a/src/test/ui/parser/macros-no-semicolon-items.stderr b/src/test/ui/parser/macros-no-semicolon-items.stderr index a869a53c1eee2..12e5764ecf8f8 100644 --- a/src/test/ui/parser/macros-no-semicolon-items.stderr +++ b/src/test/ui/parser/macros-no-semicolon-items.stderr @@ -1,8 +1,45 @@ -error: macros that expand to items must either be surrounded with braces or followed by a semicolon +error: macros that expand to items must be delimited with braces or followed by a semicolon --> $DIR/macros-no-semicolon-items.rs:1:17 | LL | macro_rules! foo() | ^^ +help: change the delimiters to curly braces + | +LL | macro_rules! foo {} //~ ERROR semicolon + | ^^ +help: add a semicolon + | +LL | macro_rules! foo(); //~ ERROR semicolon + | ^ + +error: macros that expand to items must be delimited with braces or followed by a semicolon + --> $DIR/macros-no-semicolon-items.rs:8:5 + | +LL | bar!( //~ ERROR semicolon + | _____^ +LL | | blah +LL | | blah +LL | | blah +LL | | ) + | |_^ +help: change the delimiters to curly braces + | +LL | bar! { //~ ERROR semicolon +LL | blah +LL | blah +LL | blah +LL | } + | +help: add a semicolon + | +LL | ); + | ^ + +error: unexpected end of macro invocation + --> $DIR/macros-no-semicolon-items.rs:1:1 + | +LL | macro_rules! foo() //~ ERROR semicolon + | ^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments -error: aborting due to previous error +error: aborting due to 3 previous errors diff --git a/src/test/ui/parser/numeric-lifetime.rs b/src/test/ui/parser/numeric-lifetime.rs new file mode 100644 index 0000000000000..2d82354c62cca --- /dev/null +++ b/src/test/ui/parser/numeric-lifetime.rs @@ -0,0 +1,8 @@ +struct S<'1> { s: &'1 usize } +//~^ ERROR lifetimes cannot start with a number +//~| ERROR lifetimes cannot start with a number +fn main() { + // verify that the parse error doesn't stop type checking + let x: usize = ""; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/parser/numeric-lifetime.stderr b/src/test/ui/parser/numeric-lifetime.stderr new file mode 100644 index 0000000000000..4018b24aac175 --- /dev/null +++ b/src/test/ui/parser/numeric-lifetime.stderr @@ -0,0 +1,24 @@ +error: lifetimes cannot start with a number + --> $DIR/numeric-lifetime.rs:1:10 + | +LL | struct S<'1> { s: &'1 usize } + | ^^ + +error: lifetimes cannot start with a number + --> $DIR/numeric-lifetime.rs:1:20 + | +LL | struct S<'1> { s: &'1 usize } + | ^^ + +error[E0308]: mismatched types + --> $DIR/numeric-lifetime.rs:6:20 + | +LL | let x: usize = ""; + | ^^ expected usize, found reference + | + = note: expected type `usize` + found type `&'static str` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/primitive-binop-lhs-mut.rs b/src/test/ui/primitive-binop-lhs-mut.rs new file mode 100644 index 0000000000000..4f1c456ace354 --- /dev/null +++ b/src/test/ui/primitive-binop-lhs-mut.rs @@ -0,0 +1,6 @@ +// run-pass + +fn main() { + let x = Box::new(0); + assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 }); +}