Skip to content

Commit

Permalink
Add comment for regression rust-lang#136223 on borrowck-errors.rs
Browse files Browse the repository at this point in the history
Signed-off-by: Shunpoco <[email protected]>
  • Loading branch information
Shunpoco committed Feb 4, 2025
1 parent c5592f3 commit d65b564
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 21 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if (ref_pat_matches_mut_ref && r_mutbl >= pat_mutbl)
|| r_mutbl == pat_mutbl =>
{
if ref_pat_matches_mut_ref && r_mutbl == Mutability::Not {
if r_mutbl == Mutability::Not {
pat_info.max_ref_mutbl = MutblCap::Not;
}

Expand Down

This file was deleted.

This file was deleted.

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

0 comments on commit d65b564

Please sign in to comment.