Skip to content

Add a comment pointing to ICE-136223 #136397

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ LL | let &ref mut x = &0;
| ^^^^^^^^^ cannot borrow as mutable

error[E0596]: cannot borrow data in a `&` reference as mutable
--> $DIR/borrowck-errors.rs:35:23
--> $DIR/borrowck-errors.rs:37:23
|
LL | if let &Some(Some(x)) = &Some(&mut Some(0)) {
| ^ cannot borrow as mutable

error[E0596]: cannot borrow data in a `&` reference as mutable
--> $DIR/borrowck-errors.rs:40:11
--> $DIR/borrowck-errors.rs:42:11
|
LL | let &[x] = &&mut [0];
| ^ cannot borrow as mutable

error[E0508]: cannot move out of type `[&mut i32; 1]`, a non-copy array
--> $DIR/borrowck-errors.rs:44:20
--> $DIR/borrowck-errors.rs:46:20
|
LL | let [&mut x] = &mut [&mut 0];
| - ^^^^^^^^^^^^^ cannot move out of here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub fn main() {
let &ref mut x = &0;
//~^ cannot borrow data in a `&` reference as mutable [E0596]

// For 2021 edition, this is also a regression test for #136223
// since the maximum mutability is downgraded during the pattern check process.
if let &Some(Some(x)) = &Some(&mut Some(0)) {
//[stable2021,classic2024]~^ ERROR: cannot borrow data in a `&` reference as mutable
let _: &u32 = x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ LL | let &ref mut x = &0;
| ^^^^^^^^^ cannot borrow as mutable

error[E0596]: cannot borrow data in a `&` reference as mutable
--> $DIR/borrowck-errors.rs:35:23
--> $DIR/borrowck-errors.rs:37:23
|
LL | if let &Some(Some(x)) = &Some(&mut Some(0)) {
| ^ cannot borrow as mutable

error[E0596]: cannot borrow data in a `&` reference as mutable
--> $DIR/borrowck-errors.rs:40:11
--> $DIR/borrowck-errors.rs:42:11
|
LL | let &[x] = &&mut [0];
| ^ cannot borrow as mutable
Expand Down
Loading