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:
commit
9788a7bb2a
5 changed files with 49 additions and 0 deletions
9
src/test/ui/issues/issue-52240.nll.stderr
Normal file
9
src/test/ui/issues/issue-52240.nll.stderr
Normal 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`.
|
||||
16
src/test/ui/issues/issue-52240.rs
Normal file
16
src/test/ui/issues/issue-52240.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
9
src/test/ui/issues/issue-52240.stderr
Normal file
9
src/test/ui/issues/issue-52240.stderr
Normal 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`.
|
||||
6
src/test/ui/issues/issue-54966.rs
Normal file
6
src/test/ui/issues/issue-54966.rs
Normal 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() {}
|
||||
9
src/test/ui/issues/issue-54966.stderr
Normal file
9
src/test/ui/issues/issue-54966.stderr
Normal 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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue