@@ -222,11 +222,11 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
222222 disambiguator,
223223 None | Some ( Disambiguator :: Namespace ( Namespace :: TypeNS ) )
224224 ) {
225- if let Some ( prim) = is_primitive ( path_str, ns) {
225+ if let Some ( ( path , prim) ) = is_primitive ( path_str, ns) {
226226 if extra_fragment. is_some ( ) {
227227 return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: Primitive ) ) ;
228228 }
229- return Ok ( ( prim, Some ( path_str . to_owned ( ) ) ) ) ;
229+ return Ok ( ( prim, Some ( path . to_owned ( ) ) ) ) ;
230230 }
231231 }
232232 return Ok ( ( res, extra_fragment. clone ( ) ) ) ;
@@ -239,11 +239,11 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
239239 if value != ( ns == ValueNS ) {
240240 return Err ( ErrorKind :: ResolutionFailure ) ;
241241 }
242- } else if let Some ( prim) = is_primitive ( path_str, ns) {
242+ } else if let Some ( ( path , prim) ) = is_primitive ( path_str, ns) {
243243 if extra_fragment. is_some ( ) {
244244 return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: Primitive ) ) ;
245245 }
246- return Ok ( ( prim, Some ( path_str . to_owned ( ) ) ) ) ;
246+ return Ok ( ( prim, Some ( path . to_owned ( ) ) ) ) ;
247247 } else {
248248 // If resolution failed, it may still be a method
249249 // because methods are not handled by the resolver
@@ -269,7 +269,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
269269 } )
270270 . ok_or ( ErrorKind :: ResolutionFailure ) ?;
271271
272- if let Some ( prim) = is_primitive ( & path, TypeNS ) {
272+ if let Some ( ( path , prim) ) = is_primitive ( & path, TypeNS ) {
273273 let did = primitive_impl ( cx, & path) . ok_or ( ErrorKind :: ResolutionFailure ) ?;
274274 return cx
275275 . tcx
@@ -1220,11 +1220,22 @@ const PRIMITIVES: &[(&str, Res)] = &[
12201220 ( "f64" , Res :: PrimTy ( hir:: PrimTy :: Float ( rustc_ast:: FloatTy :: F64 ) ) ) ,
12211221 ( "str" , Res :: PrimTy ( hir:: PrimTy :: Str ) ) ,
12221222 ( "bool" , Res :: PrimTy ( hir:: PrimTy :: Bool ) ) ,
1223+ ( "true" , Res :: PrimTy ( hir:: PrimTy :: Bool ) ) ,
1224+ ( "false" , Res :: PrimTy ( hir:: PrimTy :: Bool ) ) ,
12231225 ( "char" , Res :: PrimTy ( hir:: PrimTy :: Char ) ) ,
12241226] ;
12251227
1226- fn is_primitive ( path_str : & str , ns : Namespace ) -> Option < Res > {
1227- if ns == TypeNS { PRIMITIVES . iter ( ) . find ( |x| x. 0 == path_str) . map ( |x| x. 1 ) } else { None }
1228+ fn is_primitive ( path_str : & str , ns : Namespace ) -> Option < ( & ' static str , Res ) > {
1229+ if ns == TypeNS {
1230+ PRIMITIVES
1231+ . iter ( )
1232+ . filter ( |x| x. 0 == path_str)
1233+ . copied ( )
1234+ . map ( |x| if x. 0 == "true" || x. 0 == "false" { ( "bool" , x. 1 ) } else { x } )
1235+ . next ( )
1236+ } else {
1237+ None
1238+ }
12281239}
12291240
12301241fn primitive_impl ( cx : & DocContext < ' _ > , path_str : & str ) -> Option < DefId > {
0 commit comments