summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2020-09-27 01:53:25 +0200
committerGitHub <noreply@github.com>2020-09-27 01:53:25 +0200
commit593b38be6a1cb3a800c3241786df5abe2df2cfa4 (patch)
tree58b8f4752bec21092aba7e494dc135ae052b5acb
parentRollup merge of #77208 - mati865:late-link-args-order, r=petrochenkov (diff)
parentFix documentation highlighting in ty::BorrowKind (diff)
downloadrust-593b38be6a1cb3a800c3241786df5abe2df2cfa4.tar.gz
rust-593b38be6a1cb3a800c3241786df5abe2df2cfa4.tar.bz2
rust-593b38be6a1cb3a800c3241786df5abe2df2cfa4.tar.xz
Rollup merge of #77209 - jyn514:fix-docs, r=petrochenkov
Fix documentation highlighting in ty::BorrowKind Previously it looked a little odd: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.BorrowKind.html#variant.UniqueImmBorrow Noticed this while reviewing https://github.com/rust-lang/rustc-dev-guide/pull/894.
-rw-r--r--compiler/rustc_middle/src/ty/mod.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index 492afa5..d6cf68a 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -682,25 +682,31 @@ pub enum BorrowKind {
682 /// implicit closure bindings. It is needed when the closure 682 /// implicit closure bindings. It is needed when the closure
683 /// is borrowing or mutating a mutable referent, e.g.: 683 /// is borrowing or mutating a mutable referent, e.g.:
684 /// 684 ///
685 /// let x: &mut isize = ...; 685 /// ```
686 /// let y = || *x += 5; 686 /// let x: &mut isize = ...;
687 /// let y = || *x += 5;
688 /// ```
687 /// 689 ///
688 /// If we were to try to translate this closure into a more explicit 690 /// If we were to try to translate this closure into a more explicit
689 /// form, we'd encounter an error with the code as written: 691 /// form, we'd encounter an error with the code as written:
690 /// 692 ///
691 /// struct Env { x: & &mut isize } 693 /// ```
692 /// let x: &mut isize = ...; 694 /// struct Env { x: & &mut isize }
693 /// let y = (&mut Env { &x }, fn_ptr); // Closure is pair of env and fn 695 /// let x: &mut isize = ...;
694 /// fn fn_ptr(env: &mut Env) { **env.x += 5; } 696 /// let y = (&mut Env { &x }, fn_ptr); // Closure is pair of env and fn
697 /// fn fn_ptr(env: &mut Env) { **env.x += 5; }
698 /// ```
695 /// 699 ///
696 /// This is then illegal because you cannot mutate a `&mut` found 700 /// This is then illegal because you cannot mutate a `&mut` found
697 /// in an aliasable location. To solve, you'd have to translate with 701 /// in an aliasable location. To solve, you'd have to translate with
698 /// an `&mut` borrow: 702 /// an `&mut` borrow:
699 /// 703 ///
700 /// struct Env { x: & &mut isize } 704 /// ```
701 /// let x: &mut isize = ...; 705 /// struct Env { x: & &mut isize }
702 /// let y = (&mut Env { &mut x }, fn_ptr); // changed from &x to &mut x 706 /// let x: &mut isize = ...;
703 /// fn fn_ptr(env: &mut Env) { **env.x += 5; } 707 /// let y = (&mut Env { &mut x }, fn_ptr); // changed from &x to &mut x
708 /// fn fn_ptr(env: &mut Env) { **env.x += 5; }
709 /// ```
704 /// 710 ///
705 /// Now the assignment to `**env.x` is legal, but creating a 711 /// Now the assignment to `**env.x` is legal, but creating a
706 /// mutable pointer to `x` is not because `x` is not mutable. We 712 /// mutable pointer to `x` is not because `x` is not mutable. We