X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_hir%2Fsrc%2Fdef.rs;h=324e110005717ac6517f4f357e4b4dc7c08cc1a2;hb=472404039e72dee0c23c7f58563e528c0f506f67;hp=352f369f0d4bc84ca67dae3476f0e10981eb26cd;hpb=94ffb29ee4441246ec3da1f207891549409ce7b1;p=rust.git diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 352f369f0d4..324e1100057 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -1,4 +1,4 @@ -use crate::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; +use crate::def_id::DefId; use crate::hir; use rustc_ast as ast; @@ -124,9 +124,7 @@ impl DefKind { pub fn descr(self, def_id: DefId) -> &'static str { match self { DefKind::Fn => "function", - DefKind::Mod if def_id.index == CRATE_DEF_INDEX && def_id.krate != LOCAL_CRATE => { - "crate" - } + DefKind::Mod if def_id.is_crate_root() && !def_id.is_local() => "crate", DefKind::Mod => "module", DefKind::Static(..) => "static", DefKind::Enum => "enum", @@ -223,6 +221,14 @@ pub fn ns(&self) -> Option { | DefKind::Impl => None, } } + + #[inline] + pub fn is_fn_like(self) -> bool { + match self { + DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator => true, + _ => false, + } + } } /// The resolution of a path or export.