@@ -181,11 +181,6 @@ enum ResolutionFailure<'a> {
181
181
/// In `[std::io::Error::x]`, `x` would be unresolved.
182
182
unresolved : Cow < ' a , str > ,
183
183
} ,
184
- /// Used to communicate that this should be ignored, but shouldn't be reported to the user.
185
- ///
186
- /// This happens when there is no disambiguator and one of the namespaces
187
- /// failed to resolve.
188
- Dummy ,
189
184
}
190
185
191
186
#[ derive( Clone , Copy , Debug ) ]
@@ -405,35 +400,22 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
405
400
let ty_res = self . resolve_path ( & path, TypeNS , item_id, module_id) . ok_or_else ( no_res) ?;
406
401
407
402
match ty_res {
408
- Res :: Def ( DefKind :: Enum , did) => {
409
- if tcx
410
- . inherent_impls ( did)
411
- . iter ( )
412
- . flat_map ( |imp| tcx. associated_items ( * imp) . in_definition_order ( ) )
413
- . any ( |item| item. name == variant_name)
414
- {
415
- // This is just to let `fold_item` know that this shouldn't be considered;
416
- // it's a bug for the error to make it to the user
417
- return Err ( ResolutionFailure :: Dummy . into ( ) ) ;
418
- }
419
- match tcx. type_of ( did) . kind ( ) {
420
- ty:: Adt ( def, _) if def. is_enum ( ) => {
421
- if let Some ( field) = def. all_fields ( ) . find ( |f| f. name == variant_field_name)
422
- {
423
- Ok ( ( ty_res, Some ( ItemFragment ( FragmentKind :: VariantField , field. did ) ) ) )
424
- } else {
425
- Err ( ResolutionFailure :: NotResolved {
426
- item_id,
427
- module_id,
428
- partial_res : Some ( Res :: Def ( DefKind :: Enum , def. did ( ) ) ) ,
429
- unresolved : variant_field_name. to_string ( ) . into ( ) ,
430
- }
431
- . into ( ) )
403
+ Res :: Def ( DefKind :: Enum , did) => match tcx. type_of ( did) . kind ( ) {
404
+ ty:: Adt ( def, _) if def. is_enum ( ) => {
405
+ if let Some ( field) = def. all_fields ( ) . find ( |f| f. name == variant_field_name) {
406
+ Ok ( ( ty_res, Some ( ItemFragment ( FragmentKind :: VariantField , field. did ) ) ) )
407
+ } else {
408
+ Err ( ResolutionFailure :: NotResolved {
409
+ item_id,
410
+ module_id,
411
+ partial_res : Some ( Res :: Def ( DefKind :: Enum , def. did ( ) ) ) ,
412
+ unresolved : variant_field_name. to_string ( ) . into ( ) ,
432
413
}
414
+ . into ( ) )
433
415
}
434
- _ => unreachable ! ( ) ,
435
416
}
436
- }
417
+ _ => unreachable ! ( ) ,
418
+ } ,
437
419
_ => Err ( ResolutionFailure :: NotResolved {
438
420
item_id,
439
421
module_id,
@@ -1535,7 +1517,7 @@ impl LinkCollector<'_, '_> {
1535
1517
}
1536
1518
None => {
1537
1519
// Try everything!
1538
- let mut candidates = PerNS {
1520
+ let candidates = PerNS {
1539
1521
macro_ns : self
1540
1522
. resolve_macro ( path_str, item_id, base_node)
1541
1523
. map ( |res| ( res, extra_fragment. clone ( ) . map ( UrlFragment :: UserWritten ) ) ) ,
@@ -1611,11 +1593,13 @@ impl LinkCollector<'_, '_> {
1611
1593
} else if len == 2 && is_derive_trait_collision ( & candidates) {
1612
1594
Some ( candidates. type_ns . unwrap ( ) )
1613
1595
} else {
1614
- if is_derive_trait_collision ( & candidates) {
1615
- candidates. macro_ns = Err ( ResolutionFailure :: Dummy ) ;
1616
- }
1596
+ let ignore_macro = is_derive_trait_collision ( & candidates) ;
1617
1597
// If we're reporting an ambiguity, don't mention the namespaces that failed
1618
- let candidates = candidates. map ( |candidate| candidate. ok ( ) . map ( |( res, _) | res) ) ;
1598
+ let mut candidates =
1599
+ candidates. map ( |candidate| candidate. ok ( ) . map ( |( res, _) | res) ) ;
1600
+ if ignore_macro {
1601
+ candidates. macro_ns = None ;
1602
+ }
1619
1603
ambiguity_error ( self . cx , diag, path_str, candidates. present_items ( ) . collect ( ) ) ;
1620
1604
None
1621
1605
}
@@ -2092,7 +2076,6 @@ fn resolution_failure(
2092
2076
}
2093
2077
let note = match failure {
2094
2078
ResolutionFailure :: NotResolved { .. } => unreachable ! ( "handled above" ) ,
2095
- ResolutionFailure :: Dummy => continue ,
2096
2079
ResolutionFailure :: WrongNamespace { res, expected_ns } => {
2097
2080
suggest_disambiguator ( res, diag, path_str, diag_info. ori_link , sp) ;
2098
2081
0 commit comments