forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#66737 - GuillaumeGomez:err-codes-cleanup, r…
…=Dylan-DPC Error codes cleanup r? @Dylan-DPC
- Loading branch information
Showing
5 changed files
with
39 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters