提交 f5bba2c6 编写于 作者: L ljedrz

HirIdification: change some NodeId to HirId calls

上级 36fffa81
...@@ -88,8 +88,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveErr ...@@ -88,8 +88,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveErr
} }
} }
if let NoteClosureEnv(upvar_id) = error.move_from.note { if let NoteClosureEnv(upvar_id) = error.move_from.note {
let var_node_id = bccx.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id); err.span_label(bccx.tcx.hir().span_by_hir_id(upvar_id.var_path.hir_id),
err.span_label(bccx.tcx.hir().span(var_node_id),
"captured outer variable"); "captured outer variable");
} }
err.emit(); err.emit();
......
...@@ -703,20 +703,20 @@ pub fn report_use_of_moved_value(&self, ...@@ -703,20 +703,20 @@ pub fn report_use_of_moved_value(&self,
// Get type of value and span where it was previously // Get type of value and span where it was previously
// moved. // moved.
let node_id = self.tcx.hir().hir_to_node_id(hir::HirId { let hir_id = hir::HirId {
owner: self.body.value.hir_id.owner, owner: self.body.value.hir_id.owner,
local_id: the_move.id local_id: the_move.id
}); };
let (move_span, move_note) = match the_move.kind { let (move_span, move_note) = match the_move.kind {
move_data::Declared => { move_data::Declared => {
unreachable!(); unreachable!();
} }
move_data::MoveExpr | move_data::MoveExpr |
move_data::MovePat => (self.tcx.hir().span(node_id), ""), move_data::MovePat => (self.tcx.hir().span_by_hir_id(hir_id), ""),
move_data::Captured => move_data::Captured =>
(match self.tcx.hir().expect_expr(node_id).node { (match self.tcx.hir().expect_expr_by_hir_id(hir_id).node {
hir::ExprKind::Closure(.., fn_decl_span, _) => fn_decl_span, hir::ExprKind::Closure(.., fn_decl_span, _) => fn_decl_span,
ref r => bug!("Captured({:?}) maps to non-closure: {:?}", ref r => bug!("Captured({:?}) maps to non-closure: {:?}",
the_move.id, r), the_move.id, r),
...@@ -828,8 +828,8 @@ fn report_bckerr(&self, err: &BckError<'a, 'tcx>) { ...@@ -828,8 +828,8 @@ fn report_bckerr(&self, err: &BckError<'a, 'tcx>) {
MutabilityViolation => { MutabilityViolation => {
let mut db = self.cannot_assign(error_span, &descr, Origin::Ast); let mut db = self.cannot_assign(error_span, &descr, Origin::Ast);
if let mc::NoteClosureEnv(upvar_id) = err.cmt.note { if let mc::NoteClosureEnv(upvar_id) = err.cmt.note {
let node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id); let hir_id = upvar_id.var_path.hir_id;
let sp = self.tcx.hir().span(node_id); let sp = self.tcx.hir().span_by_hir_id(hir_id);
let fn_closure_msg = "`Fn` closures cannot capture their enclosing \ let fn_closure_msg = "`Fn` closures cannot capture their enclosing \
environment for modifications"; environment for modifications";
match (self.tcx.sess.source_map().span_to_snippet(sp), &err.cmt.cat) { match (self.tcx.sess.source_map().span_to_snippet(sp), &err.cmt.cat) {
...@@ -1120,8 +1120,8 @@ pub fn report_aliasability_violation(&self, ...@@ -1120,8 +1120,8 @@ pub fn report_aliasability_violation(&self,
} else { } else {
"consider changing this closure to take self by mutable reference" "consider changing this closure to take self by mutable reference"
}; };
let node_id = self.tcx.hir().local_def_id_to_node_id(id); let hir_id = self.tcx.hir().local_def_id_to_hir_id(id);
let help_span = self.tcx.hir().span(node_id); let help_span = self.tcx.hir().span_by_hir_id(hir_id);
self.cannot_act_on_capture_in_sharable_fn(span, self.cannot_act_on_capture_in_sharable_fn(span,
prefix, prefix,
(help_span, help_msg), (help_span, help_msg),
...@@ -1362,9 +1362,9 @@ fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder<'_>, err: &Bck ...@@ -1362,9 +1362,9 @@ fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder<'_>, err: &Bck
_ => bug!() _ => bug!()
}; };
if *kind == ty::ClosureKind::Fn { if *kind == ty::ClosureKind::Fn {
let closure_node_id = let closure_hir_id =
self.tcx.hir().local_def_id_to_node_id(upvar_id.closure_expr_id); self.tcx.hir().local_def_id_to_hir_id(upvar_id.closure_expr_id);
db.span_help(self.tcx.hir().span(closure_node_id), db.span_help(self.tcx.hir().span_by_hir_id(closure_hir_id),
"consider changing this closure to take \ "consider changing this closure to take \
self by mutable reference"); self by mutable reference");
} }
...@@ -1397,8 +1397,8 @@ pub fn append_loan_path_to_string(&self, ...@@ -1397,8 +1397,8 @@ pub fn append_loan_path_to_string(&self,
loan_path: &LoanPath<'tcx>, loan_path: &LoanPath<'tcx>,
out: &mut String) { out: &mut String) {
match loan_path.kind { match loan_path.kind {
LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id}, closure_expr_id: _ }) => { LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id }, closure_expr_id: _ }) => {
out.push_str(&self.tcx.hir().name(self.tcx.hir().hir_to_node_id(id)).as_str()); out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
} }
LpVar(id) => { LpVar(id) => {
out.push_str(&self.tcx.hir().name(id).as_str()); out.push_str(&self.tcx.hir().name(id).as_str());
......
...@@ -454,8 +454,8 @@ fn update_visibility_of_intermediate_use_statements(&mut self, segments: &[hir:: ...@@ -454,8 +454,8 @@ fn update_visibility_of_intermediate_use_statements(&mut self, segments: &[hir::
if let Some([module, segment]) = segments.rchunks_exact(2).next() { if let Some([module, segment]) = segments.rchunks_exact(2).next() {
if let Some(item) = module.def if let Some(item) = module.def
.and_then(|def| def.mod_def_id()) .and_then(|def| def.mod_def_id())
.and_then(|def_id| self.tcx.hir().as_local_node_id(def_id)) .and_then(|def_id| self.tcx.hir().as_local_hir_id(def_id))
.map(|module_node_id| self.tcx.hir().expect_item(module_node_id)) .map(|module_hir_id| self.tcx.hir().expect_item_by_hir_id(module_hir_id))
{ {
if let hir::ItemKind::Mod(m) = &item.node { if let hir::ItemKind::Mod(m) = &item.node {
for item_id in m.item_ids.as_ref() { for item_id in m.item_ids.as_ref() {
......
...@@ -296,8 +296,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) { ...@@ -296,8 +296,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
} }
} }
let for_ = if let Some(nodeid) = tcx.hir().as_local_node_id(did) { let for_ = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
match tcx.hir().expect_item(nodeid).node { match tcx.hir().expect_item_by_hir_id(hir_id).node {
hir::ItemKind::Impl(.., ref t, _) => { hir::ItemKind::Impl(.., ref t, _) => {
t.clean(cx) t.clean(cx)
} }
...@@ -318,8 +318,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) { ...@@ -318,8 +318,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
} }
let predicates = tcx.predicates_of(did); let predicates = tcx.predicates_of(did);
let (trait_items, generics) = if let Some(nodeid) = tcx.hir().as_local_node_id(did) { let (trait_items, generics) = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
match tcx.hir().expect_item(nodeid).node { match tcx.hir().expect_item_by_hir_id(hir_id).node {
hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => { hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => {
( (
item_ids.iter() item_ids.iter()
......
...@@ -2562,9 +2562,9 @@ fn clean(&self, cx: &DocContext) -> Type { ...@@ -2562,9 +2562,9 @@ fn clean(&self, cx: &DocContext) -> Type {
let mut alias = None; let mut alias = None;
if let Def::TyAlias(def_id) = path.def { if let Def::TyAlias(def_id) = path.def {
// Substitute private type aliases // Substitute private type aliases
if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) { if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
if !cx.renderinfo.borrow().access_levels.is_exported(def_id) { if !cx.renderinfo.borrow().access_levels.is_exported(def_id) {
alias = Some(&cx.tcx.hir().expect_item(node_id).node); alias = Some(&cx.tcx.hir().expect_item_by_hir_id(hir_id).node);
} }
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册