@@ -45,20 +45,25 @@ macro_rules! language_item_table {
45
45
/// A representation of all the valid language items in Rust.
46
46
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash , Encodable , Decodable ) ]
47
47
pub enum LangItem {
48
- $( $variant, ) *
48
+ $(
49
+ #[ doc = concat!( "The `" , stringify!( $name) , "` lang item." ) ]
50
+ $variant,
51
+ ) *
49
52
}
50
53
}
51
54
52
55
impl LangItem {
53
56
/// Returns the `name` symbol in `#[lang = "$name"]`.
54
- /// For example, `LangItem::EqTraitLangItem`,
55
- /// that is `#[lang = "eq"]` would result in `sym::eq `.
57
+ /// For example, [ `LangItem::PartialEq`]`.name()`
58
+ /// would result in [`sym::eq`] since it is `#[lang = "eq"]`.
56
59
pub fn name( self ) -> Symbol {
57
60
match self {
58
61
$( LangItem :: $variant => $name, ) *
59
62
}
60
63
}
61
64
65
+ /// The [group](LangItemGroup) that this lang item belongs to,
66
+ /// or `None` if it doesn't belong to a group.
62
67
pub fn group( self ) -> Option <LangItemGroup > {
63
68
use LangItemGroup :: * ;
64
69
match self {
@@ -67,15 +72,16 @@ macro_rules! language_item_table {
67
72
}
68
73
}
69
74
75
+ /// All of the language items in the current crate, defined or not.
70
76
#[ derive( HashStable_Generic , Debug ) ]
71
77
pub struct LanguageItems {
72
- /// Mappings from lang items to their possibly found `DefId`s.
73
- /// The index corresponds to the order in `LangItem`.
78
+ /// Mappings from lang items to their possibly found [ `DefId`] s.
79
+ /// The index corresponds to the order in [ `LangItem`] .
74
80
pub items: Vec <Option <DefId >>,
75
81
/// Lang items that were not found during collection.
76
82
pub missing: Vec <LangItem >,
77
- /// Mapping from `LangItemGroup` discriminants to all
78
- /// `DefId`s of lang items in that group.
83
+ /// Mapping from [ `LangItemGroup`] discriminants to all
84
+ /// [ `DefId`] s of lang items in that group.
79
85
pub groups: [ Vec <DefId >; NUM_GROUPS ] ,
80
86
}
81
87
@@ -103,13 +109,13 @@ macro_rules! language_item_table {
103
109
self . items[ it as usize ] . ok_or_else( || format!( "requires `{}` lang_item" , it. name( ) ) )
104
110
}
105
111
112
+ /// Returns the [`DefId`]s of all lang items in a group.
106
113
pub fn group( & self , group: LangItemGroup ) -> & [ DefId ] {
107
114
self . groups[ group as usize ] . as_ref( )
108
115
}
109
116
110
117
$(
111
- /// Returns the corresponding `DefId` for the lang item if it
112
- /// exists.
118
+ #[ doc = concat!( "Returns the [`DefId`] of the `" , stringify!( $name) , "` lang item if it is defined." ) ]
113
119
#[ allow( dead_code) ]
114
120
pub fn $method( & self ) -> Option <DefId > {
115
121
self . items[ LangItem :: $variant as usize ]
@@ -140,7 +146,7 @@ impl<CTX> HashStable<CTX> for LangItem {
140
146
///
141
147
/// About the `check_name` argument: passing in a `Session` would be simpler,
142
148
/// because then we could call `Session::check_name` directly. But we want to
143
- /// avoid the need for `librustc_hir ` to depend on `librustc_session `, so we
149
+ /// avoid the need for `rustc_hir ` to depend on `rustc_session `, so we
144
150
/// use a closure instead.
145
151
pub fn extract < ' a , F > ( check_name : F , attrs : & ' a [ ast:: Attribute ] ) -> Option < ( Symbol , Span ) >
146
152
where
0 commit comments