mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Auto merge of #50345 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests Successful merges: - #50233 (Make `Vec::new` a `const fn`) - #50312 (Add more links in panic docs) - #50316 (Fix some broken links in docs.) - #50325 (Add a few more tests for proc macro feature gating) - #50327 (Display correct unused field suggestion for nested struct patterns) - #50330 (check that #[used] is used only on statics) - #50344 (Update Cargo to 2018-04-28 122fd5be5201913d42e219e132d6569493583bca) Failed merges:
This commit is contained in:
@@ -79,7 +79,7 @@ fn ptr(&self) -> *mut HashUint {
|
||||
///
|
||||
/// Essential invariants of this structure:
|
||||
///
|
||||
/// - if t.hashes[i] == EMPTY_BUCKET, then `Bucket::at_index(&t, i).raw`
|
||||
/// - if `t.hashes[i] == EMPTY_BUCKET`, then `Bucket::at_index(&t, i).raw`
|
||||
/// points to 'undefined' contents. Don't read from it. This invariant is
|
||||
/// enforced outside this module with the `EmptyBucket`, `FullBucket`,
|
||||
/// and `SafeHash` types.
|
||||
|
||||
@@ -1118,6 +1118,7 @@ pub fn to_str(&self) -> Result<&str, str::Utf8Error> {
|
||||
///
|
||||
/// [`Cow`]: ../borrow/enum.Cow.html
|
||||
/// [`Borrowed`]: ../borrow/enum.Cow.html#variant.Borrowed
|
||||
/// [`Owned`]: ../borrow/enum.Cow.html#variant.Owned
|
||||
/// [`str`]: ../primitive.str.html
|
||||
/// [`String`]: ../string/struct.String.html
|
||||
///
|
||||
|
||||
+33
-18
@@ -31,10 +31,14 @@
|
||||
/// 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 @@
|
||||
///
|
||||
/// ## 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 @@
|
||||
/// 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 @@
|
||||
|
||||
/// 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 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
/// 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<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -76,7 +76,9 @@ enum Hook {
|
||||
/// 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<Fn(&PanicInfo) + 'static + Sync + Send>) {
|
||||
|
||||
/// 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
|
||||
|
||||
Reference in New Issue
Block a user