Skip to content

Add tests for issues #54966 and #52240 #55017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-52240.nll.stderr
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions src/test/ui/issues/issue-52240.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions src/test/ui/issues/issue-52240.stderr
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions src/test/ui/issues/issue-54966.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions src/test/ui/issues/issue-54966.stderr
Original file line number Diff line number Diff line change
@@ -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`.