1use std::array::IntoIter;
2use std::borrow::Cow;
3use std::fmt::Debug;
4
5use rustc_ast as ast;
6use rustc_ast::NodeId;
7use rustc_data_structures::stable_hasher::ToStableHashKey;
8use rustc_data_structures::unord::UnordMap;
9use rustc_error_messages::{DiagArgValue, IntoDiagArg};
10use rustc_macros::{Decodable, Encodable, HashStable_Generic};
11use rustc_span::Symbol;
12use rustc_span::def_id::{DefId, LocalDefId};
13use rustc_span::hygiene::MacroKind;
14
15use crate::definitions::DefPathData;
16use crate::hir;
17
18#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
20pub enum CtorOf {
21 Struct,
23 Variant,
25}
26
27#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
29pub enum CtorKind {
30 Fn,
32 Const,
34}
35
36#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)]
38#[derive(HashStable_Generic)]
39pub struct MacroKinds(u8);
40bitflags::bitflags! {
41 impl MacroKinds: u8 {
42 const BANG = 1 << 0;
43 const ATTR = 1 << 1;
44 const DERIVE = 1 << 2;
45 }
46}
47
48impl From<MacroKind> for MacroKinds {
49 fn from(kind: MacroKind) -> Self {
50 match kind {
51 MacroKind::Bang => Self::BANG,
52 MacroKind::Attr => Self::ATTR,
53 MacroKind::Derive => Self::DERIVE,
54 }
55 }
56}
57
58impl MacroKinds {
59 pub fn descr(self) -> &'static str {
63 match self {
64 Self::BANG => "macro",
66 Self::ATTR => "attribute macro",
67 Self::DERIVE => "derive macro",
68 _ if self == (Self::ATTR | Self::BANG) => "attribute/function macro",
69 _ if self == (Self::DERIVE | Self::BANG) => "derive/function macro",
70 _ if self == (Self::ATTR | Self::DERIVE) => "attribute/derive macro",
71 _ if self.is_all() => "attribute/derive/function macro",
72 _ if self.is_empty() => "useless macro",
73 _ => unreachable!(),
74 }
75 }
76
77 pub fn article(self) -> &'static str {
79 if self.contains(Self::ATTR) { "an" } else { "a" }
80 }
81}
82
83#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
85pub enum NonMacroAttrKind {
86 Builtin(Symbol),
88 Tool,
90 DeriveHelper,
92 DeriveHelperCompat,
95}
96
97#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
100pub enum DefKind {
101 Mod,
103 Struct,
105 Union,
106 Enum,
107 Variant,
109 Trait,
110 TyAlias,
112 ForeignTy,
114 TraitAlias,
116 AssocTy,
118 TyParam,
120
121 Fn,
123 Const,
124 ConstParam,
126 Static {
127 safety: hir::Safety,
129 mutability: ast::Mutability,
131 nested: bool,
133 },
134 Ctor(CtorOf, CtorKind),
146 AssocFn,
149 AssocConst,
151
152 Macro(MacroKinds),
154
155 ExternCrate,
157 Use,
158 ForeignMod,
160 AnonConst,
171 InlineConst,
173 OpaqueTy,
175 Field,
179 LifetimeParam,
181 GlobalAsm,
183 Impl {
184 of_trait: bool,
185 },
186 Closure,
193 SyntheticCoroutineBody,
196}
197
198impl DefKind {
199 pub fn descr(self, def_id: DefId) -> &'static str {
205 match self {
206 DefKind::Fn => "function",
207 DefKind::Mod if def_id.is_crate_root() && !def_id.is_local() => "crate",
208 DefKind::Mod => "module",
209 DefKind::Static { .. } => "static",
210 DefKind::Enum => "enum",
211 DefKind::Variant => "variant",
212 DefKind::Ctor(CtorOf::Variant, CtorKind::Fn) => "tuple variant",
213 DefKind::Ctor(CtorOf::Variant, CtorKind::Const) => "unit variant",
214 DefKind::Struct => "struct",
215 DefKind::Ctor(CtorOf::Struct, CtorKind::Fn) => "tuple struct",
216 DefKind::Ctor(CtorOf::Struct, CtorKind::Const) => "unit struct",
217 DefKind::OpaqueTy => "opaque type",
218 DefKind::TyAlias => "type alias",
219 DefKind::TraitAlias => "trait alias",
220 DefKind::AssocTy => "associated type",
221 DefKind::Union => "union",
222 DefKind::Trait => "trait",
223 DefKind::ForeignTy => "foreign type",
224 DefKind::AssocFn => "associated function",
225 DefKind::Const => "constant",
226 DefKind::AssocConst => "associated constant",
227 DefKind::TyParam => "type parameter",
228 DefKind::ConstParam => "const parameter",
229 DefKind::Macro(kinds) => kinds.descr(),
230 DefKind::LifetimeParam => "lifetime parameter",
231 DefKind::Use => "import",
232 DefKind::ForeignMod => "foreign module",
233 DefKind::AnonConst => "constant expression",
234 DefKind::InlineConst => "inline constant",
235 DefKind::Field => "field",
236 DefKind::Impl { .. } => "implementation",
237 DefKind::Closure => "closure",
238 DefKind::ExternCrate => "extern crate",
239 DefKind::GlobalAsm => "global assembly block",
240 DefKind::SyntheticCoroutineBody => "synthetic mir body",
241 }
242 }
243
244 pub fn article(&self) -> &'static str {
250 match *self {
251 DefKind::AssocTy
252 | DefKind::AssocConst
253 | DefKind::AssocFn
254 | DefKind::Enum
255 | DefKind::OpaqueTy
256 | DefKind::Impl { .. }
257 | DefKind::Use
258 | DefKind::InlineConst
259 | DefKind::ExternCrate => "an",
260 DefKind::Macro(kinds) => kinds.article(),
261 _ => "a",
262 }
263 }
264
265 pub fn ns(&self) -> Option<Namespace> {
266 match self {
267 DefKind::Mod
268 | DefKind::Struct
269 | DefKind::Union
270 | DefKind::Enum
271 | DefKind::Variant
272 | DefKind::Trait
273 | DefKind::TyAlias
274 | DefKind::ForeignTy
275 | DefKind::TraitAlias
276 | DefKind::AssocTy
277 | DefKind::TyParam => Some(Namespace::TypeNS),
278
279 DefKind::Fn
280 | DefKind::Const
281 | DefKind::ConstParam
282 | DefKind::Static { .. }
283 | DefKind::Ctor(..)
284 | DefKind::AssocFn
285 | DefKind::AssocConst => Some(Namespace::ValueNS),
286
287 DefKind::Macro(..) => Some(Namespace::MacroNS),
288
289 DefKind::AnonConst
291 | DefKind::InlineConst
292 | DefKind::Field
293 | DefKind::LifetimeParam
294 | DefKind::ExternCrate
295 | DefKind::Closure
296 | DefKind::Use
297 | DefKind::ForeignMod
298 | DefKind::GlobalAsm
299 | DefKind::Impl { .. }
300 | DefKind::OpaqueTy
301 | DefKind::SyntheticCoroutineBody => None,
302 }
303 }
304
305 pub fn def_path_data(self, name: Option<Symbol>) -> DefPathData {
308 match self {
309 DefKind::Mod
310 | DefKind::Struct
311 | DefKind::Union
312 | DefKind::Enum
313 | DefKind::Variant
314 | DefKind::Trait
315 | DefKind::TyAlias
316 | DefKind::ForeignTy
317 | DefKind::TraitAlias
318 | DefKind::TyParam
319 | DefKind::ExternCrate => DefPathData::TypeNs(name.unwrap()),
320
321 DefKind::AssocTy => DefPathData::TypeNs(name.unwrap()),
324
325 DefKind::Fn
326 | DefKind::Const
327 | DefKind::ConstParam
328 | DefKind::Static { .. }
329 | DefKind::AssocFn
330 | DefKind::AssocConst
331 | DefKind::Field => DefPathData::ValueNs(name.unwrap()),
332 DefKind::Macro(..) => DefPathData::MacroNs(name.unwrap()),
333 DefKind::LifetimeParam => DefPathData::LifetimeNs(name.unwrap()),
334 DefKind::Ctor(..) => DefPathData::Ctor,
335 DefKind::Use => DefPathData::Use,
336 DefKind::ForeignMod => DefPathData::ForeignMod,
337 DefKind::AnonConst => DefPathData::AnonConst,
338 DefKind::InlineConst => DefPathData::AnonConst,
339 DefKind::OpaqueTy => DefPathData::OpaqueTy,
340 DefKind::GlobalAsm => DefPathData::GlobalAsm,
341 DefKind::Impl { .. } => DefPathData::Impl,
342 DefKind::Closure => DefPathData::Closure,
343 DefKind::SyntheticCoroutineBody => DefPathData::SyntheticCoroutineBody,
344 }
345 }
346
347 pub fn is_assoc(self) -> bool {
348 matches!(self, DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy)
349 }
350
351 #[inline]
353 pub fn is_module_like(self) -> bool {
354 matches!(self, DefKind::Mod | DefKind::Enum | DefKind::Trait)
355 }
356
357 #[inline]
358 pub fn is_adt(self) -> bool {
359 matches!(self, DefKind::Struct | DefKind::Union | DefKind::Enum)
360 }
361
362 #[inline]
363 pub fn is_fn_like(self) -> bool {
364 matches!(
365 self,
366 DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::SyntheticCoroutineBody
367 )
368 }
369
370 pub fn has_generics(self) -> bool {
372 match self {
373 DefKind::AnonConst
374 | DefKind::AssocConst
375 | DefKind::AssocFn
376 | DefKind::AssocTy
377 | DefKind::Closure
378 | DefKind::Const
379 | DefKind::Ctor(..)
380 | DefKind::Enum
381 | DefKind::Field
382 | DefKind::Fn
383 | DefKind::ForeignTy
384 | DefKind::Impl { .. }
385 | DefKind::InlineConst
386 | DefKind::OpaqueTy
387 | DefKind::Static { .. }
388 | DefKind::Struct
389 | DefKind::SyntheticCoroutineBody
390 | DefKind::Trait
391 | DefKind::TraitAlias
392 | DefKind::TyAlias
393 | DefKind::Union
394 | DefKind::Variant => true,
395 DefKind::ConstParam
396 | DefKind::ExternCrate
397 | DefKind::ForeignMod
398 | DefKind::GlobalAsm
399 | DefKind::LifetimeParam
400 | DefKind::Macro(_)
401 | DefKind::Mod
402 | DefKind::TyParam
403 | DefKind::Use => false,
404 }
405 }
406
407 pub fn has_codegen_attrs(self) -> bool {
409 match self {
410 DefKind::Fn
411 | DefKind::AssocFn
412 | DefKind::Ctor(..)
413 | DefKind::Closure
414 | DefKind::Static { .. }
415 | DefKind::SyntheticCoroutineBody => true,
416 DefKind::Mod
417 | DefKind::Struct
418 | DefKind::Union
419 | DefKind::Enum
420 | DefKind::Variant
421 | DefKind::Trait
422 | DefKind::TyAlias
423 | DefKind::ForeignTy
424 | DefKind::TraitAlias
425 | DefKind::AssocTy
426 | DefKind::Const
427 | DefKind::AssocConst
428 | DefKind::Macro(..)
429 | DefKind::Use
430 | DefKind::ForeignMod
431 | DefKind::OpaqueTy
432 | DefKind::Impl { .. }
433 | DefKind::Field
434 | DefKind::TyParam
435 | DefKind::ConstParam
436 | DefKind::LifetimeParam
437 | DefKind::AnonConst
438 | DefKind::InlineConst
439 | DefKind::GlobalAsm
440 | DefKind::ExternCrate => false,
441 }
442 }
443
444 #[inline]
447 pub fn is_typeck_child(self) -> bool {
448 match self {
449 DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody => true,
450 DefKind::Mod
451 | DefKind::Struct
452 | DefKind::Union
453 | DefKind::Enum
454 | DefKind::Variant
455 | DefKind::Trait
456 | DefKind::TyAlias
457 | DefKind::ForeignTy
458 | DefKind::TraitAlias
459 | DefKind::AssocTy
460 | DefKind::TyParam
461 | DefKind::Fn
462 | DefKind::Const
463 | DefKind::ConstParam
464 | DefKind::Static { .. }
465 | DefKind::Ctor(_, _)
466 | DefKind::AssocFn
467 | DefKind::AssocConst
468 | DefKind::Macro(_)
469 | DefKind::ExternCrate
470 | DefKind::Use
471 | DefKind::ForeignMod
472 | DefKind::AnonConst
473 | DefKind::OpaqueTy
474 | DefKind::Field
475 | DefKind::LifetimeParam
476 | DefKind::GlobalAsm
477 | DefKind::Impl { .. } => false,
478 }
479 }
480}
481
482#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
511pub enum Res<Id = hir::HirId> {
512 Def(DefKind, DefId),
516
517 PrimTy(hir::PrimTy),
522
523 SelfTyParam {
529 trait_: DefId,
531 },
532
533 SelfTyAlias {
562 alias_to: DefId,
565
566 is_trait_impl: bool,
568 },
569
570 SelfCtor(DefId),
578
579 Local(Id),
583
584 ToolMod,
588
589 NonMacroAttr(NonMacroAttrKind), Err,
603}
604
605impl<Id> IntoDiagArg for Res<Id> {
606 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
607 DiagArgValue::Str(Cow::Borrowed(self.descr()))
608 }
609}
610
611#[derive(Copy, Clone, Debug)]
628pub struct PartialRes {
629 base_res: Res<NodeId>,
630 unresolved_segments: usize,
631}
632
633impl PartialRes {
634 #[inline]
635 pub fn new(base_res: Res<NodeId>) -> Self {
636 PartialRes { base_res, unresolved_segments: 0 }
637 }
638
639 #[inline]
640 pub fn with_unresolved_segments(base_res: Res<NodeId>, mut unresolved_segments: usize) -> Self {
641 if base_res == Res::Err {
642 unresolved_segments = 0
643 }
644 PartialRes { base_res, unresolved_segments }
645 }
646
647 #[inline]
648 pub fn base_res(&self) -> Res<NodeId> {
649 self.base_res
650 }
651
652 #[inline]
653 pub fn unresolved_segments(&self) -> usize {
654 self.unresolved_segments
655 }
656
657 #[inline]
658 pub fn full_res(&self) -> Option<Res<NodeId>> {
659 (self.unresolved_segments == 0).then_some(self.base_res)
660 }
661
662 #[inline]
663 pub fn expect_full_res(&self) -> Res<NodeId> {
664 self.full_res().expect("unexpected unresolved segments")
665 }
666}
667
668#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)]
671#[derive(HashStable_Generic)]
672pub enum Namespace {
673 TypeNS,
679 ValueNS,
681 MacroNS,
685}
686
687impl Namespace {
688 pub fn descr(self) -> &'static str {
690 match self {
691 Self::TypeNS => "type",
692 Self::ValueNS => "value",
693 Self::MacroNS => "macro",
694 }
695 }
696}
697
698impl IntoDiagArg for Namespace {
699 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
700 DiagArgValue::Str(Cow::Borrowed(self.descr()))
701 }
702}
703
704impl<CTX: crate::HashStableContext> ToStableHashKey<CTX> for Namespace {
705 type KeyType = Namespace;
706
707 #[inline]
708 fn to_stable_hash_key(&self, _: &CTX) -> Namespace {
709 *self
710 }
711}
712
713#[derive(Copy, Clone, Default, Debug, HashStable_Generic)]
715pub struct PerNS<T> {
716 pub value_ns: T,
717 pub type_ns: T,
718 pub macro_ns: T,
719}
720
721impl<T> PerNS<T> {
722 pub fn map<U, F: FnMut(T) -> U>(self, mut f: F) -> PerNS<U> {
723 PerNS { value_ns: f(self.value_ns), type_ns: f(self.type_ns), macro_ns: f(self.macro_ns) }
724 }
725
726 pub fn into_iter(self) -> IntoIter<T, 3> {
730 [self.value_ns, self.type_ns, self.macro_ns].into_iter()
731 }
732
733 pub fn iter(&self) -> IntoIter<&T, 3> {
737 [&self.value_ns, &self.type_ns, &self.macro_ns].into_iter()
738 }
739}
740
741impl<T> ::std::ops::Index<Namespace> for PerNS<T> {
742 type Output = T;
743
744 fn index(&self, ns: Namespace) -> &T {
745 match ns {
746 Namespace::ValueNS => &self.value_ns,
747 Namespace::TypeNS => &self.type_ns,
748 Namespace::MacroNS => &self.macro_ns,
749 }
750 }
751}
752
753impl<T> ::std::ops::IndexMut<Namespace> for PerNS<T> {
754 fn index_mut(&mut self, ns: Namespace) -> &mut T {
755 match ns {
756 Namespace::ValueNS => &mut self.value_ns,
757 Namespace::TypeNS => &mut self.type_ns,
758 Namespace::MacroNS => &mut self.macro_ns,
759 }
760 }
761}
762
763impl<T> PerNS<Option<T>> {
764 pub fn is_empty(&self) -> bool {
766 self.type_ns.is_none() && self.value_ns.is_none() && self.macro_ns.is_none()
767 }
768
769 pub fn present_items(self) -> impl Iterator<Item = T> {
775 [self.type_ns, self.value_ns, self.macro_ns].into_iter().flatten()
776 }
777}
778
779impl CtorKind {
780 pub fn from_ast(vdata: &ast::VariantData) -> Option<(CtorKind, NodeId)> {
781 match *vdata {
782 ast::VariantData::Tuple(_, node_id) => Some((CtorKind::Fn, node_id)),
783 ast::VariantData::Unit(node_id) => Some((CtorKind::Const, node_id)),
784 ast::VariantData::Struct { .. } => None,
785 }
786 }
787}
788
789impl NonMacroAttrKind {
790 pub fn descr(self) -> &'static str {
791 match self {
792 NonMacroAttrKind::Builtin(..) => "built-in attribute",
793 NonMacroAttrKind::Tool => "tool attribute",
794 NonMacroAttrKind::DeriveHelper | NonMacroAttrKind::DeriveHelperCompat => {
795 "derive helper attribute"
796 }
797 }
798 }
799
800 pub fn article(self) -> &'static str {
803 "a"
804 }
805
806 pub fn is_used(self) -> bool {
808 match self {
809 NonMacroAttrKind::Tool
810 | NonMacroAttrKind::DeriveHelper
811 | NonMacroAttrKind::DeriveHelperCompat => true,
812 NonMacroAttrKind::Builtin(..) => false,
813 }
814 }
815}
816
817impl<Id> Res<Id> {
818 pub fn def_id(&self) -> DefId
820 where
821 Id: Debug,
822 {
823 self.opt_def_id().unwrap_or_else(|| panic!("attempted .def_id() on invalid res: {self:?}"))
824 }
825
826 pub fn opt_def_id(&self) -> Option<DefId> {
828 match *self {
829 Res::Def(_, id) => Some(id),
830
831 Res::Local(..)
832 | Res::PrimTy(..)
833 | Res::SelfTyParam { .. }
834 | Res::SelfTyAlias { .. }
835 | Res::SelfCtor(..)
836 | Res::ToolMod
837 | Res::NonMacroAttr(..)
838 | Res::Err => None,
839 }
840 }
841
842 pub fn mod_def_id(&self) -> Option<DefId> {
844 match *self {
845 Res::Def(DefKind::Mod, id) => Some(id),
846 _ => None,
847 }
848 }
849
850 #[inline]
852 pub fn module_like_def_id(&self) -> Option<DefId> {
853 match self {
854 Res::Def(def_kind, def_id) if def_kind.is_module_like() => Some(*def_id),
855 _ => None,
856 }
857 }
858
859 pub fn descr(&self) -> &'static str {
861 match *self {
862 Res::Def(kind, def_id) => kind.descr(def_id),
863 Res::SelfCtor(..) => "self constructor",
864 Res::PrimTy(..) => "builtin type",
865 Res::Local(..) => "local variable",
866 Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } => "self type",
867 Res::ToolMod => "tool module",
868 Res::NonMacroAttr(attr_kind) => attr_kind.descr(),
869 Res::Err => "unresolved item",
870 }
871 }
872
873 pub fn article(&self) -> &'static str {
875 match *self {
876 Res::Def(kind, _) => kind.article(),
877 Res::NonMacroAttr(kind) => kind.article(),
878 Res::Err => "an",
879 _ => "a",
880 }
881 }
882
883 pub fn map_id<R>(self, mut map: impl FnMut(Id) -> R) -> Res<R> {
884 match self {
885 Res::Def(kind, id) => Res::Def(kind, id),
886 Res::SelfCtor(id) => Res::SelfCtor(id),
887 Res::PrimTy(id) => Res::PrimTy(id),
888 Res::Local(id) => Res::Local(map(id)),
889 Res::SelfTyParam { trait_ } => Res::SelfTyParam { trait_ },
890 Res::SelfTyAlias { alias_to, is_trait_impl } => {
891 Res::SelfTyAlias { alias_to, is_trait_impl }
892 }
893 Res::ToolMod => Res::ToolMod,
894 Res::NonMacroAttr(attr_kind) => Res::NonMacroAttr(attr_kind),
895 Res::Err => Res::Err,
896 }
897 }
898
899 pub fn apply_id<R, E>(self, mut map: impl FnMut(Id) -> Result<R, E>) -> Result<Res<R>, E> {
900 Ok(match self {
901 Res::Def(kind, id) => Res::Def(kind, id),
902 Res::SelfCtor(id) => Res::SelfCtor(id),
903 Res::PrimTy(id) => Res::PrimTy(id),
904 Res::Local(id) => Res::Local(map(id)?),
905 Res::SelfTyParam { trait_ } => Res::SelfTyParam { trait_ },
906 Res::SelfTyAlias { alias_to, is_trait_impl } => {
907 Res::SelfTyAlias { alias_to, is_trait_impl }
908 }
909 Res::ToolMod => Res::ToolMod,
910 Res::NonMacroAttr(attr_kind) => Res::NonMacroAttr(attr_kind),
911 Res::Err => Res::Err,
912 })
913 }
914
915 #[track_caller]
916 pub fn expect_non_local<OtherId>(self) -> Res<OtherId> {
917 self.map_id(
918 #[track_caller]
919 |_| panic!("unexpected `Res::Local`"),
920 )
921 }
922
923 pub fn macro_kinds(self) -> Option<MacroKinds> {
924 match self {
925 Res::Def(DefKind::Macro(kinds), _) => Some(kinds),
926 Res::NonMacroAttr(..) => Some(MacroKinds::ATTR),
927 _ => None,
928 }
929 }
930
931 pub fn ns(&self) -> Option<Namespace> {
933 match self {
934 Res::Def(kind, ..) => kind.ns(),
935 Res::PrimTy(..) | Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } | Res::ToolMod => {
936 Some(Namespace::TypeNS)
937 }
938 Res::SelfCtor(..) | Res::Local(..) => Some(Namespace::ValueNS),
939 Res::NonMacroAttr(..) => Some(Namespace::MacroNS),
940 Res::Err => None,
941 }
942 }
943
944 pub fn matches_ns(&self, ns: Namespace) -> bool {
946 self.ns().is_none_or(|actual_ns| actual_ns == ns)
947 }
948
949 pub fn expected_in_tuple_struct_pat(&self) -> bool {
951 matches!(self, Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) | Res::SelfCtor(..))
952 }
953
954 pub fn expected_in_unit_struct_pat(&self) -> bool {
956 matches!(self, Res::Def(DefKind::Ctor(_, CtorKind::Const), _) | Res::SelfCtor(..))
957 }
958}
959
960#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
962pub enum LifetimeRes {
963 Param {
965 param: LocalDefId,
967 binder: NodeId,
975 },
976 Fresh {
978 param: NodeId,
982 binder: NodeId,
984 kind: hir::MissingLifetimeKind,
986 },
987 Infer,
990 Static,
992 Error,
994 ElidedAnchor { start: NodeId, end: NodeId },
996}
997
998pub type DocLinkResMap = UnordMap<(Symbol, Namespace), Option<Res<NodeId>>>;