Skip to content

Commit 5327eae

Browse files
authored
Rollup merge of rust-lang#61627 - davidtwco:ice-async-fn-lint, r=alexcrichton
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.
2 parents 32a4b4c + 5604d9a commit 5327eae

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// edition:2018
2+
#![feature(async_await)]
3+
4+
pub async fn f(x: Option<usize>) {
5+
x.take();
6+
//~^ ERROR cannot borrow `x` as mutable, as it is not declared as mutable [E0596]
7+
}
8+
9+
pub async fn g(x: usize) {
10+
x += 1;
11+
//~^ ERROR cannot assign twice to immutable variable `x` [E0384]
12+
}
13+
14+
fn main() {}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
2+
--> $DIR/issue-61452.rs:5:5
3+
|
4+
LL | pub async fn f(x: Option<usize>) {
5+
| - help: consider changing this to be mutable: `mut x`
6+
LL | x.take();
7+
| ^ cannot borrow as mutable
8+
9+
error[E0384]: cannot assign twice to immutable variable `x`
10+
--> $DIR/issue-61452.rs:10:5
11+
|
12+
LL | pub async fn g(x: usize) {
13+
| -
14+
| |
15+
| first assignment to `x`
16+
| help: make this binding mutable: `mut x`
17+
LL | x += 1;
18+
| ^^^^^^ cannot assign twice to immutable variable
19+
20+
error: aborting due to 2 previous errors
21+
22+
Some errors have detailed explanations: E0384, E0596.
23+
For more information about an error, try `rustc --explain E0384`.

0 commit comments

Comments
 (0)