@@ -60,13 +60,6 @@ impl<'a> From<ResolutionFailure<'a>> for ErrorKind<'a> {
60
60
61
61
#[ derive( Debug ) ]
62
62
enum ResolutionFailure < ' a > {
63
- /// this is a primitive type without an impls (no associated methods)
64
- /// when will this actually happen?
65
- /// the `Res` is the primitive it resolved to
66
- NoPrimitiveImpl ( Res , String ) ,
67
- /// `[u8::not_found]`
68
- /// the `Res` is the primitive it resolved to
69
- NoPrimitiveAssocItem { res : Res , prim_name : & ' a str , assoc_item : Symbol } ,
70
63
/// This resolved, but with the wrong namespace.
71
64
/// `Namespace` is the expected namespace (as opposed to the actual).
72
65
WrongNamespace ( Res , Namespace ) ,
@@ -326,8 +319,12 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
326
319
} ) ?;
327
320
328
321
if let Some ( ( path, prim) ) = is_primitive ( & path_root, TypeNS ) {
329
- let impls = primitive_impl ( cx, & path)
330
- . ok_or_else ( || ResolutionFailure :: NoPrimitiveImpl ( prim, path_root. into ( ) ) ) ?;
322
+ let impls =
323
+ primitive_impl ( cx, & path) . ok_or_else ( || ResolutionFailure :: NotResolved {
324
+ module_id,
325
+ partial_res : Some ( prim) ,
326
+ unresolved : item_str. into ( ) ,
327
+ } ) ?;
331
328
for & impl_ in impls {
332
329
let link = cx
333
330
. tcx
@@ -354,10 +351,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
354
351
item_name,
355
352
ns. descr( )
356
353
) ;
357
- return Err ( ResolutionFailure :: NoPrimitiveAssocItem {
358
- res : prim ,
359
- prim_name : path ,
360
- assoc_item : item_name ,
354
+ return Err ( ResolutionFailure :: NotResolved {
355
+ module_id ,
356
+ partial_res : Some ( prim ) ,
357
+ unresolved : item_str . into ( ) ,
361
358
}
362
359
. into ( ) ) ;
363
360
}
@@ -1009,7 +1006,7 @@ impl LinkCollector<'_, '_> {
1009
1006
suggest_disambiguator ( resolved, diag, path_str, dox, sp, & link_range) ;
1010
1007
} ) ;
1011
1008
} ;
1012
- if let Res :: PrimTy ( ty ) = res {
1009
+ if let Res :: PrimTy ( .. ) = res {
1013
1010
match disambiguator {
1014
1011
Some ( Disambiguator :: Primitive | Disambiguator :: Namespace ( _) ) | None => {
1015
1012
item. attrs . links . push ( ItemLink {
@@ -1489,10 +1486,6 @@ fn resolution_failure(
1489
1486
link_range : Option < Range < usize > > ,
1490
1487
kinds : SmallVec < [ ResolutionFailure < ' _ > ; 3 ] > ,
1491
1488
) {
1492
- let has_primitive = kinds. iter ( ) . any ( |err|
1493
- matches ! ( err, ResolutionFailure :: NoPrimitiveAssocItem { ..} | ResolutionFailure :: NoPrimitiveImpl ( _, _) )
1494
- ) ;
1495
-
1496
1489
report_diagnostic (
1497
1490
collector. cx ,
1498
1491
& format ! ( "unresolved link to `{}`" , path_str) ,
@@ -1533,7 +1526,7 @@ fn resolution_failure(
1533
1526
1534
1527
let module_id = * module_id;
1535
1528
// FIXME(jynelson): this might conflict with my `Self` fix in #76467
1536
- // FIXME: use itertools `collect_tuple` instead
1529
+ // FIXME: maybe use itertools `collect_tuple` instead?
1537
1530
fn split ( path : & str ) -> Option < ( & str , & str ) > {
1538
1531
let mut splitter = path. rsplitn ( 2 , "::" ) ;
1539
1532
splitter. next ( ) . and_then ( |right| splitter. next ( ) . map ( |left| ( left, right) ) )
@@ -1600,10 +1593,7 @@ fn resolution_failure(
1600
1593
diagnostic_name = collector. cx . tcx . item_name ( def_id) . as_str ( ) ;
1601
1594
( Some ( kind) , & * diagnostic_name)
1602
1595
}
1603
- Res :: PrimTy ( _) => {
1604
- assert ! ( has_primitive) ;
1605
- continue ;
1606
- }
1596
+ Res :: PrimTy ( ty) => ( None , ty. name_str ( ) ) ,
1607
1597
_ => unreachable ! ( "only ADTs and primitives are in scope at module level" ) ,
1608
1598
} ;
1609
1599
let path_description = if let Some ( kind) = kind {
@@ -1640,7 +1630,7 @@ fn resolution_failure(
1640
1630
Impl | GlobalAsm => unreachable ! ( "not a path" ) ,
1641
1631
}
1642
1632
} else {
1643
- res . descr ( )
1633
+ "associated item"
1644
1634
} ;
1645
1635
let note = format ! (
1646
1636
"the {} `{}` has no {} named `{}`" ,
@@ -1683,16 +1673,6 @@ fn resolution_failure(
1683
1673
diag. level = rustc_errors:: Level :: Bug ;
1684
1674
"all intra doc links should have a parent item" . to_owned ( )
1685
1675
}
1686
- ResolutionFailure :: NoPrimitiveImpl ( res, _) => format ! (
1687
- "this link partially resolves to {}, which does not have any associated items" ,
1688
- item( res) ,
1689
- ) ,
1690
- ResolutionFailure :: NoPrimitiveAssocItem { prim_name, assoc_item, .. } => {
1691
- format ! (
1692
- "the builtin type `{}` does not have an associated item named `{}`" ,
1693
- prim_name, assoc_item
1694
- )
1695
- }
1696
1676
} ;
1697
1677
if let Some ( span) = sp {
1698
1678
diag. span_label ( span, & note) ;
0 commit comments