@@ -28,10 +28,12 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
2828use rustc_span:: { self , Pos } ;
2929use rustc_typeck:: hir_ty_to_ty;
3030
31+ use std:: cell:: RefCell ;
3132use std:: collections:: hash_map:: Entry ;
3233use std:: default:: Default ;
3334use std:: hash:: Hash ;
3435use std:: rc:: Rc ;
36+ use std:: sync:: Arc ;
3537use std:: { mem, vec} ;
3638
3739use crate :: core:: { self , DocContext , ImplTraitParam } ;
@@ -48,6 +50,13 @@ pub use self::types::Type::*;
4850pub use self :: types:: Visibility :: { Inherited , Public } ;
4951pub use self :: types:: * ;
5052
53+ thread_local ! ( static PRIMITIVES : RefCell <Arc <FxHashMap <PrimitiveType , DefId >>> =
54+ Default :: default ( ) ) ;
55+
56+ crate fn primitives ( ) -> Arc < FxHashMap < PrimitiveType , DefId > > {
57+ PRIMITIVES . with ( |c| c. borrow ( ) . clone ( ) )
58+ }
59+
5160const FN_OUTPUT_NAME : & str = "Output" ;
5261
5362pub trait Clean < T > {
@@ -126,7 +135,7 @@ impl Clean<ExternalCrate> for CrateNum {
126135 }
127136 None
128137 } ;
129- let primitives = if root. is_local ( ) {
138+ let primitives: Vec < ( DefId , PrimitiveType , Attributes ) > = if root. is_local ( ) {
130139 cx. tcx
131140 . hir ( )
132141 . krate ( )
@@ -161,6 +170,13 @@ impl Clean<ExternalCrate> for CrateNum {
161170 . filter_map ( as_primitive)
162171 . collect ( )
163172 } ;
173+ PRIMITIVES . with ( |v| {
174+ let mut tmp = v. borrow_mut ( ) ;
175+ let stored_primitives = Arc :: make_mut ( & mut * tmp) ;
176+ for ( prim, did) in primitives. iter ( ) . map ( |x| ( x. 1 , x. 0 ) ) {
177+ stored_primitives. insert ( prim, did) ;
178+ }
179+ } ) ;
164180
165181 let as_keyword = |res : Res | {
166182 if let Res :: Def ( DefKind :: Mod , def_id) = res {
0 commit comments