forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#61627 - davidtwco:ice-async-fn-lint, r=alex…
…crichton Add regression test for rust-lang#61452. Fixes rust-lang#61452. Turns out this ICE had already been fixed, so this PR only adds a regression test.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// edition:2018 | ||
#![feature(async_await)] | ||
|
||
pub async fn f(x: Option<usize>) { | ||
x.take(); | ||
//~^ ERROR cannot borrow `x` as mutable, as it is not declared as mutable [E0596] | ||
} | ||
|
||
pub async fn g(x: usize) { | ||
x += 1; | ||
//~^ ERROR cannot assign twice to immutable variable `x` [E0384] | ||
} | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable | ||
--> $DIR/issue-61452.rs:5:5 | ||
| | ||
LL | pub async fn f(x: Option<usize>) { | ||
| - help: consider changing this to be mutable: `mut x` | ||
LL | x.take(); | ||
| ^ cannot borrow as mutable | ||
|
||
error[E0384]: cannot assign twice to immutable variable `x` | ||
--> $DIR/issue-61452.rs:10:5 | ||
| | ||
LL | pub async fn g(x: usize) { | ||
| - | ||
| | | ||
| first assignment to `x` | ||
| help: make this binding mutable: `mut x` | ||
LL | x += 1; | ||
| ^^^^^^ cannot assign twice to immutable variable | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0384, E0596. | ||
For more information about an error, try `rustc --explain E0384`. |