@@ -28,10 +28,12 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
28
28
use rustc_span:: { self , Pos } ;
29
29
use rustc_typeck:: hir_ty_to_ty;
30
30
31
+ use std:: cell:: RefCell ;
31
32
use std:: collections:: hash_map:: Entry ;
32
33
use std:: default:: Default ;
33
34
use std:: hash:: Hash ;
34
35
use std:: rc:: Rc ;
36
+ use std:: sync:: Arc ;
35
37
use std:: { mem, vec} ;
36
38
37
39
use crate :: core:: { self , DocContext , ImplTraitParam } ;
@@ -48,6 +50,13 @@ pub use self::types::Type::*;
48
50
pub use self :: types:: Visibility :: { Inherited , Public } ;
49
51
pub use self :: types:: * ;
50
52
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
+
51
60
const FN_OUTPUT_NAME : & str = "Output" ;
52
61
53
62
pub trait Clean < T > {
@@ -126,7 +135,7 @@ impl Clean<ExternalCrate> for CrateNum {
126
135
}
127
136
None
128
137
} ;
129
- let primitives = if root. is_local ( ) {
138
+ let primitives: Vec < ( DefId , PrimitiveType , Attributes ) > = if root. is_local ( ) {
130
139
cx. tcx
131
140
. hir ( )
132
141
. krate ( )
@@ -161,6 +170,13 @@ impl Clean<ExternalCrate> for CrateNum {
161
170
. filter_map ( as_primitive)
162
171
. collect ( )
163
172
} ;
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
+ } ) ;
164
180
165
181
let as_keyword = |res : Res | {
166
182
if let Res :: Def ( DefKind :: Mod , def_id) = res {
0 commit comments