Skip to content

Commit 9788a7b

Browse files
committed
Auto merge of #55017 - memoryruins:add-tests, r=alexcrichton
Add tests for issues #54966 and #52240 Closes #54966 Closes #52240
2 parents 4699283 + ba446d7 commit 9788a7b

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

Diff for: src/test/ui/issues/issue-52240.nll.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0596]: cannot borrow data in a `&` reference as mutable
2+
--> $DIR/issue-52240.rs:9:27
3+
|
4+
LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) {
5+
| ^^^^^^^^^^^ cannot borrow as mutable
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0596`.

Diff for: src/test/ui/issues/issue-52240.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// issue-52240: Can turn immutable into mut with `ref mut`
2+
3+
enum Foo {
4+
Bar(i32),
5+
}
6+
7+
fn main() {
8+
let arr = vec!(Foo::Bar(0));
9+
if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) {
10+
//~^ ERROR cannot borrow field of immutable binding as mutable
11+
*val = 9001;
12+
}
13+
match arr[0] {
14+
Foo::Bar(ref s) => println!("{}", s)
15+
}
16+
}

Diff for: src/test/ui/issues/issue-52240.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0596]: cannot borrow field of immutable binding as mutable
2+
--> $DIR/issue-52240.rs:9:27
3+
|
4+
LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) {
5+
| ^^^^^^^^^^^ cannot mutably borrow field of immutable binding
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0596`.

Diff for: src/test/ui/issues/issue-54966.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// issue-54966: ICE returning an unknown type with impl FnMut
2+
3+
fn generate_duration() -> Oper<impl FnMut()> {}
4+
//~^ ERROR cannot find type `Oper` in this scope
5+
6+
fn main() {}

Diff for: src/test/ui/issues/issue-54966.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `Oper` in this scope
2+
--> $DIR/issue-54966.rs:3:27
3+
|
4+
LL | fn generate_duration() -> Oper<impl FnMut()> {}
5+
| ^^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)