Add comment for regression #136223 on borrowck-errors.rs

Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
This commit is contained in:
Shunpoco 2025-02-01 19:47:12 +00:00
parent a9e7b30487
commit ba124898c0
3 changed files with 7 additions and 5 deletions

View file

@ -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

View file

@ -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;

View file

@ -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