diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-11-25 13:49:32 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-11-25 15:39:07 +0100 |
| commit | 98e29176264635da8a8c0b2f2ccabf282cfa2282 (patch) | |
| tree | 59e05b95333cdea92d12b92a1190cae0a41a2a56 /src | |
| parent | 7e813c4a014de141a09b4e8b74532b2896b2766a (diff) | |
| download | rust-98e29176264635da8a8c0b2f2ccabf282cfa2282.tar.gz rust-98e29176264635da8a8c0b2f2ccabf282cfa2282.zip | |
Clean up E0067 long explanation
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0067.md | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/src/librustc_error_codes/error_codes/E0067.md b/src/librustc_error_codes/error_codes/E0067.md index 101b96f7983..11041bb53ee 100644 --- a/src/librustc_error_codes/error_codes/E0067.md +++ b/src/librustc_error_codes/error_codes/E0067.md @@ -1,33 +1,15 @@ -The left-hand side of a compound assignment expression must be a place -expression. A place expression represents a memory location and includes -item paths (ie, namespaced variables), dereferences, indexing expressions, -and field references. +An invalid left-hand side expression was used on an assignment operation. -Let's start with some erroneous code examples: +Erroneous code example: ```compile_fail,E0067 -use std::collections::LinkedList; - -// Bad: assignment to non-place expression -LinkedList::new() += 1; - -// ... - -fn some_func(i: &mut i32) { - i += 12; // Error : '+=' operation cannot be applied on a reference ! -} +12 += 1; // error! ``` -And now some working examples: +You need to have a place expression to be able to assign it something. For +example: ``` -let mut i : i32 = 0; - -i += 12; // Good ! - -// ... - -fn some_func(i: &mut i32) { - *i += 12; // Good ! -} +let mut x: i8 = 12; +x += 1; // ok! ``` |
