@@ -222,11 +222,11 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
222
222
disambiguator,
223
223
None | Some ( Disambiguator :: Namespace ( Namespace :: TypeNS ) )
224
224
) {
225
- if let Some ( prim) = is_primitive ( path_str, ns) {
225
+ if let Some ( ( path , prim) ) = is_primitive ( path_str, ns) {
226
226
if extra_fragment. is_some ( ) {
227
227
return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: Primitive ) ) ;
228
228
}
229
- return Ok ( ( prim, Some ( path_str . to_owned ( ) ) ) ) ;
229
+ return Ok ( ( prim, Some ( path . to_owned ( ) ) ) ) ;
230
230
}
231
231
}
232
232
return Ok ( ( res, extra_fragment. clone ( ) ) ) ;
@@ -239,11 +239,11 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
239
239
if value != ( ns == ValueNS ) {
240
240
return Err ( ErrorKind :: ResolutionFailure ) ;
241
241
}
242
- } else if let Some ( prim) = is_primitive ( path_str, ns) {
242
+ } else if let Some ( ( path , prim) ) = is_primitive ( path_str, ns) {
243
243
if extra_fragment. is_some ( ) {
244
244
return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: Primitive ) ) ;
245
245
}
246
- return Ok ( ( prim, Some ( path_str . to_owned ( ) ) ) ) ;
246
+ return Ok ( ( prim, Some ( path . to_owned ( ) ) ) ) ;
247
247
} else {
248
248
// If resolution failed, it may still be a method
249
249
// because methods are not handled by the resolver
@@ -269,7 +269,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
269
269
} )
270
270
. ok_or ( ErrorKind :: ResolutionFailure ) ?;
271
271
272
- if let Some ( prim) = is_primitive ( & path, TypeNS ) {
272
+ if let Some ( ( path , prim) ) = is_primitive ( & path, TypeNS ) {
273
273
let did = primitive_impl ( cx, & path) . ok_or ( ErrorKind :: ResolutionFailure ) ?;
274
274
return cx
275
275
. tcx
@@ -1220,11 +1220,22 @@ const PRIMITIVES: &[(&str, Res)] = &[
1220
1220
( "f64" , Res :: PrimTy ( hir:: PrimTy :: Float ( rustc_ast:: FloatTy :: F64 ) ) ) ,
1221
1221
( "str" , Res :: PrimTy ( hir:: PrimTy :: Str ) ) ,
1222
1222
( "bool" , Res :: PrimTy ( hir:: PrimTy :: Bool ) ) ,
1223
+ ( "true" , Res :: PrimTy ( hir:: PrimTy :: Bool ) ) ,
1224
+ ( "false" , Res :: PrimTy ( hir:: PrimTy :: Bool ) ) ,
1223
1225
( "char" , Res :: PrimTy ( hir:: PrimTy :: Char ) ) ,
1224
1226
] ;
1225
1227
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
+ }
1228
1239
}
1229
1240
1230
1241
fn primitive_impl ( cx : & DocContext < ' _ > , path_str : & str ) -> Option < DefId > {
0 commit comments