Skip to content

Commit a9a2dec

Browse files
committed
Add test for the ICE
Signed-off-by: Shunpoco <[email protected]>
1 parent db60f89 commit a9a2dec

2 files changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This test is for https://github.com/rust-lang/rust/issues/136223.
2+
// `&mut` inside `&` should not panic by `Pattern mutability cap violdated` debug assertion.
3+
fn main() {
4+
if let &Some(Some(x)) = &Some(&mut Some(0)) {}
5+
//~^ ERROR: cannot borrow data in a `&` reference as mutable
6+
}
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/ref-mut-inside-ref-not-pattern-mutability-cap-violated.rs:4:21
3+
|
4+
LL | if let &Some(Some(x)) = &Some(&mut Some(0)) {}
5+
| ^ cannot borrow as mutable
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0596`.

0 commit comments

Comments
 (0)