diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index d1b607bbe9b53..bcdfd8c9aa5d5 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -76,6 +76,7 @@ #![cfg_attr(not(test), feature(fn_traits))] #![cfg_attr(not(test), feature(generator_trait))] +#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(test, feature(test))] #![feature(allocator_api)] diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index b3b20715511a7..480a24b9bd1f2 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -16,6 +16,7 @@ #![feature(core_intrinsics)] #![feature(libc)] #![feature(linkage)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(staged_api)] #![feature(rustc_attrs)] #![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))] diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index 8e30b0d5d5a17..c5e056f6b12be 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -14,8 +14,10 @@ reason = "this library is unlikely to be stabilized in its current \ form or name", issue = "32838")] + #![feature(allocator_api)] #![feature(core_intrinsics)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(staged_api)] #![feature(rustc_attrs)] #![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))] diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 0f4a5d16e1759..265721c749755 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -26,6 +26,7 @@ #![feature(alloc)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(raw_vec_internals)] #![cfg_attr(test, feature(test))] diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 3626a266ad5d3..58d6c4f5e0923 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -469,6 +469,7 @@ pub trait Ord: Eq + PartialOrd { /// assert_eq!(2, 2.max(2)); /// ``` #[stable(feature = "ord_max_min", since = "1.21.0")] + #[inline] fn max(self, other: Self) -> Self where Self: Sized { if other >= self { other } else { self } @@ -485,6 +486,7 @@ pub trait Ord: Eq + PartialOrd { /// assert_eq!(2, 2.min(2)); /// ``` #[stable(feature = "ord_max_min", since = "1.21.0")] + #[inline] fn min(self, other: Self) -> Self where Self: Sized { if self <= other { self } else { other } diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 4f37b462583d1..d18e167fc3fa4 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -95,7 +95,7 @@ impl !Send for *mut T { } message="the size for values of type `{Self}` cannot be known at compilation time", label="doesn't have a size known at compile-time", note="to learn more, visit ", + ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>", )] #[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable pub trait Sized { diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 44a3b310ebe4d..960853333f6c7 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -188,7 +188,7 @@ mod wrapping; // `Int` + `SignedInt` implemented for signed integers macro_rules! int_impl { ($SelfT:ty, $ActualT:ident, $UnsignedT:ty, $BITS:expr, $Min:expr, $Max:expr, $Feature:expr, - $EndFeature:expr) => { + $EndFeature:expr, $rot:expr, $rot_op:expr, $rot_result:expr) => { doc_comment! { concat!("Returns the smallest value that can be represented by this integer type. @@ -334,55 +334,52 @@ $EndFeature, " } } - /// Shifts the bits to the left by a specified amount, `n`, - /// wrapping the truncated bits to the end of the resulting integer. - /// - /// Please note this isn't the same operation as `<<`! - /// - /// # Examples - /// - /// Please note that this example is shared between integer types. - /// Which explains why `i64` is used here. - /// - /// Basic usage: - /// - /// ``` - /// let n = 0x0123456789ABCDEFi64; - /// let m = -0x76543210FEDCBA99i64; - /// - /// assert_eq!(n.rotate_left(32), m); - /// ``` - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - pub fn rotate_left(self, n: u32) -> Self { - (self as $UnsignedT).rotate_left(n) as Self - } + doc_comment! { + concat!("Shifts the bits to the left by a specified amount, `n`, +wrapping the truncated bits to the end of the resulting integer. - /// Shifts the bits to the right by a specified amount, `n`, - /// wrapping the truncated bits to the beginning of the resulting - /// integer. - /// - /// Please note this isn't the same operation as `>>`! - /// - /// # Examples - /// - /// Please note that this example is shared between integer types. - /// Which explains why `i64` is used here. - /// - /// Basic usage: - /// - /// ``` - /// let n = 0x0123456789ABCDEFi64; - /// let m = -0xFEDCBA987654322i64; - /// - /// assert_eq!(n.rotate_right(4), m); - /// ``` - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - pub fn rotate_right(self, n: u32) -> Self { - (self as $UnsignedT).rotate_right(n) as Self +Please note this isn't the same operation as `<<`! + +# Examples + +Basic usage: + +``` +let n = ", $rot_op, stringify!($SelfT), "; +let m = ", $rot_result, "; + +assert_eq!(n.rotate_left(", $rot, "), m); +```"), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn rotate_left(self, n: u32) -> Self { + (self as $UnsignedT).rotate_left(n) as Self + } } + doc_comment! { + concat!("Shifts the bits to the right by a specified amount, `n`, +wrapping the truncated bits to the beginning of the resulting +integer. + +Please note this isn't the same operation as `>>`! + +# Examples + +Basic usage: + +``` +let n = ", $rot_result, stringify!($SelfT), "; +let m = ", $rot_op, "; + +assert_eq!(n.rotate_right(", $rot, "), m); +```"), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn rotate_right(self, n: u32) -> Self { + (self as $UnsignedT).rotate_right(n) as Self + } + } /// Reverses the byte order of the integer. /// /// # Examples @@ -2012,46 +2009,50 @@ $EndFeature, " #[lang = "i8"] impl i8 { - int_impl! { i8, i8, u8, 8, -128, 127, "", "" } + int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa" } } #[lang = "i16"] impl i16 { - int_impl! { i16, i16, u16, 16, -32768, 32767, "", "" } + int_impl! { i16, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" } } #[lang = "i32"] impl i32 { - int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "" } + int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" } } #[lang = "i64"] impl i64 { - int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" } + int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "", 12, + "0xaa00000000006e1", "0x6e10aa" } } #[lang = "i128"] impl i128 { int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, - 170141183460469231731687303715884105727, "", "" } + 170141183460469231731687303715884105727, "", "", 16, + "0x13f40000000000000000000000004f76", "0x4f7613f4" + } } #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { - int_impl! { isize, i16, u16, 16, -32768, 32767, "", "" } + int_impl! { isize, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" } } #[cfg(target_pointer_width = "32")] #[lang = "isize"] impl isize { - int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "" } + int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" } } #[cfg(target_pointer_width = "64")] #[lang = "isize"] impl isize { - int_impl! { isize, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" } + int_impl! { isize, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "", + 12, "0xaa00000000006e1", "0x6e10aa" } } // Emits the correct `cttz` call, depending on the size of the type. @@ -2069,7 +2070,8 @@ macro_rules! uint_cttz_call { // `Int` + `UnsignedInt` implemented for unsigned integers macro_rules! uint_impl { - ($SelfT:ty, $ActualT:ty, $BITS:expr, $MaxV:expr, $Feature:expr, $EndFeature:expr) => { + ($SelfT:ty, $ActualT:ty, $BITS:expr, $MaxV:expr, $Feature:expr, $EndFeature:expr, + $rot:expr, $rot_op:expr, $rot_result:expr) => { doc_comment! { concat!("Returns the smallest value that can be represented by this integer type. @@ -2210,57 +2212,55 @@ assert_eq!(n.trailing_zeros(), 3);", $EndFeature, " } } - /// Shifts the bits to the left by a specified amount, `n`, - /// wrapping the truncated bits to the end of the resulting integer. - /// - /// Please note this isn't the same operation as `<<`! - /// - /// # Examples - /// - /// Basic usage: - /// - /// Please note that this example is shared between integer types. - /// Which explains why `u64` is used here. - /// - /// ``` - /// let n = 0x0123456789ABCDEFu64; - /// let m = 0x3456789ABCDEF012u64; - /// - /// assert_eq!(n.rotate_left(12), m); - /// ``` - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - pub fn rotate_left(self, n: u32) -> Self { - // Protect against undefined behaviour for over-long bit shifts - let n = n % $BITS; - (self << n) | (self >> (($BITS - n) % $BITS)) + doc_comment! { + concat!("Shifts the bits to the left by a specified amount, `n`, +wrapping the truncated bits to the end of the resulting integer. + +Please note this isn't the same operation as `<<`! + +# Examples + +Basic usage: + +``` +let n = ", $rot_op, stringify!($SelfT), "; +let m = ", $rot_result, "; + +assert_eq!(n.rotate_left(", $rot, "), m); +```"), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn rotate_left(self, n: u32) -> Self { + // Protect against undefined behaviour for over-long bit shifts + let n = n % $BITS; + (self << n) | (self >> (($BITS - n) % $BITS)) + } } - /// Shifts the bits to the right by a specified amount, `n`, - /// wrapping the truncated bits to the beginning of the resulting - /// integer. - /// - /// Please note this isn't the same operation as `>>`! - /// - /// # Examples - /// - /// Basic usage: - /// - /// Please note that this example is shared between integer types. - /// Which explains why `u64` is used here. - /// - /// ``` - /// let n = 0x0123456789ABCDEFu64; - /// let m = 0xDEF0123456789ABCu64; - /// - /// assert_eq!(n.rotate_right(12), m); - /// ``` - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - pub fn rotate_right(self, n: u32) -> Self { - // Protect against undefined behaviour for over-long bit shifts - let n = n % $BITS; - (self >> n) | (self << (($BITS - n) % $BITS)) + doc_comment! { + concat!("Shifts the bits to the right by a specified amount, `n`, +wrapping the truncated bits to the beginning of the resulting +integer. + +Please note this isn't the same operation as `>>`! + +# Examples + +Basic usage: + +``` +let n = ", $rot_result, stringify!($SelfT), "; +let m = ", $rot_op, "; + +assert_eq!(n.rotate_right(", $rot, "), m); +```"), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn rotate_right(self, n: u32) -> Self { + // Protect against undefined behaviour for over-long bit shifts + let n = n % $BITS; + (self >> n) | (self << (($BITS - n) % $BITS)) + } } /// Reverses the byte order of the integer. @@ -3621,7 +3621,7 @@ $EndFeature, " #[lang = "u8"] impl u8 { - uint_impl! { u8, u8, 8, 255, "", "" } + uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa" } /// Checks if the value is within the ASCII range. @@ -4147,39 +4147,41 @@ impl u8 { #[lang = "u16"] impl u16 { - uint_impl! { u16, u16, 16, 65535, "", "" } + uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a" } } #[lang = "u32"] impl u32 { - uint_impl! { u32, u32, 32, 4294967295, "", "" } + uint_impl! { u32, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" } } #[lang = "u64"] impl u64 { - uint_impl! { u64, u64, 64, 18446744073709551615, "", "" } + uint_impl! { u64, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa" } } #[lang = "u128"] impl u128 { - uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "" } + uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16, + "0x13f40000000000000000000000004f76", "0x4f7613f4" } } #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { - uint_impl! { usize, u16, 16, 65536, "", "" } + uint_impl! { usize, u16, 16, 65536, "", "", 4, "0xa003", "0x3a" } } #[cfg(target_pointer_width = "32")] #[lang = "usize"] impl usize { - uint_impl! { usize, u32, 32, 4294967295, "", "" } + uint_impl! { usize, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" } } #[cfg(target_pointer_width = "64")] #[lang = "usize"] impl usize { - uint_impl! { usize, u64, 64, 18446744073709551615, "", "" } + uint_impl! { usize, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", + "0x6e10aa" } } /// A classification of floating point numbers. diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 2b6c376f8a71c..f743fbfd0752b 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1141,6 +1141,7 @@ unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, A> Clone for Iter<'a, A> { + #[inline] fn clone(&self) -> Iter<'a, A> { Iter { inner: self.inner.clone() } } @@ -1307,14 +1308,17 @@ impl ops::Try for Option { type Ok = T; type Error = NoneError; + #[inline] fn into_result(self) -> Result { self.ok_or(NoneError) } + #[inline] fn from_ok(v: T) -> Self { Some(v) } + #[inline] fn from_error(_: NoneError) -> Self { None } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index fb496836c2c10..ac908342655b6 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -1084,6 +1084,7 @@ unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Clone for Iter<'a, T> { + #[inline] fn clone(&self) -> Iter<'a, T> { Iter { inner: self.inner } } } @@ -1235,14 +1236,17 @@ impl ops::Try for Result { type Ok = T; type Error = E; + #[inline] fn into_result(self) -> Self { self } + #[inline] fn from_ok(v: T) -> Self { Ok(v) } + #[inline] fn from_error(v: E) -> Self { Err(v) } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index e98194c17c885..5bb713f576741 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -29,7 +29,7 @@ //! //! [`Ordering`]: enum.Ordering.html //! -//! [1]: http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations +//! [1]: https://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations //! [2]: ../../../nomicon/atomics.html //! //! Atomic variables are safe to share between threads (they implement [`Sync`]) @@ -178,7 +178,7 @@ unsafe impl Sync for AtomicPtr {} /// "relaxed" atomics allow all reorderings. /// /// Rust's memory orderings are [the same as -/// LLVM's](http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations). +/// LLVM's](https://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations). /// /// For more information see the [nomicon]. /// @@ -190,35 +190,70 @@ pub enum Ordering { /// /// Corresponds to LLVM's [`Monotonic`] ordering. /// - /// [`Monotonic`]: http://llvm.org/docs/Atomics.html#monotonic + /// [`Monotonic`]: https://llvm.org/docs/Atomics.html#monotonic #[stable(feature = "rust1", since = "1.0.0")] Relaxed, - /// When coupled with a store, all previous writes become visible - /// to the other threads that perform a load with [`Acquire`] ordering - /// on the same value. + /// When coupled with a store, all previous operations become ordered + /// before any load of this value with [`Acquire`] (or stronger) ordering. + /// In particular, all previous writes become visible to all threads + /// that perform an [`Acquire`] (or stronger) load of this value. /// - /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire + /// Notice that using this ordering for an operation that combines loads + /// and stores leads to a [`Relaxed`] load operation! + /// + /// This ordering is only applicable for operations that can perform a store. + /// + /// Corresponds to LLVM's [`Release`] ordering. + /// + /// [`Release`]: https://llvm.org/docs/Atomics.html#release + /// [`Acquire`]: https://llvm.org/docs/Atomics.html#acquire + /// [`Relaxed`]: https://llvm.org/docs/Atomics.html#monotonic #[stable(feature = "rust1", since = "1.0.0")] Release, - /// When coupled with a load, all subsequent loads will see data - /// written before a store with [`Release`] ordering on the same value - /// in other threads. + /// When coupled with a load, if the loaded value was written by a store operation with + /// [`Release`] (or stronger) ordering, then all subsequent operations + /// become ordered after that store. In particular, all subsequent loads will see data + /// written before the store. + /// + /// Notice that using this ordering for an operation that combines loads + /// and stores leads to a [`Relaxed`] store operation! + /// + /// This ordering is only applicable for operations that can perform a load. /// - /// [`Release`]: http://llvm.org/docs/Atomics.html#release + /// Corresponds to LLVM's [`Acquire`] ordering. + /// + /// [`Acquire`]: https://llvm.org/docs/Atomics.html#acquire + /// [`Release`]: https://llvm.org/docs/Atomics.html#release + /// [`Relaxed`]: https://llvm.org/docs/Atomics.html#monotonic #[stable(feature = "rust1", since = "1.0.0")] Acquire, - /// Has the effects of both [`Acquire`] and [`Release`] together. + /// Has the effects of both [`Acquire`] and [`Release`] together: + /// For loads it uses [`Acquire`] ordering. For stores it uses the [`Release`] ordering. + /// + /// Notice that in the case of `compare_and_swap`, it is possible that the operation ends up + /// not performing any store and hence it has just `Acquire` ordering. However, + /// `AcqRel` will never perform [`Relaxed`] accesses. /// /// This ordering is only applicable for operations that combine both loads and stores. /// - /// For loads it uses [`Acquire`] ordering. For stores it uses the [`Release`] ordering. + /// Corresponds to LLVM's [`AcquireRelease`] ordering. /// - /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire - /// [`Release`]: http://llvm.org/docs/Atomics.html#release + /// [`AcquireRelease`]: https://llvm.org/docs/Atomics.html#acquirerelease + /// [`Acquire`]: https://llvm.org/docs/Atomics.html#acquire + /// [`Release`]: https://llvm.org/docs/Atomics.html#release + /// [`Relaxed`]: https://llvm.org/docs/Atomics.html#monotonic #[stable(feature = "rust1", since = "1.0.0")] AcqRel, - /// Like `AcqRel` with the additional guarantee that all threads see all + /// Like [`Acquire`]/[`Release`]/[`AcqRel`] (for load, store, and load-with-store + /// operations, respectively) with the additional guarantee that all threads see all /// sequentially consistent operations in the same order. + /// + /// Corresponds to LLVM's [`SequentiallyConsistent`] ordering. + /// + /// [`SequentiallyConsistent`]: https://llvm.org/docs/Atomics.html#sequentiallyconsistent + /// [`Acquire`]: https://llvm.org/docs/Atomics.html#acquire + /// [`Release`]: https://llvm.org/docs/Atomics.html#release + /// [`AcqRel`]: https://llvm.org/docs/Atomics.html#acquirerelease #[stable(feature = "rust1", since = "1.0.0")] SeqCst, // Prevent exhaustive matching to allow for future extension @@ -297,15 +332,18 @@ impl AtomicBool { /// Loads a value from the bool. /// /// `load` takes an [`Ordering`] argument which describes the memory ordering - /// of this operation. + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`]. /// /// # Panics /// /// Panics if `order` is [`Release`] or [`AcqRel`]. /// /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel + /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -325,9 +363,18 @@ impl AtomicBool { /// Stores a value into the bool. /// /// `store` takes an [`Ordering`] argument which describes the memory ordering - /// of this operation. + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`]. + /// + /// # Panics + /// + /// Panics if `order` is [`Acquire`] or [`AcqRel`]. /// /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel + /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -339,13 +386,6 @@ impl AtomicBool { /// some_bool.store(false, Ordering::Relaxed); /// assert_eq!(some_bool.load(Ordering::Relaxed), false); /// ``` - /// - /// # Panics - /// - /// Panics if `order` is [`Acquire`] or [`AcqRel`]. - /// - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn store(&self, val: bool, order: Ordering) { @@ -357,9 +397,14 @@ impl AtomicBool { /// Stores a value into the bool, returning the previous value. /// /// `swap` takes an [`Ordering`] argument which describes the memory ordering - /// of this operation. + /// of this operation. All ordering modes are possible. Note that using + /// [`Acquire`] makes the store part of this operation [`Relaxed`], and + /// using [`Release`] makes the load part [`Relaxed`]. /// /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire /// /// # Examples /// @@ -384,9 +429,16 @@ impl AtomicBool { /// was updated. /// /// `compare_and_swap` also takes an [`Ordering`] argument which describes the memory - /// ordering of this operation. + /// ordering of this operation. Notice that even when using [`AcqRel`], the operation + /// might fail and hence just perform an `Acquire` load, but not have `Release` semantics. + /// Using [`Acquire`] makes the store part of this operation [`Relaxed`] if it + /// happens, and using [`Release`] makes the load part [`Relaxed`]. /// /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel /// [`bool`]: ../../../std/primitive.bool.html /// /// # Examples @@ -420,13 +472,18 @@ impl AtomicBool { /// `compare_exchange` takes two [`Ordering`] arguments to describe the memory /// ordering of this operation. The first describes the required ordering if the /// operation succeeds while the second describes the required ordering when the - /// operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and must - /// be equivalent or weaker than the success ordering. + /// operation fails. Using [`Acquire`] as success ordering makes the store part + /// of this operation [`Relaxed`], and using [`Release`] makes the successful load + /// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`] + /// and must be equivalent to or weaker than the success ordering. + /// /// /// [`bool`]: ../../../std/primitive.bool.html /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed /// [`Release`]: enum.Ordering.html#variant.Release - /// [`AcqRel`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -473,16 +530,20 @@ impl AtomicBool { /// previous value. /// /// `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory - /// ordering of this operation. The first describes the required ordering if the operation - /// succeeds while the second describes the required ordering when the operation fails. The - /// failure ordering can't be [`Release`] or [`AcqRel`] and must be equivalent or - /// weaker than the success ordering. + /// ordering of this operation. The first describes the required ordering if the + /// operation succeeds while the second describes the required ordering when the + /// operation fails. Using [`Acquire`] as success ordering makes the store part + /// of this operation [`Relaxed`], and using [`Release`] makes the successful load + /// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`] + /// and must be equivalent to or weaker than the success ordering. /// /// [`bool`]: ../../../std/primitive.bool.html /// [`compare_exchange`]: #method.compare_exchange /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed /// [`Release`]: enum.Ordering.html#variant.Release - /// [`AcqRel`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -523,6 +584,16 @@ impl AtomicBool { /// /// Returns the previous value. /// + /// `fetch_and` takes an [`Ordering`] argument which describes the memory ordering + /// of this operation. All ordering modes are possible. Note that using + /// [`Acquire`] makes the store part of this operation [`Relaxed`], and + /// using [`Release`] makes the load part [`Relaxed`]. + /// + /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// /// # Examples /// /// ``` @@ -554,6 +625,16 @@ impl AtomicBool { /// /// Returns the previous value. /// + /// `fetch_nand` takes an [`Ordering`] argument which describes the memory ordering + /// of this operation. All ordering modes are possible. Note that using + /// [`Acquire`] makes the store part of this operation [`Relaxed`], and + /// using [`Release`] makes the load part [`Relaxed`]. + /// + /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// /// # Examples /// /// ``` @@ -598,6 +679,16 @@ impl AtomicBool { /// /// Returns the previous value. /// + /// `fetch_or` takes an [`Ordering`] argument which describes the memory ordering + /// of this operation. All ordering modes are possible. Note that using + /// [`Acquire`] makes the store part of this operation [`Relaxed`], and + /// using [`Release`] makes the load part [`Relaxed`]. + /// + /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// /// # Examples /// /// ``` @@ -629,6 +720,16 @@ impl AtomicBool { /// /// Returns the previous value. /// + /// `fetch_xor` takes an [`Ordering`] argument which describes the memory ordering + /// of this operation. All ordering modes are possible. Note that using + /// [`Acquire`] makes the store part of this operation [`Relaxed`], and + /// using [`Release`] makes the load part [`Relaxed`]. + /// + /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// /// # Examples /// /// ``` @@ -714,15 +815,18 @@ impl AtomicPtr { /// Loads a value from the pointer. /// /// `load` takes an [`Ordering`] argument which describes the memory ordering - /// of this operation. + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`]. /// /// # Panics /// /// Panics if `order` is [`Release`] or [`AcqRel`]. /// /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel + /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -743,9 +847,18 @@ impl AtomicPtr { /// Stores a value into the pointer. /// /// `store` takes an [`Ordering`] argument which describes the memory ordering - /// of this operation. + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`]. + /// + /// # Panics + /// + /// Panics if `order` is [`Acquire`] or [`AcqRel`]. /// /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel + /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -759,13 +872,6 @@ impl AtomicPtr { /// /// some_ptr.store(other_ptr, Ordering::Relaxed); /// ``` - /// - /// # Panics - /// - /// Panics if `order` is [`Acquire`] or [`AcqRel`]. - /// - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn store(&self, ptr: *mut T, order: Ordering) { @@ -777,9 +883,14 @@ impl AtomicPtr { /// Stores a value into the pointer, returning the previous value. /// /// `swap` takes an [`Ordering`] argument which describes the memory ordering - /// of this operation. + /// of this operation. All ordering modes are possible. Note that using + /// [`Acquire`] makes the store part of this operation [`Relaxed`], and + /// using [`Release`] makes the load part [`Relaxed`]. /// /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire /// /// # Examples /// @@ -806,9 +917,16 @@ impl AtomicPtr { /// was updated. /// /// `compare_and_swap` also takes an [`Ordering`] argument which describes the memory - /// ordering of this operation. + /// ordering of this operation. Notice that even when using [`AcqRel`], the operation + /// might fail and hence just perform an `Acquire` load, but not have `Release` semantics. + /// Using [`Acquire`] makes the store part of this operation [`Relaxed`] if it + /// happens, and using [`Release`] makes the load part [`Relaxed`]. /// /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed + /// [`Release`]: enum.Ordering.html#variant.Release + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel /// /// # Examples /// @@ -839,14 +957,18 @@ impl AtomicPtr { /// the previous value. On success this value is guaranteed to be equal to `current`. /// /// `compare_exchange` takes two [`Ordering`] arguments to describe the memory - /// ordering of this operation. The first describes the required ordering if - /// the operation succeeds while the second describes the required ordering when - /// the operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] - /// and must be equivalent or weaker than the success ordering. + /// ordering of this operation. The first describes the required ordering if the + /// operation succeeds while the second describes the required ordering when the + /// operation fails. Using [`Acquire`] as success ordering makes the store part + /// of this operation [`Relaxed`], and using [`Release`] makes the successful load + /// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`] + /// and must be equivalent to or weaker than the success ordering. /// /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed /// [`Release`]: enum.Ordering.html#variant.Release - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -892,15 +1014,19 @@ impl AtomicPtr { /// previous value. /// /// `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory - /// ordering of this operation. The first describes the required ordering if the operation - /// succeeds while the second describes the required ordering when the operation fails. The - /// failure ordering can't be [`Release`] or [`AcqRel`] and must be equivalent or - /// weaker than the success ordering. + /// ordering of this operation. The first describes the required ordering if the + /// operation succeeds while the second describes the required ordering when the + /// operation fails. Using [`Acquire`] as success ordering makes the store part + /// of this operation [`Relaxed`], and using [`Release`] makes the successful load + /// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`] + /// and must be equivalent to or weaker than the success ordering. /// /// [`compare_exchange`]: #method.compare_exchange /// [`Ordering`]: enum.Ordering.html + /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed /// [`Release`]: enum.Ordering.html#variant.Release - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel + /// [`Acquire`]: enum.Ordering.html#variant.Acquire + /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -1077,14 +1203,18 @@ assert_eq!(some_var.into_inner(), 5); concat!("Loads a value from the atomic integer. `load` takes an [`Ordering`] argument which describes the memory ordering of this operation. +Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`]. # Panics Panics if `order` is [`Release`] or [`AcqRel`]. [`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed [`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire [`AcqRel`]: enum.Ordering.html#variant.AcqRel +[`SeqCst`]: enum.Ordering.html#variant.SeqCst # Examples @@ -1106,8 +1236,18 @@ assert_eq!(some_var.load(Ordering::Relaxed), 5); concat!("Stores a value into the atomic integer. `store` takes an [`Ordering`] argument which describes the memory ordering of this operation. + Possible values are [`SeqCst`], [`Release`] and [`Relaxed`]. + +# Panics + +Panics if `order` is [`Acquire`] or [`AcqRel`]. [`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire +[`AcqRel`]: enum.Ordering.html#variant.AcqRel +[`SeqCst`]: enum.Ordering.html#variant.SeqCst # Examples @@ -1118,14 +1258,7 @@ let some_var = ", stringify!($atomic_type), "::new(5); some_var.store(10, Ordering::Relaxed); assert_eq!(some_var.load(Ordering::Relaxed), 10); -``` - -# Panics - -Panics if `order` is [`Acquire`] or [`AcqRel`]. - -[`Acquire`]: enum.Ordering.html#variant.Acquire -[`AcqRel`]: enum.Ordering.html#variant.AcqRel"), +```"), #[inline] #[$stable] pub fn store(&self, val: $int_type, order: Ordering) { @@ -1136,9 +1269,15 @@ Panics if `order` is [`Acquire`] or [`AcqRel`]. doc_comment! { concat!("Stores a value into the atomic integer, returning the previous value. -`swap` takes an [`Ordering`] argument which describes the memory ordering of this operation. +`swap` takes an [`Ordering`] argument which describes the memory ordering +of this operation. All ordering modes are possible. Note that using +[`Acquire`] makes the store part of this operation [`Relaxed`], and +using [`Release`] makes the load part [`Relaxed`]. [`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire # Examples @@ -1165,9 +1304,16 @@ The return value is always the previous value. If it is equal to `current`, then value was updated. `compare_and_swap` also takes an [`Ordering`] argument which describes the memory -ordering of this operation. +ordering of this operation. Notice that even when using [`AcqRel`], the operation +might fail and hence just perform an `Acquire` load, but not have `Release` semantics. +Using [`Acquire`] makes the store part of this operation [`Relaxed`] if it +happens, and using [`Release`] makes the load part [`Relaxed`]. [`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire +[`AcqRel`]: enum.Ordering.html#variant.AcqRel # Examples @@ -1208,14 +1354,18 @@ containing the previous value. On success this value is guaranteed to be equal t `current`. `compare_exchange` takes two [`Ordering`] arguments to describe the memory -ordering of this operation. The first describes the required ordering if -the operation succeeds while the second describes the required ordering when -the operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and -must be equivalent or weaker than the success ordering. +ordering of this operation. The first describes the required ordering if the +operation succeeds while the second describes the required ordering when the +operation fails. Using [`Acquire`] as success ordering makes the store part +of this operation [`Relaxed`], and using [`Release`] makes the successful load +[`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`] +and must be equivalent to or weaker than the success ordering. [`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed [`Release`]: enum.Ordering.html#variant.Release -[`AcqRel`]: enum.Ordering.html#variant.AcqRel +[`Acquire`]: enum.Ordering.html#variant.Acquire +[`SeqCst`]: enum.Ordering.html#variant.SeqCst # Examples @@ -1260,13 +1410,17 @@ written and containing the previous value. `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory ordering of this operation. The first describes the required ordering if the operation succeeds while the second describes the required ordering when the -operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and -must be equivalent or weaker than the success ordering. +operation fails. Using [`Acquire`] as success ordering makes the store part +of this operation [`Relaxed`], and using [`Release`] makes the successful load +[`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`] +and must be equivalent to or weaker than the success ordering. [`compare_exchange`]: #method.compare_exchange [`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed [`Release`]: enum.Ordering.html#variant.Release -[`AcqRel`]: enum.Ordering.html#variant.AcqRel +[`Acquire`]: enum.Ordering.html#variant.Acquire +[`SeqCst`]: enum.Ordering.html#variant.SeqCst # Examples @@ -1302,6 +1456,16 @@ loop { This operation wraps around on overflow. +`fetch_add` takes an [`Ordering`] argument which describes the memory ordering +of this operation. All ordering modes are possible. Note that using +[`Acquire`] makes the store part of this operation [`Relaxed`], and +using [`Release`] makes the load part [`Relaxed`]. + +[`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire + # Examples ``` @@ -1323,6 +1487,16 @@ assert_eq!(foo.load(Ordering::SeqCst), 10); This operation wraps around on overflow. +`fetch_sub` takes an [`Ordering`] argument which describes the memory ordering +of this operation. All ordering modes are possible. Note that using +[`Acquire`] makes the store part of this operation [`Relaxed`], and +using [`Release`] makes the load part [`Relaxed`]. + +[`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire + # Examples ``` @@ -1347,6 +1521,16 @@ sets the new value to the result. Returns the previous value. +`fetch_and` takes an [`Ordering`] argument which describes the memory ordering +of this operation. All ordering modes are possible. Note that using +[`Acquire`] makes the store part of this operation [`Relaxed`], and +using [`Release`] makes the load part [`Relaxed`]. + +[`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire + # Examples ``` @@ -1371,6 +1555,16 @@ sets the new value to the result. Returns the previous value. +`fetch_nand` takes an [`Ordering`] argument which describes the memory ordering +of this operation. All ordering modes are possible. Note that using +[`Acquire`] makes the store part of this operation [`Relaxed`], and +using [`Release`] makes the load part [`Relaxed`]. + +[`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire + # Examples ``` @@ -1396,6 +1590,16 @@ sets the new value to the result. Returns the previous value. +`fetch_or` takes an [`Ordering`] argument which describes the memory ordering +of this operation. All ordering modes are possible. Note that using +[`Acquire`] makes the store part of this operation [`Relaxed`], and +using [`Release`] makes the load part [`Relaxed`]. + +[`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire + # Examples ``` @@ -1420,6 +1624,16 @@ sets the new value to the result. Returns the previous value. +`fetch_xor` takes an [`Ordering`] argument which describes the memory ordering +of this operation. All ordering modes are possible. Note that using +[`Acquire`] makes the store part of this operation [`Relaxed`], and +using [`Release`] makes the load part [`Relaxed`]. + +[`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire + # Examples ``` @@ -1445,6 +1659,25 @@ Note: This may call the function multiple times if the value has been changed fr the meantime, as long as the function returns `Some(_)`, but the function will have been applied but once to the stored value. +`fetch_update` takes two [`Ordering`] arguments to describe the memory +ordering of this operation. The first describes the required ordering for loads +and failed updates while the second describes the required ordering when the +operation finally succeeds. Beware that this is different from the two +modes in [`compare_exchange`]! + +Using [`Acquire`] as success ordering makes the store part +of this operation [`Relaxed`], and using [`Release`] makes the final successful load +[`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`] +and must be equivalent to or weaker than the success ordering. + +[`bool`]: ../../../std/primitive.bool.html +[`compare_exchange`]: #method.compare_exchange +[`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire +[`SeqCst`]: enum.Ordering.html#variant.SeqCst + # Examples ```rust @@ -1485,6 +1718,16 @@ sets the new value to the result. Returns the previous value. +`fetch_max` takes an [`Ordering`] argument which describes the memory ordering +of this operation. All ordering modes are possible. Note that using +[`Acquire`] makes the store part of this operation [`Relaxed`], and +using [`Release`] makes the load part [`Relaxed`]. + +[`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire + # Examples ``` @@ -1524,6 +1767,16 @@ sets the new value to the result. Returns the previous value. +`fetch_min` takes an [`Ordering`] argument which describes the memory ordering +of this operation. All ordering modes are possible. Note that using +[`Acquire`] makes the store part of this operation [`Relaxed`], and +using [`Release`] makes the load part [`Relaxed`]. + +[`Ordering`]: enum.Ordering.html +[`Relaxed`]: enum.Ordering.html#variant.Relaxed +[`Release`]: enum.Ordering.html#variant.Release +[`Acquire`]: enum.Ordering.html#variant.Acquire + # Examples ``` diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 373db1f1664cd..d2209da0ca30c 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -20,6 +20,8 @@ html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] +#![cfg_attr(not(stage0), feature(nll))] + pub use self::Piece::*; pub use self::Position::*; pub use self::Alignment::*; diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 158d010151586..a8eea18e46461 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -288,6 +288,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(allow(unused_variables), deny(warnings))))] +#![cfg_attr(not(stage0), feature(nll))] #![feature(str_escape)] use self::LabelText::*; diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index 392bf17968fbd..da568fae70e14 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -24,6 +24,7 @@ #![feature(core_intrinsics)] #![feature(libc)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(panic_runtime)] #![feature(staged_api)] #![feature(rustc_attrs)] diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs index 2abdf7cee6321..a61b2c1f06394 100644 --- a/src/libpanic_unwind/lib.rs +++ b/src/libpanic_unwind/lib.rs @@ -34,6 +34,7 @@ #![feature(core_intrinsics)] #![feature(lang_items)] #![feature(libc)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(panic_unwind)] #![feature(raw)] #![feature(staged_api)] diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index cfe3583a9806f..1ffe8157a0fb4 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -681,10 +681,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { } } &ty::Predicate::RegionOutlives(ref binder) => { - if let Err(_) = select - .infcx() - .region_outlives_predicate(&dummy_cause, binder) - { + if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() { return false; } } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index c04785aac2095..a02b63755dc12 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -143,7 +143,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // Eventually I'll need to implement param-env-aware // `Γ₁ ⊦ φ₁ => Γ₂ ⊦ φ₂` logic. let param_env = ty::ParamEnv::empty(); - if let Ok(_) = self.can_sub(param_env, error, implication) { + if self.can_sub(param_env, error, implication).is_ok() { debug!("error_implies: {:?} -> {:?} -> {:?}", cond, error, implication); return true } diff --git a/src/librustc/traits/query/outlives_bounds.rs b/src/librustc/traits/query/outlives_bounds.rs index f79ce73ad928a..0127ae423da54 100644 --- a/src/librustc/traits/query/outlives_bounds.rs +++ b/src/librustc/traits/query/outlives_bounds.rs @@ -137,7 +137,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { // variables. Process these constraints. let mut fulfill_cx = FulfillmentContext::new(); fulfill_cx.register_predicate_obligations(self, result.obligations); - if let Err(_) = fulfill_cx.select_all_or_error(self) { + if fulfill_cx.select_all_or_error(self).is_err() { self.tcx.sess.delay_span_bug( span, "implied_outlives_bounds failed to solve obligations from instantiation" diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 35184ca6a2559..1e3fe70535bcc 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -1587,8 +1587,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { -> bool { assert!(!skol_trait_ref.has_escaping_regions()); - if let Err(_) = self.infcx.at(&obligation.cause, obligation.param_env) - .sup(ty::Binder::dummy(skol_trait_ref), trait_bound) { + if self.infcx.at(&obligation.cause, obligation.param_env) + .sup(ty::Binder::dummy(skol_trait_ref), trait_bound).is_err() { return false; } diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 66edbeff749f7..7329f4832f2e2 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -294,7 +294,7 @@ fn resolve_associated_item<'a, 'tcx>( }) } traits::VtableBuiltin(..) => { - if let Some(_) = tcx.lang_items().clone_trait() { + if tcx.lang_items().clone_trait().is_some() { Some(Instance { def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()), substs: rcvr_substs diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs index 08438805a703e..d6e821d427d05 100644 --- a/src/librustc_apfloat/lib.rs +++ b/src/librustc_apfloat/lib.rs @@ -45,6 +45,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![forbid(unsafe_code)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(try_from)] // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] diff --git a/src/librustc_asan/lib.rs b/src/librustc_asan/lib.rs index 0c78fd74a234e..b3ba86ad8a4b3 100644 --- a/src/librustc_asan/lib.rs +++ b/src/librustc_asan/lib.rs @@ -10,6 +10,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index c7e7465a353fe..aa85582432b75 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -14,6 +14,7 @@ #![allow(non_camel_case_types)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(quote)] #![recursion_limit="256"] diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index 441fff5f08c8f..ff26e0f35f00f 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -169,6 +169,10 @@ const MIPS_WHITELIST: &[(&str, Option<&str>)] = &[ ("msa", Some("mips_target_feature")), ]; +const WASM_WHITELIST: &[(&str, Option<&str>)] = &[ + ("simd128", Some("wasm_target_feature")), +]; + /// When rustdoc is running, provide a list of all known features so that all their respective /// primtives may be documented. /// @@ -181,6 +185,7 @@ pub fn all_known_features() -> impl Iterator(sess: &Session, s: &'a str) -> &'a str { @@ -228,6 +233,7 @@ pub fn target_feature_whitelist(sess: &Session) "hexagon" => HEXAGON_WHITELIST, "mips" | "mips64" => MIPS_WHITELIST, "powerpc" | "powerpc64" => POWERPC_WHITELIST, + "wasm32" => WASM_WHITELIST, _ => &[], } } diff --git a/src/librustc_cratesio_shim/src/lib.rs b/src/librustc_cratesio_shim/src/lib.rs index 85a5b331d8c45..39087c5f74616 100644 --- a/src/librustc_cratesio_shim/src/lib.rs +++ b/src/librustc_cratesio_shim/src/lib.rs @@ -11,5 +11,7 @@ // See Cargo.toml for a comment explaining this crate. #![allow(unused_extern_crates)] +#![cfg_attr(not(stage0), feature(nll))] + extern crate bitflags; extern crate log; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 556ee9f5716ea..c3bdf07cd2079 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -20,6 +20,7 @@ #![feature(box_syntax)] #![cfg_attr(unix, feature(libc))] +#![cfg_attr(not(stage0), feature(nll))] #![feature(option_replace)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 09295e2c7ff00..6b1298750fba0 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1295,7 +1295,7 @@ impl EmitterWriter { } // if we elided some lines, add an ellipsis - if let Some(_) = lines.next() { + if lines.next().is_some() { buffer.puts(row_num, max_line_num_len - 1, "...", Style::LineNumber); } else if !show_underline { draw_col_separator_no_space(&mut buffer, row_num, max_line_num_len + 1); diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 82546747755f9..1666369e422ca 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -16,6 +16,7 @@ #![allow(unused_attributes)] #![feature(range_contains)] #![cfg_attr(unix, feature(libc))] +#![cfg_attr(not(stage0), feature(nll))] #![feature(optin_builtin_traits)] extern crate atty; diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index 73886e5e2816c..22b260642e424 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -14,6 +14,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), feature(nll))] #![feature(specialization)] #![recursion_limit="256"] diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 75d16232a37e0..801604d1379e3 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -27,6 +27,7 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(macro_vis_matcher)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(macro_at_most_once_rep)] diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 98946ad6081eb..a3591b2415a89 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -15,6 +15,7 @@ #![feature(box_patterns)] #![feature(libc)] #![feature(macro_at_most_once_rep)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(proc_macro_internals)] #![feature(proc_macro_quote)] #![feature(quote)] diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index aabed6686858f..67b92d92a343d 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -138,7 +138,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let tables = self.tcx.typeck_tables_of(id); let node_id = self.tcx.hir.as_local_node_id(id).unwrap(); let hir_id = self.tcx.hir.node_to_hir_id(node_id); - if let Some(_) = tables.closure_kind_origins().get(hir_id) { + if tables.closure_kind_origins().get(hir_id).is_some() { false } else { true @@ -735,7 +735,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { &including_downcast, )?; buf.push_str("["); - if let Err(_) = self.append_local_to_string(index, buf) { + if self.append_local_to_string(index, buf).is_err() { buf.push_str(".."); } buf.push_str("]"); diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 41f1e7829658a..d62cb00923f70 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -18,6 +18,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), feature(nll))] #![feature(rustc_diagnostic_macros)] #[macro_use] diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 348aa6a7cef4c..67f53a67313f7 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -64,6 +64,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), feature(nll))] #![feature(rustc_diagnostic_macros)] #[macro_use] extern crate syntax; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index b6dd0e8b9b21d..fcb1b65014be0 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -12,6 +12,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), feature(nll))] #![feature(rustc_diagnostic_macros)] #![recursion_limit="256"] diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index d96967725f45e..8ff4483492906 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -13,6 +13,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(crate_visibility_modifier)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(rustc_diagnostic_macros)] #![feature(slice_sort_by_cached_key)] @@ -2698,7 +2699,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { self.label_ribs.pop(); } self.ribs[ValueNS].pop(); - if let Some(_) = anonymous_module { + if anonymous_module.is_some() { self.ribs[TypeNS].pop(); } debug!("(resolving block) leaving block"); @@ -4256,7 +4257,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { while let Some((in_module, path_segments)) = worklist.pop() { // abort if the module is already found - if let Some(_) = result { break; } + if result.is_some() { break; } self.populate_module_if_necessary(in_module); diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/json_dumper.rs index 2fe7d73de8aa0..d2e52f98238dd 100644 --- a/src/librustc_save_analysis/json_dumper.rs +++ b/src/librustc_save_analysis/json_dumper.rs @@ -39,7 +39,7 @@ pub struct WriteOutput<'b, W: Write + 'b> { impl<'b, W: Write> DumpOutput for WriteOutput<'b, W> { fn dump(&mut self, result: &Analysis) { - if let Err(_) = write!(self.output, "{}", as_json(&result)) { + if write!(self.output, "{}", as_json(&result)).is_err() { error!("Error writing output"); } } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 703489f56c1fd..50aa48e8c5249 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -12,6 +12,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] +#![cfg_attr(not(stage0), feature(nll))] #![allow(unused_attributes)] #![recursion_limit="256"] @@ -125,7 +126,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { result.push(ExternalCrateData { // FIXME: change file_name field to PathBuf in rls-data // https://github.com/nrc/rls-data/issues/7 - file_name: SpanUtils::make_path_string(&lo_loc.file.name), + file_name: self.span_utils.make_path_string(&lo_loc.file.name), num: n.as_u32(), id: GlobalCrateId { name: self.tcx.crate_name(n).to_string(), diff --git a/src/librustc_save_analysis/span_utils.rs b/src/librustc_save_analysis/span_utils.rs index 4d93e81a78fa1..85dd2a3a20683 100644 --- a/src/librustc_save_analysis/span_utils.rs +++ b/src/librustc_save_analysis/span_utils.rs @@ -13,7 +13,6 @@ use rustc::session::Session; use generated_code; use std::cell::Cell; -use std::env; use syntax::parse::lexer::{self, StringReader}; use syntax::parse::token::{self, Token}; @@ -36,11 +35,10 @@ impl<'a> SpanUtils<'a> { } } - pub fn make_path_string(path: &FileName) -> String { + pub fn make_path_string(&self, path: &FileName) -> String { match *path { FileName::Real(ref path) if !path.is_absolute() => - env::current_dir() - .unwrap() + self.sess.working_dir.0 .join(&path) .display() .to_string(), diff --git a/src/librustc_target/abi/call/mips64.rs b/src/librustc_target/abi/call/mips64.rs index 3734e563d585e..8e2dd99696e17 100644 --- a/src/librustc_target/abi/call/mips64.rs +++ b/src/librustc_target/abi/call/mips64.rs @@ -145,7 +145,7 @@ fn classify_arg_ty<'a, Ty, C>(cx: C, arg: &mut ArgType<'a, Ty>) // Extract first 8 chunks as the prefix let rest_size = size - Size::from_bytes(8) * prefix_index as u64; arg.cast_to(CastTarget { - prefix: prefix, + prefix, prefix_chunk: Size::from_bytes(8), rest: Uniform { unit: Reg::i64(), total: rest_size } }); diff --git a/src/librustc_target/abi/call/mod.rs b/src/librustc_target/abi/call/mod.rs index f65fa341231e3..af874b1035b89 100644 --- a/src/librustc_target/abi/call/mod.rs +++ b/src/librustc_target/abi/call/mod.rs @@ -90,7 +90,7 @@ impl ArgAttributes { } pub fn set(&mut self, attr: ArgAttribute) -> &mut Self { - self.regular = self.regular | attr; + self.regular |= attr; self } @@ -229,7 +229,7 @@ impl CastTarget { pub fn align(&self, cx: C) -> Align { self.prefix.iter() - .filter_map(|x| x.map(|kind| Reg { kind: kind, size: self.prefix_chunk }.align(cx))) + .filter_map(|x| x.map(|kind| Reg { kind, size: self.prefix_chunk }.align(cx))) .fold(cx.data_layout().aggregate_align.max(self.rest.align(cx)), |acc, align| acc.max(align)) } diff --git a/src/librustc_target/abi/call/x86_64.rs b/src/librustc_target/abi/call/x86_64.rs index a443255b9700f..eade086ec48ec 100644 --- a/src/librustc_target/abi/call/x86_64.rs +++ b/src/librustc_target/abi/call/x86_64.rs @@ -199,10 +199,8 @@ pub fn compute_abi_info<'a, Ty, C>(cx: C, fty: &mut FnType<'a, Ty>) _ => {} } } - if arg.layout.is_aggregate() { - if int_regs < needed_int || sse_regs < needed_sse { - cls_or_mem = Err(Memory); - } + if arg.layout.is_aggregate() && (int_regs < needed_int || sse_regs < needed_sse) { + cls_or_mem = Err(Memory); } } } diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index dac4738e2b4bf..4f25360d8eae2 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -93,17 +93,17 @@ impl TargetDataLayout { let mut dl = TargetDataLayout::default(); let mut i128_align_src = 64; for spec in target.data_layout.split('-') { - match &spec.split(':').collect::>()[..] { - &["e"] => dl.endian = Endian::Little, - &["E"] => dl.endian = Endian::Big, - &["a", ref a..] => dl.aggregate_align = align(a, "a")?, - &["f32", ref a..] => dl.f32_align = align(a, "f32")?, - &["f64", ref a..] => dl.f64_align = align(a, "f64")?, - &[p @ "p", s, ref a..] | &[p @ "p0", s, ref a..] => { + match spec.split(':').collect::>()[..] { + ["e"] => dl.endian = Endian::Little, + ["E"] => dl.endian = Endian::Big, + ["a", ref a..] => dl.aggregate_align = align(a, "a")?, + ["f32", ref a..] => dl.f32_align = align(a, "f32")?, + ["f64", ref a..] => dl.f64_align = align(a, "f64")?, + [p @ "p", s, ref a..] | [p @ "p0", s, ref a..] => { dl.pointer_size = size(s, p)?; dl.pointer_align = align(a, p)?; } - &[s, ref a..] if s.starts_with("i") => { + [s, ref a..] if s.starts_with("i") => { let bits = match s[1..].parse::() { Ok(bits) => bits, Err(_) => { @@ -127,7 +127,7 @@ impl TargetDataLayout { dl.i128_align = a; } } - &[s, ref a..] if s.starts_with("v") => { + [s, ref a..] if s.starts_with("v") => { let v_size = size(&s[1..], "v")?; let a = align(a, s)?; if let Some(v) = dl.vector_align.iter_mut().find(|v| v.0 == v_size) { @@ -429,8 +429,8 @@ pub enum Integer { } impl Integer { - pub fn size(&self) -> Size { - match *self { + pub fn size(self) -> Size { + match self { I8 => Size::from_bytes(1), I16 => Size::from_bytes(2), I32 => Size::from_bytes(4), @@ -439,10 +439,10 @@ impl Integer { } } - pub fn align(&self, cx: C) -> Align { + pub fn align(self, cx: C) -> Align { let dl = cx.data_layout(); - match *self { + match self { I8 => dl.i8_align, I16 => dl.i16_align, I32 => dl.i32_align, @@ -522,15 +522,15 @@ impl fmt::Display for FloatTy { } impl FloatTy { - pub fn ty_to_string(&self) -> &'static str { - match *self { + pub fn ty_to_string(self) -> &'static str { + match self { FloatTy::F32 => "f32", FloatTy::F64 => "f64", } } - pub fn bit_width(&self) -> usize { - match *self { + pub fn bit_width(self) -> usize { + match self { FloatTy::F32 => 32, FloatTy::F64 => 64, } diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index af2697f62f79e..5f5cc4c5ff7c8 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -23,6 +23,7 @@ #![feature(box_syntax)] #![feature(const_fn)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(slice_patterns)] #[macro_use] diff --git a/src/librustc_target/spec/abi.rs b/src/librustc_target/spec/abi.rs index 317cdb400636c..6d8c8eb19f057 100644 --- a/src/librustc_target/spec/abi.rs +++ b/src/librustc_target/spec/abi.rs @@ -51,7 +51,7 @@ pub struct AbiData { } #[allow(non_upper_case_globals)] -const AbiDatas: &'static [AbiData] = &[ +const AbiDatas: &[AbiData] = &[ // Platform-specific ABIs AbiData {abi: Abi::Cdecl, name: "cdecl", generic: false }, AbiData {abi: Abi::Stdcall, name: "stdcall", generic: false }, @@ -87,20 +87,20 @@ pub fn all_names() -> Vec<&'static str> { impl Abi { #[inline] - pub fn index(&self) -> usize { - *self as usize + pub fn index(self) -> usize { + self as usize } #[inline] - pub fn data(&self) -> &'static AbiData { + pub fn data(self) -> &'static AbiData { &AbiDatas[self.index()] } - pub fn name(&self) -> &'static str { + pub fn name(self) -> &'static str { self.data().name } - pub fn generic(&self) -> bool { + pub fn generic(self) -> bool { self.data().generic } } diff --git a/src/librustc_target/spec/apple_base.rs b/src/librustc_target/spec/apple_base.rs index 4b66891e36f8c..38b3f2528fe86 100644 --- a/src/librustc_target/spec/apple_base.rs +++ b/src/librustc_target/spec/apple_base.rs @@ -26,7 +26,7 @@ pub fn opts() -> TargetOptions { // TLS is flagged as enabled if it looks to be supported. let deployment_target = env::var("MACOSX_DEPLOYMENT_TARGET").ok(); let version = deployment_target.as_ref().and_then(|s| { - let mut i = s.splitn(2, "."); + let mut i = s.splitn(2, '.'); i.next().and_then(|a| i.next().map(|b| (a, b))) }).and_then(|(a, b)| { a.parse::().and_then(|a| b.parse::().map(|b| (a, b))).ok() diff --git a/src/librustc_target/spec/apple_ios_base.rs b/src/librustc_target/spec/apple_ios_base.rs index 46bb01e7c420d..296eaca7c7df0 100644 --- a/src/librustc_target/spec/apple_ios_base.rs +++ b/src/librustc_target/spec/apple_ios_base.rs @@ -25,13 +25,13 @@ pub enum Arch { } impl Arch { - pub fn to_string(&self) -> &'static str { + pub fn to_string(self) -> &'static str { match self { - &Armv7 => "armv7", - &Armv7s => "armv7s", - &Arm64 => "arm64", - &I386 => "i386", - &X86_64 => "x86_64" + Armv7 => "armv7", + Armv7s => "armv7s", + Arm64 => "arm64", + I386 => "i386", + X86_64 => "x86_64" } } } diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 6faab77d7709f..4945784659517 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -747,7 +747,7 @@ impl Target { /// Maximum integer size in bits that this target can perform atomic /// operations on. pub fn max_atomic_width(&self) -> u64 { - self.options.max_atomic_width.unwrap_or(self.target_pointer_width.parse().unwrap()) + self.options.max_atomic_width.unwrap_or_else(|| self.target_pointer_width.parse().unwrap()) } pub fn is_abi_supported(&self, abi: Abi) -> bool { @@ -777,7 +777,7 @@ impl Target { let get_opt_field = |name: &str, default: &str| { obj.find(name).and_then(|s| s.as_string()) .map(|s| s.to_string()) - .unwrap_or(default.to_string()) + .unwrap_or_else(|| default.to_string()) }; let mut base = Target { @@ -1007,7 +1007,6 @@ impl Target { /// filesystem access and JSON decoding. pub fn search(target_triple: &TargetTriple) -> Result { use std::env; - use std::ffi::OsString; use std::fs; use serialize::json; @@ -1018,8 +1017,8 @@ impl Target { Target::from_json(obj) } - match target_triple { - &TargetTriple::TargetTriple(ref target_triple) => { + match *target_triple { + TargetTriple::TargetTriple(ref target_triple) => { // check if triple is in list of supported targets if let Ok(t) = load_specific(target_triple) { return Ok(t) @@ -1032,8 +1031,7 @@ impl Target { PathBuf::from(target) }; - let target_path = env::var_os("RUST_TARGET_PATH") - .unwrap_or(OsString::new()); + let target_path = env::var_os("RUST_TARGET_PATH").unwrap_or_default(); // FIXME 16351: add a sane default search path? @@ -1045,7 +1043,7 @@ impl Target { } Err(format!("Could not find specification for target {:?}", target_triple)) } - &TargetTriple::TargetPath(ref target_path) => { + TargetTriple::TargetPath(ref target_path) => { if target_path.is_file() { return load_file(&target_path); } @@ -1190,7 +1188,7 @@ impl ToJson for Target { if default.abi_blacklist != self.options.abi_blacklist { d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter() - .map(Abi::name).map(|name| name.to_json()) + .map(|&name| Abi::name(name).to_json()) .collect::>().to_json()); } @@ -1229,9 +1227,9 @@ impl TargetTriple { /// /// If this target is a path, the file name (without extension) is returned. pub fn triple(&self) -> &str { - match self { - &TargetTriple::TargetTriple(ref triple) => triple, - &TargetTriple::TargetPath(ref path) => { + match *self { + TargetTriple::TargetTriple(ref triple) => triple, + TargetTriple::TargetPath(ref path) => { path.file_stem().expect("target path must not be empty").to_str() .expect("target path must be valid unicode") } @@ -1247,7 +1245,7 @@ impl TargetTriple { use std::collections::hash_map::DefaultHasher; let triple = self.triple(); - if let &TargetTriple::TargetPath(ref path) = self { + if let TargetTriple::TargetPath(ref path) = *self { let mut hasher = DefaultHasher::new(); path.hash(&mut hasher); let hash = hasher.finish(); diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index d17cf35f1816a..ba6b2c57bfac6 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -16,6 +16,7 @@ #![feature(extern_prelude)] #![feature(iterator_find_map)] #![feature(in_band_lifetimes)] +#![cfg_attr(not(stage0), feature(nll))] #![recursion_limit="256"] diff --git a/src/librustc_tsan/lib.rs b/src/librustc_tsan/lib.rs index 0c78fd74a234e..b3ba86ad8a4b3 100644 --- a/src/librustc_tsan/lib.rs +++ b/src/librustc_tsan/lib.rs @@ -10,6 +10,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 8d8482208b97d..68e851446dc96 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -758,8 +758,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { self.span, infer::FnCall, &fty); if let Some(self_ty) = self_ty { - if let Err(_) = self.at(&ObligationCause::dummy(), self.param_env) - .sup(fty.inputs()[0], self_ty) + if self.at(&ObligationCause::dummy(), self.param_env) + .sup(fty.inputs()[0], self_ty) + .is_err() { return false } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 8c47df8b04221..9b6772e2dbb21 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3915,7 +3915,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } hir::ExprKind::Continue(destination) => { - if let Ok(_) = destination.target_id { + if destination.target_id.is_ok() { tcx.types.never } else { // There was an error, make typecheck fail diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 86e5bbeab706a..68e4618328077 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -486,7 +486,7 @@ pub fn run_core(search_paths: SearchPaths, &name, &output_filenames, |tcx, analysis, _, result| { - if let Err(_) = result { + if result.is_err() { sess.fatal("Compilation failed, aborting rustdoc"); } diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 73d7a9ab8599d..ff2cc35fce807 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -44,7 +44,7 @@ pub fn render_with_highlighting(src: &str, class: Option<&str>, write_header(class, &mut out).unwrap(); let mut classifier = Classifier::new(lexer::StringReader::new(&sess, fm, None), sess.codemap()); - if let Err(_) = classifier.write_source(&mut out) { + if classifier.write_source(&mut out).is_err() { return format!("
{}
", src); } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index b22e239e20a0e..c104b88334061 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -625,7 +625,7 @@ impl LangString { data.no_run = true; } x if allow_error_code_check && x.starts_with("E") && x.len() == 5 => { - if let Ok(_) = x[1..].parse::() { + if x[1..].parse::().is_ok() { data.error_codes.push(x.to_owned()); seen_rust_tags = !seen_other_tags || seen_rust_tags; } else { diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 62ef5626ee5bb..07507047dc2c9 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2208,6 +2208,25 @@ }; autoCollapse(getPageId(), getCurrentValue("rustdoc-collapse") === "true"); + + if (window.location.hash && window.location.hash.length > 0) { + var hash = getPageId(); + if (hash !== null) { + var elem = document.getElementById(hash); + if (elem && elem.offsetParent === null) { + console.log(elem, elem.parentNode); + if (elem.parentNode && elem.parentNode.previousSibling) { + var collapses = elem.parentNode + .previousSibling + .getElementsByClassName("collapse-toggle"); + if (collapses.length > 0) { + // The element is not visible, we need to make it appear! + collapseDocs(collapses[0], "show"); + } + } + } + } + } }()); // Sets the focus on the search bar at the top of the page diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs index d5eeb5252f0f1..4b8dda493b097 100644 --- a/src/libstd/os/raw/mod.rs +++ b/src/libstd/os/raw/mod.rs @@ -29,6 +29,8 @@ use fmt; all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")), all(target_os = "l4re", target_arch = "x86_64"), + all(target_os = "netbsd", any(target_arch = "arm", + target_arch = "powerpc")), all(target_os = "openbsd", target_arch = "aarch64"), all(target_os = "fuchsia", target_arch = "aarch64")))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8; @@ -41,6 +43,8 @@ use fmt; all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")), all(target_os = "l4re", target_arch = "x86_64"), + all(target_os = "netbsd", any(target_arch = "arm", + target_arch = "powerpc")), all(target_os = "openbsd", target_arch = "aarch64"), all(target_os = "fuchsia", target_arch = "aarch64"))))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8; diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index e7e94614ac865..f51d079a6c058 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -181,7 +181,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, for lhs in lhses { // try each arm's matchers let lhs_tt = match *lhs { quoted::TokenTree::Delimited(_, ref delim) => &delim.tts[..], - _ => cx.span_bug(sp, "malformed macro lhs") + _ => continue, }; match TokenTree::parse(cx, lhs_tt, arg.clone()) { Success(_) => { @@ -191,7 +191,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, err.span_suggestion_short( comma_span, "missing comma here", - ",".to_string(), + ", ".to_string(), ); } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 65eeaff3f1078..976708ae78816 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -452,6 +452,7 @@ declare_features! ( (active, mmx_target_feature, "1.27.0", Some(44839), None), (active, sse4a_target_feature, "1.27.0", Some(44839), None), (active, tbm_target_feature, "1.27.0", Some(44839), None), + (active, wasm_target_feature, "1.30.0", Some(44839), None), // Allows macro invocations of the form `#[foo::bar]` (active, proc_macro_path_invoc, "1.27.0", Some(38356), None), diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index d8b8d13a38c2e..62dd00387d3ab 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -631,7 +631,7 @@ fn path_name_i(idents: &[Ident]) -> String { let mut idents_iter = idents.iter().peekable(); while let Some(ident) = idents_iter.next() { path_name.push_str(&ident.as_str()); - if let Some(_) = idents_iter.peek() { + if idents_iter.peek().is_some() { path_name.push_str("::") } } diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index f84b5307a1137..fda975e6c456b 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -186,21 +186,43 @@ impl TokenStream { /// Given a `TokenStream` with a `Stream` of only two arguments, return a new `TokenStream` /// separating the two arguments with a comma for diagnostic suggestions. pub(crate) fn add_comma(&self) -> Option<(TokenStream, Span)> { - // Used to suggest if a user writes `println!("{}" a);` + // Used to suggest if a user writes `foo!(a b);` if let TokenStreamKind::Stream(ref slice) = self.kind { - if slice.len() == 2 { - let comma_span = match slice[0] { - TokenStream { kind: TokenStreamKind::Tree(TokenTree::Token(sp, _)) } | - TokenStream { kind: TokenStreamKind::Tree(TokenTree::Delimited(sp, _)) } => { - sp.shrink_to_hi() + let mut suggestion = None; + let mut iter = slice.iter().enumerate().peekable(); + while let Some((pos, ts)) = iter.next() { + if let Some((_, next)) = iter.peek() { + match (ts, next) { + (TokenStream { + kind: TokenStreamKind::Tree(TokenTree::Token(_, token::Token::Comma)) + }, _) | + (_, TokenStream { + kind: TokenStreamKind::Tree(TokenTree::Token(_, token::Token::Comma)) + }) => {} + (TokenStream { + kind: TokenStreamKind::Tree(TokenTree::Token(sp, _)) + }, _) | + (TokenStream { + kind: TokenStreamKind::Tree(TokenTree::Delimited(sp, _)) + }, _) => { + let sp = sp.shrink_to_hi(); + let comma = TokenStream { + kind: TokenStreamKind::Tree(TokenTree::Token(sp, token::Comma)), + }; + suggestion = Some((pos, comma, sp)); + } + _ => {} } - _ => DUMMY_SP, - }; - let comma = TokenStream { - kind: TokenStreamKind::Tree(TokenTree::Token(comma_span, token::Comma)), - }; - let slice = RcSlice::new(vec![slice[0].clone(), comma, slice[1].clone()]); - return Some((TokenStream { kind: TokenStreamKind::Stream(slice) }, comma_span)); + } + } + if let Some((pos, comma, sp)) = suggestion { + let mut new_slice = vec![]; + let parts = slice.split_at(pos + 1); + new_slice.extend_from_slice(parts.0); + new_slice.push(comma); + new_slice.extend_from_slice(parts.1); + let slice = RcSlice::new(new_slice); + return Some((TokenStream { kind: TokenStreamKind::Stream(slice) }, sp)); } } None diff --git a/src/libsyntax_ext/env.rs b/src/libsyntax_ext/env.rs index 3c34bf496da59..8f26b2402aadf 100644 --- a/src/libsyntax_ext/env.rs +++ b/src/libsyntax_ext/env.rs @@ -81,7 +81,7 @@ pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, } }; - if let Some(_) = exprs.next() { + if exprs.next().is_some() { cx.span_err(sp, "env! takes 1 or 2 arguments"); return DummyResult::expr(sp); } diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 53f8fe2b0c223..61f52194aad3e 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -14,8 +14,7 @@ use self::Position::*; use fmt_macros as parse; use syntax::ast; -use syntax::ext::base; -use syntax::ext::base::*; +use syntax::ext::base::{self, *}; use syntax::ext::build::AstBuilder; use syntax::feature_gate; use syntax::parse::token; @@ -24,6 +23,7 @@ use syntax::symbol::Symbol; use syntax::tokenstream; use syntax_pos::{MultiSpan, Span, DUMMY_SP}; +use std::borrow::Cow; use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; @@ -143,8 +143,10 @@ fn parse_args(ecx: &mut ExtCtxt, ecx.span_err(sp, "requires at least a format string argument"); return None; } + let fmtstr = panictry!(p.parse_expr()); let mut named = false; + while p.token != token::Eof { if !p.eat(&token::Comma) { ecx.span_err(p.span, "expected token: `,`"); @@ -264,11 +266,11 @@ impl<'a, 'b> Context<'a, 'b> { } } - fn describe_num_args(&self) -> String { + fn describe_num_args(&self) -> Cow { match self.args.len() { - 0 => "no arguments were given".to_string(), - 1 => "there is 1 argument".to_string(), - x => format!("there are {} arguments", x), + 0 => "no arguments were given".into(), + 1 => "there is 1 argument".into(), + x => format!("there are {} arguments", x).into(), } } @@ -772,8 +774,10 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, // `ArgumentType` does not derive `Clone`. let arg_types: Vec<_> = (0..args.len()).map(|_| Vec::new()).collect(); let arg_unique_types: Vec<_> = (0..args.len()).map(|_| Vec::new()).collect(); + let mut macsp = ecx.call_site(); macsp = macsp.apply_mark(ecx.current_expansion.mark); + let msg = "format argument must be a string literal"; let fmt_sp = efmt.span; let fmt = match expr_to_spanned_string(ecx, efmt, msg) { @@ -796,11 +800,46 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, return DummyResult::raw_expr(sp); } }; + let is_literal = match ecx.codemap().span_to_snippet(fmt_sp) { Ok(ref s) if s.starts_with("\"") || s.starts_with("r#") => true, _ => false, }; + let fmt_str = &*fmt.node.0.as_str(); + let str_style = match fmt.node.1 { + ast::StrStyle::Cooked => None, + ast::StrStyle::Raw(raw) => Some(raw as usize), + }; + + let mut parser = parse::Parser::new(fmt_str, str_style); + + let mut unverified_pieces = Vec::new(); + while let Some(piece) = parser.next() { + if !parser.errors.is_empty() { + break; + } else { + unverified_pieces.push(piece); + } + } + + if !parser.errors.is_empty() { + let err = parser.errors.remove(0); + let sp = fmt.span.from_inner_byte_pos(err.start, err.end); + let mut e = ecx.struct_span_err(sp, &format!("invalid format string: {}", + err.description)); + e.span_label(sp, err.label + " in format string"); + if let Some(note) = err.note { + e.note(¬e); + } + e.emit(); + return DummyResult::raw_expr(sp); + } + + let arg_spans = parser.arg_places.iter() + .map(|&(start, end)| fmt.span.from_inner_byte_pos(start, end)) + .collect(); + let mut cx = Context { ecx, args, @@ -815,42 +854,22 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, count_positions_count: 0, count_args_index_offset: 0, literal: String::new(), - pieces: Vec::new(), - str_pieces: Vec::new(), + pieces: Vec::with_capacity(unverified_pieces.len()), + str_pieces: Vec::with_capacity(unverified_pieces.len()), all_pieces_simple: true, macsp, fmtsp: fmt.span, invalid_refs: Vec::new(), - arg_spans: Vec::new(), + arg_spans, is_literal, }; - let fmt_str = &*fmt.node.0.as_str(); - let str_style = match fmt.node.1 { - ast::StrStyle::Cooked => None, - ast::StrStyle::Raw(raw) => Some(raw as usize), - }; - let mut parser = parse::Parser::new(fmt_str, str_style); - let mut unverified_pieces = vec![]; - let mut pieces = vec![]; - - while let Some(piece) = parser.next() { - if !parser.errors.is_empty() { - break; - } - unverified_pieces.push(piece); - } - - cx.arg_spans = parser.arg_places.iter() - .map(|&(start, end)| fmt.span.from_inner_byte_pos(start, end)) - .collect(); - // This needs to happen *after* the Parser has consumed all pieces to create all the spans - for mut piece in unverified_pieces { + let pieces = unverified_pieces.into_iter().map(|mut piece| { cx.verify_piece(&piece); cx.resolve_name_inplace(&mut piece); - pieces.push(piece); - } + piece + }).collect::>(); let numbered_position_args = pieces.iter().any(|arg: &parse::Piece| { match *arg { @@ -867,6 +886,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, cx.build_index_map(); let mut arg_index_consumed = vec![0usize; cx.arg_index_map.len()]; + for piece in pieces { if let Some(piece) = cx.build_piece(&piece, &mut arg_index_consumed) { let s = cx.build_literal_string(); @@ -875,18 +895,6 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, } } - if !parser.errors.is_empty() { - let err = parser.errors.remove(0); - let sp = cx.fmtsp.from_inner_byte_pos(err.start, err.end); - let mut e = cx.ecx.struct_span_err(sp, &format!("invalid format string: {}", - err.description)); - e.span_label(sp, err.label + " in format string"); - if let Some(note) = err.note { - e.note(¬e); - } - e.emit(); - return DummyResult::raw_expr(sp); - } if !cx.literal.is_empty() { let s = cx.build_literal_string(); cx.str_pieces.push(s); @@ -898,24 +906,25 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, // Make sure that all arguments were used and all arguments have types. let num_pos_args = cx.args.len() - cx.names.len(); - let mut errs = vec![]; - for (i, ty) in cx.arg_types.iter().enumerate() { - if ty.len() == 0 { - if cx.count_positions.contains_key(&i) { - continue; - } - let msg = if i >= num_pos_args { - // named argument - "named argument never used" - } else { - // positional argument - "argument never used" - }; - errs.push((cx.args[i].span, msg)); - } - } + + let errs = cx.arg_types + .iter() + .enumerate() + .filter(|(i, ty)| ty.is_empty() && !cx.count_positions.contains_key(&i)) + .map(|(i, _)| { + let msg = if i >= num_pos_args { + // named argument + "named argument never used" + } else { + // positional argument + "argument never used" + }; + (cx.args[i].span, msg) + }) + .collect::>(); + let errs_len = errs.len(); - if errs_len > 0 { + if !errs.is_empty() { let args_used = cx.arg_types.len() - errs_len; let args_unused = errs_len; diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 44cd53282ec9f..98d7d77308f89 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -21,6 +21,7 @@ #![feature(const_fn)] #![feature(crate_visibility_modifier)] #![feature(custom_attribute)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(non_exhaustive)] #![feature(optin_builtin_traits)] #![feature(specialization)] diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index cf92ce27ee587..a49fd67639dbe 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -50,6 +50,7 @@ #![cfg_attr(windows, feature(libc))] // Handle rustfmt skips #![feature(custom_attribute)] +#![cfg_attr(not(stage0), feature(nll))] #![allow(unused_attributes)] use std::io::prelude::*; diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs index 2b3c19c067ed4..424a7e3d009ec 100644 --- a/src/libunwind/lib.rs +++ b/src/libunwind/lib.rs @@ -13,6 +13,7 @@ #![feature(cfg_target_vendor)] #![feature(link_cfg)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(staged_api)] #![feature(unwind_attributes)] #![feature(static_nobundle)] diff --git a/src/test/ui/const-unsized.stderr b/src/test/ui/const-unsized.stderr index 4103ea02f2eaa..83d23bcba0493 100644 --- a/src/test/ui/const-unsized.stderr +++ b/src/test/ui/const-unsized.stderr @@ -5,7 +5,7 @@ LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: constant expressions must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -15,7 +15,7 @@ LL | const CONST_FOO: str = *"foo"; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: constant expressions must have a statically known size error[E0277]: the size for values of type `(dyn std::fmt::Debug + std::marker::Sync + 'static)` cannot be known at compilation time @@ -25,7 +25,7 @@ LL | static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: constant expressions must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -35,7 +35,7 @@ LL | static STATIC_BAR: str = *"bar"; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: constant expressions must have a statically known size error: aborting due to 4 previous errors diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index 3f934b60f06bb..e4c2f10226799 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -5,7 +5,7 @@ LL | fn f(p: Path) { } | ^ doesn't have a size known at compile-time | = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `std::path::Path` = note: all local variables must have a statically known size diff --git a/src/test/ui/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gate-trivial_bounds.stderr index 02b2f99d99277..f20c1ebb37aa9 100644 --- a/src/test/ui/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gate-trivial_bounds.stderr @@ -94,7 +94,7 @@ LL | struct TwoStrs(str, str) where str: Sized; //~ ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable @@ -107,7 +107,7 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: within `Dst<(dyn A + 'static)>`, the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Dst<(dyn A + 'static)>` = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable @@ -121,7 +121,7 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr index 953268ec30ff9..d91db6763ab24 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -9,7 +9,7 @@ LL | | }; | |____^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: the yield type of a generator must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -19,7 +19,7 @@ LL | unsafe { gen.resume(); } | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 2 previous errors diff --git a/src/test/ui/issue-14366.stderr b/src/test/ui/issue-14366.stderr index ff61ef0bde344..3c3ecd23bef6e 100644 --- a/src/test/ui/issue-14366.stderr +++ b/src/test/ui/issue-14366.stderr @@ -5,7 +5,7 @@ LL | let _x = "test" as &::std::any::Any; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn std::any::Any` error: aborting due to previous error diff --git a/src/test/ui/issue-15756.stderr b/src/test/ui/issue-15756.stderr index cea201816ec81..e142a504eb638 100644 --- a/src/test/ui/issue-15756.stderr +++ b/src/test/ui/issue-15756.stderr @@ -5,7 +5,7 @@ LL | &mut something | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[T]` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size error: aborting due to previous error diff --git a/src/test/ui/issue-17651.stderr b/src/test/ui/issue-17651.stderr index 7b7e5b5f07ed7..3e5679bdc3b3f 100644 --- a/src/test/ui/issue-17651.stderr +++ b/src/test/ui/issue-17651.stderr @@ -5,7 +5,7 @@ LL | (|| Box::new(*(&[0][..])))(); | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[{integer}]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `>::new` error: aborting due to previous error diff --git a/src/test/ui/issue-18107.stderr b/src/test/ui/issue-18107.stderr index 6fa9fb6f0165f..c813e290b9e6a 100644 --- a/src/test/ui/issue-18107.stderr +++ b/src/test/ui/issue-18107.stderr @@ -5,7 +5,7 @@ LL | AbstractRenderer | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn AbstractRenderer + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: the return type of a function must have a statically known size error: aborting due to previous error diff --git a/src/test/ui/issue-18919.stderr b/src/test/ui/issue-18919.stderr index f9a098ba29034..0e71b0bbedde2 100644 --- a/src/test/ui/issue-18919.stderr +++ b/src/test/ui/issue-18919.stderr @@ -7,7 +7,7 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn for<'r> std::ops::Fn(&'r isize) -> isize` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::option::Option` error: aborting due to previous error diff --git a/src/test/ui/issue-20005.stderr b/src/test/ui/issue-20005.stderr index 645dcb1a9dc07..b0b38c9746231 100644 --- a/src/test/ui/issue-20005.stderr +++ b/src/test/ui/issue-20005.stderr @@ -9,7 +9,7 @@ LL | | } | |_____^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Self` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Self: std::marker::Sized` bound note: required by `From` --> $DIR/issue-20005.rs:11:1 diff --git a/src/test/ui/issue-20433.stderr b/src/test/ui/issue-20433.stderr index 5e8bf2858bf34..9800c9b3b58e1 100644 --- a/src/test/ui/issue-20433.stderr +++ b/src/test/ui/issue-20433.stderr @@ -5,7 +5,7 @@ LL | fn iceman(c: Vec<[i32]>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i32]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issue-20605.stderr b/src/test/ui/issue-20605.stderr index e85ea873e680e..fb32283ddf7b9 100644 --- a/src/test/ui/issue-20605.stderr +++ b/src/test/ui/issue-20605.stderr @@ -5,7 +5,7 @@ LL | for item in *things { *item = 0 } | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn std::iter::Iterator` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::iter::IntoIterator::into_iter` error: aborting due to previous error diff --git a/src/test/ui/issue-22874.stderr b/src/test/ui/issue-22874.stderr index a8144dc6dad92..a69ee7c9ff01b 100644 --- a/src/test/ui/issue-22874.stderr +++ b/src/test/ui/issue-22874.stderr @@ -5,7 +5,7 @@ LL | rows: [[String]], | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[std::string::String]` - = note: to learn more, visit + = note: to learn more, visit = note: slice and array elements must have `Sized` type error: aborting due to previous error diff --git a/src/test/ui/issue-23281.stderr b/src/test/ui/issue-23281.stderr index c7391ad8b5fa6..78db19d6b06ff 100644 --- a/src/test/ui/issue-23281.stderr +++ b/src/test/ui/issue-23281.stderr @@ -5,7 +5,7 @@ LL | pub fn function(funs: Vec ()>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issue-24446.stderr b/src/test/ui/issue-24446.stderr index 8614fc647dd30..3c42462743700 100644 --- a/src/test/ui/issue-24446.stderr +++ b/src/test/ui/issue-24446.stderr @@ -24,7 +24,7 @@ LL | | }; | |_____^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() -> u32 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: constant expressions must have a statically known size error: aborting due to 2 previous errors diff --git a/src/test/ui/issue-27060-2.stderr b/src/test/ui/issue-27060-2.stderr index 7961b1720f329..ed9db2ea55ed9 100644 --- a/src/test/ui/issue-27060-2.stderr +++ b/src/test/ui/issue-27060-2.stderr @@ -5,7 +5,7 @@ LL | data: T, //~ ERROR the size for values of type | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: only the last field of a struct may have a dynamically sized type diff --git a/src/test/ui/issue-27078.stderr b/src/test/ui/issue-27078.stderr index dcfd82fec0bef..65b66997ee829 100644 --- a/src/test/ui/issue-27078.stderr +++ b/src/test/ui/issue-27078.stderr @@ -5,7 +5,7 @@ LL | fn foo(self) -> &'static i32 { | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Self` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Self: std::marker::Sized` bound = note: all local variables must have a statically known size diff --git a/src/test/ui/issue-35988.stderr b/src/test/ui/issue-35988.stderr index 38a9409b6a0ab..0b9d846924798 100644 --- a/src/test/ui/issue-35988.stderr +++ b/src/test/ui/issue-35988.stderr @@ -5,7 +5,7 @@ LL | V([Box]), | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[std::boxed::Box]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error: aborting due to previous error diff --git a/src/test/ui/issue-38954.stderr b/src/test/ui/issue-38954.stderr index 714ab00b00c78..2f0e579378ffc 100644 --- a/src/test/ui/issue-38954.stderr +++ b/src/test/ui/issue-38954.stderr @@ -5,7 +5,7 @@ LL | fn _test(ref _p: str) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to previous error diff --git a/src/test/ui/issue-41229-ref-str.stderr b/src/test/ui/issue-41229-ref-str.stderr index d8933a3dfab12..effc5f6999e36 100644 --- a/src/test/ui/issue-41229-ref-str.stderr +++ b/src/test/ui/issue-41229-ref-str.stderr @@ -5,7 +5,7 @@ LL | pub fn example(ref s: str) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to previous error diff --git a/src/test/ui/issue-42312.stderr b/src/test/ui/issue-42312.stderr index 8c7d5d8828ff9..8c2a0987f2f3f 100644 --- a/src/test/ui/issue-42312.stderr +++ b/src/test/ui/issue-42312.stderr @@ -5,7 +5,7 @@ LL | fn baz(_: Self::Target) where Self: Deref {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `::Target` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where ::Target: std::marker::Sized` bound error[E0277]: the size for values of type `(dyn std::string::ToString + 'static)` cannot be known at compilation time @@ -15,7 +15,7 @@ LL | pub fn f(_: ToString) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::string::ToString + 'static)` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 2 previous errors diff --git a/src/test/ui/issue-5883.stderr b/src/test/ui/issue-5883.stderr index 8dfeaa7f88891..6a321abeaed9c 100644 --- a/src/test/ui/issue-5883.stderr +++ b/src/test/ui/issue-5883.stderr @@ -5,7 +5,7 @@ LL | fn new_struct(r: A+'static) | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time @@ -15,7 +15,7 @@ LL | -> Struct { //~^ ERROR the size for values of type | ^^^^^^ doesn't have a size known at compile-time | = help: within `Struct`, the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Struct` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/macros/missing-comma.rs b/src/test/ui/macros/missing-comma.rs index ac82171a4e8cc..07e69b9619d1f 100644 --- a/src/test/ui/macros/missing-comma.rs +++ b/src/test/ui/macros/missing-comma.rs @@ -9,7 +9,11 @@ // except according to those terms. macro_rules! foo { - ($a:ident, $b:ident) => () + ($a:ident) => (); + ($a:ident, $b:ident) => (); + ($a:ident, $b:ident, $c:ident) => (); + ($a:ident, $b:ident, $c:ident, $d:ident) => (); + ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => (); } fn main() { @@ -17,4 +21,10 @@ fn main() { //~^ ERROR expected token: `,` foo!(a b); //~^ ERROR no rules expected the token `b` + foo!(a, b, c, d e); + //~^ ERROR no rules expected the token `e` + foo!(a, b, c d, e); + //~^ ERROR no rules expected the token `d` + foo!(a, b, c d e); + //~^ ERROR no rules expected the token `d` } diff --git a/src/test/ui/macros/missing-comma.stderr b/src/test/ui/macros/missing-comma.stderr index 3467032d9b5f3..9d8de87e5bb7f 100644 --- a/src/test/ui/macros/missing-comma.stderr +++ b/src/test/ui/macros/missing-comma.stderr @@ -1,16 +1,38 @@ error: expected token: `,` - --> $DIR/missing-comma.rs:16:19 + --> $DIR/missing-comma.rs:20:19 | LL | println!("{}" a); | ^ error: no rules expected the token `b` - --> $DIR/missing-comma.rs:18:12 + --> $DIR/missing-comma.rs:22:12 | LL | foo!(a b); | -^ | | | help: missing comma here -error: aborting due to 2 previous errors +error: no rules expected the token `e` + --> $DIR/missing-comma.rs:24:21 + | +LL | foo!(a, b, c, d e); + | -^ + | | + | help: missing comma here + +error: no rules expected the token `d` + --> $DIR/missing-comma.rs:26:18 + | +LL | foo!(a, b, c d, e); + | -^ + | | + | help: missing comma here + +error: no rules expected the token `d` + --> $DIR/missing-comma.rs:28:18 + | +LL | foo!(a, b, c d e); + | ^ + +error: aborting due to 5 previous errors diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr index d3b9adeff406f..81fe49328116d 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.stderr +++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr @@ -223,7 +223,7 @@ LL | let _ = fat_v as *const Foo; //~ ERROR the size for values of type | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -233,7 +233,7 @@ LL | let _ = a as *const Foo; //~ ERROR the size for values of type | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error[E0606]: casting `&{float}` as `f32` is invalid diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr index 21c0a620f6931..10d7a52297f55 100644 --- a/src/test/ui/resolve/issue-5035-2.stderr +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -5,7 +5,7 @@ LL | fn foo(_x: K) {} | ^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn I + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size error: aborting due to previous error diff --git a/src/test/ui/str-array-assignment.stderr b/src/test/ui/str-array-assignment.stderr index 7a774cab38e40..59521bd2e2fab 100644 --- a/src/test/ui/str-array-assignment.stderr +++ b/src/test/ui/str-array-assignment.stderr @@ -28,7 +28,7 @@ LL | let v = s[..2]; | doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size error[E0308]: mismatched types diff --git a/src/test/ui/target-feature-gate.rs b/src/test/ui/target-feature-gate.rs index c2dc927c4b524..8a045884cae31 100644 --- a/src/test/ui/target-feature-gate.rs +++ b/src/test/ui/target-feature-gate.rs @@ -23,6 +23,7 @@ // gate-test-hexagon_target_feature // gate-test-mips_target_feature // gate-test-mmx_target_feature +// gate-test-wasm_target_feature // min-llvm-version 6.0 #[target_feature(enable = "avx512bw")] diff --git a/src/test/ui/target-feature-gate.stderr b/src/test/ui/target-feature-gate.stderr index 24141d0064fb0..f18bebc0c290d 100644 --- a/src/test/ui/target-feature-gate.stderr +++ b/src/test/ui/target-feature-gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `avx512bw` is currently unstable (see issue #44839) - --> $DIR/target-feature-gate.rs:28:18 + --> $DIR/target-feature-gate.rs:29:18 | LL | #[target_feature(enable = "avx512bw")] | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/trait-suggest-where-clause.stderr b/src/test/ui/trait-suggest-where-clause.stderr index f50644042bbd0..3b33596086711 100644 --- a/src/test/ui/trait-suggest-where-clause.stderr +++ b/src/test/ui/trait-suggest-where-clause.stderr @@ -5,7 +5,7 @@ LL | mem::size_of::(); | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `U` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where U: std::marker::Sized` bound = note: required by `std::mem::size_of` @@ -16,7 +16,7 @@ LL | mem::size_of::>(); | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Misc`, the trait `std::marker::Sized` is not implemented for `U` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where U: std::marker::Sized` bound = note: required because it appears within the type `Misc` = note: required by `std::mem::size_of` @@ -54,7 +54,7 @@ LL | mem::size_of::<[T]>(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[T]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::mem::size_of` error[E0277]: the size for values of type `[&U]` cannot be known at compilation time @@ -64,7 +64,7 @@ LL | mem::size_of::<[&U]>(); | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[&U]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::mem::size_of` error: aborting due to 7 previous errors diff --git a/src/test/ui/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds-leak.stderr index 5510b9f2874e3..984e492281fc5 100644 --- a/src/test/ui/trivial-bounds-leak.stderr +++ b/src/test/ui/trivial-bounds-leak.stderr @@ -5,7 +5,7 @@ LL | fn cant_return_str() -> str { //~ ERROR | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: the return type of a function must have a statically known size error[E0599]: no method named `test` found for type `i32` in the current scope diff --git a/src/test/ui/union/union-sized-field.stderr b/src/test/ui/union/union-sized-field.stderr index 75a6542fe23af..85e9702a40ebf 100644 --- a/src/test/ui/union/union-sized-field.stderr +++ b/src/test/ui/union/union-sized-field.stderr @@ -5,7 +5,7 @@ LL | value: T, | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: no field of a union may have a dynamically sized type @@ -16,7 +16,7 @@ LL | value: T, | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: only the last field of a struct may have a dynamically sized type @@ -27,7 +27,7 @@ LL | Value(T), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type diff --git a/src/test/ui/unsized-enum2.stderr b/src/test/ui/unsized-enum2.stderr index bd97978ea64b2..ecaa01464690c 100644 --- a/src/test/ui/unsized-enum2.stderr +++ b/src/test/ui/unsized-enum2.stderr @@ -5,7 +5,7 @@ LL | VA(W), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `W` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where W: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -16,7 +16,7 @@ LL | VB{x: X}, | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -27,7 +27,7 @@ LL | VC(isize, Y), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Y` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Y: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -38,7 +38,7 @@ LL | VD{u: isize, x: Z}, | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Z` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Z: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -49,7 +49,7 @@ LL | VE([u8]), | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -59,7 +59,7 @@ LL | VF{x: str}, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[f32]` cannot be known at compilation time @@ -69,7 +69,7 @@ LL | VG(isize, [f32]), | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[f32]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[u32]` cannot be known at compilation time @@ -79,7 +79,7 @@ LL | VH{u: isize, x: [u32]}, | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u32]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time @@ -89,7 +89,7 @@ LL | VM(Foo), | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn Bar + 'static)` cannot be known at compilation time @@ -99,7 +99,7 @@ LL | VN{x: Bar}, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Bar + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn FooBar + 'static)` cannot be known at compilation time @@ -109,7 +109,7 @@ LL | VO(isize, FooBar), | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn FooBar + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn BarFoo + 'static)` cannot be known at compilation time @@ -119,7 +119,7 @@ LL | VP{u: isize, x: BarFoo}, | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn BarFoo + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[i8]` cannot be known at compilation time @@ -129,7 +129,7 @@ LL | VQ(<&'static [i8] as Deref>::Target), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i8]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[char]` cannot be known at compilation time @@ -139,7 +139,7 @@ LL | VR{x: <&'static [char] as Deref>::Target}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[char]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[f64]` cannot be known at compilation time @@ -149,7 +149,7 @@ LL | VS(isize, <&'static [f64] as Deref>::Target), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[f64]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[i32]` cannot be known at compilation time @@ -159,7 +159,7 @@ LL | VT{u: isize, x: <&'static [i32] as Deref>::Target}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i32]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn PathHelper1 + 'static)` cannot be known at compilation time @@ -169,7 +169,7 @@ LL | VI(Path1), | ^^^^^ doesn't have a size known at compile-time | = help: within `Path1`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper1 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path1` = note: no field of an enum variant may have a dynamically sized type @@ -180,7 +180,7 @@ LL | VJ{x: Path2}, | ^^^^^^^^ doesn't have a size known at compile-time | = help: within `Path2`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper2 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path2` = note: no field of an enum variant may have a dynamically sized type @@ -191,7 +191,7 @@ LL | VK(isize, Path3), | ^^^^^ doesn't have a size known at compile-time | = help: within `Path3`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper3 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path3` = note: no field of an enum variant may have a dynamically sized type @@ -202,7 +202,7 @@ LL | VL{u: isize, x: Path4}, | ^^^^^^^^ doesn't have a size known at compile-time | = help: within `Path4`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper4 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path4` = note: no field of an enum variant may have a dynamically sized type