about summary refs log tree commit diff
diff options
context:
space:
mode:
authordianne <diannes.gm@gmail.com>2025-02-16 16:20:52 -0800
committerdianne <diannes.gm@gmail.com>2025-02-18 18:00:17 -0800
commit37bcc1cc5ccd6b87257388e11a7573df61ebc990 (patch)
tree672d7796cb30d7f0536f375f00f010abb2978200
parent20149629ba8b143f0529295be22450488e173f30 (diff)
downloadrust-37bcc1cc5ccd6b87257388e11a7573df61ebc990.tar.gz
rust-37bcc1cc5ccd6b87257388e11a7573df61ebc990.zip
clarify wording on doc comment
Co-authored-by: Nadrieril <Nadrieril@users.noreply.github.com>
-rw-r--r--compiler/rustc_hir_typeck/src/pat.rs15
1 files 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,
     },
 }