@@ -45,20 +45,25 @@ macro_rules! language_item_table {
4545 /// A representation of all the valid language items in Rust.
4646 #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash , Encodable , Decodable ) ]
4747 pub enum LangItem {
48- $( $variant, ) *
48+ $(
49+ #[ doc = concat!( "The `" , stringify!( $name) , "` lang item." ) ]
50+ $variant,
51+ ) *
4952 }
5053 }
5154
5255 impl LangItem {
5356 /// 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"]`.
5659 pub fn name( self ) -> Symbol {
5760 match self {
5861 $( LangItem :: $variant => $name, ) *
5962 }
6063 }
6164
65+ /// The [group](LangItemGroup) that this lang item belongs to,
66+ /// or `None` if it doesn't belong to a group.
6267 pub fn group( self ) -> Option <LangItemGroup > {
6368 use LangItemGroup :: * ;
6469 match self {
@@ -67,15 +72,16 @@ macro_rules! language_item_table {
6772 }
6873 }
6974
75+ /// All of the language items in the current crate, defined or not.
7076 #[ derive( HashStable_Generic , Debug ) ]
7177 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`] .
7480 pub items: Vec <Option <DefId >>,
7581 /// Lang items that were not found during collection.
7682 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.
7985 pub groups: [ Vec <DefId >; NUM_GROUPS ] ,
8086 }
8187
@@ -103,13 +109,13 @@ macro_rules! language_item_table {
103109 self . items[ it as usize ] . ok_or_else( || format!( "requires `{}` lang_item" , it. name( ) ) )
104110 }
105111
112+ /// Returns the [`DefId`]s of all lang items in a group.
106113 pub fn group( & self , group: LangItemGroup ) -> & [ DefId ] {
107114 self . groups[ group as usize ] . as_ref( )
108115 }
109116
110117 $(
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." ) ]
113119 #[ allow( dead_code) ]
114120 pub fn $method( & self ) -> Option <DefId > {
115121 self . items[ LangItem :: $variant as usize ]
@@ -140,7 +146,7 @@ impl<CTX> HashStable<CTX> for LangItem {
140146///
141147/// About the `check_name` argument: passing in a `Session` would be simpler,
142148/// 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
144150/// use a closure instead.
145151pub fn extract < ' a , F > ( check_name : F , attrs : & ' a [ ast:: Attribute ] ) -> Option < ( Symbol , Span ) >
146152where
0 commit comments