@@ -273,13 +273,13 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
273
273
return handle_variant ( cx, res, extra_fragment) ;
274
274
}
275
275
// Not a trait item; just return what we found.
276
- Res :: PrimTy ( .. ) => {
276
+ Res :: PrimTy ( ty ) => {
277
277
if extra_fragment. is_some ( ) {
278
278
return Err ( ErrorKind :: AnchorFailure (
279
279
AnchorFailure :: RustdocAnchorConflict ( res) ,
280
280
) ) ;
281
281
}
282
- return Ok ( ( res, Some ( path_str . to_owned ( ) ) ) ) ;
282
+ return Ok ( ( res, Some ( ty . name_str ( ) . to_owned ( ) ) ) ) ;
283
283
}
284
284
Res :: Def ( DefKind :: Mod , _) => {
285
285
return Ok ( ( res, extra_fragment. clone ( ) ) ) ;
@@ -292,6 +292,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
292
292
if value != ( ns == ValueNS ) {
293
293
return Err ( ResolutionFailure :: WrongNamespace ( res, ns) . into ( ) ) ;
294
294
}
295
+ // FIXME: why is this necessary?
295
296
} else if let Some ( ( path, prim) ) = is_primitive ( path_str, ns) {
296
297
if extra_fragment. is_some ( ) {
297
298
return Err ( ErrorKind :: AnchorFailure ( AnchorFailure :: RustdocAnchorConflict ( prim) ) ) ;
@@ -1008,12 +1009,12 @@ impl LinkCollector<'_, '_> {
1008
1009
suggest_disambiguator ( resolved, diag, path_str, dox, sp, & link_range) ;
1009
1010
} ) ;
1010
1011
} ;
1011
- if let Res :: PrimTy ( _ ) = res {
1012
+ if let Res :: PrimTy ( ty ) = res {
1012
1013
match disambiguator {
1013
1014
Some ( Disambiguator :: Primitive | Disambiguator :: Namespace ( _) ) | None => {
1014
1015
item. attrs . links . push ( ItemLink {
1015
1016
link : ori_link,
1016
- link_text : path_str . to_owned ( ) ,
1017
+ link_text,
1017
1018
did : None ,
1018
1019
fragment,
1019
1020
} ) ;
@@ -1488,6 +1489,10 @@ fn resolution_failure(
1488
1489
link_range : Option < Range < usize > > ,
1489
1490
kinds : SmallVec < [ ResolutionFailure < ' _ > ; 3 ] > ,
1490
1491
) {
1492
+ let has_primitive = kinds. iter ( ) . any ( |err|
1493
+ matches ! ( err, ResolutionFailure :: NoPrimitiveAssocItem { ..} | ResolutionFailure :: NoPrimitiveImpl ( _, _) )
1494
+ ) ;
1495
+
1491
1496
report_diagnostic (
1492
1497
collector. cx ,
1493
1498
& format ! ( "unresolved link to `{}`" , path_str) ,
@@ -1528,6 +1533,7 @@ fn resolution_failure(
1528
1533
1529
1534
let module_id = * module_id;
1530
1535
// FIXME(jynelson): this might conflict with my `Self` fix in #76467
1536
+ // FIXME: use itertools `collect_tuple` instead
1531
1537
fn split ( path : & str ) -> Option < ( & str , & str ) > {
1532
1538
let mut splitter = path. rsplitn ( 2 , "::" ) ;
1533
1539
splitter. next ( ) . and_then ( |right| splitter. next ( ) . map ( |left| ( left, right) ) )
@@ -1567,7 +1573,6 @@ fn resolution_failure(
1567
1573
} ;
1568
1574
// See if this was a module: `[path]` or `[std::io::nope]`
1569
1575
if let Some ( module) = last_found_module {
1570
- // NOTE: uses an explicit `continue` so the `note:` will come before the `help:`
1571
1576
let module_name = collector. cx . tcx . item_name ( module) ;
1572
1577
let note = format ! (
1573
1578
"the module `{}` contains no item named `{}`" ,
@@ -1595,7 +1600,10 @@ fn resolution_failure(
1595
1600
diagnostic_name = collector. cx . tcx . item_name ( def_id) . as_str ( ) ;
1596
1601
( Some ( kind) , & * diagnostic_name)
1597
1602
}
1598
- Res :: PrimTy ( _) => ( None , name) ,
1603
+ Res :: PrimTy ( _) => {
1604
+ assert ! ( has_primitive) ;
1605
+ continue ;
1606
+ }
1599
1607
_ => unreachable ! ( "only ADTs and primitives are in scope at module level" ) ,
1600
1608
} ;
1601
1609
let path_description = if let Some ( kind) = kind {
0 commit comments