@@ -60,13 +60,6 @@ impl<'a> From<ResolutionFailure<'a>> for ErrorKind<'a> {
6060
6161#[ derive( Debug ) ]
6262enum 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 } ,
7063 /// This resolved, but with the wrong namespace.
7164 /// `Namespace` is the expected namespace (as opposed to the actual).
7265 WrongNamespace ( Res , Namespace ) ,
@@ -326,8 +319,12 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
326319 } ) ?;
327320
328321 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+ } ) ?;
331328 for & impl_ in impls {
332329 let link = cx
333330 . tcx
@@ -354,10 +351,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
354351 item_name,
355352 ns. descr( )
356353 ) ;
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 ( ) ,
361358 }
362359 . into ( ) ) ;
363360 }
@@ -1009,7 +1006,7 @@ impl LinkCollector<'_, '_> {
10091006 suggest_disambiguator ( resolved, diag, path_str, dox, sp, & link_range) ;
10101007 } ) ;
10111008 } ;
1012- if let Res :: PrimTy ( ty ) = res {
1009+ if let Res :: PrimTy ( .. ) = res {
10131010 match disambiguator {
10141011 Some ( Disambiguator :: Primitive | Disambiguator :: Namespace ( _) ) | None => {
10151012 item. attrs . links . push ( ItemLink {
@@ -1489,10 +1486,6 @@ fn resolution_failure(
14891486 link_range : Option < Range < usize > > ,
14901487 kinds : SmallVec < [ ResolutionFailure < ' _ > ; 3 ] > ,
14911488) {
1492- let has_primitive = kinds. iter ( ) . any ( |err|
1493- matches ! ( err, ResolutionFailure :: NoPrimitiveAssocItem { ..} | ResolutionFailure :: NoPrimitiveImpl ( _, _) )
1494- ) ;
1495-
14961489 report_diagnostic (
14971490 collector. cx ,
14981491 & format ! ( "unresolved link to `{}`" , path_str) ,
@@ -1533,7 +1526,7 @@ fn resolution_failure(
15331526
15341527 let module_id = * module_id;
15351528 // 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?
15371530 fn split ( path : & str ) -> Option < ( & str , & str ) > {
15381531 let mut splitter = path. rsplitn ( 2 , "::" ) ;
15391532 splitter. next ( ) . and_then ( |right| splitter. next ( ) . map ( |left| ( left, right) ) )
@@ -1600,10 +1593,7 @@ fn resolution_failure(
16001593 diagnostic_name = collector. cx . tcx . item_name ( def_id) . as_str ( ) ;
16011594 ( Some ( kind) , & * diagnostic_name)
16021595 }
1603- Res :: PrimTy ( _) => {
1604- assert ! ( has_primitive) ;
1605- continue ;
1606- }
1596+ Res :: PrimTy ( ty) => ( None , ty. name_str ( ) ) ,
16071597 _ => unreachable ! ( "only ADTs and primitives are in scope at module level" ) ,
16081598 } ;
16091599 let path_description = if let Some ( kind) = kind {
@@ -1640,7 +1630,7 @@ fn resolution_failure(
16401630 Impl | GlobalAsm => unreachable ! ( "not a path" ) ,
16411631 }
16421632 } else {
1643- res . descr ( )
1633+ "associated item"
16441634 } ;
16451635 let note = format ! (
16461636 "the {} `{}` has no {} named `{}`" ,
@@ -1683,16 +1673,6 @@ fn resolution_failure(
16831673 diag. level = rustc_errors:: Level :: Bug ;
16841674 "all intra doc links should have a parent item" . to_owned ( )
16851675 }
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- }
16961676 } ;
16971677 if let Some ( span) = sp {
16981678 diag. span_label ( span, & note) ;
0 commit comments