diff options
| author | bors <bors@rust-lang.org> | 2020-07-16 03:16:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-07-16 03:16:07 +0000 |
| commit | e2e29de5e8a2908260d54182638241ff086a26c2 (patch) | |
| tree | e44d40c0247410d83ffa8a34aa0becdca30b9418 /src/librustc_error_codes/error_codes | |
| parent | 7e11379f3b4c376fbb9a6c4d44f3286ccc28d149 (diff) | |
| parent | 0bde1c3ae5b75eb07338ecf26e797c2f1c436518 (diff) | |
| download | rust-e2e29de5e8a2908260d54182638241ff086a26c2.tar.gz rust-e2e29de5e8a2908260d54182638241ff086a26c2.zip | |
Auto merge of #74375 - Manishearth:rollup-10vbpdh, r=Manishearth
Rollup of 14 pull requests Successful merges: - #72973 (RISC-V GNU/Linux as host platform) - #73918 (Clean up E0715 explanation) - #73959 (Clean up E0716 explanation) - #74119 (Remove `Compiler::compile()`.) - #74196 (Add option to collapse automatically implementors) - #74218 (Add margin after doc search results) - #74276 (improve DiscriminantKind handling) - #74291 (Added docs for `From<c_int>` for `ExitStatus`) - #74294 (Update cross-compilation README) - #74337 (Handle case of incomplete local ty more gracefully) - #74344 (Remove string comparison and use diagnostic item instead) - #74347 (Initialize default providers only once) - #74353 (Edit docs for rustc_middle::dep_graph::dep_node) - #74374 (Add a 1.45 release note on lto vs. embed-bitcode) Failed merges: - #74251 (Teach bootstrap about target files vs target triples) r? @ghost
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0715.md | 3 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0716.md | 55 |
2 files changed, 26 insertions, 32 deletions
diff --git a/src/librustc_error_codes/error_codes/E0715.md b/src/librustc_error_codes/error_codes/E0715.md index 8f0022d9425..b27702b3c26 100644 --- a/src/librustc_error_codes/error_codes/E0715.md +++ b/src/librustc_error_codes/error_codes/E0715.md @@ -15,8 +15,7 @@ struct OverrideConst; impl Marker for OverrideConst { // error! const N: usize = 1; } - -fn main() {} +# fn main() {} ``` Because marker traits are allowed to have multiple implementations for the same diff --git a/src/librustc_error_codes/error_codes/E0716.md b/src/librustc_error_codes/error_codes/E0716.md index 25567c1d128..c6d0337ddda 100644 --- a/src/librustc_error_codes/error_codes/E0716.md +++ b/src/librustc_error_codes/error_codes/E0716.md @@ -1,5 +1,4 @@ -This error indicates that a temporary value is being dropped -while a borrow is still in active use. +A temporary value is being dropped while a borrow is still in active use. Erroneous code example: @@ -11,12 +10,11 @@ let p = bar(&foo()); let q = *p; ``` -Here, the expression `&foo()` is borrowing the expression -`foo()`. As `foo()` is a call to a function, and not the name of -a variable, this creates a **temporary** -- that temporary stores -the return value from `foo()` so that it can be borrowed. -You could imagine that `let p = bar(&foo());` is equivalent -to this: +Here, the expression `&foo()` is borrowing the expression `foo()`. As `foo()` is +a call to a function, and not the name of a variable, this creates a +**temporary** -- that temporary stores the return value from `foo()` so that it +can be borrowed. You could imagine that `let p = bar(&foo());` is equivalent to +this: ```compile_fail,E0597 # fn foo() -> i32 { 22 } @@ -28,16 +26,14 @@ let p = { let q = p; ``` -Whenever a temporary is created, it is automatically dropped (freed) -according to fixed rules. Ordinarily, the temporary is dropped -at the end of the enclosing statement -- in this case, after the `let`. -This is illustrated in the example above by showing that `tmp` would -be freed as we exit the block. +Whenever a temporary is created, it is automatically dropped (freed) according +to fixed rules. Ordinarily, the temporary is dropped at the end of the enclosing +statement -- in this case, after the `let`. This is illustrated in the example +above by showing that `tmp` would be freed as we exit the block. -To fix this problem, you need to create a local variable -to store the value in rather than relying on a temporary. -For example, you might change the original program to -the following: +To fix this problem, you need to create a local variable to store the value in +rather than relying on a temporary. For example, you might change the original +program to the following: ``` fn foo() -> i32 { 22 } @@ -47,16 +43,15 @@ let p = bar(&value); let q = *p; ``` -By introducing the explicit `let value`, we allocate storage -that will last until the end of the enclosing block (when `value` -goes out of scope). When we borrow `&value`, we are borrowing a -local variable that already exists, and hence no temporary is created. +By introducing the explicit `let value`, we allocate storage that will last +until the end of the enclosing block (when `value` goes out of scope). When we +borrow `&value`, we are borrowing a local variable that already exists, and +hence no temporary is created. -Temporaries are not always dropped at the end of the enclosing -statement. In simple cases where the `&` expression is immediately -stored into a variable, the compiler will automatically extend -the lifetime of the temporary until the end of the enclosing -block. Therefore, an alternative way to fix the original +Temporaries are not always dropped at the end of the enclosing statement. In +simple cases where the `&` expression is immediately stored into a variable, the +compiler will automatically extend the lifetime of the temporary until the end +of the enclosing block. Therefore, an alternative way to fix the original program is to write `let tmp = &foo()` and not `let tmp = foo()`: ``` @@ -67,10 +62,10 @@ let p = bar(value); let q = *p; ``` -Here, we are still borrowing `foo()`, but as the borrow is assigned -directly into a variable, the temporary will not be dropped until -the end of the enclosing block. Similar rules apply when temporaries -are stored into aggregate structures like a tuple or struct: +Here, we are still borrowing `foo()`, but as the borrow is assigned directly +into a variable, the temporary will not be dropped until the end of the +enclosing block. Similar rules apply when temporaries are stored into aggregate +structures like a tuple or struct: ``` // Here, two temporaries are created, but |
