From 37bcc1cc5ccd6b87257388e11a7573df61ebc990 Mon Sep 17 00:00:00 2001 From: dianne Date: Sun, 16 Feb 2025 16:20:52 -0800 Subject: [PATCH] clarify wording on doc comment Co-authored-by: Nadrieril --- compiler/rustc_hir_typeck/src/pat.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 4201ef66741..40df87188cd 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -232,12 +232,15 @@ enum InheritedRefMatchRule { /// When the underlying type is a reference type, reference patterns consume both layers of /// reference, i.e. they both reset the binding mode and consume the reference type. EatBoth { - /// This represents two behaviors implemented by both the `ref_pat_eat_one_layer_2024` and - /// `ref_pat_eat_one_layer_2024_structural` feature gates, and is false for stable Rust. - /// - Whether to allow reference patterns to consume only an inherited reference when - /// matching against a non-reference type. - /// - Whether to allow a `&mut` reference pattern to eat a `&` reference type if it's also - /// able to consume a mutable inherited reference. + /// If `true`, an inherited reference will be considered when determining whether a reference + /// pattern matches a given type: + /// - If the underlying type is not a reference, a reference pattern may eat the inherited reference; + /// - If the underlying type is a reference, a reference pattern matches if it can eat either one + /// of the underlying and inherited references. E.g. a `&mut` pattern is allowed if either the + /// underlying type is `&mut` or the inherited reference is `&mut`. + /// If `false`, a reference pattern is only matched against the underlying type. + /// This is `false` for stable Rust and `true` for both the `ref_pat_eat_one_layer_2024` and + /// `ref_pat_eat_one_layer_2024_structural` feature gates. consider_inherited_ref_first: bool, }, }