From f19baf0977b176ba26277af479a19b71b7ee1fdb Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 22 Dec 2017 18:58:39 +0100 Subject: Rename std::ptr::Shared to NonNull `Shared` is now a deprecated `type` alias. CC https://github.com/rust-lang/rust/issues/27730#issuecomment-352800629 --- src/libstd/panic.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 53c2211745c..68584b7cf25 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -17,7 +17,7 @@ use cell::UnsafeCell; use fmt; use ops::{Deref, DerefMut}; use panicking; -use ptr::{Unique, Shared}; +use ptr::{Unique, NonNull}; use rc::Rc; use sync::{Arc, Mutex, RwLock, atomic}; use thread::Result; @@ -198,8 +198,8 @@ impl UnwindSafe for *const T {} impl UnwindSafe for *mut T {} #[unstable(feature = "unique", issue = "27730")] impl UnwindSafe for Unique {} -#[unstable(feature = "shared", issue = "27730")] -impl UnwindSafe for Shared {} +#[unstable(feature = "nonnull", issue = "27730")] +impl UnwindSafe for NonNull {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for Mutex {} #[stable(feature = "catch_unwind", since = "1.9.0")] -- cgit 1.4.1-3-g733a5 From c97c1f7dc3b8c2e5e1c40681094c45cf55be5832 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 22 Dec 2017 19:29:16 +0100 Subject: Mark Unique as perma-unstable, with the feature renamed to ptr_internals. --- src/doc/nomicon | 2 +- src/liballoc/lib.rs | 2 +- src/libcore/ptr.rs | 30 +++++++++++++++--------------- src/libcore/tests/lib.rs | 2 +- src/libcore/tests/ptr.rs | 4 ++-- src/libstd/lib.rs | 2 +- src/libstd/panic.rs | 2 +- src/test/run-pass/issue-23433.rs | 6 +++--- 8 files changed, 25 insertions(+), 25 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/doc/nomicon b/src/doc/nomicon index 2f7b05fd593..fec3182d0b0 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit 2f7b05fd5939aa49d52c4ab309b9a47776ba7bd8 +Subproject commit fec3182d0b0a3cf8122e192b3270064a5b19be5b diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index eaad6f1116f..07e4ccc45a9 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -110,6 +110,7 @@ #![feature(pattern)] #![feature(placement_in_syntax)] #![feature(placement_new_protocol)] +#![feature(ptr_internals)] #![feature(rustc_attrs)] #![feature(slice_get_slice)] #![feature(slice_patterns)] @@ -120,7 +121,6 @@ #![feature(trusted_len)] #![feature(unboxed_closures)] #![feature(unicode)] -#![feature(unique)] #![feature(unsize)] #![feature(allocator_internals)] #![feature(on_unimplemented)] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 89ecb3457fc..e39c520880a 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2330,8 +2330,9 @@ impl PartialOrd for *mut T { /// /// Unlike `*mut T`, `Unique` is covariant over `T`. This should always be correct /// for any type which upholds Unique's aliasing requirements. -#[unstable(feature = "unique", reason = "needs an RFC to flesh out design", - issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0", + reason = "use NonNull instead and consider PhantomData \ + (if you also use #[may_dangle]), Send, and/or Sync")] pub struct Unique { pointer: NonZero<*const T>, // NOTE: this marker has no consequences for variance, but is necessary @@ -2342,7 +2343,7 @@ pub struct Unique { _marker: PhantomData, } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl fmt::Debug for Unique { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:p}", self.as_ptr()) @@ -2353,17 +2354,17 @@ impl fmt::Debug for Unique { /// reference is unaliased. Note that this aliasing invariant is /// unenforced by the type system; the abstraction using the /// `Unique` must enforce it. -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] unsafe impl Send for Unique { } /// `Unique` pointers are `Sync` if `T` is `Sync` because the data they /// reference is unaliased. Note that this aliasing invariant is /// unenforced by the type system; the abstraction using the /// `Unique` must enforce it. -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] unsafe impl Sync for Unique { } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl Unique { /// Creates a new `Unique` that is dangling, but well-aligned. /// @@ -2377,14 +2378,13 @@ impl Unique { } } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl Unique { /// Creates a new `Unique`. /// /// # Safety /// /// `ptr` must be non-null. - #[unstable(feature = "unique", issue = "27730")] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { Unique { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData } } @@ -2418,41 +2418,41 @@ impl Unique { } } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl Clone for Unique { fn clone(&self) -> Self { *self } } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl Copy for Unique { } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl CoerceUnsized> for Unique where T: Unsize { } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl fmt::Pointer for Unique { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) } } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl<'a, T: ?Sized> From<&'a mut T> for Unique { fn from(reference: &'a mut T) -> Self { Unique { pointer: NonZero::from(reference), _marker: PhantomData } } } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl<'a, T: ?Sized> From<&'a T> for Unique { fn from(reference: &'a T) -> Self { Unique { pointer: NonZero::from(reference), _marker: PhantomData } } } -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl<'a, T: ?Sized> From> for Unique { fn from(p: NonNull) -> Self { Unique { pointer: p.pointer, _marker: PhantomData } diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 2c0009569d7..bc7052d676d 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -27,6 +27,7 @@ #![feature(iterator_try_fold)] #![feature(iter_rfind)] #![feature(iter_rfold)] +#![feature(nonnull)] #![feature(nonzero)] #![feature(pattern)] #![feature(raw)] @@ -41,7 +42,6 @@ #![feature(trusted_len)] #![feature(try_from)] #![feature(try_trait)] -#![feature(unique)] #![feature(exact_chunks)] extern crate core; diff --git a/src/libcore/tests/ptr.rs b/src/libcore/tests/ptr.rs index 98436f0e1d1..00f87336f3c 100644 --- a/src/libcore/tests/ptr.rs +++ b/src/libcore/tests/ptr.rs @@ -249,9 +249,9 @@ fn test_set_memory() { } #[test] -fn test_unsized_unique() { +fn test_unsized_nonnull() { let xs: &[i32] = &[1, 2, 3]; - let ptr = unsafe { Unique::new_unchecked(xs as *const [i32] as *mut [i32]) }; + let ptr = unsafe { NonNull::new_unchecked(xs as *const [i32] as *mut [i32]) }; let ys = unsafe { ptr.as_ref() }; let zs: &[i32] = &[1, 2, 3]; assert!(ys == zs); diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8a1ba32f7dc..9f65d61658c 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -294,6 +294,7 @@ #![feature(placement_in_syntax)] #![feature(placement_new_protocol)] #![feature(prelude_import)] +#![feature(ptr_internals)] #![feature(rand)] #![feature(raw)] #![feature(repr_align)] @@ -315,7 +316,6 @@ #![feature(try_from)] #![feature(unboxed_closures)] #![feature(unicode)] -#![feature(unique)] #![feature(untagged_unions)] #![feature(unwind_attributes)] #![feature(vec_push_all)] diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 68584b7cf25..6f7d8ddb770 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -196,7 +196,7 @@ impl<'a, T: RefUnwindSafe + ?Sized> UnwindSafe for &'a T {} impl UnwindSafe for *const T {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for *mut T {} -#[unstable(feature = "unique", issue = "27730")] +#[unstable(feature = "ptr_internals", issue = "0")] impl UnwindSafe for Unique {} #[unstable(feature = "nonnull", issue = "27730")] impl UnwindSafe for NonNull {} diff --git a/src/test/run-pass/issue-23433.rs b/src/test/run-pass/issue-23433.rs index aa13d6fad47..37cc1b134c3 100644 --- a/src/test/run-pass/issue-23433.rs +++ b/src/test/run-pass/issue-23433.rs @@ -10,13 +10,13 @@ // Don't fail if we encounter a NonZero<*T> where T is an unsized type -#![feature(unique)] +#![feature(nonnull)] -use std::ptr::Unique; +use std::ptr::NonNull; fn main() { let mut a = [0u8; 5]; - let b: Option> = Some(Unique::from(&mut a)); + let b: Option> = Some(NonNull::from(&mut a)); match b { Some(_) => println!("Got `Some`"), None => panic!("Unexpected `None`"), -- cgit 1.4.1-3-g733a5 From 55c50cd8ac5ed5a799bc9f5aa1fe8fcfbb956706 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 22 Dec 2017 19:50:21 +0100 Subject: Stabilize std::ptr::NonNull --- src/liballoc/boxed.rs | 10 ++-------- src/liballoc/lib.rs | 1 - src/libcore/ptr.rs | 32 +++++++++++++++++--------------- src/libcore/tests/lib.rs | 1 - src/librustc_data_structures/lib.rs | 1 - src/libstd/lib.rs | 1 - src/libstd/panic.rs | 2 +- src/test/run-pass/issue-23433.rs | 2 -- 8 files changed, 20 insertions(+), 30 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 994466e2249..e7bc10dfaa9 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -288,16 +288,13 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(nonnull)] - /// /// fn main() { /// let x = Box::new(5); /// let ptr = Box::into_nonnull_raw(x); /// let x = unsafe { Box::from_nonnull_raw(ptr) }; /// } /// ``` - #[unstable(feature = "nonnull", reason = "needs an RFC to flesh out design", - issue = "27730")] + #[stable(feature = "nonnull", since = "1.24.0")] #[inline] pub unsafe fn from_nonnull_raw(u: NonNull) -> Self { Box(u.into()) @@ -352,15 +349,12 @@ impl Box { /// # Examples /// /// ``` - /// #![feature(nonnull)] - /// /// fn main() { /// let x = Box::new(5); /// let ptr = Box::into_nonnull_raw(x); /// } /// ``` - #[unstable(feature = "nonnull", reason = "needs an RFC to flesh out design", - issue = "27730")] + #[stable(feature = "nonnull", since = "1.24.0")] #[inline] pub fn into_nonnull_raw(b: Box) -> NonNull { Box::into_unique(b).into() diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 07e4ccc45a9..f25b455f915 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -103,7 +103,6 @@ #![feature(iter_rfold)] #![feature(lang_items)] #![feature(needs_allocator)] -#![feature(nonnull)] #![feature(nonzero)] #![feature(offset_to)] #![feature(optin_builtin_traits)] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 6cb84615d09..2e5f36ed71f 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2481,13 +2481,12 @@ pub type Shared = NonNull; /// Usually this won't be necessary; covariance is correct for most safe abstractions, /// such as Box, Rc, Arc, Vec, and LinkedList. This is the case because they /// provide a public API that follows the normal shared XOR mutable rules of Rust. -#[unstable(feature = "shared", reason = "needs an RFC to flesh out design", - issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] pub struct NonNull { pointer: NonZero<*const T>, } -#[unstable(feature = "shared", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl fmt::Debug for NonNull { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:p}", self.as_ptr()) @@ -2496,20 +2495,20 @@ impl fmt::Debug for NonNull { /// `NonNull` pointers are not `Send` because the data they reference may be aliased. // NB: This impl is unnecessary, but should provide better error messages. -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl !Send for NonNull { } /// `NonNull` pointers are not `Sync` because the data they reference may be aliased. // NB: This impl is unnecessary, but should provide better error messages. -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl !Sync for NonNull { } -#[unstable(feature = "nonnull", issue = "27730")] impl NonNull { /// Creates a new `NonNull` that is dangling, but well-aligned. /// /// This is useful for initializing types which lazily allocate, like /// `Vec::new` does. + #[stable(feature = "nonnull", since = "1.24.0")] pub fn empty() -> Self { unsafe { let ptr = mem::align_of::() as *mut T; @@ -2518,24 +2517,25 @@ impl NonNull { } } -#[unstable(feature = "nonnull", issue = "27730")] impl NonNull { /// Creates a new `NonNull`. /// /// # Safety /// /// `ptr` must be non-null. - #[unstable(feature = "nonnull", issue = "27730")] + #[stable(feature = "nonnull", since = "1.24.0")] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { NonNull { pointer: NonZero::new_unchecked(ptr) } } /// Creates a new `NonNull` if `ptr` is non-null. + #[stable(feature = "nonnull", since = "1.24.0")] pub fn new(ptr: *mut T) -> Option { NonZero::new(ptr as *const T).map(|nz| NonNull { pointer: nz }) } /// Acquires the underlying `*mut` pointer. + #[stable(feature = "nonnull", since = "1.24.0")] pub fn as_ptr(self) -> *mut T { self.pointer.get() as *mut T } @@ -2545,6 +2545,7 @@ impl NonNull { /// The resulting lifetime is bound to self so this behaves "as if" /// it were actually an instance of T that is getting borrowed. If a longer /// (unbound) lifetime is needed, use `&*my_ptr.ptr()`. + #[stable(feature = "nonnull", since = "1.24.0")] pub unsafe fn as_ref(&self) -> &T { &*self.as_ptr() } @@ -2554,46 +2555,47 @@ impl NonNull { /// The resulting lifetime is bound to self so this behaves "as if" /// it were actually an instance of T that is getting borrowed. If a longer /// (unbound) lifetime is needed, use `&mut *my_ptr.ptr_mut()`. + #[stable(feature = "nonnull", since = "1.24.0")] pub unsafe fn as_mut(&mut self) -> &mut T { &mut *self.as_ptr() } } -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl Clone for NonNull { fn clone(&self) -> Self { *self } } -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl Copy for NonNull { } -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl CoerceUnsized> for NonNull where T: Unsize { } -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl fmt::Pointer for NonNull { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) } } -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl From> for NonNull { fn from(unique: Unique) -> Self { NonNull { pointer: unique.pointer } } } -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl<'a, T: ?Sized> From<&'a mut T> for NonNull { fn from(reference: &'a mut T) -> Self { NonNull { pointer: NonZero::from(reference) } } } -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl<'a, T: ?Sized> From<&'a T> for NonNull { fn from(reference: &'a T) -> Self { NonNull { pointer: NonZero::from(reference) } diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index bc7052d676d..1c32452f846 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -27,7 +27,6 @@ #![feature(iterator_try_fold)] #![feature(iter_rfind)] #![feature(iter_rfold)] -#![feature(nonnull)] #![feature(nonzero)] #![feature(pattern)] #![feature(raw)] diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 1d53825ac37..a35ef2f7ce7 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -22,7 +22,6 @@ #![deny(warnings)] #![feature(collections_range)] -#![feature(nonnull)] #![feature(nonzero)] #![feature(unboxed_closures)] #![feature(fn_traits)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 9f65d61658c..91cc6d25cce 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -283,7 +283,6 @@ #![feature(macro_vis_matcher)] #![feature(needs_panic_runtime)] #![feature(never_type)] -#![feature(nonnull)] #![feature(num_bits_bytes)] #![feature(old_wrapping)] #![feature(on_unimplemented)] diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 6f7d8ddb770..560876006d3 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -198,7 +198,7 @@ impl UnwindSafe for *const T {} impl UnwindSafe for *mut T {} #[unstable(feature = "ptr_internals", issue = "0")] impl UnwindSafe for Unique {} -#[unstable(feature = "nonnull", issue = "27730")] +#[stable(feature = "nonnull", since = "1.24.0")] impl UnwindSafe for NonNull {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for Mutex {} diff --git a/src/test/run-pass/issue-23433.rs b/src/test/run-pass/issue-23433.rs index 37cc1b134c3..7af732f561d 100644 --- a/src/test/run-pass/issue-23433.rs +++ b/src/test/run-pass/issue-23433.rs @@ -10,8 +10,6 @@ // Don't fail if we encounter a NonZero<*T> where T is an unsized type -#![feature(nonnull)] - use std::ptr::NonNull; fn main() { -- cgit 1.4.1-3-g733a5 From 3f557947abf99b262aab994e896522c76329d315 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 21 Jan 2018 09:48:23 +0100 Subject: NonNull ended up landing in 1.25 --- src/libcore/ptr.rs | 36 ++++++++++++++++++------------------ src/libstd/panic.rs | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index fab5832d905..607e4a1a9fa 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2461,7 +2461,7 @@ impl<'a, T: ?Sized> From> for Unique { } /// Previous name of `NonNull`. -#[rustc_deprecated(since = "1.24", reason = "renamed to `NonNull`")] +#[rustc_deprecated(since = "1.25.0", reason = "renamed to `NonNull`")] #[unstable(feature = "shared", issue = "27730")] pub type Shared = NonNull; @@ -2482,12 +2482,12 @@ pub type Shared = NonNull; /// Usually this won't be necessary; covariance is correct for most safe abstractions, /// such as Box, Rc, Arc, Vec, and LinkedList. This is the case because they /// provide a public API that follows the normal shared XOR mutable rules of Rust. -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] pub struct NonNull { pointer: NonZero<*const T>, } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl fmt::Debug for NonNull { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) @@ -2496,12 +2496,12 @@ impl fmt::Debug for NonNull { /// `NonNull` pointers are not `Send` because the data they reference may be aliased. // NB: This impl is unnecessary, but should provide better error messages. -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl !Send for NonNull { } /// `NonNull` pointers are not `Sync` because the data they reference may be aliased. // NB: This impl is unnecessary, but should provide better error messages. -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl !Sync for NonNull { } impl NonNull { @@ -2509,7 +2509,7 @@ impl NonNull { /// /// This is useful for initializing types which lazily allocate, like /// `Vec::new` does. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub fn dangling() -> Self { unsafe { let ptr = mem::align_of::() as *mut T; @@ -2524,19 +2524,19 @@ impl NonNull { /// # Safety /// /// `ptr` must be non-null. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { NonNull { pointer: NonZero::new_unchecked(ptr) } } /// Creates a new `NonNull` if `ptr` is non-null. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub fn new(ptr: *mut T) -> Option { NonZero::new(ptr as *const T).map(|nz| NonNull { pointer: nz }) } /// Acquires the underlying `*mut` pointer. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub fn as_ptr(self) -> *mut T { self.pointer.get() as *mut T } @@ -2546,7 +2546,7 @@ impl NonNull { /// The resulting lifetime is bound to self so this behaves "as if" /// it were actually an instance of T that is getting borrowed. If a longer /// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub unsafe fn as_ref(&self) -> &T { &*self.as_ptr() } @@ -2556,47 +2556,47 @@ impl NonNull { /// The resulting lifetime is bound to self so this behaves "as if" /// it were actually an instance of T that is getting borrowed. If a longer /// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub unsafe fn as_mut(&mut self) -> &mut T { &mut *self.as_ptr() } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl Clone for NonNull { fn clone(&self) -> Self { *self } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl Copy for NonNull { } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl CoerceUnsized> for NonNull where T: Unsize { } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl fmt::Pointer for NonNull { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl From> for NonNull { fn from(unique: Unique) -> Self { NonNull { pointer: unique.pointer } } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl<'a, T: ?Sized> From<&'a mut T> for NonNull { fn from(reference: &'a mut T) -> Self { NonNull { pointer: NonZero::from(reference) } } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl<'a, T: ?Sized> From<&'a T> for NonNull { fn from(reference: &'a T) -> Self { NonNull { pointer: NonZero::from(reference) } diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 560876006d3..112e1106093 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -198,7 +198,7 @@ impl UnwindSafe for *const T {} impl UnwindSafe for *mut T {} #[unstable(feature = "ptr_internals", issue = "0")] impl UnwindSafe for Unique {} -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl UnwindSafe for NonNull {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for Mutex {} -- cgit 1.4.1-3-g733a5 From 2f98f4b12b8fd5d93ffff3d7b98931b3f1f2b07a Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 23 Jan 2018 16:31:53 +0100 Subject: Move PanicInfo and Location to libcore Per https://rust-lang.github.io/rfcs/2070-panic-implementation.html --- src/libcore/lib.rs | 1 + src/libcore/panic.rs | 213 ++++++++++++++++++++++++++++++++++++++++++++++++ src/libstd/lib.rs | 1 + src/libstd/panic.rs | 5 +- src/libstd/panicking.rs | 200 +++------------------------------------------ 5 files changed, 230 insertions(+), 190 deletions(-) create mode 100644 src/libcore/panic.rs (limited to 'src/libstd/panic.rs') diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index d5190b65863..11476a05dd3 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -158,6 +158,7 @@ pub mod array; pub mod sync; pub mod cell; pub mod char; +pub mod panic; pub mod panicking; pub mod iter; pub mod option; diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs new file mode 100644 index 00000000000..dbfe531063b --- /dev/null +++ b/src/libcore/panic.rs @@ -0,0 +1,213 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Panic support in the standard library. + +#![unstable(feature = "core_panic_info", + reason = "newly available in libcore", + issue = "44489")] + +use any::Any; + +/// A struct providing information about a panic. +/// +/// `PanicInfo` structure is passed to a panic hook set by the [`set_hook`] +/// function. +/// +/// [`set_hook`]: ../../std/panic/fn.set_hook.html +/// +/// # Examples +/// +/// ```should_panic +/// use std::panic; +/// +/// panic::set_hook(Box::new(|panic_info| { +/// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); +/// })); +/// +/// panic!("Normal panic"); +/// ``` +#[stable(feature = "panic_hooks", since = "1.10.0")] +#[derive(Debug)] +pub struct PanicInfo<'a> { + payload: &'a (Any + Send), + location: Location<'a>, +} + +impl<'a> PanicInfo<'a> { + #![unstable(feature = "panic_internals", + reason = "internal details of the implementation of the `panic!` \ + and related macros", + issue = "0")] + #[doc(hidden)] + pub fn internal_constructor(payload: &'a (Any + Send), location: Location<'a>,) -> Self { + PanicInfo { payload, location } + } + + /// Returns the payload associated with the panic. + /// + /// This will commonly, but not always, be a `&'static str` or [`String`]. + /// + /// [`String`]: ../../std/string/struct.String.html + /// + /// # Examples + /// + /// ```should_panic + /// use std::panic; + /// + /// panic::set_hook(Box::new(|panic_info| { + /// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); + /// })); + /// + /// panic!("Normal panic"); + /// ``` + #[stable(feature = "panic_hooks", since = "1.10.0")] + pub fn payload(&self) -> &(Any + Send) { + self.payload + } + + /// Returns information about the location from which the panic originated, + /// if available. + /// + /// This method will currently always return [`Some`], but this may change + /// in future versions. + /// + /// [`Some`]: ../../std/option/enum.Option.html#variant.Some + /// + /// # Examples + /// + /// ```should_panic + /// use std::panic; + /// + /// panic::set_hook(Box::new(|panic_info| { + /// if let Some(location) = panic_info.location() { + /// println!("panic occurred in file '{}' at line {}", location.file(), + /// location.line()); + /// } else { + /// println!("panic occurred but can't get location information..."); + /// } + /// })); + /// + /// panic!("Normal panic"); + /// ``` + #[stable(feature = "panic_hooks", since = "1.10.0")] + pub fn location(&self) -> Option<&Location> { + // NOTE: If this is changed to sometimes return None, + // deal with that case in std::panicking::default_hook. + Some(&self.location) + } +} + +/// A struct containing information about the location of a panic. +/// +/// This structure is created by the [`location`] method of [`PanicInfo`]. +/// +/// [`location`]: ../../std/panic/struct.PanicInfo.html#method.location +/// [`PanicInfo`]: ../../std/panic/struct.PanicInfo.html +/// +/// # Examples +/// +/// ```should_panic +/// use std::panic; +/// +/// panic::set_hook(Box::new(|panic_info| { +/// if let Some(location) = panic_info.location() { +/// println!("panic occurred in file '{}' at line {}", location.file(), location.line()); +/// } else { +/// println!("panic occurred but can't get location information..."); +/// } +/// })); +/// +/// panic!("Normal panic"); +/// ``` +#[derive(Debug)] +#[stable(feature = "panic_hooks", since = "1.10.0")] +pub struct Location<'a> { + file: &'a str, + line: u32, + col: u32, +} + +impl<'a> Location<'a> { + #![unstable(feature = "panic_internals", + reason = "internal details of the implementation of the `panic!` \ + and related macros", + issue = "0")] + #[doc(hidden)] + pub fn internal_constructor(file: &'a str, line: u32, col: u32) -> Self { + Location { file, line, col } + } + + /// Returns the name of the source file from which the panic originated. + /// + /// # Examples + /// + /// ```should_panic + /// use std::panic; + /// + /// panic::set_hook(Box::new(|panic_info| { + /// if let Some(location) = panic_info.location() { + /// println!("panic occurred in file '{}'", location.file()); + /// } else { + /// println!("panic occurred but can't get location information..."); + /// } + /// })); + /// + /// panic!("Normal panic"); + /// ``` + #[stable(feature = "panic_hooks", since = "1.10.0")] + pub fn file(&self) -> &str { + self.file + } + + /// Returns the line number from which the panic originated. + /// + /// # Examples + /// + /// ```should_panic + /// use std::panic; + /// + /// panic::set_hook(Box::new(|panic_info| { + /// if let Some(location) = panic_info.location() { + /// println!("panic occurred at line {}", location.line()); + /// } else { + /// println!("panic occurred but can't get location information..."); + /// } + /// })); + /// + /// panic!("Normal panic"); + /// ``` + #[stable(feature = "panic_hooks", since = "1.10.0")] + pub fn line(&self) -> u32 { + self.line + } + + /// Returns the column from which the panic originated. + /// + /// # Examples + /// + /// ```should_panic + /// use std::panic; + /// + /// panic::set_hook(Box::new(|panic_info| { + /// if let Some(location) = panic_info.location() { + /// println!("panic occurred at column {}", location.column()); + /// } else { + /// println!("panic occurred but can't get location information..."); + /// } + /// })); + /// + /// panic!("Normal panic"); + /// ``` + #[stable(feature = "panic_col", since = "1.25")] + pub fn column(&self) -> u32 { + self.col + } +} diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 91cc6d25cce..4b374dc1407 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -288,6 +288,7 @@ #![feature(on_unimplemented)] #![feature(oom)] #![feature(optin_builtin_traits)] +#![feature(panic_internals)] #![feature(panic_unwind)] #![feature(peek)] #![feature(placement_in_syntax)] diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 560876006d3..566ef16f295 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -23,7 +23,10 @@ use sync::{Arc, Mutex, RwLock, atomic}; use thread::Result; #[stable(feature = "panic_hooks", since = "1.10.0")] -pub use panicking::{take_hook, set_hook, PanicInfo, Location}; +pub use panicking::{take_hook, set_hook}; + +#[stable(feature = "panic_hooks", since = "1.10.0")] +pub use core::panic::{PanicInfo, Location}; /// A marker trait which represents "panic safe" types in Rust. /// diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index f91eaf433d7..a748c89f9d4 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -21,6 +21,7 @@ use io::prelude::*; use any::Any; use cell::RefCell; +use core::panic::{PanicInfo, Location}; use fmt; use intrinsics; use mem; @@ -158,182 +159,6 @@ pub fn take_hook() -> Box { } } -/// A struct providing information about a panic. -/// -/// `PanicInfo` structure is passed to a panic hook set by the [`set_hook`] -/// function. -/// -/// [`set_hook`]: ../../std/panic/fn.set_hook.html -/// -/// # Examples -/// -/// ```should_panic -/// use std::panic; -/// -/// panic::set_hook(Box::new(|panic_info| { -/// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); -/// })); -/// -/// panic!("Normal panic"); -/// ``` -#[stable(feature = "panic_hooks", since = "1.10.0")] -#[derive(Debug)] -pub struct PanicInfo<'a> { - payload: &'a (Any + Send), - location: Location<'a>, -} - -impl<'a> PanicInfo<'a> { - /// Returns the payload associated with the panic. - /// - /// This will commonly, but not always, be a `&'static str` or [`String`]. - /// - /// [`String`]: ../../std/string/struct.String.html - /// - /// # Examples - /// - /// ```should_panic - /// use std::panic; - /// - /// panic::set_hook(Box::new(|panic_info| { - /// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); - /// })); - /// - /// panic!("Normal panic"); - /// ``` - #[stable(feature = "panic_hooks", since = "1.10.0")] - pub fn payload(&self) -> &(Any + Send) { - self.payload - } - - /// Returns information about the location from which the panic originated, - /// if available. - /// - /// This method will currently always return [`Some`], but this may change - /// in future versions. - /// - /// [`Some`]: ../../std/option/enum.Option.html#variant.Some - /// - /// # Examples - /// - /// ```should_panic - /// use std::panic; - /// - /// panic::set_hook(Box::new(|panic_info| { - /// if let Some(location) = panic_info.location() { - /// println!("panic occurred in file '{}' at line {}", location.file(), - /// location.line()); - /// } else { - /// println!("panic occurred but can't get location information..."); - /// } - /// })); - /// - /// panic!("Normal panic"); - /// ``` - #[stable(feature = "panic_hooks", since = "1.10.0")] - pub fn location(&self) -> Option<&Location> { - Some(&self.location) - } -} - -/// A struct containing information about the location of a panic. -/// -/// This structure is created by the [`location`] method of [`PanicInfo`]. -/// -/// [`location`]: ../../std/panic/struct.PanicInfo.html#method.location -/// [`PanicInfo`]: ../../std/panic/struct.PanicInfo.html -/// -/// # Examples -/// -/// ```should_panic -/// use std::panic; -/// -/// panic::set_hook(Box::new(|panic_info| { -/// if let Some(location) = panic_info.location() { -/// println!("panic occurred in file '{}' at line {}", location.file(), location.line()); -/// } else { -/// println!("panic occurred but can't get location information..."); -/// } -/// })); -/// -/// panic!("Normal panic"); -/// ``` -#[derive(Debug)] -#[stable(feature = "panic_hooks", since = "1.10.0")] -pub struct Location<'a> { - file: &'a str, - line: u32, - col: u32, -} - -impl<'a> Location<'a> { - /// Returns the name of the source file from which the panic originated. - /// - /// # Examples - /// - /// ```should_panic - /// use std::panic; - /// - /// panic::set_hook(Box::new(|panic_info| { - /// if let Some(location) = panic_info.location() { - /// println!("panic occurred in file '{}'", location.file()); - /// } else { - /// println!("panic occurred but can't get location information..."); - /// } - /// })); - /// - /// panic!("Normal panic"); - /// ``` - #[stable(feature = "panic_hooks", since = "1.10.0")] - pub fn file(&self) -> &str { - self.file - } - - /// Returns the line number from which the panic originated. - /// - /// # Examples - /// - /// ```should_panic - /// use std::panic; - /// - /// panic::set_hook(Box::new(|panic_info| { - /// if let Some(location) = panic_info.location() { - /// println!("panic occurred at line {}", location.line()); - /// } else { - /// println!("panic occurred but can't get location information..."); - /// } - /// })); - /// - /// panic!("Normal panic"); - /// ``` - #[stable(feature = "panic_hooks", since = "1.10.0")] - pub fn line(&self) -> u32 { - self.line - } - - /// Returns the column from which the panic originated. - /// - /// # Examples - /// - /// ```should_panic - /// use std::panic; - /// - /// panic::set_hook(Box::new(|panic_info| { - /// if let Some(location) = panic_info.location() { - /// println!("panic occurred at column {}", location.column()); - /// } else { - /// println!("panic occurred but can't get location information..."); - /// } - /// })); - /// - /// panic!("Normal panic"); - /// ``` - #[stable(feature = "panic_col", since = "1.25")] - pub fn column(&self) -> u32 { - self.col - } -} - fn default_hook(info: &PanicInfo) { #[cfg(feature = "backtrace")] use sys_common::backtrace; @@ -351,13 +176,14 @@ fn default_hook(info: &PanicInfo) { } }; - let file = info.location.file; - let line = info.location.line; - let col = info.location.col; + let location = info.location().unwrap(); // The current implementation always returns Some + let file = location.file(); + let line = location.line(); + let col = location.column(); - let msg = match info.payload.downcast_ref::<&'static str>() { + let msg = match info.payload().downcast_ref::<&'static str>() { Some(s) => *s, - None => match info.payload.downcast_ref::() { + None => match info.payload().downcast_ref::() { Some(s) => &s[..], None => "Box", } @@ -563,14 +389,10 @@ fn rust_panic_with_hook(msg: Box, } unsafe { - let info = PanicInfo { - payload: &*msg, - location: Location { - file, - line, - col, - }, - }; + let info = PanicInfo::internal_constructor( + &*msg, + Location::internal_constructor(file, line, col), + ); HOOK_LOCK.read(); match HOOK { Hook::Default => default_hook(&info), -- cgit 1.4.1-3-g733a5 From 64ddb390efb2143f11c1583d52c78da5a290e097 Mon Sep 17 00:00:00 2001 From: memoryleak47 Date: Thu, 5 Apr 2018 13:04:00 +0200 Subject: typos --- src/libstd/lib.rs | 2 +- src/libstd/panic.rs | 2 +- src/libstd/sys/windows/pipe.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 36eb7291822..67ef47569d6 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -380,7 +380,7 @@ extern crate compiler_builtins; // During testing, this crate is not actually the "real" std library, but rather // it links to the real std library, which was compiled from this same source // code. So any lang items std defines are conditionally excluded (or else they -// wolud generate duplicate lang item errors), and any globals it defines are +// would generate duplicate lang item errors), and any globals it defines are // _not_ the globals used by "real" std. So this import, defined only during // testing gives test-std access to real-std lang items and globals. See #2912 #[cfg(test)] extern crate std as realstd; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 79857104b9b..28c178307a5 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -188,7 +188,7 @@ pub struct AssertUnwindSafe( // * By default everything is unwind safe // * pointers T contains mutability of some form are not unwind safe // * Unique, an owning pointer, lifts an implementation -// * Types like Mutex/RwLock which are explicilty poisoned are unwind safe +// * Types like Mutex/RwLock which are explicitly poisoned are unwind safe // * Our custom AssertUnwindSafe wrapper is indeed unwind safe #[stable(feature = "catch_unwind", since = "1.9.0")] diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index f3b1185c6ea..df1dd7401af 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -236,7 +236,7 @@ enum State { impl<'a> AsyncPipe<'a> { fn new(pipe: Handle, dst: &'a mut Vec) -> io::Result> { // Create an event which we'll use to coordinate our overlapped - // opreations, this event will be used in WaitForMultipleObjects + // operations, this event will be used in WaitForMultipleObjects // and passed as part of the OVERLAPPED handle. // // Note that we do a somewhat clever thing here by flagging the -- cgit 1.4.1-3-g733a5 From 368fe37c226c6e067ba4fa93cab0bbd5b1c09e6c Mon Sep 17 00:00:00 2001 From: Pazzaz Date: Sun, 29 Apr 2018 13:45:33 +0200 Subject: Add more links in panic docs --- src/libstd/panic.rs | 51 ++++++++++++++++++++++++++++++++----------------- src/libstd/panicking.rs | 8 +++++++- 2 files changed, 40 insertions(+), 19 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 28c178307a5..229034eb779 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -31,10 +31,14 @@ pub use core::panic::{PanicInfo, Location}; /// A marker trait which represents "panic safe" types in Rust. /// /// This trait is implemented by default for many types and behaves similarly in -/// terms of inference of implementation to the `Send` and `Sync` traits. The -/// purpose of this trait is to encode what types are safe to cross a `catch_unwind` +/// terms of inference of implementation to the [`Send`] and [`Sync`] traits. The +/// purpose of this trait is to encode what types are safe to cross a [`catch_unwind`] /// boundary with no fear of unwind safety. /// +/// [`Send`]: ../marker/trait.Send.html +/// [`Sync`]: ../marker/trait.Sync.html +/// [`catch_unwind`]: ./fn.catch_unwind.html +/// /// ## What is unwind safety? /// /// In Rust a function can "return" early if it either panics or calls a @@ -95,12 +99,13 @@ pub use core::panic::{PanicInfo, Location}; /// /// ## When should `UnwindSafe` be used? /// -/// Is not intended that most types or functions need to worry about this trait. -/// It is only used as a bound on the `catch_unwind` function and as mentioned above, -/// the lack of `unsafe` means it is mostly an advisory. The `AssertUnwindSafe` -/// wrapper struct in this module can be used to force this trait to be -/// implemented for any closed over variables passed to the `catch_unwind` function -/// (more on this below). +/// It is not intended that most types or functions need to worry about this trait. +/// It is only used as a bound on the `catch_unwind` function and as mentioned +/// above, the lack of `unsafe` means it is mostly an advisory. The +/// [`AssertUnwindSafe`] wrapper struct can be used to force this trait to be +/// implemented for any closed over variables passed to `catch_unwind`. +/// +/// [`AssertUnwindSafe`]: ./struct.AssertUnwindSafe.html #[stable(feature = "catch_unwind", since = "1.9.0")] #[rustc_on_unimplemented = "the type {Self} may not be safely transferred \ across an unwind boundary"] @@ -109,11 +114,14 @@ pub auto trait UnwindSafe {} /// A marker trait representing types where a shared reference is considered /// unwind safe. /// -/// This trait is namely not implemented by `UnsafeCell`, the root of all +/// This trait is namely not implemented by [`UnsafeCell`], the root of all /// interior mutability. /// /// This is a "helper marker trait" used to provide impl blocks for the -/// `UnwindSafe` trait, for more information see that documentation. +/// [`UnwindSafe`] trait, for more information see that documentation. +/// +/// [`UnsafeCell`]: ../cell/struct.UnsafeCell.html +/// [`UnwindSafe`]: ./trait.UnwindSafe.html #[stable(feature = "catch_unwind", since = "1.9.0")] #[rustc_on_unimplemented = "the type {Self} may contain interior mutability \ and a reference may not be safely transferrable \ @@ -122,14 +130,15 @@ pub auto trait RefUnwindSafe {} /// A simple wrapper around a type to assert that it is unwind safe. /// -/// When using `catch_unwind` it may be the case that some of the closed over +/// When using [`catch_unwind`] it may be the case that some of the closed over /// variables are not unwind safe. For example if `&mut T` is captured the /// compiler will generate a warning indicating that it is not unwind safe. It /// may not be the case, however, that this is actually a problem due to the -/// specific usage of `catch_unwind` if unwind safety is specifically taken into +/// specific usage of [`catch_unwind`] if unwind safety is specifically taken into /// account. This wrapper struct is useful for a quick and lightweight /// annotation that a variable is indeed unwind safe. /// +/// [`catch_unwind`]: ./fn.catch_unwind.html /// # Examples /// /// One way to use `AssertUnwindSafe` is to assert that the entire closure @@ -318,18 +327,22 @@ impl fmt::Debug for AssertUnwindSafe { /// panic and allowing a graceful handling of the error. /// /// It is **not** recommended to use this function for a general try/catch -/// mechanism. The `Result` type is more appropriate to use for functions that +/// mechanism. The [`Result`] type is more appropriate to use for functions that /// can fail on a regular basis. Additionally, this function is not guaranteed /// to catch all panics, see the "Notes" section below. /// -/// The closure provided is required to adhere to the `UnwindSafe` trait to ensure +/// [`Result`]: ../result/enum.Result.html +/// +/// The closure provided is required to adhere to the [`UnwindSafe`] trait to ensure /// that all captured variables are safe to cross this boundary. The purpose of /// this bound is to encode the concept of [exception safety][rfc] in the type /// system. Most usage of this function should not need to worry about this /// bound as programs are naturally unwind safe without `unsafe` code. If it -/// becomes a problem the associated `AssertUnwindSafe` wrapper type in this -/// module can be used to quickly assert that the usage here is indeed unwind -/// safe. +/// becomes a problem the [`AssertUnwindSafe`] wrapper struct can be used to quickly +/// assert that the usage here is indeed unwind safe. +/// +/// [`AssertUnwindSafe`]: ./struct.AssertUnwindSafe.html +/// [`UnwindSafe`]: ./trait.UnwindSafe.html /// /// [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1236-stabilize-catch-panic.md /// @@ -364,9 +377,11 @@ pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { /// Triggers a panic without invoking the panic hook. /// -/// This is designed to be used in conjunction with `catch_unwind` to, for +/// This is designed to be used in conjunction with [`catch_unwind`] to, for /// example, carry a panic across a layer of C code. /// +/// [`catch_unwind`]: ./fn.catch_unwind.html +/// /// # Notes /// /// Note that panics in Rust are not always implemented via unwinding, but they diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 24eae6a4c82..403056240bf 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -76,7 +76,9 @@ static mut HOOK: Hook = Hook::Default; /// is invoked. As such, the hook will run with both the aborting and unwinding /// runtimes. The default hook prints a message to standard error and generates /// a backtrace if requested, but this behavior can be customized with the -/// `set_hook` and `take_hook` functions. +/// `set_hook` and [`take_hook`] functions. +/// +/// [`take_hook`]: ./fn.take_hook.html /// /// The hook is provided with a `PanicInfo` struct which contains information /// about the origin of the panic, including the payload passed to `panic!` and @@ -121,6 +123,10 @@ pub fn set_hook(hook: Box) { /// Unregisters the current panic hook, returning it. /// +/// *See also the function [`set_hook`].* +/// +/// [`set_hook`]: ./fn.set_hook.html +/// /// If no custom hook is registered, the default hook will be returned. /// /// # Panics -- cgit 1.4.1-3-g733a5 From 6e5c18e8dc94a679126d276884a3ad4b9a3e0934 Mon Sep 17 00:00:00 2001 From: tinaun Date: Fri, 8 Jun 2018 16:45:27 -0400 Subject: add a few blanket future impls to std --- src/liballoc/boxed.rs | 39 +++++++++++++++++++++++++++++++++++++++ src/liballoc/lib.rs | 1 + src/libcore/future.rs | 17 +++++++++++++++++ src/libcore/task.rs | 6 ++++++ src/libstd/lib.rs | 1 + src/libstd/panic.rs | 18 ++++++++++++++++++ 6 files changed, 82 insertions(+) (limited to 'src/libstd/panic.rs') diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index a64b94b6517..896d9dee3ee 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -914,6 +914,45 @@ impl, U: ?Sized> CoerceUnsized> for PinBox {} #[unstable(feature = "pin", issue = "49150")] impl Unpin for PinBox {} +#[unstable(feature = "futures_api", issue = "50547")] +impl<'a, F: ?Sized + Future + Unpin> Future for Box { + type Output = F::Output; + + fn poll(mut self: PinMut, cx: &mut Context) -> Poll { + PinMut::new(&mut **self).poll(cx) + } +} + +#[unstable(feature = "futures_api", issue = "50547")] +impl<'a, F: ?Sized + Future> Future for PinBox { + type Output = F::Output; + + fn poll(mut self: PinMut, cx: &mut Context) -> Poll { + self.as_pin_mut().poll(cx) + } +} + +#[unstable(feature = "futures_api", issue = "50547")] +unsafe impl + Send + 'static> UnsafePoll for Box { + fn into_raw(self) -> *mut () { + unsafe { + mem::transmute(self) + } + } + + unsafe fn poll(task: *mut (), cx: &mut Context) -> Poll<()> { + let ptr: *mut F = mem::transmute(task); + let pin: PinMut = PinMut::new_unchecked(&mut *ptr); + pin.poll(cx) + } + + unsafe fn drop(task: *mut ()) { + let ptr: *mut F = mem::transmute(task); + let boxed = Box::from_raw(ptr); + drop(boxed) + } +} + #[unstable(feature = "futures_api", issue = "50547")] unsafe impl + Send + 'static> UnsafePoll for PinBox { fn into_raw(self) -> *mut () { diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 242c7d2e70f..a1139189c9a 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -80,6 +80,7 @@ #![cfg_attr(test, feature(rand, test))] #![feature(allocator_api)] #![feature(allow_internal_unstable)] +#![feature(arbitrary_self_types)] #![feature(ascii_ctype)] #![feature(box_into_raw_non_null)] #![feature(box_patterns)] diff --git a/src/libcore/future.rs b/src/libcore/future.rs index b4d087f8edb..a8c8f69411e 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -15,6 +15,7 @@ //! Asynchronous values. use mem::PinMut; +use marker::Unpin; use task::{self, Poll}; /// A future represents an asychronous computation. @@ -91,3 +92,19 @@ pub trait Future { /// about the behavior of `poll` after a future has completed. fn poll(self: PinMut, cx: &mut task::Context) -> Poll; } + +impl<'a, F: ?Sized + Future + Unpin> Future for &'a mut F { + type Output = F::Output; + + fn poll(mut self: PinMut, cx: &mut task::Context) -> Poll { + F::poll(PinMut::new(&mut **self), cx) + } +} + +impl<'a, F: ?Sized + Future> Future for PinMut<'a, F> { + type Output = F::Output; + + fn poll(mut self: PinMut, cx: &mut task::Context) -> Poll { + F::poll((*self).reborrow(), cx) + } +} diff --git a/src/libcore/task.rs b/src/libcore/task.rs index e46a6d41d7a..ab1c1da5790 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -32,6 +32,12 @@ pub enum Poll { Pending, } +impl From for Poll { + fn from(t: T) -> Poll { + Poll::Ready(t) + } +} + /// A `Waker` is a handle for waking up a task by notifying its executor that it /// is ready to be run. /// diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 7bbc99b83be..bb23fe5fa91 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -239,6 +239,7 @@ #![feature(allow_internal_unsafe)] #![feature(allow_internal_unstable)] #![feature(align_offset)] +#![feature(arbitrary_self_types)] #![feature(array_error_internals)] #![feature(ascii_ctype)] #![feature(asm)] diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 229034eb779..b70de73991f 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -15,11 +15,14 @@ use any::Any; use cell::UnsafeCell; use fmt; +use future::Future; +use mem::PinMut; use ops::{Deref, DerefMut}; use panicking; use ptr::{Unique, NonNull}; use rc::Rc; use sync::{Arc, Mutex, RwLock, atomic}; +use task::{self, Poll}; use thread::Result; #[stable(feature = "panic_hooks", since = "1.10.0")] @@ -315,6 +318,21 @@ impl fmt::Debug for AssertUnwindSafe { } } +#[unstable(feature = "futures_api", issue = "50547")] +impl<'a, F: Future> Future for AssertUnwindSafe { + type Output = F::Output; + + fn poll(mut self: PinMut, cx: &mut task::Context) -> Poll { + unsafe { + let pinned_field = PinMut::new_unchecked( + &mut PinMut::get_mut(self.reborrow()).0 + ); + + pinned_field.poll(cx) + } + } +} + /// Invokes a closure, capturing the cause of an unwinding panic if one occurs. /// /// This function will return `Ok` with the closure's result if the closure -- cgit 1.4.1-3-g733a5 From 49eb754cc0108d8546eae70cdcebf81aaddbece3 Mon Sep 17 00:00:00 2001 From: tinaun Date: Fri, 8 Jun 2018 23:16:51 -0400 Subject: addressed nits --- src/liballoc/boxed.rs | 21 --------------------- src/libstd/panic.rs | 6 +++--- 2 files changed, 3 insertions(+), 24 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 896d9dee3ee..c794fb8220a 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -932,27 +932,6 @@ impl<'a, F: ?Sized + Future> Future for PinBox { } } -#[unstable(feature = "futures_api", issue = "50547")] -unsafe impl + Send + 'static> UnsafePoll for Box { - fn into_raw(self) -> *mut () { - unsafe { - mem::transmute(self) - } - } - - unsafe fn poll(task: *mut (), cx: &mut Context) -> Poll<()> { - let ptr: *mut F = mem::transmute(task); - let pin: PinMut = PinMut::new_unchecked(&mut *ptr); - pin.poll(cx) - } - - unsafe fn drop(task: *mut ()) { - let ptr: *mut F = mem::transmute(task); - let boxed = Box::from_raw(ptr); - drop(boxed) - } -} - #[unstable(feature = "futures_api", issue = "50547")] unsafe impl + Send + 'static> UnsafePoll for PinBox { fn into_raw(self) -> *mut () { diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index b70de73991f..8aee15b5eda 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -326,9 +326,9 @@ impl<'a, F: Future> Future for AssertUnwindSafe { unsafe { let pinned_field = PinMut::new_unchecked( &mut PinMut::get_mut(self.reborrow()).0 - ); - - pinned_field.poll(cx) + ); + + pinned_field.poll(cx) } } } -- cgit 1.4.1-3-g733a5 From fb507cadf32e1eacccc07c1c3511636fd6378f7b Mon Sep 17 00:00:00 2001 From: tinaun Date: Fri, 8 Jun 2018 23:24:52 -0400 Subject: add inherent methods to Poll --- src/libcore/task.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/libstd/panic.rs | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) (limited to 'src/libstd/panic.rs') diff --git a/src/libcore/task.rs b/src/libcore/task.rs index ab1c1da5790..bef6d3677d0 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -32,6 +32,55 @@ pub enum Poll { Pending, } +impl Poll { + /// Change the ready value of this `Poll` with the closure provided + pub fn map(self, f: F) -> Poll + where F: FnOnce(T) -> U + { + match self { + Poll::Ready(t) => Poll::Ready(f(t)), + Poll::Pending => Poll::Pending, + } + } + + /// Returns whether this is `Poll::Ready` + pub fn is_ready(&self) -> bool { + match *self { + Poll::Ready(_) => true, + Poll::Pending => false, + } + } + + /// Returns whether this is `Poll::Pending` + pub fn is_pending(&self) -> bool { + !self.is_ready() + } +} + +impl Poll> { + /// Change the success value of this `Poll` with the closure provided + pub fn map_ok(self, f: F) -> Poll> + where F: FnOnce(T) -> U + { + match self { + Poll::Ready(Ok(t)) => Poll::Ready(Ok(f(t))), + Poll::Ready(Err(e)) => Poll::Ready(Err(e)), + Poll::Pending => Poll::Pending, + } + } + + /// Change the error value of this `Poll` with the closure provided + pub fn map_err(self, f: F) -> Poll> + where F: FnOnce(E) -> U + { + match self { + Poll::Ready(Ok(t)) => Poll::Ready(Ok(t)), + Poll::Ready(Err(e)) => Poll::Ready(Err(f(e))), + Poll::Pending => Poll::Pending, + } + } +} + impl From for Poll { fn from(t: T) -> Poll { Poll::Ready(t) diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 8aee15b5eda..4b5a063ea73 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -327,7 +327,7 @@ impl<'a, F: Future> Future for AssertUnwindSafe { let pinned_field = PinMut::new_unchecked( &mut PinMut::get_mut(self.reborrow()).0 ); - + pinned_field.poll(cx) } } -- cgit 1.4.1-3-g733a5 From 776544f011a6a5beccb7923a261b0dcecdd2396a Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Sat, 9 Jun 2018 16:53:36 -0700 Subject: Add message to `rustc_on_unimplemented` attributes in core --- src/liballoc/vec.rs | 10 +- src/libcore/cmp.rs | 10 +- src/libcore/iter/traits.rs | 7 +- src/libcore/marker.rs | 10 +- src/libcore/ops/index.rs | 10 +- src/libstd/panic.rs | 15 ++- src/libsyntax/parse/parser.rs | 8 -- src/test/compile-fail/associated-types-unsized.rs | 2 +- src/test/compile-fail/bad-method-typaram-kind.rs | 2 +- src/test/compile-fail/bad-sized.rs | 4 +- .../builtin-superkinds-double-superkind.rs | 2 +- .../compile-fail/builtin-superkinds-in-metadata.rs | 2 +- src/test/compile-fail/builtin-superkinds-simple.rs | 2 +- .../builtin-superkinds-typaram-not-send.rs | 3 +- ...sure-bounds-cant-promote-superkind-in-struct.rs | 2 +- src/test/compile-fail/dst-bad-assign-2.rs | 2 +- src/test/compile-fail/dst-bad-assign-3.rs | 2 +- src/test/compile-fail/dst-bad-assign.rs | 2 +- src/test/compile-fail/dst-bad-deep-2.rs | 2 +- src/test/compile-fail/dst-bad-deep.rs | 2 +- .../compile-fail/dst-object-from-unsized-type.rs | 8 +- src/test/compile-fail/dst-sized-trait-param.rs | 4 +- .../compile-fail/extern-types-not-sync-send.rs | 2 +- src/test/compile-fail/extern-types-unsized.rs | 8 +- src/test/compile-fail/issue-14366.rs | 2 +- src/test/compile-fail/issue-15756.rs | 2 +- src/test/compile-fail/issue-17651.rs | 2 +- src/test/compile-fail/issue-18107.rs | 2 +- src/test/compile-fail/issue-18919.rs | 2 +- src/test/compile-fail/issue-20005.rs | 2 +- src/test/compile-fail/issue-20433.rs | 2 +- src/test/compile-fail/issue-20605.rs | 2 +- src/test/compile-fail/issue-21763.rs | 2 +- src/test/compile-fail/issue-22874.rs | 2 +- src/test/compile-fail/issue-23281.rs | 2 +- src/test/compile-fail/issue-24446.rs | 2 +- src/test/compile-fail/issue-27060-2.rs | 2 +- src/test/compile-fail/issue-27078.rs | 2 +- src/test/compile-fail/issue-35988.rs | 2 +- src/test/compile-fail/issue-38954.rs | 2 +- src/test/compile-fail/issue-41229-ref-str.rs | 4 +- src/test/compile-fail/issue-42312.rs | 4 +- src/test/compile-fail/issue-5883.rs | 4 +- src/test/compile-fail/issue-7013.rs | 2 +- src/test/compile-fail/kindck-impl-type-params.rs | 8 +- src/test/compile-fail/kindck-nonsendable-1.rs | 2 +- src/test/compile-fail/kindck-send-object.rs | 3 +- src/test/compile-fail/kindck-send-object1.rs | 2 +- src/test/compile-fail/kindck-send-object2.rs | 3 +- src/test/compile-fail/kindck-send-owned.rs | 3 +- src/test/compile-fail/kindck-send-unsafe.rs | 2 +- src/test/compile-fail/no-send-res-ports.rs | 2 +- src/test/compile-fail/no_send-enum.rs | 2 +- src/test/compile-fail/no_send-rc.rs | 2 +- src/test/compile-fail/no_send-struct.rs | 2 +- src/test/compile-fail/not-panic-safe-2.rs | 4 +- src/test/compile-fail/not-panic-safe-3.rs | 4 +- src/test/compile-fail/not-panic-safe-4.rs | 4 +- src/test/compile-fail/not-panic-safe-6.rs | 4 +- src/test/compile-fail/not-panic-safe.rs | 3 +- src/test/compile-fail/range-1.rs | 2 +- src/test/compile-fail/range_traits-1.rs | 24 ++--- src/test/compile-fail/str-idx.rs | 2 +- src/test/compile-fail/str-mut-idx.rs | 6 +- src/test/compile-fail/substs-ppaux.rs | 4 +- .../compile-fail/trait-bounds-not-on-bare-trait.rs | 2 +- src/test/compile-fail/traits-negative-impls.rs | 14 +-- .../typeck-default-trait-impl-negation-send.rs | 2 +- src/test/compile-fail/union/union-unsized.rs | 6 +- src/test/compile-fail/unsized-bare-typaram.rs | 3 +- src/test/compile-fail/unsized-enum.rs | 2 +- .../unsized-inherent-impl-self-type.rs | 3 +- src/test/compile-fail/unsized-struct.rs | 4 +- .../compile-fail/unsized-trait-impl-self-type.rs | 3 +- .../compile-fail/unsized-trait-impl-trait-arg.rs | 2 +- src/test/compile-fail/unsized3.rs | 12 +-- src/test/compile-fail/unsized5.rs | 18 ++-- src/test/compile-fail/unsized6.rs | 39 ++++--- src/test/compile-fail/unsized7.rs | 2 +- src/test/ui/const-unsized.rs | 8 +- src/test/ui/const-unsized.stderr | 8 +- src/test/ui/error-codes/E0277-2.rs | 2 +- src/test/ui/error-codes/E0277-2.stderr | 2 +- src/test/ui/error-codes/E0277.rs | 2 +- src/test/ui/error-codes/E0277.stderr | 2 +- src/test/ui/feature-gate-trivial_bounds.stderr | 6 +- src/test/ui/generator/sized-yield.rs | 6 +- src/test/ui/generator/sized-yield.stderr | 11 +- src/test/ui/impl-trait/auto-trait-leak.rs | 2 +- src/test/ui/impl-trait/auto-trait-leak.stderr | 2 +- src/test/ui/impl-trait/auto-trait-leak2.rs | 4 +- src/test/ui/impl-trait/auto-trait-leak2.stderr | 4 +- .../ui/interior-mutability/interior-mutability.rs | 3 +- .../interior-mutability/interior-mutability.stderr | 6 +- src/test/ui/mismatched_types/binops.rs | 4 +- src/test/ui/mismatched_types/binops.stderr | 12 +-- src/test/ui/mismatched_types/cast-rfc0401.rs | 4 +- src/test/ui/mismatched_types/cast-rfc0401.stderr | 8 +- src/test/ui/partialeq_help.stderr | 4 +- src/test/ui/resolve/issue-5035-2.rs | 3 +- src/test/ui/resolve/issue-5035-2.stderr | 4 +- src/test/ui/suggestions/str-array-assignment.rs | 2 +- .../ui/suggestions/str-array-assignment.stderr | 2 +- src/test/ui/trait-suggest-where-clause.rs | 8 +- src/test/ui/trait-suggest-where-clause.stderr | 8 +- src/test/ui/trivial-bounds-leak.stderr | 2 +- src/test/ui/type-check-defaults.rs | 14 +-- src/test/ui/type-check-defaults.stderr | 8 +- src/test/ui/union/union-sized-field.rs | 9 +- src/test/ui/union/union-sized-field.stderr | 16 +-- src/test/ui/unsized-enum2.rs | 57 +++++++---- src/test/ui/unsized-enum2.stderr | 112 ++++++++++----------- 112 files changed, 394 insertions(+), 318 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index b5739e1a825..752a6c966d5 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1693,7 +1693,10 @@ impl Hash for Vec { } #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"] +#[rustc_on_unimplemented( + message="vector indices are of type `usize` or ranges of `usize`", + label="vector indices are of type `usize` or ranges of `usize`", +)] impl Index for Vec where I: ::core::slice::SliceIndex<[T]>, @@ -1707,7 +1710,10 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"] +#[rustc_on_unimplemented( + message="vector indices are of type `usize` or ranges of `usize`", + label="vector indices are of type `usize` or ranges of `usize`", +)] impl IndexMut for Vec where I: ::core::slice::SliceIndex<[T]>, diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 13e838773a5..3626a266ad5 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -108,7 +108,10 @@ use self::Ordering::*; #[stable(feature = "rust1", since = "1.0.0")] #[doc(alias = "==")] #[doc(alias = "!=")] -#[rustc_on_unimplemented = "can't compare `{Self}` with `{Rhs}`"] +#[rustc_on_unimplemented( + message="can't compare `{Self}` with `{Rhs}`", + label="no implementation for `{Self} == {Rhs}`", +)] pub trait PartialEq { /// This method tests for `self` and `other` values to be equal, and is used /// by `==`. @@ -611,7 +614,10 @@ impl PartialOrd for Ordering { #[doc(alias = "<")] #[doc(alias = "<=")] #[doc(alias = ">=")] -#[rustc_on_unimplemented = "can't compare `{Self}` with `{Rhs}`"] +#[rustc_on_unimplemented( + message="can't compare `{Self}` with `{Rhs}`", + label="no implementation for `{Self} < {Rhs}` and `{Self} > {Rhs}`", +)] pub trait PartialOrd: PartialEq { /// This method returns an ordering between `self` and `other` values if one exists. /// diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index 3d2ce9e6b10..4b2c1aa551e 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -104,8 +104,11 @@ use super::LoopState; /// assert_eq!(c.0, vec![0, 1, 2, 3, 4]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented="a collection of type `{Self}` cannot be \ - built from an iterator over elements of type `{A}`"] +#[rustc_on_unimplemented( + message="a collection of type `{Self}` cannot be built from an iterator \ + over elements of type `{A}`", + label="a collection of type `{Self}` cannot be built from `std::iter::Iterator`", +)] pub trait FromIterator: Sized { /// Creates a value from an iterator. /// diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 3d3f63ecf37..d5416e393f4 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -39,7 +39,10 @@ use hash::Hasher; /// [arc]: ../../std/sync/struct.Arc.html /// [ub]: ../../reference/behavior-considered-undefined.html #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"] +#[rustc_on_unimplemented( + message="`{Self}` cannot be sent between threads safely", + label="`{Self}` cannot be sent between threads safely" +)] pub unsafe auto trait Send { // empty. } @@ -88,7 +91,10 @@ impl !Send for *mut T { } /// [trait object]: ../../book/first-edition/trait-objects.html #[stable(feature = "rust1", since = "1.0.0")] #[lang = "sized"] -#[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"] +#[rustc_on_unimplemented( + message="`{Self}` does not have a constant size known at compile-time", + label="`{Self}` does not have a constant size known at compile-time" +)] #[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable pub trait Sized { // Empty. diff --git a/src/libcore/ops/index.rs b/src/libcore/ops/index.rs index 0a0e92a9180..1ac80ecc96f 100644 --- a/src/libcore/ops/index.rs +++ b/src/libcore/ops/index.rs @@ -60,7 +60,10 @@ /// assert_eq!(nucleotide_count[Nucleotide::T], 12); /// ``` #[lang = "index"] -#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"] +#[rustc_on_unimplemented( + message="the type `{Self}` cannot be indexed by `{Idx}`", + label="`{Self}` cannot be indexed by `{Idx}`", +)] #[stable(feature = "rust1", since = "1.0.0")] #[doc(alias = "]")] #[doc(alias = "[")] @@ -147,7 +150,10 @@ pub trait Index { /// balance[Side::Left] = Weight::Kilogram(3.0); /// ``` #[lang = "index_mut"] -#[rustc_on_unimplemented = "the type `{Self}` cannot be mutably indexed by `{Idx}`"] +#[rustc_on_unimplemented( + message="the type `{Self}` cannot be mutably indexed by `{Idx}`", + label="`{Self}` cannot be mutably indexed by `{Idx}`", +)] #[stable(feature = "rust1", since = "1.0.0")] #[doc(alias = "[")] #[doc(alias = "]")] diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 4b5a063ea73..2c11c262488 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -110,8 +110,10 @@ pub use core::panic::{PanicInfo, Location}; /// /// [`AssertUnwindSafe`]: ./struct.AssertUnwindSafe.html #[stable(feature = "catch_unwind", since = "1.9.0")] -#[rustc_on_unimplemented = "the type {Self} may not be safely transferred \ - across an unwind boundary"] +#[rustc_on_unimplemented( + message="the type `{Self}` may not be safely transferred across an unwind boundary", + label="`{Self}` may not be safely transferred across an unwind boundary", +)] pub auto trait UnwindSafe {} /// A marker trait representing types where a shared reference is considered @@ -126,9 +128,12 @@ pub auto trait UnwindSafe {} /// [`UnsafeCell`]: ../cell/struct.UnsafeCell.html /// [`UnwindSafe`]: ./trait.UnwindSafe.html #[stable(feature = "catch_unwind", since = "1.9.0")] -#[rustc_on_unimplemented = "the type {Self} may contain interior mutability \ - and a reference may not be safely transferrable \ - across a catch_unwind boundary"] +#[rustc_on_unimplemented( + message="the type `{Self}` may contain interior mutability and a reference may not be safely \ + transferrable across a catch_unwind boundary", + label="`{Self}` may contain interior mutability and a reference may not be safely \ + transferrable across a catch_unwind boundary", +)] pub auto trait RefUnwindSafe {} /// A simple wrapper around a type to assert that it is unwind safe. diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index afb0931f950..5d04aa711c1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1204,14 +1204,6 @@ impl<'a> Parser<'a> { fn span_fatal_err>(&self, sp: S, err: Error) -> DiagnosticBuilder<'a> { err.span_err(sp, self.diagnostic()) } - fn span_fatal_help>(&self, - sp: S, - m: &str, - help: &str) -> DiagnosticBuilder<'a> { - let mut err = self.sess.span_diagnostic.struct_span_fatal(sp, m); - err.help(help); - err - } fn bug(&self, m: &str) -> ! { self.sess.span_diagnostic.span_bug(self.span, m) } diff --git a/src/test/compile-fail/associated-types-unsized.rs b/src/test/compile-fail/associated-types-unsized.rs index f1827022964..8c0ce26b294 100644 --- a/src/test/compile-fail/associated-types-unsized.rs +++ b/src/test/compile-fail/associated-types-unsized.rs @@ -14,7 +14,7 @@ trait Get { } fn foo(t: T) { - let x = t.get(); //~ ERROR `::Value: std::marker::Sized` is not + let x = t.get(); //~ ERROR `::Value` does not have a constant size known at compile-time } fn main() { diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs index 5be90f05018..7cef3f13dfc 100644 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ b/src/test/compile-fail/bad-method-typaram-kind.rs @@ -9,7 +9,7 @@ // except according to those terms. fn foo() { - 1.bar::(); //~ ERROR `T: std::marker::Send` is not satisfied + 1.bar::(); //~ ERROR `T` cannot be sent between threads safely } trait bar { diff --git a/src/test/compile-fail/bad-sized.rs b/src/test/compile-fail/bad-sized.rs index df3da5096bf..55b009aef4f 100644 --- a/src/test/compile-fail/bad-sized.rs +++ b/src/test/compile-fail/bad-sized.rs @@ -13,6 +13,6 @@ trait Trait {} pub fn main() { let x: Vec = Vec::new(); //~^ ERROR only auto traits can be used as additional traits in a trait object - //~| ERROR the trait bound `Trait: std::marker::Sized` is not satisfied - //~| ERROR the trait bound `Trait: std::marker::Sized` is not satisfied + //~| ERROR `Trait` does not have a constant size known at compile-time + //~| ERROR `Trait` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/builtin-superkinds-double-superkind.rs b/src/test/compile-fail/builtin-superkinds-double-superkind.rs index 261881d880b..3f7f2adabdf 100644 --- a/src/test/compile-fail/builtin-superkinds-double-superkind.rs +++ b/src/test/compile-fail/builtin-superkinds-double-superkind.rs @@ -14,7 +14,7 @@ trait Foo : Send+Sync { } impl Foo for (T,) { } -//~^ ERROR the trait bound `T: std::marker::Send` is not satisfied in `(T,)` [E0277] +//~^ ERROR `T` cannot be sent between threads safely [E0277] impl Foo for (T,T) { } //~^ ERROR `T` cannot be shared between threads safely [E0277] diff --git a/src/test/compile-fail/builtin-superkinds-in-metadata.rs b/src/test/compile-fail/builtin-superkinds-in-metadata.rs index de2084c4e81..88b5a3fbb55 100644 --- a/src/test/compile-fail/builtin-superkinds-in-metadata.rs +++ b/src/test/compile-fail/builtin-superkinds-in-metadata.rs @@ -22,6 +22,6 @@ struct X(T); impl RequiresShare for X { } impl RequiresRequiresShareAndSend for X { } -//~^ ERROR `T: std::marker::Send` is not satisfied +//~^ ERROR `T` cannot be sent between threads safely [E0277] fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-simple.rs b/src/test/compile-fail/builtin-superkinds-simple.rs index 6dc5f39cb30..22dc9598d29 100644 --- a/src/test/compile-fail/builtin-superkinds-simple.rs +++ b/src/test/compile-fail/builtin-superkinds-simple.rs @@ -14,6 +14,6 @@ trait Foo : Send { } impl Foo for std::rc::Rc { } -//~^ ERROR `std::rc::Rc: std::marker::Send` is not satisfied +//~^ ERROR `std::rc::Rc` cannot be sent between threads safely fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs index d4bb8de13d0..e0b2043c110 100644 --- a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs +++ b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs @@ -12,6 +12,7 @@ trait Foo : Send { } -impl Foo for T { } //~ ERROR `T: std::marker::Send` is not satisfied +impl Foo for T { } +//~^ ERROR `T` cannot be sent between threads safely fn main() { } diff --git a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs index b9224e7be7f..12e9fb30902 100644 --- a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs +++ b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs @@ -13,7 +13,7 @@ struct X where F: FnOnce() + 'static + Send { } fn foo(blk: F) -> X where F: FnOnce() + 'static { - //~^ ERROR `F: std::marker::Send` is not satisfied + //~^ ERROR `F` cannot be sent between threads safely return X { field: blk }; } diff --git a/src/test/compile-fail/dst-bad-assign-2.rs b/src/test/compile-fail/dst-bad-assign-2.rs index 10c8f1eed00..c3cbc904842 100644 --- a/src/test/compile-fail/dst-bad-assign-2.rs +++ b/src/test/compile-fail/dst-bad-assign-2.rs @@ -43,5 +43,5 @@ pub fn main() { let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; let z: Box = Box::new(Bar1 {f: 36}); f5.ptr = *z; - //~^ ERROR `ToBar: std::marker::Sized` is not satisfied + //~^ ERROR `ToBar` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/dst-bad-assign-3.rs b/src/test/compile-fail/dst-bad-assign-3.rs index ceaa3716232..1cd5b51fe34 100644 --- a/src/test/compile-fail/dst-bad-assign-3.rs +++ b/src/test/compile-fail/dst-bad-assign-3.rs @@ -45,5 +45,5 @@ pub fn main() { //~| expected type `ToBar` //~| found type `Bar1` //~| expected trait ToBar, found struct `Bar1` - //~| ERROR `ToBar: std::marker::Sized` is not satisfied + //~| ERROR `ToBar` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/dst-bad-assign.rs b/src/test/compile-fail/dst-bad-assign.rs index 4f7d07600ad..dcd78ac044c 100644 --- a/src/test/compile-fail/dst-bad-assign.rs +++ b/src/test/compile-fail/dst-bad-assign.rs @@ -47,5 +47,5 @@ pub fn main() { //~| expected type `ToBar` //~| found type `Bar1` //~| expected trait ToBar, found struct `Bar1` - //~| ERROR `ToBar: std::marker::Sized` is not satisfied + //~| ERROR `ToBar` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/dst-bad-deep-2.rs b/src/test/compile-fail/dst-bad-deep-2.rs index 0c812b1d815..9ed2ec8d98d 100644 --- a/src/test/compile-fail/dst-bad-deep-2.rs +++ b/src/test/compile-fail/dst-bad-deep-2.rs @@ -19,5 +19,5 @@ pub fn main() { let f: ([isize; 3],) = ([5, 6, 7],); let g: &([isize],) = &f; let h: &(([isize],),) = &(*g,); - //~^ ERROR `[isize]: std::marker::Sized` is not satisfied + //~^ ERROR `[isize]` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/dst-bad-deep.rs b/src/test/compile-fail/dst-bad-deep.rs index f508364d751..9b575ae4aad 100644 --- a/src/test/compile-fail/dst-bad-deep.rs +++ b/src/test/compile-fail/dst-bad-deep.rs @@ -21,5 +21,5 @@ pub fn main() { let f: Fat<[isize; 3]> = Fat { ptr: [5, 6, 7] }; let g: &Fat<[isize]> = &f; let h: &Fat> = &Fat { ptr: *g }; - //~^ ERROR `[isize]: std::marker::Sized` is not satisfied + //~^ ERROR `[isize]` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/dst-object-from-unsized-type.rs b/src/test/compile-fail/dst-object-from-unsized-type.rs index 8fafd78d407..678eef76fde 100644 --- a/src/test/compile-fail/dst-object-from-unsized-type.rs +++ b/src/test/compile-fail/dst-object-from-unsized-type.rs @@ -16,22 +16,22 @@ impl Foo for [u8] {} fn test1(t: &T) { let u: &Foo = t; - //~^ ERROR `T: std::marker::Sized` is not satisfied + //~^ ERROR `T` does not have a constant size known at compile-time } fn test2(t: &T) { let v: &Foo = t as &Foo; - //~^ ERROR `T: std::marker::Sized` is not satisfied + //~^ ERROR `T` does not have a constant size known at compile-time } fn test3() { let _: &[&Foo] = &["hi"]; - //~^ ERROR `str: std::marker::Sized` is not satisfied + //~^ ERROR `str` does not have a constant size known at compile-time } fn test4(x: &[u8]) { let _: &Foo = x as &Foo; - //~^ ERROR `[u8]: std::marker::Sized` is not satisfied + //~^ ERROR `[u8]` does not have a constant size known at compile-time } fn main() { } diff --git a/src/test/compile-fail/dst-sized-trait-param.rs b/src/test/compile-fail/dst-sized-trait-param.rs index bd5fd3ee3b7..cafd67809f8 100644 --- a/src/test/compile-fail/dst-sized-trait-param.rs +++ b/src/test/compile-fail/dst-sized-trait-param.rs @@ -15,9 +15,9 @@ trait Foo : Sized { fn take(self, x: &T) { } } // Note: T is sized impl Foo<[isize]> for usize { } -//~^ ERROR `[isize]: std::marker::Sized` is not satisfied +//~^ ERROR `[isize]` does not have a constant size known at compile-time impl Foo for [usize] { } -//~^ ERROR `[usize]: std::marker::Sized` is not satisfied +//~^ ERROR `[usize]` does not have a constant size known at compile-time pub fn main() { } diff --git a/src/test/compile-fail/extern-types-not-sync-send.rs b/src/test/compile-fail/extern-types-not-sync-send.rs index 6a7a515ba5f..10abb80a2f7 100644 --- a/src/test/compile-fail/extern-types-not-sync-send.rs +++ b/src/test/compile-fail/extern-types-not-sync-send.rs @@ -24,5 +24,5 @@ fn main() { //~^ ERROR `A` cannot be shared between threads safely [E0277] assert_send::(); - //~^ ERROR the trait bound `A: std::marker::Send` is not satisfied + //~^ ERROR `A` cannot be sent between threads safely [E0277] } diff --git a/src/test/compile-fail/extern-types-unsized.rs b/src/test/compile-fail/extern-types-unsized.rs index faa27894806..b3e19899a67 100644 --- a/src/test/compile-fail/extern-types-unsized.rs +++ b/src/test/compile-fail/extern-types-unsized.rs @@ -30,14 +30,14 @@ fn assert_sized() { } fn main() { assert_sized::(); - //~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied + //~^ ERROR `A` does not have a constant size known at compile-time assert_sized::(); - //~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied + //~^ ERROR `A` does not have a constant size known at compile-time assert_sized::>(); - //~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied + //~^ ERROR `A` does not have a constant size known at compile-time assert_sized::>>(); - //~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied + //~^ ERROR `A` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/issue-14366.rs b/src/test/compile-fail/issue-14366.rs index 84452accc9a..7b4954a2d4e 100644 --- a/src/test/compile-fail/issue-14366.rs +++ b/src/test/compile-fail/issue-14366.rs @@ -10,5 +10,5 @@ fn main() { let _x = "test" as &::std::any::Any; -//~^ ERROR `str: std::marker::Sized` is not satisfied + //~^ ERROR `str` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/issue-15756.rs b/src/test/compile-fail/issue-15756.rs index 41349d7d744..0df82de8338 100644 --- a/src/test/compile-fail/issue-15756.rs +++ b/src/test/compile-fail/issue-15756.rs @@ -15,7 +15,7 @@ fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: ChunksMut<'a,T>) { for &mut something -//~^ ERROR `[T]: std::marker::Sized` is not satisfied + //~^ ERROR `[T]` does not have a constant size known at compile-time in arg2 { } diff --git a/src/test/compile-fail/issue-17651.rs b/src/test/compile-fail/issue-17651.rs index 4996da057dd..13548b06ea1 100644 --- a/src/test/compile-fail/issue-17651.rs +++ b/src/test/compile-fail/issue-17651.rs @@ -13,5 +13,5 @@ fn main() { (|| Box::new(*(&[0][..])))(); - //~^ ERROR `[{integer}]: std::marker::Sized` is not satisfied + //~^ ERROR `[{integer}]` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/issue-18107.rs b/src/test/compile-fail/issue-18107.rs index 33d68c121bf..5faa8885e73 100644 --- a/src/test/compile-fail/issue-18107.rs +++ b/src/test/compile-fail/issue-18107.rs @@ -12,7 +12,7 @@ pub trait AbstractRenderer {} fn _create_render(_: &()) -> AbstractRenderer -//~^ ERROR: `AbstractRenderer + 'static: std::marker::Sized` is not satisfied +//~^ ERROR: `AbstractRenderer + 'static` does not have a constant size known at compile-time { match 0 { _ => unimplemented!() diff --git a/src/test/compile-fail/issue-18919.rs b/src/test/compile-fail/issue-18919.rs index 3e21360721b..14b776cb1ff 100644 --- a/src/test/compile-fail/issue-18919.rs +++ b/src/test/compile-fail/issue-18919.rs @@ -11,7 +11,7 @@ type FuncType<'f> = Fn(&isize) -> isize + 'f; fn ho_func(f: Option) { - //~^ ERROR: `for<'r> std::ops::Fn(&'r isize) -> isize: std::marker::Sized` is not satisfied + //~^ ERROR: `for<'r> std::ops::Fn(&'r isize) -> isize` does not have a constant size known at } fn main() {} diff --git a/src/test/compile-fail/issue-20005.rs b/src/test/compile-fail/issue-20005.rs index b02757fb5a3..ab47f687fc2 100644 --- a/src/test/compile-fail/issue-20005.rs +++ b/src/test/compile-fail/issue-20005.rs @@ -15,7 +15,7 @@ trait From { } trait To { - fn to( //~ ERROR `Self: std::marker::Sized` is not satisfied + fn to( //~ ERROR `Self` does not have a constant size known at compile-time self ) -> >::Result where Dst: From { From::from(self) diff --git a/src/test/compile-fail/issue-20433.rs b/src/test/compile-fail/issue-20433.rs index d1a139e698e..d8ca00d313f 100644 --- a/src/test/compile-fail/issue-20433.rs +++ b/src/test/compile-fail/issue-20433.rs @@ -14,5 +14,5 @@ struct The; impl The { fn iceman(c: Vec<[i32]>) {} - //~^ ERROR the trait bound `[i32]: std::marker::Sized` is not satisfied + //~^ ERROR `[i32]` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/issue-20605.rs b/src/test/compile-fail/issue-20605.rs index 5eb0e4360fc..c5a724bba80 100644 --- a/src/test/compile-fail/issue-20605.rs +++ b/src/test/compile-fail/issue-20605.rs @@ -10,7 +10,7 @@ fn changer<'a>(mut things: Box>) { for item in *things { *item = 0 } -//~^ ERROR the trait bound `std::iter::Iterator: std::marker::Sized` is not satisfied +//~^ ERROR `std::iter::Iterator` does not have a constant size known at compile-time } fn main() {} diff --git a/src/test/compile-fail/issue-21763.rs b/src/test/compile-fail/issue-21763.rs index cb0baee0a87..b4f952c87d4 100644 --- a/src/test/compile-fail/issue-21763.rs +++ b/src/test/compile-fail/issue-21763.rs @@ -17,5 +17,5 @@ fn foo() {} fn main() { foo::, Rc<()>>>(); - //~^ ERROR: `std::rc::Rc<()>: std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc<()>` cannot be sent between threads safely } diff --git a/src/test/compile-fail/issue-22874.rs b/src/test/compile-fail/issue-22874.rs index 0df84a436c0..de176486af7 100644 --- a/src/test/compile-fail/issue-22874.rs +++ b/src/test/compile-fail/issue-22874.rs @@ -10,7 +10,7 @@ struct Table { rows: [[String]], - //~^ ERROR the trait bound `[std::string::String]: std::marker::Sized` is not satisfied [E0277] + //~^ ERROR `[std::string::String]` does not have a constant size known at compile-time } fn f(table: &Table) -> &[String] { diff --git a/src/test/compile-fail/issue-23281.rs b/src/test/compile-fail/issue-23281.rs index 5feeb36b1e4..fdab3b59d1b 100644 --- a/src/test/compile-fail/issue-23281.rs +++ b/src/test/compile-fail/issue-23281.rs @@ -14,7 +14,7 @@ pub struct Struct; impl Struct { pub fn function(funs: Vec ()>) {} - //~^ ERROR the trait bound `std::ops::Fn() + 'static: std::marker::Sized` is not satisfied + //~^ ERROR `std::ops::Fn() + 'static` does not have a constant size known at compile-time } fn main() {} diff --git a/src/test/compile-fail/issue-24446.rs b/src/test/compile-fail/issue-24446.rs index acd50bcf9e1..5f36bbcf5fd 100644 --- a/src/test/compile-fail/issue-24446.rs +++ b/src/test/compile-fail/issue-24446.rs @@ -11,7 +11,7 @@ fn main() { static foo: Fn() -> u32 = || -> u32 { //~^ ERROR: mismatched types - //~| ERROR: `std::ops::Fn() -> u32 + 'static: std::marker::Sized` is not satisfied + //~| ERROR: `std::ops::Fn() -> u32 + 'static` does not have a constant size known at compile-time 0 }; } diff --git a/src/test/compile-fail/issue-27060-2.rs b/src/test/compile-fail/issue-27060-2.rs index 28180b05c8d..123bbf3358d 100644 --- a/src/test/compile-fail/issue-27060-2.rs +++ b/src/test/compile-fail/issue-27060-2.rs @@ -10,7 +10,7 @@ #[repr(packed)] pub struct Bad { - data: T, //~ ERROR `T: std::marker::Sized` is not satisfied + data: T, //~ ERROR `T` does not have a constant size known at compile-time } fn main() {} diff --git a/src/test/compile-fail/issue-27078.rs b/src/test/compile-fail/issue-27078.rs index f34bef62249..32933fa6176 100644 --- a/src/test/compile-fail/issue-27078.rs +++ b/src/test/compile-fail/issue-27078.rs @@ -13,7 +13,7 @@ trait Foo { const BAR: i32; fn foo(self) -> &'static i32 { - //~^ ERROR the trait bound `Self: std::marker::Sized` is not satisfied + //~^ ERROR `Self` does not have a constant size known at compile-time &::BAR } } diff --git a/src/test/compile-fail/issue-35988.rs b/src/test/compile-fail/issue-35988.rs index c2e6a88a57b..8f5b68986e5 100644 --- a/src/test/compile-fail/issue-35988.rs +++ b/src/test/compile-fail/issue-35988.rs @@ -10,7 +10,7 @@ enum E { V([Box]), - //~^ ERROR the trait bound `[std::boxed::Box]: std::marker::Sized` is not satisfied [E0277] + //~^ ERROR `[std::boxed::Box]` does not have a constant size known at compile-time } fn main() {} diff --git a/src/test/compile-fail/issue-38954.rs b/src/test/compile-fail/issue-38954.rs index 896728b6da0..960099f3193 100644 --- a/src/test/compile-fail/issue-38954.rs +++ b/src/test/compile-fail/issue-38954.rs @@ -9,6 +9,6 @@ // except according to those terms. fn _test(ref _p: str) {} -//~^ ERROR the trait bound `str: std::marker::Sized` is not satisfied [E0277] +//~^ ERROR `str` does not have a constant size known at compile-time fn main() { } diff --git a/src/test/compile-fail/issue-41229-ref-str.rs b/src/test/compile-fail/issue-41229-ref-str.rs index 31bc21c23ba..b1e24c818d8 100644 --- a/src/test/compile-fail/issue-41229-ref-str.rs +++ b/src/test/compile-fail/issue-41229-ref-str.rs @@ -9,8 +9,6 @@ // except according to those terms. pub fn example(ref s: str) {} -//~^ ERROR the trait bound `str: std::marker::Sized` is not satisfied -//~| `str` does not have a constant size known at compile-time -//~| the trait `std::marker::Sized` is not implemented for `str` +//~^ ERROR `str` does not have a constant size known at compile-time fn main() {} diff --git a/src/test/compile-fail/issue-42312.rs b/src/test/compile-fail/issue-42312.rs index 06573b42b59..89eb5c5ebc1 100644 --- a/src/test/compile-fail/issue-42312.rs +++ b/src/test/compile-fail/issue-42312.rs @@ -12,10 +12,10 @@ use std::ops::Deref; pub trait Foo { fn baz(_: Self::Target) where Self: Deref {} - //~^ ERROR `::Target: std::marker::Sized` is not satisfied + //~^ ERROR `::Target` does not have a constant size known at } pub fn f(_: ToString) {} -//~^ ERROR the trait bound `std::string::ToString + 'static: std::marker::Sized` is not satisfied +//~^ ERROR `std::string::ToString + 'static` does not have a constant size known at compile-time fn main() { } diff --git a/src/test/compile-fail/issue-5883.rs b/src/test/compile-fail/issue-5883.rs index e14d9f3a35c..580625f4955 100644 --- a/src/test/compile-fail/issue-5883.rs +++ b/src/test/compile-fail/issue-5883.rs @@ -15,8 +15,8 @@ struct Struct { } fn new_struct(r: A+'static) - -> Struct { //~^ ERROR `A + 'static: std::marker::Sized` is not satisfied - //~^ ERROR `A + 'static: std::marker::Sized` is not satisfied + -> Struct { //~^ ERROR `A + 'static` does not have a constant size known at compile-time + //~^ ERROR `A + 'static` does not have a constant size known at compile-time Struct { r: r } } diff --git a/src/test/compile-fail/issue-7013.rs b/src/test/compile-fail/issue-7013.rs index 95bbd4eccf4..0c19780bcb4 100644 --- a/src/test/compile-fail/issue-7013.rs +++ b/src/test/compile-fail/issue-7013.rs @@ -34,5 +34,5 @@ struct A { fn main() { let a = A {v: box B{v: None} as Box}; - //~^ ERROR `std::rc::Rc>: std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc>` cannot be sent between threads safely } diff --git a/src/test/compile-fail/kindck-impl-type-params.rs b/src/test/compile-fail/kindck-impl-type-params.rs index 2a86cdef981..3a0e66f58e0 100644 --- a/src/test/compile-fail/kindck-impl-type-params.rs +++ b/src/test/compile-fail/kindck-impl-type-params.rs @@ -26,15 +26,15 @@ impl Gettable for S {} fn f(val: T) { let t: S = S(marker::PhantomData); let a = &t as &Gettable; - //~^ ERROR : std::marker::Send` is not satisfied - //~^^ ERROR : std::marker::Copy` is not satisfied + //~^ ERROR `T` cannot be sent between threads safely + //~| ERROR : std::marker::Copy` is not satisfied } fn g(val: T) { let t: S = S(marker::PhantomData); let a: &Gettable = &t; - //~^ ERROR : std::marker::Send` is not satisfied - //~^^ ERROR : std::marker::Copy` is not satisfied + //~^ ERROR `T` cannot be sent between threads safely + //~| ERROR : std::marker::Copy` is not satisfied } fn foo<'a>() { diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs index dd77c2c138f..43c212b2af5 100644 --- a/src/test/compile-fail/kindck-nonsendable-1.rs +++ b/src/test/compile-fail/kindck-nonsendable-1.rs @@ -18,5 +18,5 @@ fn bar(_: F) { } fn main() { let x = Rc::new(3); bar(move|| foo(x)); - //~^ ERROR : std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc` cannot be sent between threads safely } diff --git a/src/test/compile-fail/kindck-send-object.rs b/src/test/compile-fail/kindck-send-object.rs index a84eae0bfda..a3eb47be3ee 100644 --- a/src/test/compile-fail/kindck-send-object.rs +++ b/src/test/compile-fail/kindck-send-object.rs @@ -24,7 +24,8 @@ fn object_ref_with_static_bound_not_ok() { } fn box_object_with_no_bound_not_ok<'a>() { - assert_send::>(); //~ ERROR : std::marker::Send` is not satisfied + assert_send::>(); + //~^ ERROR `Dummy` cannot be sent between threads safely } fn object_with_send_bound_ok() { diff --git a/src/test/compile-fail/kindck-send-object1.rs b/src/test/compile-fail/kindck-send-object1.rs index 66865bbcc7e..673a6abc5f0 100644 --- a/src/test/compile-fail/kindck-send-object1.rs +++ b/src/test/compile-fail/kindck-send-object1.rs @@ -37,7 +37,7 @@ fn test61() { // them not ok fn test_71<'a>() { assert_send::>(); - //~^ ERROR : std::marker::Send` is not satisfied + //~^ ERROR `Dummy + 'a` cannot be sent between threads safely } fn main() { } diff --git a/src/test/compile-fail/kindck-send-object2.rs b/src/test/compile-fail/kindck-send-object2.rs index 51bc587d74f..3a935af2000 100644 --- a/src/test/compile-fail/kindck-send-object2.rs +++ b/src/test/compile-fail/kindck-send-object2.rs @@ -19,7 +19,8 @@ fn test50() { } fn test53() { - assert_send::>(); //~ ERROR : std::marker::Send` is not satisfied + assert_send::>(); + //~^ ERROR `Dummy` cannot be sent between threads safely } // ...unless they are properly bounded diff --git a/src/test/compile-fail/kindck-send-owned.rs b/src/test/compile-fail/kindck-send-owned.rs index 583381a1c28..e48460a8753 100644 --- a/src/test/compile-fail/kindck-send-owned.rs +++ b/src/test/compile-fail/kindck-send-owned.rs @@ -19,7 +19,8 @@ fn test32() { assert_send:: >(); } // but not if they own a bad thing fn test40() { - assert_send::>(); //~ ERROR : std::marker::Send` is not satisfied + assert_send::>(); + //~^ ERROR `*mut u8` cannot be sent between threads safely } fn main() { } diff --git a/src/test/compile-fail/kindck-send-unsafe.rs b/src/test/compile-fail/kindck-send-unsafe.rs index c717d1a72e0..99b995b0906 100644 --- a/src/test/compile-fail/kindck-send-unsafe.rs +++ b/src/test/compile-fail/kindck-send-unsafe.rs @@ -14,7 +14,7 @@ fn assert_send() { } fn test71<'a>() { assert_send::<*mut &'a isize>(); - //~^ ERROR `*mut &'a isize: std::marker::Send` is not satisfied + //~^ ERROR `*mut &'a isize` cannot be sent between threads safely } fn main() { diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index 334952cefa6..6825963c486 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -33,7 +33,7 @@ fn main() { let x = foo(Port(Rc::new(()))); thread::spawn(move|| { - //~^ ERROR `std::rc::Rc<()>: std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc<()>` cannot be sent between threads safely let y = x; println!("{:?}", y); }); diff --git a/src/test/compile-fail/no_send-enum.rs b/src/test/compile-fail/no_send-enum.rs index 902710e96e2..83f19ed19ef 100644 --- a/src/test/compile-fail/no_send-enum.rs +++ b/src/test/compile-fail/no_send-enum.rs @@ -24,5 +24,5 @@ fn bar(_: T) {} fn main() { let x = Foo::A(NoSend); bar(x); - //~^ ERROR `NoSend: std::marker::Send` is not satisfied + //~^ ERROR `NoSend` cannot be sent between threads safely } diff --git a/src/test/compile-fail/no_send-rc.rs b/src/test/compile-fail/no_send-rc.rs index f31d3787334..d3616d14422 100644 --- a/src/test/compile-fail/no_send-rc.rs +++ b/src/test/compile-fail/no_send-rc.rs @@ -15,5 +15,5 @@ fn bar(_: T) {} fn main() { let x = Rc::new(5); bar(x); - //~^ ERROR `std::rc::Rc<{integer}>: std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc<{integer}>` cannot be sent between threads safely } diff --git a/src/test/compile-fail/no_send-struct.rs b/src/test/compile-fail/no_send-struct.rs index b2ca4f9f5db..d38d993e7e8 100644 --- a/src/test/compile-fail/no_send-struct.rs +++ b/src/test/compile-fail/no_send-struct.rs @@ -23,5 +23,5 @@ fn bar(_: T) {} fn main() { let x = Foo { a: 5 }; bar(x); - //~^ ERROR `Foo: std::marker::Send` is not satisfied + //~^ ERROR `Foo` cannot be sent between threads safely } diff --git a/src/test/compile-fail/not-panic-safe-2.rs b/src/test/compile-fail/not-panic-safe-2.rs index 7107211fc91..d750851b719 100644 --- a/src/test/compile-fail/not-panic-safe-2.rs +++ b/src/test/compile-fail/not-panic-safe-2.rs @@ -18,6 +18,6 @@ fn assert() {} fn main() { assert::>>(); - //~^ ERROR `std::cell::UnsafeCell: std::panic::RefUnwindSafe` is not satisfied - //~^^ ERROR `std::cell::UnsafeCell: std::panic::RefUnwindSafe` is not satisfied + //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a + //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a } diff --git a/src/test/compile-fail/not-panic-safe-3.rs b/src/test/compile-fail/not-panic-safe-3.rs index 76c34e4dc0b..cd27b274258 100644 --- a/src/test/compile-fail/not-panic-safe-3.rs +++ b/src/test/compile-fail/not-panic-safe-3.rs @@ -18,6 +18,6 @@ fn assert() {} fn main() { assert::>>(); - //~^ ERROR `std::cell::UnsafeCell: std::panic::RefUnwindSafe` is not satisfied - //~^^ ERROR `std::cell::UnsafeCell: std::panic::RefUnwindSafe` is not satisfied + //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a + //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a } diff --git a/src/test/compile-fail/not-panic-safe-4.rs b/src/test/compile-fail/not-panic-safe-4.rs index 177a43e2a7f..956eca432c5 100644 --- a/src/test/compile-fail/not-panic-safe-4.rs +++ b/src/test/compile-fail/not-panic-safe-4.rs @@ -17,6 +17,6 @@ fn assert() {} fn main() { assert::<&RefCell>(); - //~^ ERROR `std::cell::UnsafeCell: std::panic::RefUnwindSafe` is not satisfied - //~^^ ERROR `std::cell::UnsafeCell: std::panic::RefUnwindSafe` is not satisfied + //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a + //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a } diff --git a/src/test/compile-fail/not-panic-safe-6.rs b/src/test/compile-fail/not-panic-safe-6.rs index f03e1d545a8..d0ca1db5212 100644 --- a/src/test/compile-fail/not-panic-safe-6.rs +++ b/src/test/compile-fail/not-panic-safe-6.rs @@ -17,6 +17,6 @@ fn assert() {} fn main() { assert::<*mut RefCell>(); - //~^ ERROR `std::cell::UnsafeCell: std::panic::RefUnwindSafe` is not satisfied - //~^^ ERROR `std::cell::UnsafeCell: std::panic::RefUnwindSafe` is not satisfied + //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a + //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a } diff --git a/src/test/compile-fail/not-panic-safe.rs b/src/test/compile-fail/not-panic-safe.rs index ece8fa7dc47..0ebf3d3fed7 100644 --- a/src/test/compile-fail/not-panic-safe.rs +++ b/src/test/compile-fail/not-panic-safe.rs @@ -16,5 +16,6 @@ use std::panic::UnwindSafe; fn assert() {} fn main() { - assert::<&mut i32>(); //~ ERROR: UnwindSafe` is not satisfied + assert::<&mut i32>(); + //~^ ERROR the type `&mut i32` may not be safely transferred across an unwind boundary } diff --git a/src/test/compile-fail/range-1.rs b/src/test/compile-fail/range-1.rs index 58794e3b35d..3fb62b8d869 100644 --- a/src/test/compile-fail/range-1.rs +++ b/src/test/compile-fail/range-1.rs @@ -22,5 +22,5 @@ pub fn main() { // Unsized type. let arr: &[_] = &[1, 2, 3]; let range = *arr..; - //~^ ERROR `[{integer}]: std::marker::Sized` is not satisfied + //~^ ERROR `[{integer}]` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/range_traits-1.rs b/src/test/compile-fail/range_traits-1.rs index 32f9b83b6e2..78d3702b449 100644 --- a/src/test/compile-fail/range_traits-1.rs +++ b/src/test/compile-fail/range_traits-1.rs @@ -13,23 +13,23 @@ use std::ops::*; #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] struct AllTheRanges { a: Range, - //~^ ERROR PartialOrd - //~^^ ERROR Ord + //~^ ERROR can't compare + //~| ERROR Ord b: RangeTo, - //~^ ERROR PartialOrd - //~^^ ERROR Ord + //~^ ERROR can't compare + //~| ERROR Ord c: RangeFrom, - //~^ ERROR PartialOrd - //~^^ ERROR Ord + //~^ ERROR can't compare + //~| ERROR Ord d: RangeFull, - //~^ ERROR PartialOrd - //~^^ ERROR Ord + //~^ ERROR can't compare + //~| ERROR Ord e: RangeInclusive, - //~^ ERROR PartialOrd - //~^^ ERROR Ord + //~^ ERROR can't compare + //~| ERROR Ord f: RangeToInclusive, - //~^ ERROR PartialOrd - //~^^ ERROR Ord + //~^ ERROR can't compare + //~| ERROR Ord } fn main() {} diff --git a/src/test/compile-fail/str-idx.rs b/src/test/compile-fail/str-idx.rs index 2b2c23a3ce4..b5f1ffb977e 100644 --- a/src/test/compile-fail/str-idx.rs +++ b/src/test/compile-fail/str-idx.rs @@ -10,5 +10,5 @@ pub fn main() { let s: &str = "hello"; - let c: u8 = s[4]; //~ ERROR `str: std::ops::Index<{integer}>` is not satisfied + let c: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}` } diff --git a/src/test/compile-fail/str-mut-idx.rs b/src/test/compile-fail/str-mut-idx.rs index 219fcdfd702..c25d257d5f8 100644 --- a/src/test/compile-fail/str-mut-idx.rs +++ b/src/test/compile-fail/str-mut-idx.rs @@ -12,10 +12,10 @@ fn bot() -> T { loop {} } fn mutate(s: &mut str) { s[1..2] = bot(); - //~^ ERROR `str: std::marker::Sized` is not satisfied - //~| ERROR `str: std::marker::Sized` is not satisfied + //~^ ERROR `str` does not have a constant size known at compile-time + //~| ERROR `str` does not have a constant size known at compile-time s[1usize] = bot(); - //~^ ERROR `str: std::ops::IndexMut` is not satisfied + //~^ ERROR the type `str` cannot be mutably indexed by `usize` } pub fn main() {} diff --git a/src/test/compile-fail/substs-ppaux.rs b/src/test/compile-fail/substs-ppaux.rs index c857790e342..94d2a549a86 100644 --- a/src/test/compile-fail/substs-ppaux.rs +++ b/src/test/compile-fail/substs-ppaux.rs @@ -56,6 +56,6 @@ fn foo<'z>() where &'z (): Sized { //[normal]~| found type `fn() {foo::<'static>}` >::bar; - //[verbose]~^ ERROR `str: std::marker::Sized` is not satisfied - //[normal]~^^ ERROR `str: std::marker::Sized` is not satisfied + //[verbose]~^ ERROR `str` does not have a constant size known at compile-time + //[normal]~^^ ERROR `str` does not have a constant size known at compile-time } diff --git a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs index 983c66ec1c4..effee4a70f3 100644 --- a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs +++ b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs @@ -15,7 +15,7 @@ trait Foo { // This should emit the less confusing error, not the more confusing one. fn foo(_x: Foo + Send) { - //~^ ERROR the trait bound `Foo + std::marker::Send + 'static: std::marker::Sized` is not + //~^ ERROR `Foo + std::marker::Send + 'static` does not have a constant size known at compile-time } fn main() { } diff --git a/src/test/compile-fail/traits-negative-impls.rs b/src/test/compile-fail/traits-negative-impls.rs index 8014f92e173..a272686c535 100644 --- a/src/test/compile-fail/traits-negative-impls.rs +++ b/src/test/compile-fail/traits-negative-impls.rs @@ -31,8 +31,8 @@ fn dummy() { impl !Send for TestType {} Outer(TestType); - //~^ ERROR `dummy::TestType: std::marker::Send` is not satisfied - //~| ERROR `dummy::TestType: std::marker::Send` is not satisfied + //~^ ERROR `dummy::TestType` cannot be sent between threads safely + //~| ERROR `dummy::TestType` cannot be sent between threads safely } fn dummy1b() { @@ -40,7 +40,7 @@ fn dummy1b() { impl !Send for TestType {} is_send(TestType); - //~^ ERROR `dummy1b::TestType: std::marker::Send` is not satisfied + //~^ ERROR `dummy1b::TestType` cannot be sent between threads safely } fn dummy1c() { @@ -48,7 +48,7 @@ fn dummy1c() { impl !Send for TestType {} is_send((8, TestType)); - //~^ ERROR `dummy1c::TestType: std::marker::Send` is not satisfied + //~^ ERROR `dummy1c::TestType` cannot be sent between threads safely } fn dummy2() { @@ -56,7 +56,7 @@ fn dummy2() { impl !Send for TestType {} is_send(Box::new(TestType)); - //~^ ERROR `dummy2::TestType: std::marker::Send` is not satisfied + //~^ ERROR `dummy2::TestType` cannot be sent between threads safely } fn dummy3() { @@ -64,7 +64,7 @@ fn dummy3() { impl !Send for TestType {} is_send(Box::new(Outer2(TestType))); - //~^ ERROR `dummy3::TestType: std::marker::Send` is not satisfied + //~^ ERROR `dummy3::TestType` cannot be sent between threads safely } fn main() { @@ -74,5 +74,5 @@ fn main() { // This will complain about a missing Send impl because `Sync` is implement *just* // for T that are `Send`. Look at #20366 and #19950 is_sync(Outer2(TestType)); - //~^ ERROR `main::TestType: std::marker::Send` is not satisfied + //~^ ERROR `main::TestType` cannot be sent between threads safely } diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs b/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs index 853718f1e77..65438e5df8e 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs @@ -27,5 +27,5 @@ fn is_send() {} fn main() { is_send::(); is_send::(); - //~^ ERROR `MyNotSendable: std::marker::Send` is not satisfied + //~^ ERROR `MyNotSendable` cannot be sent between threads safely } diff --git a/src/test/compile-fail/union/union-unsized.rs b/src/test/compile-fail/union/union-unsized.rs index a238eaf0525..32f22f052c1 100644 --- a/src/test/compile-fail/union/union-unsized.rs +++ b/src/test/compile-fail/union/union-unsized.rs @@ -11,13 +11,15 @@ #![feature(untagged_unions)] union U { - a: str, //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied + a: str, + //~^ ERROR `str` does not have a constant size known at compile-time b: u8, } union W { a: u8, - b: str, //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied + b: str, + //~^ ERROR `str` does not have a constant size known at compile-time } fn main() {} diff --git a/src/test/compile-fail/unsized-bare-typaram.rs b/src/test/compile-fail/unsized-bare-typaram.rs index 3dcc7d248d7..be1f1dea28c 100644 --- a/src/test/compile-fail/unsized-bare-typaram.rs +++ b/src/test/compile-fail/unsized-bare-typaram.rs @@ -9,5 +9,6 @@ // except according to those terms. fn bar() { } -fn foo() { bar::() } //~ ERROR `T: std::marker::Sized` is not satisfied +fn foo() { bar::() } +//~^ ERROR `T` does not have a constant size known at compile-time fn main() { } diff --git a/src/test/compile-fail/unsized-enum.rs b/src/test/compile-fail/unsized-enum.rs index 5d791215f36..2041c69da54 100644 --- a/src/test/compile-fail/unsized-enum.rs +++ b/src/test/compile-fail/unsized-enum.rs @@ -15,7 +15,7 @@ fn not_sized() { } enum Foo { FooSome(U), FooNone } fn foo1() { not_sized::>() } // Hunky dory. fn foo2() { not_sized::>() } -//~^ ERROR `T: std::marker::Sized` is not satisfied +//~^ ERROR `T` does not have a constant size known at compile-time // // Not OK: `T` is not sized. diff --git a/src/test/compile-fail/unsized-inherent-impl-self-type.rs b/src/test/compile-fail/unsized-inherent-impl-self-type.rs index 4d0774f2ce4..5e5280ff3ea 100644 --- a/src/test/compile-fail/unsized-inherent-impl-self-type.rs +++ b/src/test/compile-fail/unsized-inherent-impl-self-type.rs @@ -14,7 +14,8 @@ struct S5(Y); -impl S5 { //~ ERROR E0277 +impl S5 { + //~^ ERROR `X` does not have a constant size known at compile-time } fn main() { } diff --git a/src/test/compile-fail/unsized-struct.rs b/src/test/compile-fail/unsized-struct.rs index bbefb2fcecd..830ac5d6c20 100644 --- a/src/test/compile-fail/unsized-struct.rs +++ b/src/test/compile-fail/unsized-struct.rs @@ -15,14 +15,14 @@ fn not_sized() { } struct Foo { data: T } fn foo1() { not_sized::>() } // Hunky dory. fn foo2() { not_sized::>() } -//~^ ERROR `T: std::marker::Sized` is not satisfied +//~^ ERROR `T` does not have a constant size known at compile-time // // Not OK: `T` is not sized. struct Bar { data: T } fn bar1() { not_sized::>() } fn bar2() { is_sized::>() } -//~^ ERROR `T: std::marker::Sized` is not satisfied +//~^ ERROR `T` does not have a constant size known at compile-time // // Not OK: `Bar` is not sized, but it should be. diff --git a/src/test/compile-fail/unsized-trait-impl-self-type.rs b/src/test/compile-fail/unsized-trait-impl-self-type.rs index c919bdf924f..9bf4cf7a0bb 100644 --- a/src/test/compile-fail/unsized-trait-impl-self-type.rs +++ b/src/test/compile-fail/unsized-trait-impl-self-type.rs @@ -17,7 +17,8 @@ trait T3 { struct S5(Y); -impl T3 for S5 { //~ ERROR E0277 +impl T3 for S5 { + //~^ ERROR `X` does not have a constant size known at compile-time } fn main() { } diff --git a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs index ad5e4c2daef..b3a848954d1 100644 --- a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs +++ b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs @@ -16,7 +16,7 @@ trait T2 { } struct S4(Box); impl T2 for S4 { - //~^ ERROR `X: std::marker::Sized` is not satisfied + //~^ ERROR `X` does not have a constant size known at compile-time } fn main() { } diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index e96e0ea3aec..e08cf8280fd 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -15,7 +15,7 @@ use std::marker; // Unbounded. fn f1(x: &X) { f2::(x); - //~^ ERROR `X: std::marker::Sized` is not satisfied + //~^ ERROR `X` does not have a constant size known at compile-time } fn f2(x: &X) { } @@ -26,7 +26,7 @@ trait T { } fn f3(x: &X) { f4::(x); - //~^ ERROR `X: std::marker::Sized` is not satisfied + //~^ ERROR `X` does not have a constant size known at compile-time } fn f4(x: &X) { } @@ -41,20 +41,20 @@ struct S { fn f8(x1: &S, x2: &S) { f5(x1); - //~^ ERROR `X: std::marker::Sized` is not satisfied + //~^ ERROR `X` does not have a constant size known at compile-time f6(x2); // ok } // Test some tuples. fn f9(x1: Box>) { f5(&(*x1, 34)); - //~^ ERROR `X: std::marker::Sized` is not satisfied + //~^ ERROR `X` does not have a constant size known at compile-time } fn f10(x1: Box>) { f5(&(32, *x1)); - //~^ ERROR `X: std::marker::Sized` is not satisfied - //~| ERROR `X: std::marker::Sized` is not satisfied + //~^ ERROR `X` does not have a constant size known at compile-time + //~| ERROR `X` does not have a constant size known at compile-time } pub fn main() { diff --git a/src/test/compile-fail/unsized5.rs b/src/test/compile-fail/unsized5.rs index 3e6c9cc4061..1fb32da5e31 100644 --- a/src/test/compile-fail/unsized5.rs +++ b/src/test/compile-fail/unsized5.rs @@ -11,27 +11,33 @@ // Test `?Sized` types not allowed in fields (except the last one). struct S1 { - f1: X, //~ ERROR `X: std::marker::Sized` is not satisfied + f1: X, + //~^ ERROR `X` does not have a constant size known at compile-time f2: isize, } struct S2 { f: isize, - g: X, //~ ERROR `X: std::marker::Sized` is not satisfied + g: X, + //~^ ERROR `X` does not have a constant size known at compile-time h: isize, } struct S3 { - f: str, //~ ERROR `str: std::marker::Sized` is not satisfied + f: str, + //~^ ERROR `str` does not have a constant size known at compile-time g: [usize] } struct S4 { - f: [u8], //~ ERROR `[u8]: std::marker::Sized` is not satisfied + f: [u8], + //~^ ERROR `[u8]` does not have a constant size known at compile-time g: usize } enum E { - V1(X, isize), //~ERROR `X: std::marker::Sized` is not satisfied + V1(X, isize), + //~^ ERROR `X` does not have a constant size known at compile-time } enum F { - V2{f1: X, f: isize}, //~ERROR `X: std::marker::Sized` is not satisfied + V2{f1: X, f: isize}, + //~^ ERROR `X` does not have a constant size known at compile-time } pub fn main() { diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs index dec8699f46e..7ce0e1eb4d8 100644 --- a/src/test/compile-fail/unsized6.rs +++ b/src/test/compile-fail/unsized6.rs @@ -14,28 +14,41 @@ trait T {} fn f1(x: &X) { let _: W; // <-- this is OK, no bindings created, no initializer. - let _: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfie - let y: Y; //~ERROR `Y: std::marker::Sized` is not satisfied - let y: (isize, (Z, usize)); //~ERROR `Z: std::marker::Sized` is not satisfied + let _: (isize, (X, isize)); + //~^ ERROR `X` does not have a constant size known at compile-time + let y: Y; + //~^ ERROR `Y` does not have a constant size known at compile-time + let y: (isize, (Z, usize)); + //~^ ERROR `Z` does not have a constant size known at compile-time } fn f2(x: &X) { - let y: X; //~ERROR `X: std::marker::Sized` is not satisfied - let y: (isize, (Y, isize)); //~ERROR `Y: std::marker::Sized` is not satisfied + let y: X; + //~^ ERROR `X` does not have a constant size known at compile-time + let y: (isize, (Y, isize)); + //~^ ERROR `Y` does not have a constant size known at compile-time } fn f3(x1: Box, x2: Box, x3: Box) { - let y: X = *x1; //~ERROR `X: std::marker::Sized` is not satisfied - let y = *x2; //~ERROR `X: std::marker::Sized` is not satisfied - let (y, z) = (*x3, 4); //~ERROR `X: std::marker::Sized` is not satisfied + let y: X = *x1; + //~^ ERROR `X` does not have a constant size known at compile-time + let y = *x2; + //~^ ERROR `X` does not have a constant size known at compile-time + let (y, z) = (*x3, 4); + //~^ ERROR `X` does not have a constant size known at compile-time } fn f4(x1: Box, x2: Box, x3: Box) { - let y: X = *x1; //~ERROR `X: std::marker::Sized` is not satisfied - let y = *x2; //~ERROR `X: std::marker::Sized` is not satisfied - let (y, z) = (*x3, 4); //~ERROR `X: std::marker::Sized` is not satisfied + let y: X = *x1; + //~^ ERROR `X` does not have a constant size known at compile-time + let y = *x2; + //~^ ERROR `X` does not have a constant size known at compile-time + let (y, z) = (*x3, 4); + //~^ ERROR `X` does not have a constant size known at compile-time } -fn g1(x: X) {} //~ERROR `X: std::marker::Sized` is not satisfied -fn g2(x: X) {} //~ERROR `X: std::marker::Sized` is not satisfied +fn g1(x: X) {} +//~^ ERROR `X` does not have a constant size known at compile-time +fn g2(x: X) {} +//~^ ERROR `X` does not have a constant size known at compile-time pub fn main() { } diff --git a/src/test/compile-fail/unsized7.rs b/src/test/compile-fail/unsized7.rs index 25868c594fe..8a3d78f0827 100644 --- a/src/test/compile-fail/unsized7.rs +++ b/src/test/compile-fail/unsized7.rs @@ -20,7 +20,7 @@ trait T1 { struct S3(Box); impl T1 for S3 { - //~^ ERROR `X: std::marker::Sized` is not satisfied + //~^ ERROR `X` does not have a constant size known at compile-time } fn main() { } diff --git a/src/test/ui/const-unsized.rs b/src/test/ui/const-unsized.rs index c6ce34b60ca..61ee622e21b 100644 --- a/src/test/ui/const-unsized.rs +++ b/src/test/ui/const-unsized.rs @@ -11,16 +11,16 @@ use std::fmt::Debug; const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); -//~^ ERROR `std::fmt::Debug + std::marker::Sync + 'static: std::marker::Sized` is not satisfied +//~^ ERROR `std::fmt::Debug + std::marker::Sync + 'static` does not have a constant size known at const CONST_FOO: str = *"foo"; -//~^ ERROR `str: std::marker::Sized` is not satisfied +//~^ ERROR `str` does not have a constant size known at compile-time static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); -//~^ ERROR `std::fmt::Debug + std::marker::Sync + 'static: std::marker::Sized` is not satisfied +//~^ ERROR `std::fmt::Debug + std::marker::Sync + 'static` does not have a constant size known at static STATIC_BAR: str = *"bar"; -//~^ ERROR `str: std::marker::Sized` is not satisfied +//~^ ERROR `str` does not have a constant size known at compile-time fn main() { println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR); diff --git a/src/test/ui/const-unsized.stderr b/src/test/ui/const-unsized.stderr index 0bbb5debbba..ca434541cc2 100644 --- a/src/test/ui/const-unsized.stderr +++ b/src/test/ui/const-unsized.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `std::fmt::Debug + std::marker::Sync + 'static: std::marker::Sized` is not satisfied +error[E0277]: `std::fmt::Debug + std::marker::Sync + 'static` does not have a constant size known at compile-time --> $DIR/const-unsized.rs:13:29 | LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); @@ -7,7 +7,7 @@ LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); = help: the trait `std::marker::Sized` is not implemented for `std::fmt::Debug + std::marker::Sync + 'static` = note: constant expressions must have a statically known size -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied +error[E0277]: `str` does not have a constant size known at compile-time --> $DIR/const-unsized.rs:16:24 | LL | const CONST_FOO: str = *"foo"; @@ -16,7 +16,7 @@ LL | const CONST_FOO: str = *"foo"; = help: the trait `std::marker::Sized` is not implemented for `str` = note: constant expressions must have a statically known size -error[E0277]: the trait bound `std::fmt::Debug + std::marker::Sync + 'static: std::marker::Sized` is not satisfied +error[E0277]: `std::fmt::Debug + std::marker::Sync + 'static` does not have a constant size known at compile-time --> $DIR/const-unsized.rs:19:31 | LL | static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); @@ -25,7 +25,7 @@ LL | static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); = help: the trait `std::marker::Sized` is not implemented for `std::fmt::Debug + std::marker::Sync + 'static` = note: constant expressions must have a statically known size -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied +error[E0277]: `str` does not have a constant size known at compile-time --> $DIR/const-unsized.rs:22:26 | LL | static STATIC_BAR: str = *"bar"; diff --git a/src/test/ui/error-codes/E0277-2.rs b/src/test/ui/error-codes/E0277-2.rs index 4d1c50002a3..313aa1f706e 100644 --- a/src/test/ui/error-codes/E0277-2.rs +++ b/src/test/ui/error-codes/E0277-2.rs @@ -24,5 +24,5 @@ fn is_send() { } fn main() { is_send::(); - //~^ ERROR the trait bound `*const u8: std::marker::Send` is not satisfied in `Foo` + //~^ ERROR `*const u8` cannot be sent between threads safely } diff --git a/src/test/ui/error-codes/E0277-2.stderr b/src/test/ui/error-codes/E0277-2.stderr index bbe04cfc6e1..32776f028b4 100644 --- a/src/test/ui/error-codes/E0277-2.stderr +++ b/src/test/ui/error-codes/E0277-2.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `*const u8: std::marker::Send` is not satisfied in `Foo` +error[E0277]: `*const u8` cannot be sent between threads safely --> $DIR/E0277-2.rs:26:5 | LL | is_send::(); diff --git a/src/test/ui/error-codes/E0277.rs b/src/test/ui/error-codes/E0277.rs index b29e4357015..9ff2ef4da90 100644 --- a/src/test/ui/error-codes/E0277.rs +++ b/src/test/ui/error-codes/E0277.rs @@ -21,7 +21,7 @@ fn some_func(foo: T) { } fn f(p: Path) { } -//~^ ERROR the trait bound `[u8]: std::marker::Sized` is not satisfied in `std::path::Path` +//~^ ERROR `[u8]` does not have a constant size known at compile-time fn main() { some_func(5i32); diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index 477128d7d9f..9cfd42b9c19 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied in `std::path::Path` +error[E0277]: `[u8]` does not have a constant size known at compile-time --> $DIR/E0277.rs:23:6 | LL | fn f(p: Path) { } diff --git a/src/test/ui/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gate-trivial_bounds.stderr index 9c2c80600b8..3c6d87e059a 100644 --- a/src/test/ui/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gate-trivial_bounds.stderr @@ -87,7 +87,7 @@ LL | | } = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied +error[E0277]: `str` does not have a constant size known at compile-time --> $DIR/feature-gate-trivial_bounds.rs:62:1 | LL | struct TwoStrs(str, str) where str: Sized; //~ ERROR @@ -97,7 +97,7 @@ LL | struct TwoStrs(str, str) where str: Sized; //~ ERROR = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable -error[E0277]: the trait bound `A + 'static: std::marker::Sized` is not satisfied in `Dst` +error[E0277]: `A + 'static` does not have a constant size known at compile-time --> $DIR/feature-gate-trivial_bounds.rs:65:1 | LL | / fn unsized_local() where Dst: Sized { //~ ERROR @@ -110,7 +110,7 @@ LL | | } = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied +error[E0277]: `str` does not have a constant size known at compile-time --> $DIR/feature-gate-trivial_bounds.rs:69:1 | LL | / fn return_str() -> str where str: Sized { //~ ERROR diff --git a/src/test/ui/generator/sized-yield.rs b/src/test/ui/generator/sized-yield.rs index a1c8ca77e41..165e2702597 100644 --- a/src/test/ui/generator/sized-yield.rs +++ b/src/test/ui/generator/sized-yield.rs @@ -14,8 +14,10 @@ use std::ops::Generator; fn main() { let s = String::from("foo"); - let mut gen = move || { //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied + let mut gen = move || { + //~^ ERROR `str` does not have a constant size known at compile-time yield s[..]; }; - unsafe { gen.resume(); } //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied + unsafe { gen.resume(); } + //~^ ERROR `str` does not have a constant size known at compile-time } diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr index 957fac172c2..45f06659053 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -1,8 +1,9 @@ -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied +error[E0277]: `str` does not have a constant size known at compile-time --> $DIR/sized-yield.rs:17:26 | -LL | let mut gen = move || { //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied +LL | let mut gen = move || { | __________________________^ +LL | | //~^ ERROR `str` does not have a constant size known at compile-time LL | | yield s[..]; LL | | }; | |____^ `str` does not have a constant size known at compile-time @@ -10,10 +11,10 @@ LL | | }; = help: the trait `std::marker::Sized` is not implemented for `str` = note: the yield type of a generator must have a statically known size -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied - --> $DIR/sized-yield.rs:20:17 +error[E0277]: `str` does not have a constant size known at compile-time + --> $DIR/sized-yield.rs:21:17 | -LL | unsafe { gen.resume(); } //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied +LL | unsafe { gen.resume(); } | ^^^^^^ `str` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` diff --git a/src/test/ui/impl-trait/auto-trait-leak.rs b/src/test/ui/impl-trait/auto-trait-leak.rs index abb3682a498..f6b64b394fc 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.rs +++ b/src/test/ui/impl-trait/auto-trait-leak.rs @@ -25,7 +25,7 @@ fn cycle1() -> impl Clone { //~^ ERROR cycle detected //~| ERROR cycle detected send(cycle2().clone()); - //~^ ERROR Send` is not satisfied + //~^ ERROR `std::rc::Rc` cannot be sent between threads safely Rc::new(Cell::new(5)) } diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index 4537c96c4ab..b34facd2d39 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -47,7 +47,7 @@ LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires processing `cycle1::{{exist-impl-Trait}}`, completing the cycle -error[E0277]: the trait bound `std::rc::Rc: std::marker::Send` is not satisfied in `impl std::clone::Clone` +error[E0277]: `std::rc::Rc` cannot be sent between threads safely --> $DIR/auto-trait-leak.rs:27:5 | LL | send(cycle2().clone()); diff --git a/src/test/ui/impl-trait/auto-trait-leak2.rs b/src/test/ui/impl-trait/auto-trait-leak2.rs index 16310e67f1b..3c61543a711 100644 --- a/src/test/ui/impl-trait/auto-trait-leak2.rs +++ b/src/test/ui/impl-trait/auto-trait-leak2.rs @@ -23,10 +23,10 @@ fn send(_: T) {} fn main() { send(before()); - //~^ ERROR the trait bound `std::rc::Rc>: std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc>` cannot be sent between threads safely send(after()); - //~^ ERROR the trait bound `std::rc::Rc>: std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc>` cannot be sent between threads safely } // Deferred path, main has to wait until typeck finishes, diff --git a/src/test/ui/impl-trait/auto-trait-leak2.stderr b/src/test/ui/impl-trait/auto-trait-leak2.stderr index 59623aed3d2..fb00c41f79c 100644 --- a/src/test/ui/impl-trait/auto-trait-leak2.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak2.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `std::rc::Rc>: std::marker::Send` is not satisfied in `impl std::ops::Fn<(i32,)>` +error[E0277]: `std::rc::Rc>` cannot be sent between threads safely --> $DIR/auto-trait-leak2.rs:25:5 | LL | send(before()); @@ -13,7 +13,7 @@ note: required by `send` LL | fn send(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `std::rc::Rc>: std::marker::Send` is not satisfied in `impl std::ops::Fn<(i32,)>` +error[E0277]: `std::rc::Rc>` cannot be sent between threads safely --> $DIR/auto-trait-leak2.rs:28:5 | LL | send(after()); diff --git a/src/test/ui/interior-mutability/interior-mutability.rs b/src/test/ui/interior-mutability/interior-mutability.rs index a772d1f90cc..b0288463e91 100644 --- a/src/test/ui/interior-mutability/interior-mutability.rs +++ b/src/test/ui/interior-mutability/interior-mutability.rs @@ -12,5 +12,6 @@ use std::cell::Cell; use std::panic::catch_unwind; fn main() { let mut x = Cell::new(22); - catch_unwind(|| { x.set(23); }); //~ ERROR the trait bound + catch_unwind(|| { x.set(23); }); + //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a } diff --git a/src/test/ui/interior-mutability/interior-mutability.stderr b/src/test/ui/interior-mutability/interior-mutability.stderr index 4c489c5964b..f2aecc55ccb 100644 --- a/src/test/ui/interior-mutability/interior-mutability.stderr +++ b/src/test/ui/interior-mutability/interior-mutability.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `std::cell::UnsafeCell: std::panic::RefUnwindSafe` is not satisfied in `std::cell::Cell` +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary --> $DIR/interior-mutability.rs:15:5 | -LL | catch_unwind(|| { x.set(23); }); //~ ERROR the trait bound - | ^^^^^^^^^^^^ the type std::cell::UnsafeCell may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary +LL | catch_unwind(|| { x.set(23); }); + | ^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | = help: within `std::cell::Cell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` = note: required because it appears within the type `std::cell::Cell` diff --git a/src/test/ui/mismatched_types/binops.rs b/src/test/ui/mismatched_types/binops.rs index 3f2cb59b11d..86785f24f36 100644 --- a/src/test/ui/mismatched_types/binops.rs +++ b/src/test/ui/mismatched_types/binops.rs @@ -13,6 +13,6 @@ fn main() { 2 as usize - Some(1); //~ ERROR cannot subtract `std::option::Option<{integer}>` from `usize` 3 * (); //~ ERROR cannot multiply `()` to `{integer}` 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` - 5 < String::new(); //~ ERROR is not satisfied - 6 == Ok(1); //~ ERROR is not satisfied + 5 < String::new(); //~ ERROR can't compare `{integer}` with `std::string::String` + 6 == Ok(1); //~ ERROR can't compare `{integer}` with `std::result::Result<{integer}, _>` } diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 9d23b256fd3..4c6d95efadb 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -30,19 +30,19 @@ LL | 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` | = help: the trait `std::ops::Div<&str>` is not implemented for `{integer}` -error[E0277]: the trait bound `{integer}: std::cmp::PartialOrd` is not satisfied +error[E0277]: can't compare `{integer}` with `std::string::String` --> $DIR/binops.rs:16:7 | -LL | 5 < String::new(); //~ ERROR is not satisfied - | ^ can't compare `{integer}` with `std::string::String` +LL | 5 < String::new(); //~ ERROR can't compare `{integer}` with `std::string::String` + | ^ no implementation for `{integer} < std::string::String` and `{integer} > std::string::String` | = help: the trait `std::cmp::PartialOrd` is not implemented for `{integer}` -error[E0277]: the trait bound `{integer}: std::cmp::PartialEq>` is not satisfied +error[E0277]: can't compare `{integer}` with `std::result::Result<{integer}, _>` --> $DIR/binops.rs:17:7 | -LL | 6 == Ok(1); //~ ERROR is not satisfied - | ^^ can't compare `{integer}` with `std::result::Result<{integer}, _>` +LL | 6 == Ok(1); //~ ERROR can't compare `{integer}` with `std::result::Result<{integer}, _>` + | ^^ no implementation for `{integer} == std::result::Result<{integer}, _>` | = help: the trait `std::cmp::PartialEq>` is not implemented for `{integer}` diff --git a/src/test/ui/mismatched_types/cast-rfc0401.rs b/src/test/ui/mismatched_types/cast-rfc0401.rs index 15388b3a764..7ec9593d2de 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.rs +++ b/src/test/ui/mismatched_types/cast-rfc0401.rs @@ -60,7 +60,7 @@ fn main() let _ = 42usize as *const [u8]; //~ ERROR is invalid let _ = v as *const [u8]; //~ ERROR cannot cast - let _ = fat_v as *const Foo; //~ ERROR is not satisfied + let _ = fat_v as *const Foo; //~ ERROR `[u8]` does not have a constant size known at compile-time let _ = foo as *const str; //~ ERROR is invalid let _ = foo as *mut str; //~ ERROR is invalid let _ = main as *mut str; //~ ERROR is invalid @@ -69,7 +69,7 @@ fn main() let _ = fat_sv as usize; //~ ERROR is invalid let a : *const str = "hello"; - let _ = a as *const Foo; //~ ERROR is not satisfied + let _ = a as *const Foo; //~ ERROR `str` does not have a constant size known at compile-time // check no error cascade let _ = main.f as *const u32; //~ ERROR no field diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr index 7931e7ff07f..2b00c20e201 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.stderr +++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr @@ -216,19 +216,19 @@ LL | let _ = cf as *const Bar; //~ ERROR is invalid | = note: vtable kinds may not match -error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied +error[E0277]: `[u8]` does not have a constant size known at compile-time --> $DIR/cast-rfc0401.rs:63:13 | -LL | let _ = fat_v as *const Foo; //~ ERROR is not satisfied +LL | let _ = fat_v as *const Foo; //~ ERROR `[u8]` does not have a constant size known at compile-time | ^^^^^ `[u8]` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: required for the cast to the object type `Foo` -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied +error[E0277]: `str` does not have a constant size known at compile-time --> $DIR/cast-rfc0401.rs:72:13 | -LL | let _ = a as *const Foo; //~ ERROR is not satisfied +LL | let _ = a as *const Foo; //~ ERROR `str` does not have a constant size known at compile-time | ^ `str` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` diff --git a/src/test/ui/partialeq_help.stderr b/src/test/ui/partialeq_help.stderr index c813b64d40b..43f13d45684 100644 --- a/src/test/ui/partialeq_help.stderr +++ b/src/test/ui/partialeq_help.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `&T: std::cmp::PartialEq` is not satisfied +error[E0277]: can't compare `&T` with `T` --> $DIR/partialeq_help.rs:12:7 | LL | a == b; //~ ERROR E0277 - | ^^ can't compare `&T` with `T` + | ^^ no implementation for `&T == T` | = help: the trait `std::cmp::PartialEq` is not implemented for `&T` = help: consider adding a `where &T: std::cmp::PartialEq` bound diff --git a/src/test/ui/resolve/issue-5035-2.rs b/src/test/ui/resolve/issue-5035-2.rs index 83ff95cc2ea..f6cdb05394a 100644 --- a/src/test/ui/resolve/issue-5035-2.rs +++ b/src/test/ui/resolve/issue-5035-2.rs @@ -11,6 +11,7 @@ trait I {} type K = I+'static; -fn foo(_x: K) {} //~ ERROR: `I + 'static: std::marker::Sized` is not satisfied +fn foo(_x: K) {} +//~^ ERROR `I + 'static` does not have a constant size known at compile-time fn main() {} diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr index 92309274e84..554e97a1281 100644 --- a/src/test/ui/resolve/issue-5035-2.stderr +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -1,7 +1,7 @@ -error[E0277]: the trait bound `I + 'static: std::marker::Sized` is not satisfied +error[E0277]: `I + 'static` does not have a constant size known at compile-time --> $DIR/issue-5035-2.rs:14:8 | -LL | fn foo(_x: K) {} //~ ERROR: `I + 'static: std::marker::Sized` is not satisfied +LL | fn foo(_x: K) {} | ^^ `I + 'static` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `I + 'static` diff --git a/src/test/ui/suggestions/str-array-assignment.rs b/src/test/ui/suggestions/str-array-assignment.rs index b70028bd926..f6b75981a66 100644 --- a/src/test/ui/suggestions/str-array-assignment.rs +++ b/src/test/ui/suggestions/str-array-assignment.rs @@ -15,7 +15,7 @@ fn main() { let u: &str = if true { s[..2] } else { s }; //~^ ERROR mismatched types let v = s[..2]; - //~^ ERROR the trait bound `str: std::marker::Sized` is not satisfied + //~^ ERROR `str` does not have a constant size known at compile-time let w: &str = s[..2]; //~^ ERROR mismatched types } diff --git a/src/test/ui/suggestions/str-array-assignment.stderr b/src/test/ui/suggestions/str-array-assignment.stderr index 76db882742a..91e86e344b4 100644 --- a/src/test/ui/suggestions/str-array-assignment.stderr +++ b/src/test/ui/suggestions/str-array-assignment.stderr @@ -19,7 +19,7 @@ LL | let u: &str = if true { s[..2] } else { s }; = note: expected type `&str` found type `str` -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied +error[E0277]: `str` does not have a constant size known at compile-time --> $DIR/str-array-assignment.rs:17:7 | LL | let v = s[..2]; diff --git a/src/test/ui/trait-suggest-where-clause.rs b/src/test/ui/trait-suggest-where-clause.rs index 5dcb4c8a220..7962dbea371 100644 --- a/src/test/ui/trait-suggest-where-clause.rs +++ b/src/test/ui/trait-suggest-where-clause.rs @@ -15,10 +15,10 @@ struct Misc(T); fn check() { // suggest a where-clause, if needed mem::size_of::(); - //~^ ERROR `U: std::marker::Sized` is not satisfied + //~^ ERROR `U` does not have a constant size known at compile-time mem::size_of::>(); - //~^ ERROR `U: std::marker::Sized` is not satisfied + //~^ ERROR `U` does not have a constant size known at compile-time // ... even if T occurs as a type parameter @@ -36,10 +36,10 @@ fn check() { // ... and also not if the error is not related to the type mem::size_of::<[T]>(); - //~^ ERROR `[T]: std::marker::Sized` is not satisfied + //~^ ERROR `[T]` does not have a constant size known at compile-time mem::size_of::<[&U]>(); - //~^ ERROR `[&U]: std::marker::Sized` is not satisfied + //~^ ERROR `[&U]` does not have a constant size known at compile-time } fn main() { diff --git a/src/test/ui/trait-suggest-where-clause.stderr b/src/test/ui/trait-suggest-where-clause.stderr index abd9f5a8b73..d31e9288037 100644 --- a/src/test/ui/trait-suggest-where-clause.stderr +++ b/src/test/ui/trait-suggest-where-clause.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `U: std::marker::Sized` is not satisfied +error[E0277]: `U` does not have a constant size known at compile-time --> $DIR/trait-suggest-where-clause.rs:17:5 | LL | mem::size_of::(); @@ -8,7 +8,7 @@ LL | mem::size_of::(); = help: consider adding a `where U: std::marker::Sized` bound = note: required by `std::mem::size_of` -error[E0277]: the trait bound `U: std::marker::Sized` is not satisfied in `Misc` +error[E0277]: `U` does not have a constant size known at compile-time --> $DIR/trait-suggest-where-clause.rs:20:5 | LL | mem::size_of::>(); @@ -45,7 +45,7 @@ LL | as From>::from; | = note: required by `std::convert::From::from` -error[E0277]: the trait bound `[T]: std::marker::Sized` is not satisfied +error[E0277]: `[T]` does not have a constant size known at compile-time --> $DIR/trait-suggest-where-clause.rs:38:5 | LL | mem::size_of::<[T]>(); @@ -54,7 +54,7 @@ LL | mem::size_of::<[T]>(); = help: the trait `std::marker::Sized` is not implemented for `[T]` = note: required by `std::mem::size_of` -error[E0277]: the trait bound `[&U]: std::marker::Sized` is not satisfied +error[E0277]: `[&U]` does not have a constant size known at compile-time --> $DIR/trait-suggest-where-clause.rs:41:5 | LL | mem::size_of::<[&U]>(); diff --git a/src/test/ui/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds-leak.stderr index df91ba0dd2a..d54414110b1 100644 --- a/src/test/ui/trivial-bounds-leak.stderr +++ b/src/test/ui/trivial-bounds-leak.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied +error[E0277]: `str` does not have a constant size known at compile-time --> $DIR/trivial-bounds-leak.rs:22:25 | LL | fn cant_return_str() -> str { //~ ERROR diff --git a/src/test/ui/type-check-defaults.rs b/src/test/ui/type-check-defaults.rs index f916df5d32d..92a45db0689 100644 --- a/src/test/ui/type-check-defaults.rs +++ b/src/test/ui/type-check-defaults.rs @@ -14,24 +14,24 @@ use std::ops::Add; struct Foo>(T, U); struct WellFormed>(Z); -//~^ error: the trait bound `i32: std::iter::FromIterator` is not satisfied [E0277] +//~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32` struct WellFormedNoBounds>(Z); -//~^ error: the trait bound `i32: std::iter::FromIterator` is not satisfied [E0277] +//~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32` struct Bounds(T); -//~^ error: the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] +//~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] struct WhereClause(T) where T: Copy; -//~^ error: the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] +//~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] trait TraitBound {} -//~^ error: the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] +//~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277] trait Super { } trait Base: Super { } -//~^ error: the trait bound `T: std::marker::Copy` is not satisfied [E0277] +//~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied [E0277] trait ProjectionPred> where T::Item : Add {} -//~^ error: cannot add `u8` to `i32` [E0277] +//~^ ERROR cannot add `u8` to `i32` [E0277] fn main() { } diff --git a/src/test/ui/type-check-defaults.stderr b/src/test/ui/type-check-defaults.stderr index a2d6e53df05..aa124110243 100644 --- a/src/test/ui/type-check-defaults.stderr +++ b/src/test/ui/type-check-defaults.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `i32: std::iter::FromIterator` is not satisfied +error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `i32` --> $DIR/type-check-defaults.rs:16:19 | LL | struct WellFormed>(Z); - | ^ a collection of type `i32` cannot be built from an iterator over elements of type `i32` + | ^ a collection of type `i32` cannot be built from `std::iter::Iterator` | = help: the trait `std::iter::FromIterator` is not implemented for `i32` note: required by `Foo` @@ -11,11 +11,11 @@ note: required by `Foo` LL | struct Foo>(T, U); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `i32: std::iter::FromIterator` is not satisfied +error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `i32` --> $DIR/type-check-defaults.rs:18:27 | LL | struct WellFormedNoBounds>(Z); - | ^ a collection of type `i32` cannot be built from an iterator over elements of type `i32` + | ^ a collection of type `i32` cannot be built from `std::iter::Iterator` | = help: the trait `std::iter::FromIterator` is not implemented for `i32` note: required by `Foo` diff --git a/src/test/ui/union/union-sized-field.rs b/src/test/ui/union/union-sized-field.rs index 8999f1e0930..e40c6d11cb3 100644 --- a/src/test/ui/union/union-sized-field.rs +++ b/src/test/ui/union/union-sized-field.rs @@ -11,16 +11,19 @@ #![feature(untagged_unions)] union Foo { - value: T, //~ ERROR the trait bound `T: std::marker::Sized` is not satisfied + value: T, + //~^ ERROR `T` does not have a constant size known at compile-time } struct Foo2 { - value: T, //~ ERROR the trait bound `T: std::marker::Sized` is not satisfied + value: T, + //~^ ERROR `T` does not have a constant size known at compile-time t: u32, } enum Foo3 { - Value(T), //~ ERROR the trait bound `T: std::marker::Sized` is not satisfied + Value(T), + //~^ ERROR `T` does not have a constant size known at compile-time } fn main() {} diff --git a/src/test/ui/union/union-sized-field.stderr b/src/test/ui/union/union-sized-field.stderr index ba80af6c7e0..ce6de86cff9 100644 --- a/src/test/ui/union/union-sized-field.stderr +++ b/src/test/ui/union/union-sized-field.stderr @@ -1,27 +1,27 @@ -error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied +error[E0277]: `T` does not have a constant size known at compile-time --> $DIR/union-sized-field.rs:14:5 | -LL | value: T, //~ ERROR the trait bound `T: std::marker::Sized` is not satisfied +LL | value: T, | ^^^^^^^^ `T` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` = help: consider adding a `where T: std::marker::Sized` bound = note: no field of a union may have a dynamically sized type -error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied - --> $DIR/union-sized-field.rs:18:5 +error[E0277]: `T` does not have a constant size known at compile-time + --> $DIR/union-sized-field.rs:19:5 | -LL | value: T, //~ ERROR the trait bound `T: std::marker::Sized` is not satisfied +LL | value: T, | ^^^^^^^^ `T` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` = help: consider adding a `where T: std::marker::Sized` bound = note: only the last field of a struct may have a dynamically sized type -error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied - --> $DIR/union-sized-field.rs:23:11 +error[E0277]: `T` does not have a constant size known at compile-time + --> $DIR/union-sized-field.rs:25:11 | -LL | Value(T), //~ ERROR the trait bound `T: std::marker::Sized` is not satisfied +LL | Value(T), | ^ `T` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` diff --git a/src/test/ui/unsized-enum2.rs b/src/test/ui/unsized-enum2.rs index 95fc3243fbe..4e42b92289b 100644 --- a/src/test/ui/unsized-enum2.rs +++ b/src/test/ui/unsized-enum2.rs @@ -30,37 +30,54 @@ struct Path4(PathHelper4); enum E { // parameter - VA(W), //~ ERROR `W: std::marker::Sized` is not satisfied - VB{x: X}, //~ ERROR `X: std::marker::Sized` is not satisfied - VC(isize, Y), //~ ERROR `Y: std::marker::Sized` is not satisfied - VD{u: isize, x: Z}, //~ ERROR `Z: std::marker::Sized` is not satisfied + VA(W), + //~^ ERROR `W` does not have a constant size known at compile-time + VB{x: X}, + //~^ ERROR `X` does not have a constant size known at compile-time + VC(isize, Y), + //~^ ERROR `Y` does not have a constant size known at compile-time + VD{u: isize, x: Z}, + //~^ ERROR `Z` does not have a constant size known at compile-time // slice / str - VE([u8]), //~ ERROR `[u8]: std::marker::Sized` is not satisfied - VF{x: str}, //~ ERROR `str: std::marker::Sized` is not satisfied - VG(isize, [f32]), //~ ERROR `[f32]: std::marker::Sized` is not satisfied - VH{u: isize, x: [u32]}, //~ ERROR `[u32]: std::marker::Sized` is not satisfied + VE([u8]), + //~^ ERROR `[u8]` does not have a constant size known at compile-time + VF{x: str}, + //~^ ERROR `str` does not have a constant size known at compile-time + VG(isize, [f32]), + //~^ ERROR `[f32]` does not have a constant size known at compile-time + VH{u: isize, x: [u32]}, + //~^ ERROR `[u32]` does not have a constant size known at compile-time // unsized struct - VI(Path1), //~ ERROR `PathHelper1 + 'static: std::marker::Sized` is not satisfied - VJ{x: Path2}, //~ ERROR `PathHelper2 + 'static: std::marker::Sized` is not satisfied - VK(isize, Path3), //~ ERROR `PathHelper3 + 'static: std::marker::Sized` is not satisfied - VL{u: isize, x: Path4}, //~ ERROR `PathHelper4 + 'static: std::marker::Sized` is not satisfied + VI(Path1), + //~^ ERROR `PathHelper1 + 'static` does not have a constant size known at compile-time + VJ{x: Path2}, + //~^ ERROR `PathHelper2 + 'static` does not have a constant size known at compile-time + VK(isize, Path3), + //~^ ERROR `PathHelper3 + 'static` does not have a constant size known at compile-time + VL{u: isize, x: Path4}, + //~^ ERROR `PathHelper4 + 'static` does not have a constant size known at compile-time // plain trait - VM(Foo), //~ ERROR `Foo + 'static: std::marker::Sized` is not satisfied - VN{x: Bar}, //~ ERROR `Bar + 'static: std::marker::Sized` is not satisfied - VO(isize, FooBar), //~ ERROR `FooBar + 'static: std::marker::Sized` is not satisfied - VP{u: isize, x: BarFoo}, //~ ERROR `BarFoo + 'static: std::marker::Sized` is not satisfied + VM(Foo), + //~^ ERROR `Foo + 'static` does not have a constant size known at compile-time + VN{x: Bar}, + //~^ ERROR `Bar + 'static` does not have a constant size known at compile-time + VO(isize, FooBar), + //~^ ERROR `FooBar + 'static` does not have a constant size known at compile-time + VP{u: isize, x: BarFoo}, + //~^ ERROR `BarFoo + 'static` does not have a constant size known at compile-time // projected - VQ(<&'static [i8] as Deref>::Target), //~ ERROR `[i8]: std::marker::Sized` is not satisfied + VQ(<&'static [i8] as Deref>::Target), + //~^ ERROR `[i8]` does not have a constant size known at compile-time VR{x: <&'static [char] as Deref>::Target}, - //~^ ERROR `[char]: std::marker::Sized` is not satisfied + //~^ ERROR `[char]` does not have a constant size known at compile-time VS(isize, <&'static [f64] as Deref>::Target), - //~^ ERROR `[f64]: std::marker::Sized` is not satisfied + //~^ ERROR `[f64]` does not have a constant size known at compile-time VT{u: isize, x: <&'static [i32] as Deref>::Target}, - //~^ ERROR `[i32]: std::marker::Sized` is not satisfied + //~^ ERROR `[i32]` does not have a constant size known at compile-time } diff --git a/src/test/ui/unsized-enum2.stderr b/src/test/ui/unsized-enum2.stderr index 0e18efbf9da..2784bf5af1b 100644 --- a/src/test/ui/unsized-enum2.stderr +++ b/src/test/ui/unsized-enum2.stderr @@ -1,126 +1,126 @@ -error[E0277]: the trait bound `W: std::marker::Sized` is not satisfied +error[E0277]: `W` does not have a constant size known at compile-time --> $DIR/unsized-enum2.rs:33:8 | -LL | VA(W), //~ ERROR `W: std::marker::Sized` is not satisfied +LL | VA(W), | ^ `W` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `W` = help: consider adding a `where W: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `X: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:34:8 +error[E0277]: `X` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:35:8 | -LL | VB{x: X}, //~ ERROR `X: std::marker::Sized` is not satisfied +LL | VB{x: X}, | ^^^^ `X` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` = help: consider adding a `where X: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `Y: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:35:15 +error[E0277]: `Y` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:37:15 | -LL | VC(isize, Y), //~ ERROR `Y: std::marker::Sized` is not satisfied +LL | VC(isize, Y), | ^ `Y` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Y` = help: consider adding a `where Y: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `Z: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:36:18 +error[E0277]: `Z` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:39:18 | -LL | VD{u: isize, x: Z}, //~ ERROR `Z: std::marker::Sized` is not satisfied +LL | VD{u: isize, x: Z}, | ^^^^ `Z` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Z` = help: consider adding a `where Z: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:39:8 +error[E0277]: `[u8]` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:43:8 | -LL | VE([u8]), //~ ERROR `[u8]: std::marker::Sized` is not satisfied +LL | VE([u8]), | ^^^^ `[u8]` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:40:8 +error[E0277]: `str` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:45:8 | -LL | VF{x: str}, //~ ERROR `str: std::marker::Sized` is not satisfied +LL | VF{x: str}, | ^^^^^^ `str` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `[f32]: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:41:15 +error[E0277]: `[f32]` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:47:15 | -LL | VG(isize, [f32]), //~ ERROR `[f32]: std::marker::Sized` is not satisfied +LL | VG(isize, [f32]), | ^^^^^ `[f32]` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[f32]` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `[u32]: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:42:18 +error[E0277]: `[u32]` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:49:18 | -LL | VH{u: isize, x: [u32]}, //~ ERROR `[u32]: std::marker::Sized` is not satisfied +LL | VH{u: isize, x: [u32]}, | ^^^^^^^^ `[u32]` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u32]` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `Foo + 'static: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:51:8 +error[E0277]: `Foo + 'static` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:63:8 | -LL | VM(Foo), //~ ERROR `Foo + 'static: std::marker::Sized` is not satisfied +LL | VM(Foo), | ^^^ `Foo + 'static` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Foo + 'static` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `Bar + 'static: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:52:8 +error[E0277]: `Bar + 'static` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:65:8 | -LL | VN{x: Bar}, //~ ERROR `Bar + 'static: std::marker::Sized` is not satisfied +LL | VN{x: Bar}, | ^^^^^^ `Bar + 'static` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Bar + 'static` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `FooBar + 'static: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:53:15 +error[E0277]: `FooBar + 'static` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:67:15 | -LL | VO(isize, FooBar), //~ ERROR `FooBar + 'static: std::marker::Sized` is not satisfied +LL | VO(isize, FooBar), | ^^^^^^ `FooBar + 'static` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `FooBar + 'static` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `BarFoo + 'static: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:54:18 +error[E0277]: `BarFoo + 'static` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:69:18 | -LL | VP{u: isize, x: BarFoo}, //~ ERROR `BarFoo + 'static: std::marker::Sized` is not satisfied +LL | VP{u: isize, x: BarFoo}, | ^^^^^^^^^ `BarFoo + 'static` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `BarFoo + 'static` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `[i8]: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:57:8 +error[E0277]: `[i8]` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:73:8 | -LL | VQ(<&'static [i8] as Deref>::Target), //~ ERROR `[i8]: std::marker::Sized` is not satisfied +LL | VQ(<&'static [i8] as Deref>::Target), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `[i8]` does not have a constant size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i8]` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `[char]: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:58:8 +error[E0277]: `[char]` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:75:8 | LL | VR{x: <&'static [char] as Deref>::Target}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `[char]` does not have a constant size known at compile-time @@ -128,8 +128,8 @@ LL | VR{x: <&'static [char] as Deref>::Target}, = help: the trait `std::marker::Sized` is not implemented for `[char]` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `[f64]: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:60:15 +error[E0277]: `[f64]` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:77:15 | LL | VS(isize, <&'static [f64] as Deref>::Target), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `[f64]` does not have a constant size known at compile-time @@ -137,8 +137,8 @@ LL | VS(isize, <&'static [f64] as Deref>::Target), = help: the trait `std::marker::Sized` is not implemented for `[f64]` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `[i32]: std::marker::Sized` is not satisfied - --> $DIR/unsized-enum2.rs:62:18 +error[E0277]: `[i32]` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:79:18 | LL | VT{u: isize, x: <&'static [i32] as Deref>::Target}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `[i32]` does not have a constant size known at compile-time @@ -146,40 +146,40 @@ LL | VT{u: isize, x: <&'static [i32] as Deref>::Target}, = help: the trait `std::marker::Sized` is not implemented for `[i32]` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `PathHelper1 + 'static: std::marker::Sized` is not satisfied in `Path1` - --> $DIR/unsized-enum2.rs:45:8 +error[E0277]: `PathHelper1 + 'static` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:53:8 | -LL | VI(Path1), //~ ERROR `PathHelper1 + 'static: std::marker::Sized` is not satisfied +LL | VI(Path1), | ^^^^^ `PathHelper1 + 'static` does not have a constant size known at compile-time | = help: within `Path1`, the trait `std::marker::Sized` is not implemented for `PathHelper1 + 'static` = note: required because it appears within the type `Path1` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `PathHelper2 + 'static: std::marker::Sized` is not satisfied in `Path2` - --> $DIR/unsized-enum2.rs:46:8 +error[E0277]: `PathHelper2 + 'static` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:55:8 | -LL | VJ{x: Path2}, //~ ERROR `PathHelper2 + 'static: std::marker::Sized` is not satisfied +LL | VJ{x: Path2}, | ^^^^^^^^ `PathHelper2 + 'static` does not have a constant size known at compile-time | = help: within `Path2`, the trait `std::marker::Sized` is not implemented for `PathHelper2 + 'static` = note: required because it appears within the type `Path2` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `PathHelper3 + 'static: std::marker::Sized` is not satisfied in `Path3` - --> $DIR/unsized-enum2.rs:47:15 +error[E0277]: `PathHelper3 + 'static` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:57:15 | -LL | VK(isize, Path3), //~ ERROR `PathHelper3 + 'static: std::marker::Sized` is not satisfied +LL | VK(isize, Path3), | ^^^^^ `PathHelper3 + 'static` does not have a constant size known at compile-time | = help: within `Path3`, the trait `std::marker::Sized` is not implemented for `PathHelper3 + 'static` = note: required because it appears within the type `Path3` = note: no field of an enum variant may have a dynamically sized type -error[E0277]: the trait bound `PathHelper4 + 'static: std::marker::Sized` is not satisfied in `Path4` - --> $DIR/unsized-enum2.rs:48:18 +error[E0277]: `PathHelper4 + 'static` does not have a constant size known at compile-time + --> $DIR/unsized-enum2.rs:59:18 | -LL | VL{u: isize, x: Path4}, //~ ERROR `PathHelper4 + 'static: std::marker::Sized` is not satisfied +LL | VL{u: isize, x: Path4}, | ^^^^^^^^ `PathHelper4 + 'static` does not have a constant size known at compile-time | = help: within `Path4`, the trait `std::marker::Sized` is not implemented for `PathHelper4 + 'static` -- cgit 1.4.1-3-g733a5 From 3bcb85ee658e7a5362f5e381c337f07381f916dc Mon Sep 17 00:00:00 2001 From: Josef Reinhard Brandl Date: Sat, 23 Jun 2018 13:32:53 +0200 Subject: `PinMut`: Add safe `get_mut` and rename unsafe fns to `get_mut_unchecked` and `map_unchecked` --- src/libcore/mem.rs | 14 ++++++++++---- src/libcore/option.rs | 2 +- src/libstd/future.rs | 2 +- src/libstd/panic.rs | 11 +++-------- 4 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 31635ffa53c..08bd9289ab4 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -1119,6 +1119,12 @@ impl<'a, T: ?Sized + Unpin> PinMut<'a, T> { pub fn new(reference: &'a mut T) -> PinMut<'a, T> { PinMut { inner: reference } } + + /// Get a mutable reference to the data inside of this `PinMut`. + #[unstable(feature = "pin", issue = "49150")] + pub fn get_mut(this: PinMut<'a, T>) -> &'a mut T { + this.inner + } } @@ -1150,21 +1156,21 @@ impl<'a, T: ?Sized> PinMut<'a, T> { /// the data out of the mutable reference you receive when you call this /// function. #[unstable(feature = "pin", issue = "49150")] - pub unsafe fn get_mut(this: PinMut<'a, T>) -> &'a mut T { + pub unsafe fn get_mut_unchecked(this: PinMut<'a, T>) -> &'a mut T { this.inner } /// Construct a new pin by mapping the interior value. /// - /// For example, if you wanted to get a `PinMut` of a field of something, you - /// could use this to get access to that field in one line of code. + /// For example, if you wanted to get a `PinMut` of a field of something, + /// you could use this to get access to that field in one line of code. /// /// This function is unsafe. You must guarantee that the data you return /// will not move so long as the argument value does not move (for example, /// because it is one of the fields of that value), and also that you do /// not move out of the argument you receive to the interior function. #[unstable(feature = "pin", issue = "49150")] - pub unsafe fn map(this: PinMut<'a, T>, f: F) -> PinMut<'a, U> where + pub unsafe fn map_unchecked(this: PinMut<'a, T>, f: F) -> PinMut<'a, U> where F: FnOnce(&mut T) -> &mut U { PinMut { inner: f(this.inner) } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 1e615042a6d..70979f631cd 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -275,7 +275,7 @@ impl Option { #[unstable(feature = "pin", issue = "49150")] pub fn as_pin_mut<'a>(self: PinMut<'a, Self>) -> Option> { unsafe { - PinMut::get_mut(self).as_mut().map(|x| PinMut::new_unchecked(x)) + PinMut::get_mut_unchecked(self).as_mut().map(|x| PinMut::new_unchecked(x)) } } diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 2da775fdc94..c1cc36f3b41 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -43,7 +43,7 @@ impl> !Unpin for GenFuture {} impl> Future for GenFuture { type Output = T::Return; fn poll(self: PinMut, cx: &mut task::Context) -> Poll { - set_task_cx(cx, || match unsafe { PinMut::get_mut(self).0.resume() } { + set_task_cx(cx, || match unsafe { PinMut::get_mut_unchecked(self).0.resume() } { GeneratorState::Yielded(()) => Poll::Pending, GeneratorState::Complete(x) => Poll::Ready(x), }) diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 2c11c262488..451420ae88a 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -327,14 +327,9 @@ impl fmt::Debug for AssertUnwindSafe { impl<'a, F: Future> Future for AssertUnwindSafe { type Output = F::Output; - fn poll(mut self: PinMut, cx: &mut task::Context) -> Poll { - unsafe { - let pinned_field = PinMut::new_unchecked( - &mut PinMut::get_mut(self.reborrow()).0 - ); - - pinned_field.poll(cx) - } + fn poll(self: PinMut, cx: &mut task::Context) -> Poll { + let pinned_field = unsafe { PinMut::map_unchecked(self, |x| &mut x.0) }; + pinned_field.poll(cx) } } -- cgit 1.4.1-3-g733a5 From 560d8079ec26f2a45ecb80e95d24917025e02104 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Tue, 10 Jul 2018 20:35:36 +0200 Subject: Deny bare trait objects in `src/libstd`. --- src/libstd/error.rs | 86 ++++++++++++++++++------------------ src/libstd/ffi/c_str.rs | 2 +- src/libstd/io/error.rs | 14 +++--- src/libstd/io/mod.rs | 4 +- src/libstd/io/stdio.rs | 8 ++-- src/libstd/lib.rs | 1 + src/libstd/net/parser.rs | 2 +- src/libstd/panic.rs | 2 +- src/libstd/panicking.rs | 36 +++++++-------- src/libstd/process.rs | 4 +- src/libstd/rt.rs | 2 +- src/libstd/sync/mpsc/mod.rs | 10 ++--- src/libstd/sync/mpsc/select.rs | 2 +- src/libstd/sync/once.rs | 2 +- src/libstd/sys/windows/thread.rs | 2 +- src/libstd/sys_common/at_exit_imp.rs | 4 +- src/libstd/sys_common/backtrace.rs | 10 ++--- src/libstd/sys_common/poison.rs | 2 +- src/libstd/sys_common/thread.rs | 2 +- src/libstd/thread/mod.rs | 2 +- 20 files changed, 99 insertions(+), 98 deletions(-) (limited to 'src/libstd/panic.rs') diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 1958915602f..8d715ac0ec3 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -138,7 +138,7 @@ pub trait Error: Debug + Display { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - fn cause(&self) -> Option<&Error> { None } + fn cause(&self) -> Option<&dyn Error> { None } /// Get the `TypeId` of `self` #[doc(hidden)] @@ -151,22 +151,22 @@ pub trait Error: Debug + Display { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, E: Error + 'a> From for Box { - fn from(err: E) -> Box { +impl<'a, E: Error + 'a> From for Box { + fn from(err: E) -> Box { Box::new(err) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, E: Error + Send + Sync + 'a> From for Box { - fn from(err: E) -> Box { +impl<'a, E: Error + Send + Sync + 'a> From for Box { + fn from(err: E) -> Box { Box::new(err) } } #[stable(feature = "rust1", since = "1.0.0")] -impl From for Box { - fn from(err: String) -> Box { +impl From for Box { + fn from(err: String) -> Box { #[derive(Debug)] struct StringError(String); @@ -185,38 +185,38 @@ impl From for Box { } #[stable(feature = "string_box_error", since = "1.6.0")] -impl From for Box { - fn from(str_err: String) -> Box { - let err1: Box = From::from(str_err); - let err2: Box = err1; +impl From for Box { + fn from(str_err: String) -> Box { + let err1: Box = From::from(str_err); + let err2: Box = err1; err2 } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b> From<&'b str> for Box { - fn from(err: &'b str) -> Box { +impl<'a, 'b> From<&'b str> for Box { + fn from(err: &'b str) -> Box { From::from(String::from(err)) } } #[stable(feature = "string_box_error", since = "1.6.0")] -impl<'a> From<&'a str> for Box { - fn from(err: &'a str) -> Box { +impl<'a> From<&'a str> for Box { + fn from(err: &'a str) -> Box { From::from(String::from(err)) } } #[stable(feature = "cow_box_error", since = "1.22.0")] -impl<'a, 'b> From> for Box { - fn from(err: Cow<'b, str>) -> Box { +impl<'a, 'b> From> for Box { + fn from(err: Cow<'b, str>) -> Box { From::from(String::from(err)) } } #[stable(feature = "cow_box_error", since = "1.22.0")] -impl<'a> From> for Box { - fn from(err: Cow<'a, str>) -> Box { +impl<'a> From> for Box { + fn from(err: Cow<'a, str>) -> Box { From::from(String::from(err)) } } @@ -327,7 +327,7 @@ impl Error for Box { Error::description(&**self) } - fn cause(&self) -> Option<&Error> { + fn cause(&self) -> Option<&dyn Error> { Error::cause(&**self) } } @@ -368,7 +368,7 @@ impl Error for char::ParseCharError { } // copied from any.rs -impl Error + 'static { +impl dyn Error + 'static { /// Returns true if the boxed type is the same as `T` #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] @@ -390,7 +390,7 @@ impl Error + 'static { pub fn downcast_ref(&self) -> Option<&T> { if self.is::() { unsafe { - Some(&*(self as *const Error as *const T)) + Some(&*(self as *const dyn Error as *const T)) } } else { None @@ -404,7 +404,7 @@ impl Error + 'static { pub fn downcast_mut(&mut self) -> Option<&mut T> { if self.is::() { unsafe { - Some(&mut *(self as *mut Error as *mut T)) + Some(&mut *(self as *mut dyn Error as *mut T)) } } else { None @@ -412,60 +412,60 @@ impl Error + 'static { } } -impl Error + 'static + Send { +impl dyn Error + 'static + Send { /// Forwards to the method defined on the type `Any`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn is(&self) -> bool { - ::is::(self) + ::is::(self) } /// Forwards to the method defined on the type `Any`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn downcast_ref(&self) -> Option<&T> { - ::downcast_ref::(self) + ::downcast_ref::(self) } /// Forwards to the method defined on the type `Any`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn downcast_mut(&mut self) -> Option<&mut T> { - ::downcast_mut::(self) + ::downcast_mut::(self) } } -impl Error + 'static + Send + Sync { +impl dyn Error + 'static + Send + Sync { /// Forwards to the method defined on the type `Any`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn is(&self) -> bool { - ::is::(self) + ::is::(self) } /// Forwards to the method defined on the type `Any`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn downcast_ref(&self) -> Option<&T> { - ::downcast_ref::(self) + ::downcast_ref::(self) } /// Forwards to the method defined on the type `Any`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn downcast_mut(&mut self) -> Option<&mut T> { - ::downcast_mut::(self) + ::downcast_mut::(self) } } -impl Error { +impl dyn Error { #[inline] #[stable(feature = "error_downcast", since = "1.3.0")] /// Attempt to downcast the box to a concrete type. - pub fn downcast(self: Box) -> Result, Box> { + pub fn downcast(self: Box) -> Result, Box> { if self.is::() { unsafe { - let raw: *mut Error = Box::into_raw(self); + let raw: *mut dyn Error = Box::into_raw(self); Ok(Box::from_raw(raw as *mut T)) } } else { @@ -474,30 +474,30 @@ impl Error { } } -impl Error + Send { +impl dyn Error + Send { #[inline] #[stable(feature = "error_downcast", since = "1.3.0")] /// Attempt to downcast the box to a concrete type. pub fn downcast(self: Box) - -> Result, Box> { - let err: Box = self; - ::downcast(err).map_err(|s| unsafe { + -> Result, Box> { + let err: Box = self; + ::downcast(err).map_err(|s| unsafe { // reapply the Send marker - transmute::, Box>(s) + transmute::, Box>(s) }) } } -impl Error + Send + Sync { +impl dyn Error + Send + Sync { #[inline] #[stable(feature = "error_downcast", since = "1.3.0")] /// Attempt to downcast the box to a concrete type. pub fn downcast(self: Box) -> Result, Box> { - let err: Box = self; - ::downcast(err).map_err(|s| unsafe { + let err: Box = self; + ::downcast(err).map_err(|s| unsafe { // reapply the Send+Sync marker - transmute::, Box>(s) + transmute::, Box>(s) }) } } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 6513d11dd51..03e0d0aa6dd 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -883,7 +883,7 @@ impl Error for IntoStringError { "C string contained non-utf8 bytes" } - fn cause(&self) -> Option<&Error> { + fn cause(&self) -> Option<&dyn Error> { Some(&self.error) } } diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index bdd675e6e2b..02a3ce8b9c4 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -83,7 +83,7 @@ enum Repr { #[derive(Debug)] struct Custom { kind: ErrorKind, - error: Box, + error: Box, } /// A list specifying general categories of I/O error. @@ -250,12 +250,12 @@ impl Error { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn new(kind: ErrorKind, error: E) -> Error - where E: Into> + where E: Into> { Self::_new(kind, error.into()) } - fn _new(kind: ErrorKind, error: Box) -> Error { + fn _new(kind: ErrorKind, error: Box) -> Error { Error { repr: Repr::Custom(Box::new(Custom { kind, @@ -373,7 +373,7 @@ impl Error { /// } /// ``` #[stable(feature = "io_error_inner", since = "1.3.0")] - pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { + pub fn get_ref(&self) -> Option<&(dyn error::Error+Send+Sync+'static)> { match self.repr { Repr::Os(..) => None, Repr::Simple(..) => None, @@ -444,7 +444,7 @@ impl Error { /// } /// ``` #[stable(feature = "io_error_inner", since = "1.3.0")] - pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { + pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error+Send+Sync+'static)> { match self.repr { Repr::Os(..) => None, Repr::Simple(..) => None, @@ -478,7 +478,7 @@ impl Error { /// } /// ``` #[stable(feature = "io_error_inner", since = "1.3.0")] - pub fn into_inner(self) -> Option> { + pub fn into_inner(self) -> Option> { match self.repr { Repr::Os(..) => None, Repr::Simple(..) => None, @@ -551,7 +551,7 @@ impl error::Error for Error { } } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match self.repr { Repr::Os(..) => None, Repr::Simple(..) => None, diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 2b4644bd013..85304874848 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1972,7 +1972,7 @@ impl BufRead for Take { } } -fn read_one_byte(reader: &mut Read) -> Option> { +fn read_one_byte(reader: &mut dyn Read) -> Option> { let mut buf = [0]; loop { return match reader.read(&mut buf) { @@ -2081,7 +2081,7 @@ impl std_error::Error for CharsError { CharsError::Other(ref e) => std_error::Error::description(e), } } - fn cause(&self) -> Option<&std_error::Error> { + fn cause(&self) -> Option<&dyn std_error::Error> { match *self { CharsError::NotUtf8 => None, CharsError::Other(ref e) => e.cause(), diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index fce85a200ba..fffe8fc559b 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -21,7 +21,7 @@ use thread::LocalKey; /// Stdout used by print! and println! macros thread_local! { - static LOCAL_STDOUT: RefCell>> = { + static LOCAL_STDOUT: RefCell>> = { RefCell::new(None) } } @@ -624,7 +624,7 @@ impl<'a> fmt::Debug for StderrLock<'a> { with a more general mechanism", issue = "0")] #[doc(hidden)] -pub fn set_panic(sink: Option>) -> Option> { +pub fn set_panic(sink: Option>) -> Option> { use panicking::LOCAL_STDERR; use mem; LOCAL_STDERR.with(move |slot| { @@ -648,7 +648,7 @@ pub fn set_panic(sink: Option>) -> Option> { with a more general mechanism", issue = "0")] #[doc(hidden)] -pub fn set_print(sink: Option>) -> Option> { +pub fn set_print(sink: Option>) -> Option> { use mem; LOCAL_STDOUT.with(move |slot| { mem::replace(&mut *slot.borrow_mut(), sink) @@ -670,7 +670,7 @@ pub fn set_print(sink: Option>) -> Option> { /// However, if the actual I/O causes an error, this function does panic. fn print_to( args: fmt::Arguments, - local_s: &'static LocalKey>>>, + local_s: &'static LocalKey>>>, global_s: fn() -> T, label: &str, ) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index d73cb1f8349..006922383cf 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -221,6 +221,7 @@ // Don't link to std. We are std. #![no_std] +#![deny(bare_trait_objects)] #![deny(missing_docs)] #![deny(missing_debug_implementations)] diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs index ae5037cc44e..234c5618a06 100644 --- a/src/libstd/net/parser.rs +++ b/src/libstd/net/parser.rs @@ -61,7 +61,7 @@ impl<'a> Parser<'a> { } // Return result of first successful parser - fn read_or(&mut self, parsers: &mut [Box Option + 'static>]) + fn read_or(&mut self, parsers: &mut [Box Option + 'static>]) -> Option { for pf in parsers { if let Some(r) = self.read_atomically(|p: &mut Parser| pf(p)) { diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 451420ae88a..b8c1c4f9e68 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -421,6 +421,6 @@ pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { /// } /// ``` #[stable(feature = "resume_unwind", since = "1.9.0")] -pub fn resume_unwind(payload: Box) -> ! { +pub fn resume_unwind(payload: Box) -> ! { panicking::update_count_then_panic(payload) } diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 46b6cf60705..283fd36af41 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -36,7 +36,7 @@ use sys_common::util; use thread; thread_local! { - pub static LOCAL_STDERR: RefCell>> = { + pub static LOCAL_STDERR: RefCell>> = { RefCell::new(None) } } @@ -64,7 +64,7 @@ extern { #[derive(Copy, Clone)] enum Hook { Default, - Custom(*mut (Fn(&PanicInfo) + 'static + Sync + Send)), + Custom(*mut (dyn Fn(&PanicInfo) + 'static + Sync + Send)), } static HOOK_LOCK: RWLock = RWLock::new(); @@ -104,7 +104,7 @@ static mut HOOK: Hook = Hook::Default; /// panic!("Normal panic"); /// ``` #[stable(feature = "panic_hooks", since = "1.10.0")] -pub fn set_hook(hook: Box) { +pub fn set_hook(hook: Box) { if thread::panicking() { panic!("cannot modify the panic hook from a panicking thread"); } @@ -149,7 +149,7 @@ pub fn set_hook(hook: Box) { /// panic!("Normal panic"); /// ``` #[stable(feature = "panic_hooks", since = "1.10.0")] -pub fn take_hook() -> Box { +pub fn take_hook() -> Box { if thread::panicking() { panic!("cannot modify the panic hook from a panicking thread"); } @@ -197,7 +197,7 @@ fn default_hook(info: &PanicInfo) { let thread = thread_info::current_thread(); let name = thread.as_ref().and_then(|t| t.name()).unwrap_or(""); - let write = |err: &mut ::io::Write| { + let write = |err: &mut dyn (::io::Write)| { let _ = writeln!(err, "thread '{}' panicked at '{}', {}", name, msg, location); @@ -248,7 +248,7 @@ pub fn update_panic_count(amt: isize) -> usize { pub use realstd::rt::update_panic_count; /// Invoke a closure, capturing the cause of an unwinding panic if one occurs. -pub unsafe fn try R>(f: F) -> Result> { +pub unsafe fn try R>(f: F) -> Result> { #[allow(unions_with_drop_fields)] union Data { f: F, @@ -369,12 +369,12 @@ fn continue_panic_fmt(info: &PanicInfo) -> ! { } unsafe impl<'a> BoxMeUp for PanicPayload<'a> { - fn box_me_up(&mut self) -> *mut (Any + Send) { + fn box_me_up(&mut self) -> *mut (dyn Any + Send) { let contents = mem::replace(self.fill(), String::new()); Box::into_raw(Box::new(contents)) } - fn get(&mut self) -> &(Any + Send) { + fn get(&mut self) -> &(dyn Any + Send) { self.fill() } } @@ -419,15 +419,15 @@ pub fn begin_panic(msg: M, file_line_col: &(&'static str, u32, u3 } unsafe impl BoxMeUp for PanicPayload { - fn box_me_up(&mut self) -> *mut (Any + Send) { + fn box_me_up(&mut self) -> *mut (dyn Any + Send) { let data = match self.inner.take() { - Some(a) => Box::new(a) as Box, + Some(a) => Box::new(a) as Box, None => Box::new(()), }; Box::into_raw(data) } - fn get(&mut self) -> &(Any + Send) { + fn get(&mut self) -> &(dyn Any + Send) { match self.inner { Some(ref a) => a, None => &(), @@ -441,7 +441,7 @@ pub fn begin_panic(msg: M, file_line_col: &(&'static str, u32, u3 /// Executes the primary logic for a panic, including checking for recursive /// panics, panic hooks, and finally dispatching to the panic runtime to either /// abort or unwind. -fn rust_panic_with_hook(payload: &mut BoxMeUp, +fn rust_panic_with_hook(payload: &mut dyn BoxMeUp, message: Option<&fmt::Arguments>, file_line_col: &(&str, u32, u32)) -> ! { let (file, line, col) = *file_line_col; @@ -496,17 +496,17 @@ fn rust_panic_with_hook(payload: &mut BoxMeUp, } /// Shim around rust_panic. Called by resume_unwind. -pub fn update_count_then_panic(msg: Box) -> ! { +pub fn update_count_then_panic(msg: Box) -> ! { update_panic_count(1); - struct RewrapBox(Box); + struct RewrapBox(Box); unsafe impl BoxMeUp for RewrapBox { - fn box_me_up(&mut self) -> *mut (Any + Send) { + fn box_me_up(&mut self) -> *mut (dyn Any + Send) { Box::into_raw(mem::replace(&mut self.0, Box::new(()))) } - fn get(&mut self) -> &(Any + Send) { + fn get(&mut self) -> &(dyn Any + Send) { &*self.0 } } @@ -517,9 +517,9 @@ pub fn update_count_then_panic(msg: Box) -> ! { /// A private no-mangle function on which to slap yer breakpoints. #[no_mangle] #[allow(private_no_mangle_fns)] // yes we get it, but we like breakpoints -pub fn rust_panic(mut msg: &mut BoxMeUp) -> ! { +pub fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! { let code = unsafe { - let obj = &mut msg as *mut &mut BoxMeUp; + let obj = &mut msg as *mut &mut dyn BoxMeUp; __rust_start_panic(obj as usize) }; rtabort!("failed to initiate panic, error {}", code) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 00051d4487a..39692836866 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -813,13 +813,13 @@ impl fmt::Debug for Output { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let stdout_utf8 = str::from_utf8(&self.stdout); - let stdout_debug: &fmt::Debug = match stdout_utf8 { + let stdout_debug: &dyn fmt::Debug = match stdout_utf8 { Ok(ref str) => str, Err(_) => &self.stdout }; let stderr_utf8 = str::from_utf8(&self.stderr); - let stderr_debug: &fmt::Debug = match stderr_utf8 { + let stderr_debug: &dyn fmt::Debug = match stderr_utf8 { Ok(ref str) => str, Err(_) => &self.stderr }; diff --git a/src/libstd/rt.rs b/src/libstd/rt.rs index 8f945470b7e..9e957bd87d7 100644 --- a/src/libstd/rt.rs +++ b/src/libstd/rt.rs @@ -29,7 +29,7 @@ pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count}; // To reduce the generated code of the new `lang_start`, this function is doing // the real work. #[cfg(not(test))] -fn lang_start_internal(main: &(Fn() -> i32 + Sync + ::panic::RefUnwindSafe), +fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe), argc: isize, argv: *const *const u8) -> isize { use panic; use sys; diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 2dd3aebe610..1dc0b1c0042 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1638,7 +1638,7 @@ impl error::Error for SendError { "sending on a closed channel" } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { None } } @@ -1681,7 +1681,7 @@ impl error::Error for TrySendError { } } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { None } } @@ -1709,7 +1709,7 @@ impl error::Error for RecvError { "receiving on a closed channel" } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { None } } @@ -1742,7 +1742,7 @@ impl error::Error for TryRecvError { } } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { None } } @@ -1783,7 +1783,7 @@ impl error::Error for RecvTimeoutError { } } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { None } } diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 9310dad9172..a7a284cfb79 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -93,7 +93,7 @@ pub struct Handle<'rx, T:Send+'rx> { next: *mut Handle<'static, ()>, prev: *mut Handle<'static, ()>, added: bool, - packet: &'rx (Packet+'rx), + packet: &'rx (dyn Packet+'rx), // due to our fun transmutes, we be sure to place this at the end. (nothing // previous relies on T) diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 7eb7be23128..1c63f99753a 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -301,7 +301,7 @@ impl Once { #[cold] fn call_inner(&'static self, ignore_poisoning: bool, - init: &mut FnMut(bool)) { + init: &mut dyn FnMut(bool)) { let mut state = self.state.load(Ordering::SeqCst); 'outer: loop { diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index b6f63303dc2..44ec872b244 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -28,7 +28,7 @@ pub struct Thread { } impl Thread { - pub unsafe fn new<'a>(stack: usize, p: Box) + pub unsafe fn new<'a>(stack: usize, p: Box) -> io::Result { let p = box p; diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs index d268d9ad6f9..b28a4d2f8be 100644 --- a/src/libstd/sys_common/at_exit_imp.rs +++ b/src/libstd/sys_common/at_exit_imp.rs @@ -17,7 +17,7 @@ use ptr; use mem; use sys_common::mutex::Mutex; -type Queue = Vec>; +type Queue = Vec>; // NB these are specifically not types from `std::sync` as they currently rely // on poisoning and this module needs to operate at a lower level than requiring @@ -68,7 +68,7 @@ pub fn cleanup() { } } -pub fn push(f: Box) -> bool { +pub fn push(f: Box) -> bool { unsafe { let _guard = LOCK.lock(); if init() { diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs index 61d7ed463dd..6184ba4ded6 100644 --- a/src/libstd/sys_common/backtrace.rs +++ b/src/libstd/sys_common/backtrace.rs @@ -49,7 +49,7 @@ pub struct Frame { const MAX_NB_FRAMES: usize = 100; /// Prints the current backtrace. -pub fn print(w: &mut Write, format: PrintFormat) -> io::Result<()> { +pub fn print(w: &mut dyn Write, format: PrintFormat) -> io::Result<()> { static LOCK: Mutex = Mutex::new(); // Use a lock to prevent mixed output in multithreading context. @@ -62,7 +62,7 @@ pub fn print(w: &mut Write, format: PrintFormat) -> io::Result<()> { } } -fn _print(w: &mut Write, format: PrintFormat) -> io::Result<()> { +fn _print(w: &mut dyn Write, format: PrintFormat) -> io::Result<()> { let mut frames = [Frame { exact_position: ptr::null(), symbol_addr: ptr::null(), @@ -177,7 +177,7 @@ pub fn log_enabled() -> Option { /// /// These output functions should now be used everywhere to ensure consistency. /// You may want to also use `output_fileline`. -fn output(w: &mut Write, idx: usize, frame: Frame, +fn output(w: &mut dyn Write, idx: usize, frame: Frame, s: Option<&str>, format: PrintFormat) -> io::Result<()> { // Remove the `17: 0x0 - ` line. if format == PrintFormat::Short && frame.exact_position == ptr::null() { @@ -202,7 +202,7 @@ fn output(w: &mut Write, idx: usize, frame: Frame, /// /// See also `output`. #[allow(dead_code)] -fn output_fileline(w: &mut Write, +fn output_fileline(w: &mut dyn Write, file: &[u8], line: u32, format: PrintFormat) -> io::Result<()> { @@ -254,7 +254,7 @@ fn output_fileline(w: &mut Write, // Note that this demangler isn't quite as fancy as it could be. We have lots // of other information in our symbols like hashes, version, type information, // etc. Additionally, this doesn't handle glue symbols at all. -pub fn demangle(writer: &mut Write, mut s: &str, format: PrintFormat) -> io::Result<()> { +pub fn demangle(writer: &mut dyn Write, mut s: &str, format: PrintFormat) -> io::Result<()> { // During ThinLTO LLVM may import and rename internal symbols, so strip out // those endings first as they're one of the last manglings applied to // symbol names. diff --git a/src/libstd/sys_common/poison.rs b/src/libstd/sys_common/poison.rs index e74c40ae04b..1625efe4a2a 100644 --- a/src/libstd/sys_common/poison.rs +++ b/src/libstd/sys_common/poison.rs @@ -251,7 +251,7 @@ impl Error for TryLockError { } } - fn cause(&self) -> Option<&Error> { + fn cause(&self) -> Option<&dyn Error> { match *self { TryLockError::Poisoned(ref p) => Some(p), _ => None diff --git a/src/libstd/sys_common/thread.rs b/src/libstd/sys_common/thread.rs index da6f58ef6bb..86a5e2b8694 100644 --- a/src/libstd/sys_common/thread.rs +++ b/src/libstd/sys_common/thread.rs @@ -21,7 +21,7 @@ pub unsafe fn start_thread(main: *mut u8) { let _handler = stack_overflow::Handler::new(); // Finally, let's run some code. - Box::from_raw(main as *mut Box)() + Box::from_raw(main as *mut Box)() } pub fn min_stack() -> usize { diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 90f054186d1..cc0ec8a5b4d 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1175,7 +1175,7 @@ impl fmt::Debug for Thread { /// /// [`Result`]: ../../std/result/enum.Result.html #[stable(feature = "rust1", since = "1.0.0")] -pub type Result = ::result::Result>; +pub type Result = ::result::Result>; // This packet is used to communicate the return value between the child thread // and the parent thread. Memory is shared through the `Arc` within and there's -- cgit 1.4.1-3-g733a5