@@ -60,7 +60,8 @@ use std::{cmp, fmt, iter, ptr};
60
60
use tracing:: debug;
61
61
62
62
use diagnostics:: { extend_span_to_previous_binding, find_span_of_binding_until_next_binding} ;
63
- use diagnostics:: { ImportSuggestion , LabelSuggestion , Suggestion } ;
63
+ use diagnostics:: { ImportSuggestion , LabelSuggestion } ;
64
+ pub use diagnostics:: Suggestion ;
64
65
use imports:: { Import , ImportKind , ImportResolver , NameResolution } ;
65
66
use late:: { HasGenericParams , PathSource , Rib , RibKind :: * } ;
66
67
use macros:: { MacroRulesBinding , MacroRulesScope } ;
@@ -3041,16 +3042,16 @@ impl<'a> Resolver<'a> {
3041
3042
3042
3043
/// Rustdoc uses this to resolve things in a recoverable way. `ResolutionError<'a>`
3043
3044
/// isn't something that can be returned because it can't be made to live that long,
3044
- /// and also it's a private type. Fortunately rustdoc doesn't need to know the error,
3045
- /// just that an error occurred .
3045
+ /// and also it's a private type. However, we can still return the suggestion in case
3046
+ /// an item failed to resolve .
3046
3047
// FIXME(Manishearth): intra-doc links won't get warned of epoch changes.
3047
3048
pub fn resolve_str_path_error (
3048
3049
& mut self ,
3049
3050
span : Span ,
3050
3051
path_str : & str ,
3051
3052
ns : Namespace ,
3052
3053
module_id : DefId ,
3053
- ) -> Result < ( ast:: Path , Res ) , ( ) > {
3054
+ ) -> Result < ( ast:: Path , Res ) , Option < Suggestion > > {
3054
3055
let path = if path_str. starts_with ( "::" ) {
3055
3056
ast:: Path {
3056
3057
span,
@@ -3071,8 +3072,11 @@ impl<'a> Resolver<'a> {
3071
3072
} ;
3072
3073
let module = self . get_module ( module_id) ;
3073
3074
let parent_scope = & ParentScope :: module ( module) ;
3074
- let res = self . resolve_ast_path ( & path, ns, parent_scope) . map_err ( |_| ( ) ) ?;
3075
- Ok ( ( path, res) )
3075
+ match self . resolve_ast_path ( & path, ns, parent_scope) {
3076
+ Ok ( res) => Ok ( ( path, res) ) ,
3077
+ Err ( ( _, ResolutionError :: FailedToResolve { suggestion, .. } ) ) => Err ( suggestion) ,
3078
+ Err ( _) => Err ( None ) ,
3079
+ }
3076
3080
}
3077
3081
3078
3082
// Resolve a path passed from rustdoc or HIR lowering.
0 commit comments