Apply suggestions from code review
Co-authored-by: Kevin Reid <kpreid@switchb.org> Co-authored-by: Herman Skogseth <herman.skogseth@me.com> Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
This commit is contained in:
parent
b73bfd26e4
commit
3a40e838bf
1 changed files with 7 additions and 8 deletions
|
@ -270,8 +270,8 @@ mod prim_bool {}
|
||||||
///
|
///
|
||||||
/// # Never type fallback
|
/// # Never type fallback
|
||||||
///
|
///
|
||||||
/// When the compiler sees a value of type `!` it implicitly inserts a coercion (if possible)
|
/// When the compiler sees a value of type `!` in a [coercion site](https://doc.rust-lang.org/reference/type-coercions.html#coercion-sites), it implicitly inserts a coercion
|
||||||
/// to allow type checker to infer any type:
|
/// to allow the type checker to infer any type:
|
||||||
///
|
///
|
||||||
/// ```rust,ignore (illustrative-and-has-placeholders)
|
/// ```rust,ignore (illustrative-and-has-placeholders)
|
||||||
/// // this
|
/// // this
|
||||||
|
@ -286,8 +286,7 @@ mod prim_bool {}
|
||||||
// FIXME: use `core::convert::absurd` here instead, once it's merged
|
// FIXME: use `core::convert::absurd` here instead, once it's merged
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// While it's convenient to be able to use non-diverging code in one of the branches (like
|
/// This can lead to compilation errors if the type cannot be inferred:
|
||||||
/// `if a { b } else { return }`) this could lead to compilation errors:
|
|
||||||
///
|
///
|
||||||
/// ```compile_fail
|
/// ```compile_fail
|
||||||
/// // this
|
/// // this
|
||||||
|
@ -298,7 +297,7 @@ mod prim_bool {}
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// To prevent such errors, the compiler remembers where it inserted `absurd` calls, and
|
/// To prevent such errors, the compiler remembers where it inserted `absurd` calls, and
|
||||||
/// if it can't infer their type, it sets the type to the fallback type:
|
/// if it can't infer the type, it uses the fallback type instead:
|
||||||
/// ```rust, ignore
|
/// ```rust, ignore
|
||||||
/// type Fallback = /* An arbitrarily selected type! */;
|
/// type Fallback = /* An arbitrarily selected type! */;
|
||||||
/// { absurd::<Fallback>(panic!()) }
|
/// { absurd::<Fallback>(panic!()) }
|
||||||
|
@ -306,9 +305,9 @@ mod prim_bool {}
|
||||||
///
|
///
|
||||||
/// This is what is known as "never type fallback".
|
/// This is what is known as "never type fallback".
|
||||||
///
|
///
|
||||||
/// Historically fallback was [`()`], causing confusing behavior where `!` spontaneously coerced
|
/// Historically, the fallback type was [`()`], causing confusing behavior where `!` spontaneously coerced
|
||||||
/// to `()`, even though `()` was never mentioned (because of the fallback). There are plans to
|
/// to `()`, even when it would not infer `()` without the fallback. There are plans to
|
||||||
/// change it in 2024 edition (and possibly in all editions on a later date), see
|
/// change it in the [2024 edition](https://doc.rust-lang.org/nightly/edition-guide/rust-2024/index.html) (and possibly in all editions on a later date); see
|
||||||
/// [Tracking Issue for making `!` fall back to `!`][fallback-ti].
|
/// [Tracking Issue for making `!` fall back to `!`][fallback-ti].
|
||||||
///
|
///
|
||||||
/// [`()`]: prim@unit
|
/// [`()`]: prim@unit
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue