Skip to content

Commit cf99f07

Browse files
fix docs of FakeBorrowKind
1 parent a27463c commit cf99f07

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,29 +1595,29 @@ pub enum TagEncoding<VariantIdx: Idx> {
15951595
/// Niche (values invalid for a type) encoding the discriminant.
15961596
/// Note that for this encoding, the discriminant and variant index of each variant coincide!
15971597
/// (This gets checked, for example, in [codegen_ssa](https://github.com/rust-lang/rust/blob/df32e15c56f582eb2bdde07711af6271f2ae660b/compiler/rustc_codegen_ssa/src/mir/operand.rs#L485).)
1598-
///
1598+
///
15991599
/// The variant `untagged_variant` contains a niche at an arbitrary
16001600
/// offset (field [`Variants::Multiple::tag_field`] of the enum).
16011601
/// For a variant with variant index `i`, such that `i!=untagged_variant`,
16021602
/// the tag is set to `(i - niche_variants.start).wrapping_add(niche_start)`
1603-
/// (this is wrapping arithmetic using the type of the niche field, cf. the
1603+
/// (this is wrapping arithmetic using the type of the niche field, cf. the
16041604
/// [`tag_for_variant`](../rustc_const_eval/interpret/struct.InterpCx.html#method.tag_for_variant)
16051605
/// query implementation).
16061606
/// To recover the variant index `i` from a `tag`, the above formula has to be reversed,
16071607
/// i.e. `i = (tag.wrapping_sub(niche_start))+niche_variants.start`. If `i` ends up outside
16081608
/// `niche_variants`, the tag must have encoded the `untagged_variant`.
1609-
///
1609+
///
16101610
/// For example, `Option<(usize, &T)>` is represented such that the tag for
16111611
/// `None` is the null pointer in the second tuple field, and
1612-
/// `Some` is the identity function (with a non-null reference)
1612+
/// `Some` is the identity function (with a non-null reference)
16131613
/// and has no additional tag, i.e. the reference being non-null uniquely identifies this variant.
16141614
///
16151615
/// Other variants that are not `untagged_variant` and that are outside the `niche_variants`
16161616
/// range cannot be represented; they must be uninhabited.
16171617
/// Nonetheless, uninhabited variants can also fall into the range of `niche_variants`.
16181618
Niche {
16191619
untagged_variant: VariantIdx,
1620-
/// This range *may* contain `untagged_variant` or uninhabited variants;
1620+
/// This range *may* contain `untagged_variant` or uninhabited variants;
16211621
/// these are then just "dead values" and not used to encode anything.
16221622
niche_variants: RangeInclusive<VariantIdx>,
16231623
/// This is inbounds of the type of the niche field

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,15 @@ pub enum FakeBorrowKind {
284284
///
285285
/// This is used when lowering deref patterns, where shallow borrows wouldn't prevent something
286286
/// like:
287-
// ```compile_fail
288-
// let mut b = Box::new(false);
289-
// match b {
290-
// deref!(true) => {} // not reached because `*b == false`
291-
// _ if { *b = true; false } => {} // not reached because the guard is `false`
292-
// deref!(false) => {} // not reached because the guard changed it
293-
// // UB because we reached the unreachable.
294-
// }
295-
// ```
287+
/// ```compile_fail
288+
/// let mut b = Box::new(false);
289+
/// match b {
290+
/// deref!(true) => {} // not reached because `*b == false`
291+
/// _ if { *b = true; false } => {} // not reached because the guard is `false`
292+
/// deref!(false) => {} // not reached because the guard changed it
293+
/// // UB because we reached the unreachable.
294+
/// }
295+
/// ```
296296
Deep,
297297
}
298298

0 commit comments

Comments
 (0)