mirror of https://github.com/rust-lang/rust.git
Match ergonomics 2024: `&` matches `&mut` on old editions
This commit is contained in:
parent
5fd5b65093
commit
5a35fc446e
|
@ -2217,7 +2217,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
debug!("check_pat_ref: expected={:?}", expected);
|
||||
match *expected.kind() {
|
||||
ty::Ref(_, r_ty, r_mutbl)
|
||||
if (new_match_ergonomics && r_mutbl >= pat_mutbl)
|
||||
if (no_ref_mut_behind_and && r_mutbl >= pat_mutbl)
|
||||
|| r_mutbl == pat_mutbl =>
|
||||
{
|
||||
if no_ref_mut_behind_and && r_mutbl == Mutability::Not {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
//@ run-pass
|
||||
//@ edition: 2021
|
||||
//@ revisions: classic structural both
|
||||
#![allow(incomplete_features)]
|
||||
#![cfg_attr(any(classic, both), feature(ref_pat_eat_one_layer_2024))]
|
||||
#![cfg_attr(any(structural, both), feature(ref_pat_eat_one_layer_2024_structural))]
|
||||
|
||||
pub fn main() {
|
||||
if let &Some(Some(x)) = &Some(&mut Some(0)) {
|
||||
let _: &u32 = x;
|
||||
}
|
||||
if let Some(&x) = Some(&mut 0) {
|
||||
let _: u32 = x;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue