Auto merge of #55017 - memoryruins:add-tests, r=alexcrichton

Add tests for issues #54966 and #52240

Closes #54966
Closes #52240
This commit is contained in:
bors 2018-10-13 23:22:15 +00:00
commit 9788a7bb2a
5 changed files with 49 additions and 0 deletions

View file

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

View file

@ -0,0 +1,16 @@
// issue-52240: Can turn immutable into mut with `ref mut`
enum Foo {
Bar(i32),
}
fn main() {
let arr = vec!(Foo::Bar(0));
if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) {
//~^ ERROR cannot borrow field of immutable binding as mutable
*val = 9001;
}
match arr[0] {
Foo::Bar(ref s) => println!("{}", s)
}
}

View file

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

View file

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

View file

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