X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_hir%2Fsrc%2Fdef.rs;h=db8807bad40b11985c88a37a87edd9831a5e88f7;hb=3346d11f4e8521894377636f145bfc68fad10bea;hp=324e110005717ac6517f4f357e4b4dc7c08cc1a2;hpb=da1ddf371c13aed51ae6f81b4dc13ed0d6d58e20;p=rust.git diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 324e1100057..db8807bad40 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -312,6 +312,7 @@ pub enum Res { /// HACK(min_const_generics): self types also have an optional requirement to **not** mention /// any generic parameters to allow the following with `min_const_generics`: /// ``` + /// # struct Foo; /// impl Foo { fn test() -> [u8; std::mem::size_of::()] { todo!() } } /// /// struct Bar([u8; baz::()]); @@ -663,4 +664,9 @@ pub fn matches_ns(&self, ns: Namespace) -> bool { 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(..)) + } }