Use LocalDefId
instead of NodeId
in resolve_str_path_error
This commit is contained in:
parent
91fb72a8a9
commit
372ba2a03d
3 changed files with 12 additions and 11 deletions
|
@ -2902,7 +2902,7 @@ impl<'a> Resolver<'a> {
|
||||||
span: Span,
|
span: Span,
|
||||||
path_str: &str,
|
path_str: &str,
|
||||||
ns: Namespace,
|
ns: Namespace,
|
||||||
module_id: NodeId,
|
module_id: LocalDefId,
|
||||||
) -> Result<(ast::Path, Res), ()> {
|
) -> Result<(ast::Path, Res), ()> {
|
||||||
let path = if path_str.starts_with("::") {
|
let path = if path_str.starts_with("::") {
|
||||||
ast::Path {
|
ast::Path {
|
||||||
|
@ -2922,10 +2922,7 @@ impl<'a> Resolver<'a> {
|
||||||
.collect(),
|
.collect(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let module = self.block_map.get(&module_id).copied().unwrap_or_else(|| {
|
let module = self.module_map.get(&module_id).copied().unwrap_or(self.graph_root);
|
||||||
let def_id = self.definitions.local_def_id(module_id);
|
|
||||||
self.module_map.get(&def_id).copied().unwrap_or(self.graph_root)
|
|
||||||
});
|
|
||||||
let parent_scope = &ParentScope::module(module);
|
let parent_scope = &ParentScope::module(module);
|
||||||
let res = self.resolve_ast_path(&path, ns, parent_scope).map_err(|_| ())?;
|
let res = self.resolve_ast_path(&path, ns, parent_scope).map_err(|_| ())?;
|
||||||
Ok((path, res))
|
Ok((path, res))
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use rustc_ast::ast::CRATE_NODE_ID;
|
|
||||||
use rustc_attr as attr;
|
use rustc_attr as attr;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::sync::{self, Lrc};
|
use rustc_data_structures::sync::{self, Lrc};
|
||||||
|
@ -7,7 +6,7 @@ use rustc_errors::emitter::{Emitter, EmitterWriter};
|
||||||
use rustc_errors::json::JsonEmitter;
|
use rustc_errors::json::JsonEmitter;
|
||||||
use rustc_feature::UnstableFeatures;
|
use rustc_feature::UnstableFeatures;
|
||||||
use rustc_hir::def::Namespace::TypeNS;
|
use rustc_hir::def::Namespace::TypeNS;
|
||||||
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||||
use rustc_hir::HirId;
|
use rustc_hir::HirId;
|
||||||
use rustc_interface::interface;
|
use rustc_interface::interface;
|
||||||
use rustc_middle::middle::cstore::CrateStore;
|
use rustc_middle::middle::cstore::CrateStore;
|
||||||
|
@ -390,7 +389,12 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||||
resolver.borrow_mut().access(|resolver| {
|
resolver.borrow_mut().access(|resolver| {
|
||||||
for extern_name in &extern_names {
|
for extern_name in &extern_names {
|
||||||
resolver
|
resolver
|
||||||
.resolve_str_path_error(DUMMY_SP, extern_name, TypeNS, CRATE_NODE_ID)
|
.resolve_str_path_error(
|
||||||
|
DUMMY_SP,
|
||||||
|
extern_name,
|
||||||
|
TypeNS,
|
||||||
|
LocalDefId { local_def_index: CRATE_DEF_INDEX },
|
||||||
|
)
|
||||||
.unwrap_or_else(|()| {
|
.unwrap_or_else(|()| {
|
||||||
panic!("Unable to resolve external crate {}", extern_name)
|
panic!("Unable to resolve external crate {}", extern_name)
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ use rustc_hir::def::{
|
||||||
Namespace::{self, *},
|
Namespace::{self, *},
|
||||||
PerNS, Res,
|
PerNS, Res,
|
||||||
};
|
};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_resolve::ParentScope;
|
use rustc_resolve::ParentScope;
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
|
@ -61,7 +61,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
|
||||||
&self,
|
&self,
|
||||||
path_str: &str,
|
path_str: &str,
|
||||||
current_item: &Option<String>,
|
current_item: &Option<String>,
|
||||||
module_id: rustc_ast::ast::NodeId,
|
module_id: LocalDefId,
|
||||||
) -> Result<(Res, Option<String>), ErrorKind> {
|
) -> Result<(Res, Option<String>), ErrorKind> {
|
||||||
let cx = self.cx;
|
let cx = self.cx;
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
|
||||||
|
|
||||||
// In case we're in a module, try to resolve the relative path.
|
// In case we're in a module, try to resolve the relative path.
|
||||||
if let Some(module_id) = parent_id.or(self.mod_ids.last().cloned()) {
|
if let Some(module_id) = parent_id.or(self.mod_ids.last().cloned()) {
|
||||||
let module_id = cx.tcx.hir().hir_id_to_node_id(module_id);
|
let module_id = cx.tcx.hir().local_def_id(module_id);
|
||||||
let result = cx.enter_resolver(|resolver| {
|
let result = cx.enter_resolver(|resolver| {
|
||||||
resolver.resolve_str_path_error(DUMMY_SP, &path_str, ns, module_id)
|
resolver.resolve_str_path_error(DUMMY_SP, &path_str, ns, module_id)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue