mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-23 13:27:11 +03:00
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:
@@ -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`.
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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`.
|
||||
@@ -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() {}
|
||||
@@ -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`.
|
||||
Reference in New Issue
Block a user