@@ -273,13 +273,13 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
273273 return handle_variant ( cx, res, extra_fragment) ;
274274 }
275275 // Not a trait item; just return what we found.
276- Res :: PrimTy ( .. ) => {
276+ Res :: PrimTy ( ty ) => {
277277 if extra_fragment. is_some ( ) {
278278 return Err ( ErrorKind :: AnchorFailure (
279279 AnchorFailure :: RustdocAnchorConflict ( res) ,
280280 ) ) ;
281281 }
282- return Ok ( ( res, Some ( path_str . to_owned ( ) ) ) ) ;
282+ return Ok ( ( res, Some ( ty . name_str ( ) . to_owned ( ) ) ) ) ;
283283 }
284284 Res :: Def ( DefKind :: Mod , _) => {
285285 return Ok ( ( res, extra_fragment. clone ( ) ) ) ;
@@ -292,6 +292,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
292292 if value != ( ns == ValueNS ) {
293293 return Err ( ResolutionFailure :: WrongNamespace ( res, ns) . into ( ) ) ;
294294 }
295+ // FIXME: why is this necessary?
295296 } else if let Some ( ( path, prim) ) = is_primitive ( path_str, ns) {
296297 if extra_fragment. is_some ( ) {
297298 return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: RustdocAnchorConflict ( prim) ) ) ;
@@ -1008,12 +1009,12 @@ impl LinkCollector<'_, '_> {
10081009 suggest_disambiguator ( resolved, diag, path_str, dox, sp, & link_range) ;
10091010 } ) ;
10101011 } ;
1011- if let Res :: PrimTy ( _ ) = res {
1012+ if let Res :: PrimTy ( ty ) = res {
10121013 match disambiguator {
10131014 Some ( Disambiguator :: Primitive | Disambiguator :: Namespace ( _) ) | None => {
10141015 item. attrs . links . push ( ItemLink {
10151016 link : ori_link,
1016- link_text : path_str . to_owned ( ) ,
1017+ link_text,
10171018 did : None ,
10181019 fragment,
10191020 } ) ;
@@ -1488,6 +1489,10 @@ fn resolution_failure(
14881489 link_range : Option < Range < usize > > ,
14891490 kinds : SmallVec < [ ResolutionFailure < ' _ > ; 3 ] > ,
14901491) {
1492+ let has_primitive = kinds. iter ( ) . any ( |err|
1493+ matches ! ( err, ResolutionFailure :: NoPrimitiveAssocItem { ..} | ResolutionFailure :: NoPrimitiveImpl ( _, _) )
1494+ ) ;
1495+
14911496 report_diagnostic (
14921497 collector. cx ,
14931498 & format ! ( "unresolved link to `{}`" , path_str) ,
@@ -1528,6 +1533,7 @@ fn resolution_failure(
15281533
15291534 let module_id = * module_id;
15301535 // FIXME(jynelson): this might conflict with my `Self` fix in #76467
1536+ // FIXME: use itertools `collect_tuple` instead
15311537 fn split ( path : & str ) -> Option < ( & str , & str ) > {
15321538 let mut splitter = path. rsplitn ( 2 , "::" ) ;
15331539 splitter. next ( ) . and_then ( |right| splitter. next ( ) . map ( |left| ( left, right) ) )
@@ -1567,7 +1573,6 @@ fn resolution_failure(
15671573 } ;
15681574 // See if this was a module: `[path]` or `[std::io::nope]`
15691575 if let Some ( module) = last_found_module {
1570- // NOTE: uses an explicit `continue` so the `note:` will come before the `help:`
15711576 let module_name = collector. cx . tcx . item_name ( module) ;
15721577 let note = format ! (
15731578 "the module `{}` contains no item named `{}`" ,
@@ -1595,7 +1600,10 @@ fn resolution_failure(
15951600 diagnostic_name = collector. cx . tcx . item_name ( def_id) . as_str ( ) ;
15961601 ( Some ( kind) , & * diagnostic_name)
15971602 }
1598- Res :: PrimTy ( _) => ( None , name) ,
1603+ Res :: PrimTy ( _) => {
1604+ assert ! ( has_primitive) ;
1605+ continue ;
1606+ }
15991607 _ => unreachable ! ( "only ADTs and primitives are in scope at module level" ) ,
16001608 } ;
16011609 let path_description = if let Some ( kind) = kind {
0 commit comments