From 96f772cb6bca026cbc15f2dcb5e7d2e2c390ef5c Mon Sep 17 00:00:00 2001 From: Youngsuk_Kim Date: Fri, 25 Sep 2020 17:23:37 -0400 Subject: [PATCH 1/4] minor punctuation/grammar error fix --- src/closure.md | 6 +++--- src/compiler-src.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/closure.md b/src/closure.md index 3a7a10f5c..665f7734e 100644 --- a/src/closure.md +++ b/src/closure.md @@ -5,7 +5,7 @@ effectively "desugared" into structs that contain the values they use (or references to the values they use) from their creator's stack frame. rustc has the job of figuring out which values a closure uses and how, so it can decide whether to capture a given variable by shared reference, mutable reference, or -by move. rustc also has to figure out which the closure traits ([`Fn`][fn], +by move. rustc also has to figure out which of the closure traits ([`Fn`][fn], [`FnMut`][fn_mut], or [`FnOnce`][fn_once]) a closure is capable of implementing. @@ -120,7 +120,7 @@ for this purpose. [upvars]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/query/queries/struct.upvars_mentioned.html -Other than lazy invocation, one other thing that the distinguishes a closure from a +Other than lazy invocation, one other thing that distinguishes a closure from a normal function is that it can use the upvars. It borrows these upvars from its surrounding context; therefore the compiler has to determine the upvar's borrow type. The compiler starts with assigning an immutable borrow type and lowers the restriction (that is, changes it from @@ -189,7 +189,7 @@ can be `ByValue` (moved) or `ByRef` (borrowed). For `ByRef` borrows, it can be [mir_mod]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/index.html `Delegate` defines a few different methods (the different callbacks): -**consume**: for *move* of a variable, **borrow** for a *borrow* of some kind +**consume** for *move* of a variable, **borrow** for a *borrow* of some kind (shared or mutable), and **mutate** when we see an *assignment* of something. All of these callbacks have a common argument *cmt* which stands for Category, diff --git a/src/compiler-src.md b/src/compiler-src.md index 843000a07..5183a7c85 100644 --- a/src/compiler-src.md +++ b/src/compiler-src.md @@ -78,7 +78,7 @@ something like this: You can see the exact dependencies by reading the `Cargo.toml` for the various crates, just like a normal Rust crate. -One final thing: [`src/llvm-project`] is a submodule for our fork of LLVM +One final thing: [`src/llvm-project`] is a submodule for our fork of LLVM. During bootstrapping, LLVM is built and the [`src/librustc_llvm`] and [`src/rustllvm`] crates contain rust wrappers around LLVM (which is written in C++), so that the compiler can interface with it. From 52ee271a0f1df5da3ada4fbca0855d409ef76c74 Mon Sep 17 00:00:00 2001 From: Youngsuk_Kim Date: Fri, 25 Sep 2020 17:39:17 -0400 Subject: [PATCH 2/4] update description of 'ByRef' borrows of closures --- src/closure.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/closure.md b/src/closure.md index 665f7734e..4e6e69d1d 100644 --- a/src/closure.md +++ b/src/closure.md @@ -183,10 +183,10 @@ The callbacks are defined by implementing the [`Delegate`] trait. The [`InferBorrowKind`][ibk] type implements `Delegate` and keeps a map that records for each upvar which mode of borrow was required. The modes of borrow can be `ByValue` (moved) or `ByRef` (borrowed). For `ByRef` borrows, it can be -`shared`, `shallow`, `unique` or `mut` as defined in the -[`compiler/rustc_middle/src/mir/mod.rs`][mir_mod]. +`ImmBorrow`, `UniqueImmBorrow`, `MutBorrow` as defined in the +[`compiler/rustc_middle/src/ty/mod.rs`][middle_ty]. -[mir_mod]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/index.html +[middle_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/index.html `Delegate` defines a few different methods (the different callbacks): **consume** for *move* of a variable, **borrow** for a *borrow* of some kind From a8b6c842b4317072064b26bbea1c6f7367060811 Mon Sep 17 00:00:00 2001 From: Youngsuk_Kim Date: Fri, 25 Sep 2020 22:42:13 -0400 Subject: [PATCH 3/4] add link to 'BorrowKind' in closure.md --- src/closure.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/closure.md b/src/closure.md index 4e6e69d1d..f357eed9c 100644 --- a/src/closure.md +++ b/src/closure.md @@ -181,11 +181,12 @@ shared borrow and another one for a mutable borrow. It will also tell us what wa The callbacks are defined by implementing the [`Delegate`] trait. The [`InferBorrowKind`][ibk] type implements `Delegate` and keeps a map that -records for each upvar which mode of borrow was required. The modes of borrow -can be `ByValue` (moved) or `ByRef` (borrowed). For `ByRef` borrows, it can be -`ImmBorrow`, `UniqueImmBorrow`, `MutBorrow` as defined in the +records for each upvar which mode of capture was required. The modes of capture +can be `ByValue` (moved) or `ByRef` (borrowed). For `ByRef` borrows, the possible +[`BorrowKind`][BorrowKind]s are `ImmBorrow`, `UniqueImmBorrow`, `MutBorrow` as defined in the [`compiler/rustc_middle/src/ty/mod.rs`][middle_ty]. +[BorrowKind]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.BorrowKind.html [middle_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/index.html `Delegate` defines a few different methods (the different callbacks): From ac4ee7aaa62c3ab30077d2ee95d9fff008c9d75d Mon Sep 17 00:00:00 2001 From: Youngsuk_Kim Date: Fri, 25 Sep 2020 22:50:50 -0400 Subject: [PATCH 4/4] update link to 'BorrowKind' to be implicit in markdown --- src/closure.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/closure.md b/src/closure.md index f357eed9c..3b535040e 100644 --- a/src/closure.md +++ b/src/closure.md @@ -183,10 +183,10 @@ The callbacks are defined by implementing the [`Delegate`] trait. The [`InferBorrowKind`][ibk] type implements `Delegate` and keeps a map that records for each upvar which mode of capture was required. The modes of capture can be `ByValue` (moved) or `ByRef` (borrowed). For `ByRef` borrows, the possible -[`BorrowKind`][BorrowKind]s are `ImmBorrow`, `UniqueImmBorrow`, `MutBorrow` as defined in the +[`BorrowKind`]s are `ImmBorrow`, `UniqueImmBorrow`, `MutBorrow` as defined in the [`compiler/rustc_middle/src/ty/mod.rs`][middle_ty]. -[BorrowKind]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.BorrowKind.html +[`BorrowKind`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.BorrowKind.html [middle_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/index.html `Delegate` defines a few different methods (the different callbacks):