Skip to content

Commit

Permalink
[NOT USEFUL] Start working on rust-lang#74207
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Aug 20, 2020
1 parent 9900178 commit 97b24c3
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::{ParentScope, PathResult, ResolutionError, Resolver, Scope, ScopeSet,
type Res = def::Res<ast::NodeId>;

/// A vector of spans and replacements, a message and applicability.
crate type Suggestion = (Vec<(Span, String)>, String, Applicability);
pub type Suggestion = (Vec<(Span, String)>, String, Applicability);

/// Potential candidate for an undeclared or out-of-scope label - contains the ident of a
/// similarly named label and whether or not it is reachable.
Expand Down
16 changes: 10 additions & 6 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ use std::{cmp, fmt, iter, ptr};
use tracing::debug;

use diagnostics::{extend_span_to_previous_binding, find_span_of_binding_until_next_binding};
use diagnostics::{ImportSuggestion, LabelSuggestion, Suggestion};
use diagnostics::{ImportSuggestion, LabelSuggestion};
pub use diagnostics::Suggestion;
use imports::{Import, ImportKind, ImportResolver, NameResolution};
use late::{HasGenericParams, PathSource, Rib, RibKind::*};
use macros::{MacroRulesBinding, MacroRulesScope};
Expand Down Expand Up @@ -3041,16 +3042,16 @@ impl<'a> Resolver<'a> {

/// Rustdoc uses this to resolve things in a recoverable way. `ResolutionError<'a>`
/// isn't something that can be returned because it can't be made to live that long,
/// and also it's a private type. Fortunately rustdoc doesn't need to know the error,
/// just that an error occurred.
/// and also it's a private type. However, we can still return the suggestion in case
/// an item failed to resolve.
// FIXME(Manishearth): intra-doc links won't get warned of epoch changes.
pub fn resolve_str_path_error(
&mut self,
span: Span,
path_str: &str,
ns: Namespace,
module_id: DefId,
) -> Result<(ast::Path, Res), ()> {
) -> Result<(ast::Path, Res), Option<Suggestion>> {
let path = if path_str.starts_with("::") {
ast::Path {
span,
Expand All @@ -3071,8 +3072,11 @@ impl<'a> Resolver<'a> {
};
let module = self.get_module(module_id);
let parent_scope = &ParentScope::module(module);
let res = self.resolve_ast_path(&path, ns, parent_scope).map_err(|_| ())?;
Ok((path, res))
match self.resolve_ast_path(&path, ns, parent_scope) {
Ok(res) => Ok((path, res)),
Err((_, ResolutionError::FailedToResolve { suggestion, .. })) => Err(suggestion),
Err(_) => Err(None),
}
}

// Resolve a path passed from rustdoc or HIR lowering.
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
TypeNS,
LocalDefId { local_def_index: CRATE_DEF_INDEX }.to_def_id(),
)
.unwrap_or_else(|()| {
.unwrap_or_else(|_| {
panic!("Unable to resolve external crate {}", extern_name)
});
}
Expand Down
Loading

0 comments on commit 97b24c3

Please sign in to comment.