@@ -221,16 +221,17 @@ impl MutblCap {
221
221
/// `&mut Option<&T>`, `x` gets type `&mut &T` and the outer `&mut` is considered "inherited".
222
222
#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
223
223
enum InheritedRefMatchRule {
224
- /// Reference patterns try to consume the inherited reference first.
225
- /// This assumes reference patterns can always match against an inherited reference.
224
+ /// Reference patterns consume only the inherited reference if possible, regardless of whether
225
+ /// the underlying type being matched against is a reference type. If there is no inherited
226
+ /// reference, a reference will be consumed from the underlying type.
226
227
EatOuter ,
227
- /// Reference patterns consume inherited references if matching against a non-reference type.
228
- /// This assumes reference patterns can always match against an inherited reference.
228
+ /// Reference patterns consume only a reference from the underlying type if possible. If the
229
+ /// underlying type is not a reference type, the inherited reference will be consumed .
229
230
EatInner ,
230
- /// Reference patterns consume both layers of reference, i.e. reset the binding mode when consuming a reference type.
231
- /// Currently, this assumes the stable Rust behavior of not allowing reference patterns to eat
232
- /// an inherited reference alone. This will need an additional field or variant to represent the
233
- /// planned edition <= 2021 behavior of experimental match ergonomics, which does allow that .
231
+ /// When the underlying type is a reference type, reference patterns consume both layers of
232
+ /// reference, i.e. they both reset the binding mode and consume the reference type. Reference
233
+ /// patterns are not permitted when there is no underlying reference type, i.e. they can't eat
234
+ /// only an inherited reference. This is the current stable Rust behavior .
234
235
EatBoth ,
235
236
}
236
237
0 commit comments