1
Fork 0

Auto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakis

Fix unit struct/enum variant in destructuring assignment

See https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md#guide-level-explanation, "including **unit** and tuple structs"

Fixes #94319
This commit is contained in:
bors 2022-05-03 22:29:58 +00:00
commit 1b2e0b60cc
4 changed files with 80 additions and 7 deletions

View file

@ -663,4 +663,9 @@ impl<Id> Res<Id> {
pub fn expected_in_tuple_struct_pat(&self) -> bool {
matches!(self, Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) | Res::SelfCtor(..))
}
/// Returns whether such a resolved path can occur in a unit struct/variant pattern
pub fn expected_in_unit_struct_pat(&self) -> bool {
matches!(self, Res::Def(DefKind::Ctor(_, CtorKind::Const), _) | Res::SelfCtor(..))
}
}