You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/src/primitive_docs.rs
+7-8
Original file line number
Diff line number
Diff line change
@@ -270,8 +270,8 @@ mod prim_bool {}
270
270
///
271
271
/// # Never type fallback
272
272
///
273
-
/// When the compiler sees a value of type `!` it implicitly inserts a coercion (if possible)
274
-
/// to allow type checker to infer any type:
273
+
/// 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
// FIXME: use `core::convert::absurd` here instead, once it's merged
287
287
/// ```
288
288
///
289
-
/// While it's convenient to be able to use non-diverging code in one of the branches (like
290
-
/// `if a { b } else { return }`) this could lead to compilation errors:
289
+
/// This can lead to compilation errors if the type cannot be inferred:
291
290
///
292
291
/// ```compile_fail
293
292
/// // this
@@ -298,17 +297,17 @@ mod prim_bool {}
298
297
/// ```
299
298
///
300
299
/// To prevent such errors, the compiler remembers where it inserted `absurd` calls, and
301
-
/// if it can't infer their type, it sets the type to the fallback type:
300
+
/// if it can't infer the type, it uses the fallback type instead:
302
301
/// ```rust, ignore
303
302
/// type Fallback = /* An arbitrarily selected type! */;
304
303
/// { absurd::<Fallback>(panic!()) }
305
304
/// ```
306
305
///
307
306
/// This is what is known as "never type fallback".
308
307
///
309
-
/// Historicallyfallback was [`()`], causing confusing behavior where `!` spontaneously coerced
310
-
/// to `()`, even though `()` was never mentioned (because of the fallback). There are plans to
311
-
/// change it in 2024 edition (and possibly in all editions on a later date), see
308
+
/// Historically, the fallback type was [`()`], causing confusing behavior where `!` spontaneously coerced
309
+
/// to `()`, even when it would not infer `()` without the fallback. There are plans to
310
+
/// 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
312
311
/// [Tracking Issue for making `!` fall back to `!`][fallback-ti].
0 commit comments