Skip to content

Commit 5a35fc4

Browse files
Match ergonomics 2024: & matches &mut on old editions
1 parent 5fd5b65 commit 5a35fc4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22172217
debug!("check_pat_ref: expected={:?}", expected);
22182218
match *expected.kind() {
22192219
ty::Ref(_, r_ty, r_mutbl)
2220-
if (new_match_ergonomics && r_mutbl >= pat_mutbl)
2220+
if (no_ref_mut_behind_and && r_mutbl >= pat_mutbl)
22212221
|| r_mutbl == pat_mutbl =>
22222222
{
22232223
if no_ref_mut_behind_and && r_mutbl == Mutability::Not {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ run-pass
2+
//@ edition: 2021
3+
//@ revisions: classic structural both
4+
#![allow(incomplete_features)]
5+
#![cfg_attr(any(classic, both), feature(ref_pat_eat_one_layer_2024))]
6+
#![cfg_attr(any(structural, both), feature(ref_pat_eat_one_layer_2024_structural))]
7+
8+
pub fn main() {
9+
if let &Some(Some(x)) = &Some(&mut Some(0)) {
10+
let _: &u32 = x;
11+
}
12+
if let Some(&x) = Some(&mut 0) {
13+
let _: u32 = x;
14+
}
15+
}

0 commit comments

Comments
 (0)