Use a function to access the Hir map to be able to turn it into a query later

This commit is contained in:
John Kåre Alsaker 2018-12-04 13:45:36 +01:00
parent 367e783e6f
commit a70babed03
160 changed files with 1220 additions and 1210 deletions

View file

@ -53,7 +53,7 @@ pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let body_exit; let body_exit;
// Find the tables for this body. // Find the tables for this body.
let owner_def_id = tcx.hir.local_def_id(tcx.hir.body_owner(body.id())); let owner_def_id = tcx.hir().local_def_id(tcx.hir().body_owner(body.id()));
let tables = tcx.typeck_tables_of(owner_def_id); let tables = tcx.typeck_tables_of(owner_def_id);
let mut cfg_builder = CFGBuilder { let mut cfg_builder = CFGBuilder {
@ -109,7 +109,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
} }
fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex { fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
let hir_id = self.tcx.hir.node_to_hir_id(stmt.node.id()); let hir_id = self.tcx.hir().node_to_hir_id(stmt.node.id());
match stmt.node { match stmt.node {
hir::StmtKind::Decl(ref decl, _) => { hir::StmtKind::Decl(ref decl, _) => {
let exit = self.decl(&decl, pred); let exit = self.decl(&decl, pred);
@ -588,9 +588,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
match destination.target_id { match destination.target_id {
Ok(loop_id) => { Ok(loop_id) => {
for b in &self.breakable_block_scopes { for b in &self.breakable_block_scopes {
if b.block_expr_id == self.tcx.hir.node_to_hir_id(loop_id).local_id { if b.block_expr_id == self.tcx.hir().node_to_hir_id(loop_id).local_id {
let scope = region::Scope { let scope = region::Scope {
id: self.tcx.hir.node_to_hir_id(loop_id).local_id, id: self.tcx.hir().node_to_hir_id(loop_id).local_id,
data: region::ScopeData::Node data: region::ScopeData::Node
}; };
return (scope, match scope_cf_kind { return (scope, match scope_cf_kind {
@ -600,9 +600,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
} }
} }
for l in &self.loop_scopes { for l in &self.loop_scopes {
if l.loop_id == self.tcx.hir.node_to_hir_id(loop_id).local_id { if l.loop_id == self.tcx.hir().node_to_hir_id(loop_id).local_id {
let scope = region::Scope { let scope = region::Scope {
id: self.tcx.hir.node_to_hir_id(loop_id).local_id, id: self.tcx.hir().node_to_hir_id(loop_id).local_id,
data: region::ScopeData::Node data: region::ScopeData::Node
}; };
return (scope, match scope_cf_kind { return (scope, match scope_cf_kind {

View file

@ -32,11 +32,11 @@ pub struct LabelledCFG<'a, 'tcx: 'a> {
impl<'a, 'tcx> LabelledCFG<'a, 'tcx> { impl<'a, 'tcx> LabelledCFG<'a, 'tcx> {
fn local_id_to_string(&self, local_id: hir::ItemLocalId) -> String { fn local_id_to_string(&self, local_id: hir::ItemLocalId) -> String {
assert!(self.cfg.owner_def_id.is_local()); assert!(self.cfg.owner_def_id.is_local());
let node_id = self.tcx.hir.hir_to_node_id(hir::HirId { let node_id = self.tcx.hir().hir_to_node_id(hir::HirId {
owner: self.tcx.hir.def_index_to_hir_id(self.cfg.owner_def_id.index).owner, owner: self.tcx.hir().def_index_to_hir_id(self.cfg.owner_def_id.index).owner,
local_id local_id
}); });
let s = self.tcx.hir.node_to_string(node_id); let s = self.tcx.hir().node_to_string(node_id);
// Replacing newlines with \\l causes each line to be left-aligned, // Replacing newlines with \\l causes each line to be left-aligned,
// improving presentation of (long) pretty-printed expressions. // improving presentation of (long) pretty-printed expressions.

View file

@ -449,10 +449,10 @@ define_dep_nodes!( <'tcx>
// Represents the `Krate` as a whole (the `hir::Krate` value) (as // Represents the `Krate` as a whole (the `hir::Krate` value) (as
// distinct from the krate module). This is basically a hash of // distinct from the krate module). This is basically a hash of
// the entire krate, so if you read from `Krate` (e.g., by calling // the entire krate, so if you read from `Krate` (e.g., by calling
// `tcx.hir.krate()`), we will have to assume that any change // `tcx.hir().krate()`), we will have to assume that any change
// means that you need to be recompiled. This is because the // means that you need to be recompiled. This is because the
// `Krate` value gives you access to all other items. To avoid // `Krate` value gives you access to all other items. To avoid
// this fate, do not call `tcx.hir.krate()`; instead, prefer // this fate, do not call `tcx.hir().krate()`; instead, prefer
// wrappers like `tcx.visit_all_items_in_krate()`. If there is no // wrappers like `tcx.visit_all_items_in_krate()`. If there is no
// suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain // suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain
// access to the krate, but you must remember to add suitable // access to the krate, but you must remember to add suitable
@ -733,7 +733,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefIndex {
const CAN_RECONSTRUCT_QUERY_KEY: bool = true; const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint { fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
tcx.hir.definitions().def_path_hash(*self).0 tcx.hir().definitions().def_path_hash(*self).0
} }
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String { fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String {

View file

@ -65,7 +65,7 @@ impl<M: DepTrackingMapConfig> MemoizationMap for RefCell<DepTrackingMap<M>> {
/// ///
/// ``` /// ```
/// fn type_of_item(..., item: &hir::Item) -> Ty<'tcx> { /// fn type_of_item(..., item: &hir::Item) -> Ty<'tcx> {
/// let item_def_id = ccx.tcx.hir.local_def_id(it.id); /// let item_def_id = ccx.tcx.hir().local_def_id(it.id);
/// ccx.tcx.item_types.memoized(item_def_id, || { /// ccx.tcx.item_types.memoized(item_def_id, || {
/// ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); // (*) /// ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); // (*)
/// compute_type_of_item(ccx, item) /// compute_type_of_item(ccx, item)

View file

@ -100,7 +100,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
/// Check any attribute. /// Check any attribute.
fn check_attributes(&self, item: &hir::Item, target: Target) { fn check_attributes(&self, item: &hir::Item, target: Target) {
if target == Target::Fn || target == Target::Const { if target == Target::Fn || target == Target::Const {
self.tcx.codegen_fn_attrs(self.tcx.hir.local_def_id(item.id)); self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(item.id));
} else if let Some(a) = item.attrs.iter().find(|a| a.check_name("target_feature")) { } else if let Some(a) = item.attrs.iter().find(|a| a.check_name("target_feature")) {
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function") self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function")
.span_label(item.span, "not a function") .span_label(item.span, "not a function")
@ -352,7 +352,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for CheckAttrVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for CheckAttrVisitor<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
fn visit_item(&mut self, item: &'tcx hir::Item) { fn visit_item(&mut self, item: &'tcx hir::Item) {
@ -375,7 +375,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckAttrVisitor<'a, 'tcx> {
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut checker = CheckAttrVisitor { tcx }; let mut checker = CheckAttrVisitor { tcx };
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor()); tcx.hir().krate().visit_all_item_likes(&mut checker.as_deep_visitor());
} }
fn is_c_like_enum(item: &hir::Item) -> bool { fn is_c_like_enum(item: &hir::Item) -> bool {

View file

@ -19,7 +19,7 @@ use super::intravisit::Visitor;
/// ///
/// 1. **Shallow visit**: Get a simple callback for every item (or item-like thing) in the HIR. /// 1. **Shallow visit**: Get a simple callback for every item (or item-like thing) in the HIR.
/// - Example: find all items with a `#[foo]` attribute on them. /// - Example: find all items with a `#[foo]` attribute on them.
/// - How: Implement `ItemLikeVisitor` and call `tcx.hir.krate().visit_all_item_likes()`. /// - How: Implement `ItemLikeVisitor` and call `tcx.hir().krate().visit_all_item_likes()`.
/// - Pro: Efficient; just walks the lists of item-like things, not the nodes themselves. /// - Pro: Efficient; just walks the lists of item-like things, not the nodes themselves.
/// - Con: Don't get information about nesting /// - Con: Don't get information about nesting
/// - Con: Don't have methods for specific bits of HIR, like "on /// - Con: Don't have methods for specific bits of HIR, like "on
@ -29,7 +29,7 @@ use super::intravisit::Visitor;
/// within one another. /// within one another.
/// - Example: Examine each expression to look for its type and do some check or other. /// - Example: Examine each expression to look for its type and do some check or other.
/// - How: Implement `intravisit::Visitor` and use /// - How: Implement `intravisit::Visitor` and use
/// `tcx.hir.krate().visit_all_item_likes(visitor.as_deep_visitor())`. Within /// `tcx.hir().krate().visit_all_item_likes(visitor.as_deep_visitor())`. Within
/// your `intravisit::Visitor` impl, implement methods like /// your `intravisit::Visitor` impl, implement methods like
/// `visit_expr()`; don't forget to invoke /// `visit_expr()`; don't forget to invoke
/// `intravisit::walk_visit_expr()` to keep walking the subparts. /// `intravisit::walk_visit_expr()` to keep walking the subparts.
@ -43,7 +43,7 @@ use super::intravisit::Visitor;
/// - How: Implement `intravisit::Visitor` and override the /// - How: Implement `intravisit::Visitor` and override the
/// `nested_visit_map()` methods to return /// `nested_visit_map()` methods to return
/// `NestedVisitorMap::All`. Walk your crate with /// `NestedVisitorMap::All`. Walk your crate with
/// `intravisit::walk_crate()` invoked on `tcx.hir.krate()`. /// `intravisit::walk_crate()` invoked on `tcx.hir().krate()`.
/// - Pro: Visitor methods for any kind of HIR node, not just item-like things. /// - Pro: Visitor methods for any kind of HIR node, not just item-like things.
/// - Pro: Preserves nesting information /// - Pro: Preserves nesting information
/// - Con: Does not integrate well into dependency tracking. /// - Con: Does not integrate well into dependency tracking.

View file

@ -1258,8 +1258,8 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
} }
pub fn describe_def(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option<Def> { pub fn describe_def(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option<Def> {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
tcx.hir.describe_def(node_id) tcx.hir().describe_def(node_id)
} else { } else {
bug!("Calling local describe_def query provider for upstream DefId: {:?}", bug!("Calling local describe_def query provider for upstream DefId: {:?}",
def_id) def_id)

View file

@ -97,7 +97,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
) )
}; };
let span = scope.span(self, region_scope_tree); let span = scope.span(self, region_scope_tree);
let tag = match self.hir.find(scope.node_id(self, region_scope_tree)) { let tag = match self.hir().find(scope.node_id(self, region_scope_tree)) {
Some(Node::Block(_)) => "block", Some(Node::Block(_)) => "block",
Some(Node::Expr(expr)) => match expr.node { Some(Node::Expr(expr)) => match expr.node {
hir::ExprKind::Call(..) => "call", hir::ExprKind::Call(..) => "call",
@ -190,8 +190,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let cm = self.sess.source_map(); let cm = self.sess.source_map();
let scope = region.free_region_binding_scope(self); let scope = region.free_region_binding_scope(self);
let node = self.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID); let node = self.hir().as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
let tag = match self.hir.find(node) { let tag = match self.hir().find(node) {
Some(Node::Block(_)) | Some(Node::Expr(_)) => "body", Some(Node::Block(_)) | Some(Node::Expr(_)) => "body",
Some(Node::Item(it)) => Self::item_scope_tag(&it), Some(Node::Item(it)) => Self::item_scope_tag(&it),
Some(Node::TraitItem(it)) => Self::trait_item_scope_tag(&it), Some(Node::TraitItem(it)) => Self::trait_item_scope_tag(&it),
@ -200,8 +200,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}; };
let (prefix, span) = match *region { let (prefix, span) = match *region {
ty::ReEarlyBound(ref br) => { ty::ReEarlyBound(ref br) => {
let mut sp = cm.def_span(self.hir.span(node)); let mut sp = cm.def_span(self.hir().span(node));
if let Some(param) = self.hir if let Some(param) = self.hir()
.get_generics(scope) .get_generics(scope)
.and_then(|generics| generics.get_named(&br.name)) .and_then(|generics| generics.get_named(&br.name))
{ {
@ -213,8 +213,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
bound_region: ty::BoundRegion::BrNamed(_, ref name), bound_region: ty::BoundRegion::BrNamed(_, ref name),
.. ..
}) => { }) => {
let mut sp = cm.def_span(self.hir.span(node)); let mut sp = cm.def_span(self.hir().span(node));
if let Some(param) = self.hir if let Some(param) = self.hir()
.get_generics(scope) .get_generics(scope)
.and_then(|generics| generics.get_named(&name)) .and_then(|generics| generics.get_named(&name))
{ {
@ -225,15 +225,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
ty::ReFree(ref fr) => match fr.bound_region { ty::ReFree(ref fr) => match fr.bound_region {
ty::BrAnon(idx) => ( ty::BrAnon(idx) => (
format!("the anonymous lifetime #{} defined on", idx + 1), format!("the anonymous lifetime #{} defined on", idx + 1),
self.hir.span(node), self.hir().span(node),
), ),
ty::BrFresh(_) => ( ty::BrFresh(_) => (
"an anonymous lifetime defined on".to_owned(), "an anonymous lifetime defined on".to_owned(),
self.hir.span(node), self.hir().span(node),
), ),
_ => ( _ => (
format!("the lifetime {} as defined on", fr.bound_region), format!("the lifetime {} as defined on", fr.bound_region),
cm.def_span(self.hir.span(node)), cm.def_span(self.hir().span(node)),
), ),
}, },
_ => bug!(), _ => bug!(),
@ -1083,7 +1083,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// the expected type argument. // the expected type argument.
if !param.is_self() { if !param.is_self() {
let type_param = generics.type_param(param, self.tcx); let type_param = generics.type_param(param, self.tcx);
let hir = &self.tcx.hir; let hir = &self.tcx.hir();
hir.as_local_node_id(type_param.def_id).map(|id| { hir.as_local_node_id(type_param.def_id).map(|id| {
// Get the `hir::Param` to verify whether it already has any bounds. // Get the `hir::Param` to verify whether it already has any bounds.
// We do this to avoid suggesting code that ends up as `T: 'a'b`, // We do this to avoid suggesting code that ends up as `T: 'a'b`,
@ -1315,8 +1315,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
format!(" for lifetime parameter `{}` in coherence check", name) format!(" for lifetime parameter `{}` in coherence check", name)
} }
infer::UpvarRegion(ref upvar_id, _) => { infer::UpvarRegion(ref upvar_id, _) => {
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id); let var_node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir.name(var_node_id); let var_name = self.tcx.hir().name(var_node_id);
format!(" for capture of `{}` by closure", var_name) format!(" for capture of `{}` by closure", var_name)
} }
infer::NLL(..) => bug!("NLL variable found in lexical phase"), infer::NLL(..) => bug!("NLL variable found in lexical phase"),

View file

@ -109,13 +109,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let mut local_visitor = FindLocalByTypeVisitor { let mut local_visitor = FindLocalByTypeVisitor {
infcx: &self, infcx: &self,
target_ty: &ty, target_ty: &ty,
hir_map: &self.tcx.hir, hir_map: &self.tcx.hir(),
found_local_pattern: None, found_local_pattern: None,
found_arg_pattern: None, found_arg_pattern: None,
}; };
if let Some(body_id) = body_id { if let Some(body_id) = body_id {
let expr = self.tcx.hir.expect_expr(body_id.node_id); let expr = self.tcx.hir().expect_expr(body_id.node_id);
local_visitor.visit_expr(expr); local_visitor.visit_expr(expr);
} }

View file

@ -38,8 +38,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
) -> Option<(&hir::Ty, &hir::FnDecl)> { ) -> Option<(&hir::Ty, &hir::FnDecl)> {
if let Some(anon_reg) = self.tcx.is_suitable_region(region) { if let Some(anon_reg) = self.tcx.is_suitable_region(region) {
let def_id = anon_reg.def_id; let def_id = anon_reg.def_id;
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
let fndecl = match self.tcx.hir.get(node_id) { let fndecl = match self.tcx.hir().get(node_id) {
Node::Item(&hir::Item { Node::Item(&hir::Item {
node: hir::ItemKind::Fn(ref fndecl, ..), node: hir::ItemKind::Fn(ref fndecl, ..),
.. ..
@ -104,7 +104,7 @@ struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
fn visit_ty(&mut self, arg: &'gcx hir::Ty) { fn visit_ty(&mut self, arg: &'gcx hir::Ty) {
@ -124,7 +124,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
hir::TyKind::Rptr(ref lifetime, _) => { hir::TyKind::Rptr(ref lifetime, _) => {
// the lifetime of the TyRptr // the lifetime of the TyRptr
let hir_id = self.tcx.hir.node_to_hir_id(lifetime.id); let hir_id = self.tcx.hir().node_to_hir_id(lifetime.id);
match (self.tcx.named_region(hir_id), self.bound_region) { match (self.tcx.named_region(hir_id), self.bound_region) {
// Find the index of the anonymous region that was part of the // Find the index of the anonymous region that was part of the
// error. We will then search the function parameters for a bound // error. We will then search the function parameters for a bound
@ -150,7 +150,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
// region at the right depth with the same index // region at the right depth with the same index
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => { (Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
debug!( debug!(
"EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \ "EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
def_id={:?}", def_id={:?}",
id, id,
def_id def_id
@ -172,7 +172,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
"FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}", "FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
debruijn_index debruijn_index
); );
debug!("self.infcx.tcx.hir.local_def_id(id)={:?}", id); debug!("self.infcx.tcx.hir().local_def_id(id)={:?}", id);
debug!("def_id={:?}", def_id); debug!("def_id={:?}", def_id);
if debruijn_index == self.current_index && id == def_id { if debruijn_index == self.current_index && id == def_id {
self.found_type = Some(arg); self.found_type = Some(arg);
@ -227,11 +227,11 @@ struct TyPathVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) { fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) {
let hir_id = self.tcx.hir.node_to_hir_id(lifetime.id); let hir_id = self.tcx.hir().node_to_hir_id(lifetime.id);
match (self.tcx.named_region(hir_id), self.bound_region) { match (self.tcx.named_region(hir_id), self.bound_region) {
// the lifetime of the TyPath! // the lifetime of the TyPath!
(Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)), ty::BrAnon(br_index)) => { (Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)), ty::BrAnon(br_index)) => {
@ -243,7 +243,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => { (Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
debug!( debug!(
"EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \ "EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
def_id={:?}", def_id={:?}",
id, id,
def_id def_id

View file

@ -56,7 +56,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
// closure, provide a specific message pointing this out. // closure, provide a specific message pointing this out.
if let (&SubregionOrigin::BindingTypeIsNotValidAtDecl(ref external_span), if let (&SubregionOrigin::BindingTypeIsNotValidAtDecl(ref external_span),
&RegionKind::ReFree(ref free_region)) = (&sub_origin, sup_region) { &RegionKind::ReFree(ref free_region)) = (&sub_origin, sup_region) {
let hir = &self.tcx.hir; let hir = &self.tcx.hir();
if let Some(node_id) = hir.as_local_node_id(free_region.scope) { if let Some(node_id) = hir.as_local_node_id(free_region.scope) {
if let Node::Expr(Expr { if let Node::Expr(Expr {
node: Closure(_, _, _, closure_span, None), node: Closure(_, _, _, closure_span, None),

View file

@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
_ => return None, // not a free region _ => return None, // not a free region
}; };
let hir = &self.tcx.hir; let hir = &self.tcx.hir();
if let Some(node_id) = hir.as_local_node_id(id) { if let Some(node_id) = hir.as_local_node_id(id) {
if let Some(body_id) = hir.maybe_body_owned_by(node_id) { if let Some(body_id) = hir.maybe_body_owned_by(node_id) {
let body = hir.body(body_id); let body = hir.body(body_id);

View file

@ -41,8 +41,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
"...so that reference does not outlive borrowed content"); "...so that reference does not outlive borrowed content");
} }
infer::ReborrowUpvar(span, ref upvar_id) => { infer::ReborrowUpvar(span, ref upvar_id) => {
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id); let var_node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir.name(var_node_id); let var_name = self.tcx.hir().name(var_node_id);
err.span_note(span, err.span_note(span,
&format!("...so that closure can access `{}`", var_name)); &format!("...so that closure can access `{}`", var_name));
} }
@ -61,7 +61,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
err.span_note(span, err.span_note(span,
&format!("...so that captured variable `{}` does not outlive the \ &format!("...so that captured variable `{}` does not outlive the \
enclosing closure", enclosing closure",
self.tcx.hir.name(id))); self.tcx.hir().name(id)));
} }
infer::IndexSlice(span) => { infer::IndexSlice(span) => {
err.span_note(span, "...so that slice is not indexed outside the lifetime"); err.span_note(span, "...so that slice is not indexed outside the lifetime");
@ -174,8 +174,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
err err
} }
infer::ReborrowUpvar(span, ref upvar_id) => { infer::ReborrowUpvar(span, ref upvar_id) => {
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id); let var_node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir.name(var_node_id); let var_name = self.tcx.hir().name(var_node_id);
let mut err = struct_span_err!(self.tcx.sess, let mut err = struct_span_err!(self.tcx.sess,
span, span,
E0313, E0313,
@ -232,7 +232,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
E0474, E0474,
"captured variable `{}` does not outlive the \ "captured variable `{}` does not outlive the \
enclosing closure", enclosing closure",
self.tcx.hir.name(id)); self.tcx.hir().name(id));
self.tcx.note_and_explain_region(region_scope_tree, &mut err, self.tcx.note_and_explain_region(region_scope_tree, &mut err,
"captured variable is valid for ", sup, ""); "captured variable is valid for ", sup, "");
self.tcx.note_and_explain_region(region_scope_tree, &mut err, self.tcx.note_and_explain_region(region_scope_tree, &mut err,

View file

@ -691,13 +691,13 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
// let x = || foo(); // returns the Opaque assoc with `foo` // let x = || foo(); // returns the Opaque assoc with `foo`
// } // }
// ``` // ```
if let Some(opaque_node_id) = tcx.hir.as_local_node_id(def_id) { if let Some(opaque_node_id) = tcx.hir().as_local_node_id(def_id) {
let parent_def_id = self.parent_def_id; let parent_def_id = self.parent_def_id;
let def_scope_default = || { let def_scope_default = || {
let opaque_parent_node_id = tcx.hir.get_parent(opaque_node_id); let opaque_parent_node_id = tcx.hir().get_parent(opaque_node_id);
parent_def_id == tcx.hir.local_def_id(opaque_parent_node_id) parent_def_id == tcx.hir().local_def_id(opaque_parent_node_id)
}; };
let in_definition_scope = match tcx.hir.find(opaque_node_id) { let in_definition_scope = match tcx.hir().find(opaque_node_id) {
Some(Node::Item(item)) => match item.node { Some(Node::Item(item)) => match item.node {
// impl trait // impl trait
hir::ItemKind::Existential(hir::ExistTy { hir::ItemKind::Existential(hir::ExistTy {
@ -725,7 +725,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
}, },
_ => bug!( _ => bug!(
"expected (impl) item, found {}", "expected (impl) item, found {}",
tcx.hir.node_to_string(opaque_node_id), tcx.hir().node_to_string(opaque_node_id),
), ),
}; };
if in_definition_scope { if in_definition_scope {
@ -848,16 +848,16 @@ pub fn may_define_existential_type(
opaque_node_id: ast::NodeId, opaque_node_id: ast::NodeId,
) -> bool { ) -> bool {
let mut node_id = tcx let mut node_id = tcx
.hir .hir()
.as_local_node_id(def_id) .as_local_node_id(def_id)
.unwrap(); .unwrap();
// named existential types can be defined by any siblings or // named existential types can be defined by any siblings or
// children of siblings // children of siblings
let mod_id = tcx.hir.get_parent(opaque_node_id); let mod_id = tcx.hir().get_parent(opaque_node_id);
// so we walk up the node tree until we hit the root or the parent // so we walk up the node tree until we hit the root or the parent
// of the opaque type // of the opaque type
while node_id != mod_id && node_id != ast::CRATE_NODE_ID { while node_id != mod_id && node_id != ast::CRATE_NODE_ID {
node_id = tcx.hir.get_parent(node_id); node_id = tcx.hir().get_parent(node_id);
} }
// syntactically we are allowed to define the concrete type // syntactically we are allowed to define the concrete type
node_id == mod_id node_id == mod_id

View file

@ -774,7 +774,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
where F: FnOnce(&mut Self), where F: FnOnce(&mut Self),
{ {
let old_param_env = self.param_env; let old_param_env = self.param_env;
self.param_env = self.tcx.param_env(self.tcx.hir.local_def_id(id)); self.param_env = self.tcx.param_env(self.tcx.hir().local_def_id(id));
f(self); f(self);
self.param_env = old_param_env; self.param_env = old_param_env;
} }
@ -797,13 +797,13 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
/// items in the context of the outer item, so enable /// items in the context of the outer item, so enable
/// deep-walking. /// deep-walking.
fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, 'tcx> {
hir_visit::NestedVisitorMap::All(&self.tcx.hir) hir_visit::NestedVisitorMap::All(&self.tcx.hir())
} }
fn visit_nested_body(&mut self, body: hir::BodyId) { fn visit_nested_body(&mut self, body: hir::BodyId) {
let old_tables = self.tables; let old_tables = self.tables;
self.tables = self.tcx.body_tables(body); self.tables = self.tcx.body_tables(body);
let body = self.tcx.hir.body(body); let body = self.tcx.hir().body(body);
self.visit_body(body); self.visit_body(body);
self.tables = old_tables; self.tables = old_tables;
} }
@ -866,7 +866,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
// in order for `check_fn` to be able to use them. // in order for `check_fn` to be able to use them.
let old_tables = self.tables; let old_tables = self.tables;
self.tables = self.tcx.body_tables(body_id); self.tables = self.tcx.body_tables(body_id);
let body = self.tcx.hir.body(body_id); let body = self.tcx.hir().body(body_id);
run_lints!(self, check_fn, fk, decl, body, span, id); run_lints!(self, check_fn, fk, decl, body, span, id);
hir_visit::walk_fn(self, fk, decl, body_id, span, id); hir_visit::walk_fn(self, fk, decl, body_id, span, id);
run_lints!(self, check_fn_post, fk, decl, body, span, id); run_lints!(self, check_fn_post, fk, decl, body, span, id);
@ -1191,7 +1191,7 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
let krate = tcx.hir.krate(); let krate = tcx.hir().krate();
let passes = tcx.sess.lint_store.borrow_mut().late_passes.take(); let passes = tcx.sess.lint_store.borrow_mut().late_passes.take();
let passes = { let passes = {

View file

@ -643,7 +643,7 @@ fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum)
levels: LintLevelSets::builder(tcx.sess), levels: LintLevelSets::builder(tcx.sess),
tcx: tcx, tcx: tcx,
}; };
let krate = tcx.hir.krate(); let krate = tcx.hir().krate();
builder.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |builder| { builder.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |builder| {
intravisit::walk_crate(builder, krate); intravisit::walk_crate(builder, krate);
@ -665,7 +665,7 @@ impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> {
where F: FnOnce(&mut Self) where F: FnOnce(&mut Self)
{ {
let push = self.levels.push(attrs); let push = self.levels.push(attrs);
self.levels.register_id(self.tcx.hir.definitions().node_to_hir_id(id)); self.levels.register_id(self.tcx.hir().definitions().node_to_hir_id(id));
f(self); f(self);
self.levels.pop(push); self.levels.pop(push);
} }
@ -673,7 +673,7 @@ impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> {
impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> { impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
intravisit::NestedVisitorMap::All(&self.tcx.hir) intravisit::NestedVisitorMap::All(&self.tcx.hir())
} }
fn visit_item(&mut self, it: &'tcx hir::Item) { fn visit_item(&mut self, it: &'tcx hir::Item) {

View file

@ -35,7 +35,7 @@ use syntax_pos;
// may need to be marked as live. // may need to be marked as live.
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
node_id: ast::NodeId) -> bool { node_id: ast::NodeId) -> bool {
match tcx.hir.find(node_id) { match tcx.hir().find(node_id) {
Some(Node::Item(..)) | Some(Node::Item(..)) |
Some(Node::ImplItem(..)) | Some(Node::ImplItem(..)) |
Some(Node::ForeignItem(..)) | Some(Node::ForeignItem(..)) |
@ -59,7 +59,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
fn check_def_id(&mut self, def_id: DefId) { fn check_def_id(&mut self, def_id: DefId) {
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
if should_explore(self.tcx, node_id) { if should_explore(self.tcx, node_id) {
self.worklist.push(node_id); self.worklist.push(node_id);
} }
@ -68,7 +68,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
} }
fn insert_def_id(&mut self, def_id: DefId) { fn insert_def_id(&mut self, def_id: DefId) {
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
debug_assert!(!should_explore(self.tcx, node_id)); debug_assert!(!should_explore(self.tcx, node_id));
self.live_symbols.insert(node_id); self.live_symbols.insert(node_id);
} }
@ -137,7 +137,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
continue continue
} }
if let Some(ref node) = self.tcx.hir.find(id) { if let Some(ref node) = self.tcx.hir().find(id) {
self.live_symbols.insert(id); self.live_symbols.insert(id);
self.visit_node(node); self.visit_node(node);
} }
@ -153,7 +153,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
Node::Item(item) => { Node::Item(item) => {
match item.node { match item.node {
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => { hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
let def = self.tcx.adt_def(def_id); let def = self.tcx.adt_def(def_id);
self.repr_has_repr_c = def.repr.c(); self.repr_has_repr_c = def.repr.c();
@ -206,7 +206,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
fn visit_nested_body(&mut self, body: hir::BodyId) { fn visit_nested_body(&mut self, body: hir::BodyId) {
let old_tables = self.tables; let old_tables = self.tables;
self.tables = self.tcx.body_tables(body); self.tables = self.tcx.body_tables(body);
let body = self.tcx.hir.body(body); let body = self.tcx.hir().body(body);
self.visit_body(body); self.visit_body(body);
self.tables = old_tables; self.tables = old_tables;
} }
@ -307,7 +307,7 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
return true; return true;
} }
let def_id = tcx.hir.local_def_id(id); let def_id = tcx.hir().local_def_id(id);
let cg_attrs = tcx.codegen_fn_attrs(def_id); let cg_attrs = tcx.codegen_fn_attrs(def_id);
// #[used], #[no_mangle], #[export_name], etc also keeps the item alive // #[used], #[no_mangle], #[export_name], etc also keeps the item alive
@ -469,7 +469,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
} }
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool { fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
let field_type = self.tcx.type_of(self.tcx.hir.local_def_id(field.id)); let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.id));
!field.is_positional() !field.is_positional()
&& !self.symbol_is_live(field.id, None) && !self.symbol_is_live(field.id, None)
&& !field_type.is_phantom_data() && !field_type.is_phantom_data()
@ -510,11 +510,11 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
// This is done to handle the case where, for example, the static // This is done to handle the case where, for example, the static
// method of a private type is used, but the type itself is never // method of a private type is used, but the type itself is never
// called directly. // called directly.
let def_id = self.tcx.hir.local_def_id(id); let def_id = self.tcx.hir().local_def_id(id);
let inherent_impls = self.tcx.inherent_impls(def_id); let inherent_impls = self.tcx.inherent_impls(def_id);
for &impl_did in inherent_impls.iter() { for &impl_did in inherent_impls.iter() {
for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] { for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {
if let Some(item_node_id) = self.tcx.hir.as_local_node_id(item_did) { if let Some(item_node_id) = self.tcx.hir().as_local_node_id(item_did) {
if self.live_symbols.contains(&item_node_id) { if self.live_symbols.contains(&item_node_id) {
return true; return true;
} }
@ -547,7 +547,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
/// an error. We could do this also by checking the parents, but /// an error. We could do this also by checking the parents, but
/// this is how the code is setup and it seems harmless enough. /// this is how the code is setup and it seems harmless enough.
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.tcx.hir) NestedVisitorMap::All(&self.tcx.hir())
} }
fn visit_item(&mut self, item: &'tcx hir::Item) { fn visit_item(&mut self, item: &'tcx hir::Item) {
@ -648,7 +648,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
let krate = tcx.hir.krate(); let krate = tcx.hir().krate();
let live_symbols = find_live(tcx, access_levels, krate); let live_symbols = find_live(tcx, access_levels, krate);
let mut visitor = DeadVisitor { let mut visitor = DeadVisitor {
tcx, tcx,

View file

@ -622,7 +622,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
match local.init { match local.init {
None => { None => {
local.pat.each_binding(|_, hir_id, span, _| { local.pat.each_binding(|_, hir_id, span, _| {
let node_id = self.mc.tcx.hir.hir_to_node_id(hir_id); let node_id = self.mc.tcx.hir().hir_to_node_id(hir_id);
self.delegate.decl_without_init(node_id, span); self.delegate.decl_without_init(node_id, span);
}) })
} }
@ -935,8 +935,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.tcx().with_freevars(closure_expr.id, |freevars| { self.tcx().with_freevars(closure_expr.id, |freevars| {
for freevar in freevars { for freevar in freevars {
let var_hir_id = self.tcx().hir.node_to_hir_id(freevar.var_id()); let var_hir_id = self.tcx().hir().node_to_hir_id(freevar.var_id());
let closure_def_id = self.tcx().hir.local_def_id(closure_expr.id); let closure_def_id = self.tcx().hir().local_def_id(closure_expr.id);
let upvar_id = ty::UpvarId { let upvar_id = ty::UpvarId {
var_path: ty::UpvarPath { hir_id: var_hir_id }, var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: closure_def_id.to_local(), closure_expr_id: closure_def_id.to_local(),
@ -973,7 +973,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
-> mc::McResult<mc::cmt_<'tcx>> { -> mc::McResult<mc::cmt_<'tcx>> {
// Create the cmt for the variable being borrowed, from the // Create the cmt for the variable being borrowed, from the
// caller's perspective // caller's perspective
let var_hir_id = self.tcx().hir.node_to_hir_id(upvar.var_id()); let var_hir_id = self.tcx().hir().node_to_hir_id(upvar.var_id());
let var_ty = self.mc.node_ty(var_hir_id)?; let var_ty = self.mc.node_ty(var_hir_id)?;
self.mc.cat_def(closure_hir_id, closure_span, var_ty, upvar.def) self.mc.cat_def(closure_hir_id, closure_span, var_ty, upvar.def)
} }

View file

@ -23,7 +23,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut visitor = ItemVisitor { let mut visitor = ItemVisitor {
tcx, tcx,
}; };
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
} }
struct ItemVisitor<'a, 'tcx: 'a> { struct ItemVisitor<'a, 'tcx: 'a> {
@ -134,8 +134,8 @@ impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> {
} }
fn visit_nested_body(&mut self, body_id: hir::BodyId) { fn visit_nested_body(&mut self, body_id: hir::BodyId) {
let owner_def_id = self.tcx.hir.body_owner_def_id(body_id); let owner_def_id = self.tcx.hir().body_owner_def_id(body_id);
let body = self.tcx.hir.body(body_id); let body = self.tcx.hir().body(body_id);
let param_env = self.tcx.param_env(owner_def_id); let param_env = self.tcx.param_env(owner_def_id);
let tables = self.tcx.typeck_tables_of(owner_def_id); let tables = self.tcx.typeck_tables_of(owner_def_id);
ExprVisitor { tcx: self.tcx, param_env, tables }.visit_body(body); ExprVisitor { tcx: self.tcx, param_env, tables }.visit_body(body);

View file

@ -108,7 +108,7 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> {
match self.item_refs.get(&*value.as_str()).cloned() { match self.item_refs.get(&*value.as_str()).cloned() {
// Known lang item with attribute on correct target. // Known lang item with attribute on correct target.
Some((item_index, expected_target)) if actual_target == expected_target => { Some((item_index, expected_target)) if actual_target == expected_target => {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
self.collect_item(item_index, def_id); self.collect_item(item_index, def_id);
}, },
// Known lang item with attribute on incorrect target. // Known lang item with attribute on incorrect target.
@ -171,7 +171,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
if let Some(original_def_id) = self.items.items[item_index] { if let Some(original_def_id) = self.items.items[item_index] {
if original_def_id != item_def_id { if original_def_id != item_def_id {
let name = LangItem::from_u32(item_index as u32).unwrap().name(); let name = LangItem::from_u32(item_index as u32).unwrap().name();
let mut err = match self.tcx.hir.span_if_local(item_def_id) { let mut err = match self.tcx.hir().span_if_local(item_def_id) {
Some(span) => struct_span_err!( Some(span) => struct_span_err!(
self.tcx.sess, self.tcx.sess,
span, span,
@ -183,7 +183,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
self.tcx.crate_name(item_def_id.krate), self.tcx.crate_name(item_def_id.krate),
name)), name)),
}; };
if let Some(span) = self.tcx.hir.span_if_local(original_def_id) { if let Some(span) = self.tcx.hir().span_if_local(original_def_id) {
span_note!(&mut err, span, "first defined here."); span_note!(&mut err, span, "first defined here.");
} else { } else {
err.note(&format!("first defined in crate `{}`.", err.note(&format!("first defined in crate `{}`.",
@ -221,7 +221,7 @@ pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LanguageItems {
collector.collect_item(item_index, def_id); collector.collect_item(item_index, def_id);
} }
} }
tcx.hir.krate().visit_all_item_likes(&mut collector); tcx.hir().krate().visit_all_item_likes(&mut collector);
let LanguageItemCollector { mut items, .. } = collector; let LanguageItemCollector { mut items, .. } = collector;
weak_lang_items::check_crate(tcx, &mut items); weak_lang_items::check_crate(tcx, &mut items);
items items

View file

@ -140,7 +140,7 @@ impl<'a, 'tcx> LibFeatureCollector<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for LibFeatureCollector<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for LibFeatureCollector<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.tcx.hir) NestedVisitorMap::All(&self.tcx.hir())
} }
fn visit_attribute(&mut self, attr: &'tcx Attribute) { fn visit_attribute(&mut self, attr: &'tcx Attribute) {
@ -152,6 +152,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LibFeatureCollector<'a, 'tcx> {
pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LibFeatures { pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LibFeatures {
let mut collector = LibFeatureCollector::new(tcx); let mut collector = LibFeatureCollector::new(tcx);
intravisit::walk_crate(&mut collector, tcx.hir.krate()); intravisit::walk_crate(&mut collector, tcx.hir().krate());
collector.lib_features collector.lib_features
} }

View file

@ -176,7 +176,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_, '_, '_>) -> Strin
impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl, fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
@ -190,7 +190,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> {
} }
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
tcx.hir.krate().visit_all_item_likes(&mut IrMaps::new(tcx).as_deep_visitor()); tcx.hir().krate().visit_all_item_likes(&mut IrMaps::new(tcx).as_deep_visitor());
tcx.sess.abort_if_errors(); tcx.sess.abort_if_errors();
} }
@ -362,8 +362,8 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
// Don't run unused pass for #[derive()] // Don't run unused pass for #[derive()]
if let FnKind::Method(..) = fk { if let FnKind::Method(..) = fk {
let parent = ir.tcx.hir.get_parent(id); let parent = ir.tcx.hir().get_parent(id);
if let Some(Node::Item(i)) = ir.tcx.hir.find(parent) { if let Some(Node::Item(i)) = ir.tcx.hir().find(parent) {
if i.attrs.iter().any(|a| a.check_name("automatically_derived")) { if i.attrs.iter().any(|a| a.check_name("automatically_derived")) {
return; return;
} }
@ -372,7 +372,7 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps<'_, '_>); debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps<'_, '_>);
let body = ir.tcx.hir.body(body_id); let body = ir.tcx.hir().body(body_id);
for arg in &body.arguments { for arg in &body.arguments {
arg.pat.each_binding(|_bm, hir_id, _x, ident| { arg.pat.each_binding(|_bm, hir_id, _x, ident| {
@ -476,7 +476,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
call_caps.extend(freevars.iter().filter_map(|fv| { call_caps.extend(freevars.iter().filter_map(|fv| {
if let Def::Local(rv) = fv.def { if let Def::Local(rv) = fv.def {
let fv_ln = ir.add_live_node(FreeVarNode(fv.span)); let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
let var_hid = ir.tcx.hir.node_to_hir_id(rv); let var_hid = ir.tcx.hir().node_to_hir_id(rv);
Some(CaptureInfo { ln: fv_ln, var_hid }) Some(CaptureInfo { ln: fv_ln, var_hid })
} else { } else {
None None
@ -924,7 +924,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// effectively a return---this only occurs in `for` loops, // effectively a return---this only occurs in `for` loops,
// where the body is really a closure. // where the body is really a closure.
debug!("compute: using id for body, {}", self.ir.tcx.hir.node_to_pretty_string(body.id)); debug!("compute: using id for body, {}", self.ir.tcx.hir().node_to_pretty_string(body.id));
let exit_ln = self.s.exit_ln; let exit_ln = self.s.exit_ln;
@ -1021,7 +1021,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
-> LiveNode { -> LiveNode {
debug!("propagate_through_expr: {}", self.ir.tcx.hir.node_to_pretty_string(expr.id)); debug!("propagate_through_expr: {}", self.ir.tcx.hir().node_to_pretty_string(expr.id));
match expr.node { match expr.node {
// Interesting cases with control flow or which gen/kill // Interesting cases with control flow or which gen/kill
@ -1035,7 +1035,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
hir::ExprKind::Closure(.., blk_id, _, _) => { hir::ExprKind::Closure(.., blk_id, _, _) => {
debug!("{} is an ExprKind::Closure", debug!("{} is an ExprKind::Closure",
self.ir.tcx.hir.node_to_pretty_string(expr.id)); self.ir.tcx.hir().node_to_pretty_string(expr.id));
// The next-node for a break is the successor of the entire // The next-node for a break is the successor of the entire
// loop. The next-node for a continue is the top of this loop. // loop. The next-node for a continue is the top of this loop.
@ -1356,7 +1356,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let ln = self.live_node(hir_id, span); let ln = self.live_node(hir_id, span);
if acc != 0 { if acc != 0 {
self.init_from_succ(ln, succ); self.init_from_succ(ln, succ);
let var_hid = self.ir.tcx.hir.node_to_hir_id(nid); let var_hid = self.ir.tcx.hir().node_to_hir_id(nid);
let var = self.variable(var_hid, span); let var = self.variable(var_hid, span);
self.acc(ln, var, acc); self.acc(ln, var, acc);
} }
@ -1413,7 +1413,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
} }
} }
debug!("propagate_through_loop: using id for loop body {} {}", debug!("propagate_through_loop: using id for loop body {} {}",
expr.id, self.ir.tcx.hir.node_to_pretty_string(body.id)); expr.id, self.ir.tcx.hir().node_to_pretty_string(body.id));
let break_ln = succ; let break_ln = succ;
let cont_ln = ln; let cont_ln = ln;
@ -1547,7 +1547,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// mutable, then check for a reassignment to flag the mutability // mutable, then check for a reassignment to flag the mutability
// as being used. // as being used.
let ln = self.live_node(expr.hir_id, expr.span); let ln = self.live_node(expr.hir_id, expr.span);
let var_hid = self.ir.tcx.hir.node_to_hir_id(nid); let var_hid = self.ir.tcx.hir().node_to_hir_id(nid);
let var = self.variable(var_hid, expr.span); let var = self.variable(var_hid, expr.span);
self.warn_about_dead_assign(expr.span, expr.hir_id, ln, var); self.warn_about_dead_assign(expr.span, expr.hir_id, ln, var);
} }

View file

@ -348,7 +348,7 @@ impl MutabilityCategory {
fn from_local(tcx: TyCtxt<'_, '_, '_>, tables: &ty::TypeckTables<'_>, fn from_local(tcx: TyCtxt<'_, '_, '_>, tables: &ty::TypeckTables<'_>,
id: ast::NodeId) -> MutabilityCategory { id: ast::NodeId) -> MutabilityCategory {
let ret = match tcx.hir.get(id) { let ret = match tcx.hir().get(id) {
Node::Binding(p) => match p.node { Node::Binding(p) => match p.node {
PatKind::Binding(..) => { PatKind::Binding(..) => {
let bm = *tables.pat_binding_modes() let bm = *tables.pat_binding_modes()
@ -362,7 +362,7 @@ impl MutabilityCategory {
} }
_ => span_bug!(p.span, "expected identifier pattern") _ => span_bug!(p.span, "expected identifier pattern")
}, },
_ => span_bug!(tcx.hir.span(id), "expected identifier pattern") _ => span_bug!(tcx.hir().span(id), "expected identifier pattern")
}; };
debug!("MutabilityCategory::{}(tcx, id={:?}) => {:?}", debug!("MutabilityCategory::{}(tcx, id={:?}) => {:?}",
"from_local", id, ret); "from_local", id, ret);
@ -495,9 +495,9 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
// FIXME // FIXME
None if self.is_tainted_by_errors() => Err(()), None if self.is_tainted_by_errors() => Err(()),
None => { None => {
let id = self.tcx.hir.hir_to_node_id(id); let id = self.tcx.hir().hir_to_node_id(id);
bug!("no type for node {}: {} in mem_categorization", bug!("no type for node {}: {} in mem_categorization",
id, self.tcx.hir.node_to_string(id)); id, self.tcx.hir().node_to_string(id));
} }
} }
} }
@ -770,7 +770,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
fn_node_id: ast::NodeId) fn_node_id: ast::NodeId)
-> McResult<cmt_<'tcx>> -> McResult<cmt_<'tcx>>
{ {
let fn_hir_id = self.tcx.hir.node_to_hir_id(fn_node_id); let fn_hir_id = self.tcx.hir().node_to_hir_id(fn_node_id);
// An upvar can have up to 3 components. We translate first to a // An upvar can have up to 3 components. We translate first to a
// `Categorization::Upvar`, which is itself a fiction -- it represents the reference to the // `Categorization::Upvar`, which is itself a fiction -- it represents the reference to the
@ -815,8 +815,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
ref t => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", t), ref t => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", t),
}; };
let closure_expr_def_id = self.tcx.hir.local_def_id(fn_node_id); let closure_expr_def_id = self.tcx.hir().local_def_id(fn_node_id);
let var_hir_id = self.tcx.hir.node_to_hir_id(var_id); let var_hir_id = self.tcx.hir().node_to_hir_id(var_id);
let upvar_id = ty::UpvarId { let upvar_id = ty::UpvarId {
var_path: ty::UpvarPath { hir_id: var_hir_id }, var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: closure_expr_def_id.to_local(), closure_expr_id: closure_expr_def_id.to_local(),
@ -1504,7 +1504,7 @@ impl<'tcx> cmt_<'tcx> {
"non-place".into() "non-place".into()
} }
Categorization::Local(vid) => { Categorization::Local(vid) => {
if tcx.hir.is_argument(vid) { if tcx.hir().is_argument(vid) {
"argument" "argument"
} else { } else {
"local variable" "local variable"

View file

@ -47,7 +47,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>,
match item.node { match item.node {
hir::ItemKind::Impl(..) | hir::ItemKind::Impl(..) |
hir::ItemKind::Fn(..) => { hir::ItemKind::Fn(..) => {
let generics = tcx.generics_of(tcx.hir.local_def_id(item.id)); let generics = tcx.generics_of(tcx.hir().local_def_id(item.id));
generics.requires_monomorphization(tcx) generics.requires_monomorphization(tcx)
} }
_ => false, _ => false,
@ -58,12 +58,12 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_item: &hir::ImplItem, impl_item: &hir::ImplItem,
impl_src: DefId) -> bool { impl_src: DefId) -> bool {
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id()); let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
let generics = tcx.generics_of(tcx.hir.local_def_id(impl_item.id)); let generics = tcx.generics_of(tcx.hir().local_def_id(impl_item.id));
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) { if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
return true return true
} }
if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) { if let Some(impl_node_id) = tcx.hir().as_local_node_id(impl_src) {
match tcx.hir.find(impl_node_id) { match tcx.hir().find(impl_node_id) {
Some(Node::Item(item)) => Some(Node::Item(item)) =>
item_might_be_inlined(tcx, &item, codegen_fn_attrs), item_might_be_inlined(tcx, &item, codegen_fn_attrs),
Some(..) | None => Some(..) | None =>
@ -96,7 +96,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
fn visit_nested_body(&mut self, body: hir::BodyId) { fn visit_nested_body(&mut self, body: hir::BodyId) {
let old_tables = self.tables; let old_tables = self.tables;
self.tables = self.tcx.body_tables(body); self.tables = self.tcx.body_tables(body);
let body = self.tcx.hir.body(body); let body = self.tcx.hir().body(body);
self.visit_body(body); self.visit_body(body);
self.tables = old_tables; self.tables = old_tables;
} }
@ -118,7 +118,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
} }
Some(def) => { Some(def) => {
if let Some((node_id, def_id)) = def.opt_def_id().and_then(|def_id| { if let Some((node_id, def_id)) = def.opt_def_id().and_then(|def_id| {
self.tcx.hir.as_local_node_id(def_id).map(|node_id| (node_id, def_id)) self.tcx.hir().as_local_node_id(def_id).map(|node_id| (node_id, def_id))
}) { }) {
if self.def_id_represents_local_inlined_item(def_id) { if self.def_id_represents_local_inlined_item(def_id) {
self.worklist.push(node_id); self.worklist.push(node_id);
@ -151,12 +151,12 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// Returns true if the given def ID represents a local item that is // Returns true if the given def ID represents a local item that is
// eligible for inlining and false otherwise. // eligible for inlining and false otherwise.
fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool { fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool {
let node_id = match self.tcx.hir.as_local_node_id(def_id) { let node_id = match self.tcx.hir().as_local_node_id(def_id) {
Some(node_id) => node_id, Some(node_id) => node_id,
None => { return false; } None => { return false; }
}; };
match self.tcx.hir.find(node_id) { match self.tcx.hir().find(node_id) {
Some(Node::Item(item)) => { Some(Node::Item(item)) => {
match item.node { match item.node {
hir::ItemKind::Fn(..) => hir::ItemKind::Fn(..) =>
@ -182,13 +182,13 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
true true
} else { } else {
let impl_did = self.tcx let impl_did = self.tcx
.hir .hir()
.get_parent_did(node_id); .get_parent_did(node_id);
// Check the impl. If the generics on the self // Check the impl. If the generics on the self
// type of the impl require inlining, this method // type of the impl require inlining, this method
// does too. // does too.
let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap(); let impl_node_id = self.tcx.hir().as_local_node_id(impl_did).unwrap();
match self.tcx.hir.expect_item(impl_node_id).node { match self.tcx.hir().expect_item(impl_node_id).node {
hir::ItemKind::Impl(..) => { hir::ItemKind::Impl(..) => {
let generics = self.tcx.generics_of(impl_did); let generics = self.tcx.generics_of(impl_did);
generics.requires_monomorphization(self.tcx) generics.requires_monomorphization(self.tcx)
@ -214,7 +214,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
continue continue
} }
if let Some(ref item) = self.tcx.hir.find(search_item) { if let Some(ref item) = self.tcx.hir().find(search_item) {
self.propagate_node(item, search_item); self.propagate_node(item, search_item);
} }
} }
@ -231,7 +231,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
} else { } else {
false false
}; };
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id); let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
let is_extern = codegen_attrs.contains_extern_indicator(); let is_extern = codegen_attrs.contains_extern_indicator();
let std_internal = codegen_attrs.flags.contains( let std_internal = codegen_attrs.flags.contains(
@ -252,7 +252,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
Node::Item(item) => { Node::Item(item) => {
match item.node { match item.node {
hir::ItemKind::Fn(.., body) => { hir::ItemKind::Fn(.., body) => {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
if item_might_be_inlined(self.tcx, if item_might_be_inlined(self.tcx,
&item, &item,
self.tcx.codegen_fn_attrs(def_id)) { self.tcx.codegen_fn_attrs(def_id)) {
@ -305,7 +305,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
self.visit_nested_body(body); self.visit_nested_body(body);
} }
hir::ImplItemKind::Method(_, body) => { hir::ImplItemKind::Method(_, body) => {
let did = self.tcx.hir.get_parent_did(search_item); let did = self.tcx.hir().get_parent_did(search_item);
if method_might_be_inlined(self.tcx, impl_item, did) { if method_might_be_inlined(self.tcx, impl_item, did) {
self.visit_nested_body(body) self.visit_nested_body(body)
} }
@ -326,7 +326,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
Node::MacroDef(_) => {} Node::MacroDef(_) => {}
_ => { _ => {
bug!("found unexpected thingy in worklist: {}", bug!("found unexpected thingy in worklist: {}",
self.tcx.hir.node_to_string(search_item)) self.tcx.hir().node_to_string(search_item))
} }
} }
} }
@ -351,7 +351,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a,
// Anything which has custom linkage gets thrown on the worklist no // Anything which has custom linkage gets thrown on the worklist no
// matter where it is in the crate, along with "special std symbols" // matter where it is in the crate, along with "special std symbols"
// which are currently akin to allocator symbols. // which are currently akin to allocator symbols.
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id); let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
if codegen_attrs.contains_extern_indicator() || if codegen_attrs.contains_extern_indicator() ||
codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) { codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) {
@ -376,7 +376,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a,
self.worklist.reserve(provided_trait_methods.len()); self.worklist.reserve(provided_trait_methods.len());
for default_method in provided_trait_methods { for default_method in provided_trait_methods {
let node_id = self.tcx let node_id = self.tcx
.hir .hir()
.as_local_node_id(default_method.def_id) .as_local_node_id(default_method.def_id)
.unwrap(); .unwrap();
self.worklist.push(node_id); self.worklist.push(node_id);
@ -422,7 +422,7 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) ->
reachable_context.worklist.extend(access_levels.map.iter().map(|(id, _)| *id)); reachable_context.worklist.extend(access_levels.map.iter().map(|(id, _)| *id));
for item in tcx.lang_items().items().iter() { for item in tcx.lang_items().items().iter() {
if let Some(did) = *item { if let Some(did) = *item {
if let Some(node_id) = tcx.hir.as_local_node_id(did) { if let Some(node_id) = tcx.hir().as_local_node_id(did) {
reachable_context.worklist.push(node_id); reachable_context.worklist.push(node_id);
} }
} }
@ -433,7 +433,7 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) ->
access_levels, access_levels,
worklist: &mut reachable_context.worklist, worklist: &mut reachable_context.worklist,
}; };
tcx.hir.krate().visit_all_item_likes(&mut collect_private_impl_items); tcx.hir().krate().visit_all_item_likes(&mut collect_private_impl_items);
} }
// Step 2: Mark all symbols that the symbols on the worklist touch. // Step 2: Mark all symbols that the symbols on the worklist touch.

View file

@ -181,7 +181,7 @@ impl Scope {
pub fn node_id(&self, tcx: TyCtxt<'_, '_, '_>, scope_tree: &ScopeTree) -> ast::NodeId { pub fn node_id(&self, tcx: TyCtxt<'_, '_, '_>, scope_tree: &ScopeTree) -> ast::NodeId {
match scope_tree.root_body { match scope_tree.root_body {
Some(hir_id) => { Some(hir_id) => {
tcx.hir.hir_to_node_id(hir::HirId { tcx.hir().hir_to_node_id(hir::HirId {
owner: hir_id.owner, owner: hir_id.owner,
local_id: self.item_local_id() local_id: self.item_local_id()
}) })
@ -198,9 +198,9 @@ impl Scope {
if node_id == ast::DUMMY_NODE_ID { if node_id == ast::DUMMY_NODE_ID {
return DUMMY_SP; return DUMMY_SP;
} }
let span = tcx.hir.span(node_id); let span = tcx.hir().span(node_id);
if let ScopeData::Remainder(first_statement_index) = self.data { if let ScopeData::Remainder(first_statement_index) = self.data {
if let Node::Block(ref blk) = tcx.hir.get(node_id) { if let Node::Block(ref blk) = tcx.hir().get(node_id) {
// Want span for scope starting after the // Want span for scope starting after the
// indexed statement and ending at end of // indexed statement and ending at end of
// `blk`; reuse span of `blk` and shift `lo` // `blk`; reuse span of `blk` and shift `lo`
@ -660,9 +660,9 @@ impl<'tcx> ScopeTree {
-> Scope { -> Scope {
let param_owner = tcx.parent_def_id(br.def_id).unwrap(); let param_owner = tcx.parent_def_id(br.def_id).unwrap();
let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap(); let param_owner_id = tcx.hir().as_local_node_id(param_owner).unwrap();
let scope = tcx.hir.maybe_body_owned_by(param_owner_id).map(|body_id| { let scope = tcx.hir().maybe_body_owned_by(param_owner_id).map(|body_id| {
tcx.hir.body(body_id).value.hir_id.local_id tcx.hir().body(body_id).value.hir_id.local_id
}).unwrap_or_else(|| { }).unwrap_or_else(|| {
// The lifetime was defined on node that doesn't own a body, // The lifetime was defined on node that doesn't own a body,
// which in practice can only mean a trait or an impl, that // which in practice can only mean a trait or an impl, that
@ -671,7 +671,7 @@ impl<'tcx> ScopeTree {
"free_scope: {:?} not recognized by the \ "free_scope: {:?} not recognized by the \
region scope tree for {:?} / {:?}", region scope tree for {:?} / {:?}",
param_owner, param_owner,
self.root_parent.map(|id| tcx.hir.local_def_id(id)), self.root_parent.map(|id| tcx.hir().local_def_id(id)),
self.root_body.map(|hir_id| DefId::local(hir_id.owner))); self.root_body.map(|hir_id| DefId::local(hir_id.owner)));
// The trait/impl lifetime is in scope for the method's body. // The trait/impl lifetime is in scope for the method's body.
@ -696,9 +696,9 @@ impl<'tcx> ScopeTree {
// on the same function that they ended up being freed in. // on the same function that they ended up being freed in.
assert_eq!(param_owner, fr.scope); assert_eq!(param_owner, fr.scope);
let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap(); let param_owner_id = tcx.hir().as_local_node_id(param_owner).unwrap();
let body_id = tcx.hir.body_owned_by(param_owner_id); let body_id = tcx.hir().body_owned_by(param_owner_id);
Scope { id: tcx.hir.body(body_id).value.hir_id.local_id, data: ScopeData::CallSite } Scope { id: tcx.hir().body(body_id).value.hir_id.local_id, data: ScopeData::CallSite }
} }
/// Checks whether the given scope contains a `yield`. If so, /// Checks whether the given scope contains a `yield`. If so,
@ -845,7 +845,7 @@ fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, pat: &
} }
fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt: &'tcx hir::Stmt) { fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt: &'tcx hir::Stmt) {
let stmt_id = visitor.tcx.hir.node_to_hir_id(stmt.node.id()).local_id; let stmt_id = visitor.tcx.hir().node_to_hir_id(stmt.node.id()).local_id;
debug!("resolve_stmt(stmt.id={:?})", stmt_id); debug!("resolve_stmt(stmt.id={:?})", stmt_id);
// Every statement will clean up the temporaries created during // Every statement will clean up the temporaries created during
@ -942,7 +942,7 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
// Manually recurse over closures, because they are the only // Manually recurse over closures, because they are the only
// case of nested bodies that share the parent environment. // case of nested bodies that share the parent environment.
hir::ExprKind::Closure(.., body, _, _) => { hir::ExprKind::Closure(.., body, _, _) => {
let body = visitor.tcx.hir.body(body); let body = visitor.tcx.hir().body(body);
visitor.visit_body(body); visitor.visit_body(body);
} }
@ -1244,7 +1244,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
fn visit_body(&mut self, body: &'tcx hir::Body) { fn visit_body(&mut self, body: &'tcx hir::Body) {
let body_id = body.id(); let body_id = body.id();
let owner_id = self.tcx.hir.body_owner(body_id); let owner_id = self.tcx.hir().body_owner(body_id);
debug!("visit_body(id={:?}, span={:?}, body.id={:?}, cx.parent={:?})", debug!("visit_body(id={:?}, span={:?}, body.id={:?}, cx.parent={:?})",
owner_id, owner_id,
@ -1273,7 +1273,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
// The body of the every fn is a root scope. // The body of the every fn is a root scope.
self.cx.parent = self.cx.var_parent; self.cx.parent = self.cx.var_parent;
if let hir::BodyOwnerKind::Fn = self.tcx.hir.body_owner_kind(owner_id) { if let hir::BodyOwnerKind::Fn = self.tcx.hir().body_owner_kind(owner_id) {
self.visit_expr(&body.value); self.visit_expr(&body.value);
} else { } else {
// Only functions have an outer terminating (drop) scope, while // Only functions have an outer terminating (drop) scope, while
@ -1333,8 +1333,8 @@ fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
return tcx.region_scope_tree(closure_base_def_id); return tcx.region_scope_tree(closure_base_def_id);
} }
let id = tcx.hir.as_local_node_id(def_id).unwrap(); let id = tcx.hir().as_local_node_id(def_id).unwrap();
let scope_tree = if let Some(body_id) = tcx.hir.maybe_body_owned_by(id) { let scope_tree = if let Some(body_id) = tcx.hir().maybe_body_owned_by(id) {
let mut visitor = RegionResolutionVisitor { let mut visitor = RegionResolutionVisitor {
tcx, tcx,
scope_tree: ScopeTree::default(), scope_tree: ScopeTree::default(),
@ -1347,16 +1347,16 @@ fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
terminating_scopes: Default::default(), terminating_scopes: Default::default(),
}; };
let body = tcx.hir.body(body_id); let body = tcx.hir().body(body_id);
visitor.scope_tree.root_body = Some(body.value.hir_id); visitor.scope_tree.root_body = Some(body.value.hir_id);
// If the item is an associated const or a method, // If the item is an associated const or a method,
// record its impl/trait parent, as it can also have // record its impl/trait parent, as it can also have
// lifetime parameters free in this body. // lifetime parameters free in this body.
match tcx.hir.get(id) { match tcx.hir().get(id) {
Node::ImplItem(_) | Node::ImplItem(_) |
Node::TraitItem(_) => { Node::TraitItem(_) => {
visitor.scope_tree.root_parent = Some(tcx.hir.get_parent(id)); visitor.scope_tree.root_parent = Some(tcx.hir().get_parent(id));
} }
_ => {} _ => {}
} }

View file

@ -398,19 +398,19 @@ fn resolve_lifetimes<'tcx>(
let mut rl = ResolveLifetimes::default(); let mut rl = ResolveLifetimes::default();
for (k, v) in named_region_map.defs { for (k, v) in named_region_map.defs {
let hir_id = tcx.hir.node_to_hir_id(k); let hir_id = tcx.hir().node_to_hir_id(k);
let map = rl.defs.entry(hir_id.owner_local_def_id()).or_default(); let map = rl.defs.entry(hir_id.owner_local_def_id()).or_default();
Lrc::get_mut(map).unwrap().insert(hir_id.local_id, v); Lrc::get_mut(map).unwrap().insert(hir_id.local_id, v);
} }
for k in named_region_map.late_bound { for k in named_region_map.late_bound {
let hir_id = tcx.hir.node_to_hir_id(k); let hir_id = tcx.hir().node_to_hir_id(k);
let map = rl.late_bound let map = rl.late_bound
.entry(hir_id.owner_local_def_id()) .entry(hir_id.owner_local_def_id())
.or_default(); .or_default();
Lrc::get_mut(map).unwrap().insert(hir_id.local_id); Lrc::get_mut(map).unwrap().insert(hir_id.local_id);
} }
for (k, v) in named_region_map.object_lifetime_defaults { for (k, v) in named_region_map.object_lifetime_defaults {
let hir_id = tcx.hir.node_to_hir_id(k); let hir_id = tcx.hir().node_to_hir_id(k);
let map = rl.object_lifetime_defaults let map = rl.object_lifetime_defaults
.entry(hir_id.owner_local_def_id()) .entry(hir_id.owner_local_def_id())
.or_default(); .or_default();
@ -423,7 +423,7 @@ fn resolve_lifetimes<'tcx>(
} }
fn krate<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> NamedRegionMap { fn krate<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> NamedRegionMap {
let krate = tcx.hir.krate(); let krate = tcx.hir().krate();
let mut map = NamedRegionMap { let mut map = NamedRegionMap {
defs: Default::default(), defs: Default::default(),
late_bound: Default::default(), late_bound: Default::default(),
@ -460,7 +460,7 @@ fn sub_items_have_self_param(node: &hir::ItemKind) -> bool {
impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.tcx.hir) NestedVisitorMap::All(&self.tcx.hir())
} }
// We want to nest trait/impl items in their parent, but nothing else. // We want to nest trait/impl items in their parent, but nothing else.
@ -469,7 +469,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
fn visit_nested_body(&mut self, body: hir::BodyId) { fn visit_nested_body(&mut self, body: hir::BodyId) {
// Each body has their own set of labels, save labels. // Each body has their own set of labels, save labels.
let saved = replace(&mut self.labels_in_fn, vec![]); let saved = replace(&mut self.labels_in_fn, vec![]);
let body = self.tcx.hir.body(body); let body = self.tcx.hir().body(body);
extract_labels(self, body); extract_labels(self, body);
self.with( self.with(
Scope::Body { Scope::Body {
@ -545,7 +545,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter() .iter()
.filter_map(|param| match param.kind { .filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
Some(Region::early(&self.tcx.hir, &mut index, param)) Some(Region::early(&self.tcx.hir(), &mut index, param))
} }
GenericParamKind::Type { .. } => { GenericParamKind::Type { .. } => {
type_count += 1; type_count += 1;
@ -596,7 +596,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter() .iter()
.filter_map(|param| match param.kind { .filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
Some(Region::late(&self.tcx.hir, param)) Some(Region::late(&self.tcx.hir(), param))
} }
_ => None, _ => None,
}) })
@ -655,7 +655,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
// `abstract type MyAnonTy<'b>: MyTrait<'b>;` // `abstract type MyAnonTy<'b>: MyTrait<'b>;`
// ^ ^ this gets resolved in the scope of // ^ ^ this gets resolved in the scope of
// the exist_ty generics // the exist_ty generics
let (generics, bounds) = match self.tcx.hir.expect_item(item_id.id).node { let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).node {
// named existential types are reached via TyKind::Path // named existential types are reached via TyKind::Path
// this arm is for `impl Trait` in the types of statics, constants and locals // this arm is for `impl Trait` in the types of statics, constants and locals
hir::ItemKind::Existential(hir::ExistTy { hir::ItemKind::Existential(hir::ExistTy {
@ -689,12 +689,12 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
// In the future, this should be fixed and this error should be removed. // In the future, this should be fixed and this error should be removed.
let def = self.map.defs.get(&lifetime.id).cloned(); let def = self.map.defs.get(&lifetime.id).cloned();
if let Some(Region::LateBound(_, def_id, _)) = def { if let Some(Region::LateBound(_, def_id, _)) = def {
if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
// Ensure that the parent of the def is an item, not HRTB // Ensure that the parent of the def is an item, not HRTB
let parent_id = self.tcx.hir.get_parent_node(node_id); let parent_id = self.tcx.hir().get_parent_node(node_id);
let parent_impl_id = hir::ImplItemId { node_id: parent_id }; let parent_impl_id = hir::ImplItemId { node_id: parent_id };
let parent_trait_id = hir::TraitItemId { node_id: parent_id }; let parent_trait_id = hir::TraitItemId { node_id: parent_id };
let krate = self.tcx.hir.forest.krate(); let krate = self.tcx.hir().forest.krate();
if !(krate.items.contains_key(&parent_id) if !(krate.items.contains_key(&parent_id)
|| krate.impl_items.contains_key(&parent_impl_id) || krate.impl_items.contains_key(&parent_impl_id)
|| krate.trait_items.contains_key(&parent_trait_id)) || krate.trait_items.contains_key(&parent_trait_id))
@ -724,7 +724,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
for param in &generics.params { for param in &generics.params {
match param.kind { match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
let (name, reg) = Region::early(&self.tcx.hir, &mut index, &param); let (name, reg) = Region::early(&self.tcx.hir(), &mut index, &param);
if let hir::ParamName::Plain(param_name) = name { if let hir::ParamName::Plain(param_name) = name {
if param_name.name == keywords::UnderscoreLifetime.name() { if param_name.name == keywords::UnderscoreLifetime.name() {
// Pick the elided lifetime "definition" if one exists // Pick the elided lifetime "definition" if one exists
@ -790,7 +790,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
Method(ref sig, _) => { Method(ref sig, _) => {
let tcx = self.tcx; let tcx = self.tcx;
self.visit_early_late( self.visit_early_late(
Some(tcx.hir.get_parent(trait_item.id)), Some(tcx.hir().get_parent(trait_item.id)),
&sig.decl, &sig.decl,
&trait_item.generics, &trait_item.generics,
|this| intravisit::walk_trait_item(this, trait_item), |this| intravisit::walk_trait_item(this, trait_item),
@ -806,7 +806,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter() .iter()
.filter_map(|param| match param.kind { .filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
Some(Region::early(&self.tcx.hir, &mut index, param)) Some(Region::early(&self.tcx.hir(), &mut index, param))
} }
GenericParamKind::Type { .. } => { GenericParamKind::Type { .. } => {
type_count += 1; type_count += 1;
@ -845,7 +845,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
Method(ref sig, _) => { Method(ref sig, _) => {
let tcx = self.tcx; let tcx = self.tcx;
self.visit_early_late( self.visit_early_late(
Some(tcx.hir.get_parent(impl_item.id)), Some(tcx.hir().get_parent(impl_item.id)),
&sig.decl, &sig.decl,
&impl_item.generics, &impl_item.generics,
|this| intravisit::walk_impl_item(this, impl_item), |this| intravisit::walk_impl_item(this, impl_item),
@ -861,7 +861,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter() .iter()
.filter_map(|param| match param.kind { .filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
Some(Region::early(&self.tcx.hir, &mut index, param)) Some(Region::early(&self.tcx.hir(), &mut index, param))
} }
GenericParamKind::Type { .. } => { GenericParamKind::Type { .. } => {
next_early_index += 1; next_early_index += 1;
@ -891,7 +891,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter() .iter()
.filter_map(|param| match param.kind { .filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
Some(Region::early(&self.tcx.hir, &mut index, param)) Some(Region::early(&self.tcx.hir(), &mut index, param))
} }
GenericParamKind::Type { .. } => { GenericParamKind::Type { .. } => {
next_early_index += 1; next_early_index += 1;
@ -976,7 +976,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter() .iter()
.filter_map(|param| match param.kind { .filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
Some(Region::late(&self.tcx.hir, param)) Some(Region::late(&self.tcx.hir(), param))
} }
_ => None, _ => None,
}) })
@ -1051,7 +1051,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter() .iter()
.filter_map(|param| match param.kind { .filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
Some(Region::late(&self.tcx.hir, param)) Some(Region::late(&self.tcx.hir(), param))
} }
_ => None, _ => None,
}) })
@ -1258,12 +1258,12 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
} => { } => {
// FIXME (#24278): non-hygienic comparison // FIXME (#24278): non-hygienic comparison
if let Some(def) = lifetimes.get(&hir::ParamName::Plain(label.modern())) { if let Some(def) = lifetimes.get(&hir::ParamName::Plain(label.modern())) {
let node_id = tcx.hir.as_local_node_id(def.id().unwrap()).unwrap(); let node_id = tcx.hir().as_local_node_id(def.id().unwrap()).unwrap();
signal_shadowing_problem( signal_shadowing_problem(
tcx, tcx,
label.name, label.name,
original_lifetime(tcx.hir.span(node_id)), original_lifetime(tcx.hir().span(node_id)),
shadower_label(label.span), shadower_label(label.span),
); );
return; return;
@ -1279,7 +1279,7 @@ fn compute_object_lifetime_defaults(
tcx: TyCtxt<'_, '_, '_>, tcx: TyCtxt<'_, '_, '_>,
) -> NodeMap<Vec<ObjectLifetimeDefault>> { ) -> NodeMap<Vec<ObjectLifetimeDefault>> {
let mut map = NodeMap::default(); let mut map = NodeMap::default();
for item in tcx.hir.krate().items.values() { for item in tcx.hir().krate().items.values() {
match item.node { match item.node {
hir::ItemKind::Struct(_, ref generics) hir::ItemKind::Struct(_, ref generics)
| hir::ItemKind::Union(_, ref generics) | hir::ItemKind::Union(_, ref generics)
@ -1355,7 +1355,7 @@ fn object_lifetime_defaults_for_item(
add_bounds(&mut set, &param.bounds); add_bounds(&mut set, &param.bounds);
let param_def_id = tcx.hir.local_def_id(param.id); let param_def_id = tcx.hir().local_def_id(param.id);
for predicate in &generics.where_clause.predicates { for predicate in &generics.where_clause.predicates {
// Look for `type: ...` where clauses. // Look for `type: ...` where clauses.
let data = match *predicate { let data = match *predicate {
@ -1399,7 +1399,7 @@ fn object_lifetime_defaults_for_item(
.enumerate() .enumerate()
.find(|&(_, (_, lt_name, _))| lt_name == name) .find(|&(_, (_, lt_name, _))| lt_name == name)
.map_or(Set1::Many, |(i, (id, _, origin))| { .map_or(Set1::Many, |(i, (id, _, origin))| {
let def_id = tcx.hir.local_def_id(id); let def_id = tcx.hir().local_def_id(id);
Set1::One(Region::EarlyBound(i as u32, def_id, origin)) Set1::One(Region::EarlyBound(i as u32, def_id, origin))
}) })
} }
@ -1492,7 +1492,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let name = lifetime.name.ident(); let name = lifetime.name.ident();
let mut remove_decl = None; let mut remove_decl = None;
if let Some(parent_def_id) = self.tcx.parent(def_id) { if let Some(parent_def_id) = self.tcx.parent(def_id) {
if let Some(generics) = self.tcx.hir.get_generics(parent_def_id) { if let Some(generics) = self.tcx.hir().get_generics(parent_def_id) {
remove_decl = self.lifetime_deletion_span(name, generics); remove_decl = self.lifetime_deletion_span(name, generics);
} }
} }
@ -1513,8 +1513,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
} }
} }
}; };
if let Node::Lifetime(hir_lifetime) = self.tcx.hir.get(lifetime.id) { if let Node::Lifetime(hir_lifetime) = self.tcx.hir().get(lifetime.id) {
if let Some(parent) = self.tcx.hir.find(self.tcx.hir.get_parent(hir_lifetime.id)) { if let Some(parent) = self.tcx.hir().find(self.tcx.hir().get_parent(hir_lifetime.id)) {
match parent { match parent {
Node::Item(item) => { Node::Item(item) => {
if let hir::ItemKind::Fn(decl, _, _, _) = &item.node { if let hir::ItemKind::Fn(decl, _, _, _) = &item.node {
@ -1590,9 +1590,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
match lifetimeuseset { match lifetimeuseset {
Some(LifetimeUseSet::One(lifetime)) => { Some(LifetimeUseSet::One(lifetime)) => {
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = self.tcx.hir().as_local_node_id(def_id).unwrap();
debug!("node id first={:?}", node_id); debug!("node id first={:?}", node_id);
if let Some((id, span, name)) = match self.tcx.hir.get(node_id) { if let Some((id, span, name)) = match self.tcx.hir().get(node_id) {
Node::Lifetime(hir_lifetime) => Some(( Node::Lifetime(hir_lifetime) => Some((
hir_lifetime.id, hir_lifetime.id,
hir_lifetime.span, hir_lifetime.span,
@ -1631,8 +1631,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
debug!("Not one use lifetime"); debug!("Not one use lifetime");
} }
None => { None => {
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = self.tcx.hir().as_local_node_id(def_id).unwrap();
if let Some((id, span, name)) = match self.tcx.hir.get(node_id) { if let Some((id, span, name)) = match self.tcx.hir().get(node_id) {
Node::Lifetime(hir_lifetime) => Some(( Node::Lifetime(hir_lifetime) => Some((
hir_lifetime.id, hir_lifetime.id,
hir_lifetime.span, hir_lifetime.span,
@ -1651,7 +1651,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
&format!("lifetime parameter `{}` never used", name), &format!("lifetime parameter `{}` never used", name),
); );
if let Some(parent_def_id) = self.tcx.parent(def_id) { if let Some(parent_def_id) = self.tcx.parent(def_id) {
if let Some(generics) = self.tcx.hir.get_generics(parent_def_id) { if let Some(generics) = self.tcx.hir().get_generics(parent_def_id) {
let unused_lt_span = self.lifetime_deletion_span(name, generics); let unused_lt_span = self.lifetime_deletion_span(name, generics);
if let Some(span) = unused_lt_span { if let Some(span) = unused_lt_span {
err.span_suggestion_with_applicability( err.span_suggestion_with_applicability(
@ -1702,7 +1702,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
// Find the start of nested early scopes, e.g. in methods. // Find the start of nested early scopes, e.g. in methods.
let mut index = 0; let mut index = 0;
if let Some(parent_id) = parent_id { if let Some(parent_id) = parent_id {
let parent = self.tcx.hir.expect_item(parent_id); let parent = self.tcx.hir().expect_item(parent_id);
if sub_items_have_self_param(&parent.node) { if sub_items_have_self_param(&parent.node) {
index += 1; // Self comes before lifetimes index += 1; // Self comes before lifetimes
} }
@ -1722,9 +1722,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
.filter_map(|param| match param.kind { .filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
if self.map.late_bound.contains(&param.id) { if self.map.late_bound.contains(&param.id) {
Some(Region::late(&self.tcx.hir, param)) Some(Region::late(&self.tcx.hir(), param))
} else { } else {
Some(Region::early(&self.tcx.hir, &mut index, param)) Some(Region::early(&self.tcx.hir(), &mut index, param))
} }
} }
GenericParamKind::Type { .. } => { GenericParamKind::Type { .. } => {
@ -1837,8 +1837,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
if let Region::EarlyBound(..) = def { if let Region::EarlyBound(..) = def {
// Do not free early-bound regions, only late-bound ones. // Do not free early-bound regions, only late-bound ones.
} else if let Some(body_id) = outermost_body { } else if let Some(body_id) = outermost_body {
let fn_id = self.tcx.hir.body_owner(body_id); let fn_id = self.tcx.hir().body_owner(body_id);
match self.tcx.hir.get(fn_id) { match self.tcx.hir().get(fn_id) {
Node::Item(&hir::Item { Node::Item(&hir::Item {
node: hir::ItemKind::Fn(..), node: hir::ItemKind::Fn(..),
.. ..
@ -1851,7 +1851,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
node: hir::ImplItemKind::Method(..), node: hir::ImplItemKind::Method(..),
.. ..
}) => { }) => {
let scope = self.tcx.hir.local_def_id(fn_id); let scope = self.tcx.hir().local_def_id(fn_id);
def = Region::Free(scope, def.id().unwrap()); def = Region::Free(scope, def.id().unwrap());
} }
_ => {} _ => {}
@ -1967,7 +1967,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}; };
let map = &self.map; let map = &self.map;
let unsubst = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) { let unsubst = if let Some(id) = self.tcx.hir().as_local_node_id(def_id) {
&map.object_lifetime_defaults[&id] &map.object_lifetime_defaults[&id]
} else { } else {
let tcx = self.tcx; let tcx = self.tcx;
@ -2061,8 +2061,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
// and whether there's a `self` argument (treated specially). // and whether there's a `self` argument (treated specially).
let mut assoc_item_kind = None; let mut assoc_item_kind = None;
let mut impl_self = None; let mut impl_self = None;
let parent = self.tcx.hir.get_parent_node(output.id); let parent = self.tcx.hir().get_parent_node(output.id);
let body = match self.tcx.hir.get(parent) { let body = match self.tcx.hir().get(parent) {
// `fn` definitions and methods. // `fn` definitions and methods.
Node::Item(&hir::Item { Node::Item(&hir::Item {
node: hir::ItemKind::Fn(.., body), node: hir::ItemKind::Fn(.., body),
@ -2074,8 +2074,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
.. ..
}) => { }) => {
if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx
.hir .hir()
.expect_item(self.tcx.hir.get_parent(parent)) .expect_item(self.tcx.hir().get_parent(parent))
.node .node
{ {
assoc_item_kind = trait_items assoc_item_kind = trait_items
@ -2094,8 +2094,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
.. ..
}) => { }) => {
if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx
.hir .hir()
.expect_item(self.tcx.hir.get_parent(parent)) .expect_item(self.tcx.hir().get_parent(parent))
.node .node
{ {
impl_self = Some(self_ty); impl_self = Some(self_ty);
@ -2396,8 +2396,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
} = info; } = info;
let help_name = if let Some(body) = parent { let help_name = if let Some(body) = parent {
let arg = &self.tcx.hir.body(body).arguments[index]; let arg = &self.tcx.hir().body(body).arguments[index];
format!("`{}`", self.tcx.hir.node_to_pretty_string(arg.pat.id)) format!("`{}`", self.tcx.hir().node_to_pretty_string(arg.pat.id))
} else { } else {
format!("argument {}", index + 1) format!("argument {}", index + 1)
}; };
@ -2603,12 +2603,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
ref lifetimes, s, .. ref lifetimes, s, ..
} => { } => {
if let Some(&def) = lifetimes.get(&param.name.modern()) { if let Some(&def) = lifetimes.get(&param.name.modern()) {
let node_id = self.tcx.hir.as_local_node_id(def.id().unwrap()).unwrap(); let node_id = self.tcx.hir().as_local_node_id(def.id().unwrap()).unwrap();
signal_shadowing_problem( signal_shadowing_problem(
self.tcx, self.tcx,
param.name.ident().name, param.name.ident().name,
original_lifetime(self.tcx.hir.span(node_id)), original_lifetime(self.tcx.hir().span(node_id)),
shadower_lifetime(&param), shadower_lifetime(&param),
); );
return; return;
@ -2675,7 +2675,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
debug!( debug!(
"insert_lifetime: {} resolved to {:?} span={:?}", "insert_lifetime: {} resolved to {:?} span={:?}",
self.tcx.hir.node_to_string(lifetime_ref.id), self.tcx.hir().node_to_string(lifetime_ref.id),
def, def,
self.tcx.sess.source_map().span_to_string(lifetime_ref.span) self.tcx.sess.source_map().span_to_string(lifetime_ref.span)
); );

View file

@ -188,7 +188,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
} }
} }
let hir_id = self.tcx.hir.node_to_hir_id(id); let hir_id = self.tcx.hir().node_to_hir_id(id);
self.index.stab_map.insert(hir_id, stab); self.index.stab_map.insert(hir_id, stab);
let orig_parent_stab = replace(&mut self.parent_stab, Some(stab)); let orig_parent_stab = replace(&mut self.parent_stab, Some(stab));
@ -198,7 +198,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
debug!("annotate: not found, parent = {:?}", self.parent_stab); debug!("annotate: not found, parent = {:?}", self.parent_stab);
if let Some(stab) = self.parent_stab { if let Some(stab) = self.parent_stab {
if stab.level.is_unstable() { if stab.level.is_unstable() {
let hir_id = self.tcx.hir.node_to_hir_id(id); let hir_id = self.tcx.hir().node_to_hir_id(id);
self.index.stab_map.insert(hir_id, stab); self.index.stab_map.insert(hir_id, stab);
} }
} }
@ -219,7 +219,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
// -Zforce-unstable-if-unmarked is set. // -Zforce-unstable-if-unmarked is set.
if let Some(stab) = self.parent_stab { if let Some(stab) = self.parent_stab {
if stab.level.is_unstable() { if stab.level.is_unstable() {
let hir_id = self.tcx.hir.node_to_hir_id(id); let hir_id = self.tcx.hir().node_to_hir_id(id);
self.index.stab_map.insert(hir_id, stab); self.index.stab_map.insert(hir_id, stab);
} }
} }
@ -230,7 +230,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
} }
// `Deprecation` is just two pointers, no need to intern it // `Deprecation` is just two pointers, no need to intern it
let hir_id = self.tcx.hir.node_to_hir_id(id); let hir_id = self.tcx.hir().node_to_hir_id(id);
let depr_entry = DeprecationEntry::local(depr, hir_id); let depr_entry = DeprecationEntry::local(depr, hir_id);
self.index.depr_map.insert(hir_id, depr_entry.clone()); self.index.depr_map.insert(hir_id, depr_entry.clone());
@ -239,7 +239,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
visit_children(self); visit_children(self);
self.parent_depr = orig_parent_depr; self.parent_depr = orig_parent_depr;
} else if let Some(parent_depr) = self.parent_depr.clone() { } else if let Some(parent_depr) = self.parent_depr.clone() {
let hir_id = self.tcx.hir.node_to_hir_id(id); let hir_id = self.tcx.hir().node_to_hir_id(id);
self.index.depr_map.insert(hir_id, parent_depr); self.index.depr_map.insert(hir_id, parent_depr);
visit_children(self); visit_children(self);
} else { } else {
@ -254,7 +254,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
/// nested items in the context of the outer item, so enable /// nested items in the context of the outer item, so enable
/// deep-walking. /// deep-walking.
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.tcx.hir) NestedVisitorMap::All(&self.tcx.hir())
} }
fn visit_item(&mut self, i: &'tcx Item) { fn visit_item(&mut self, i: &'tcx Item) {
@ -333,7 +333,7 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> { impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
fn check_missing_stability(&self, id: NodeId, span: Span) { fn check_missing_stability(&self, id: NodeId, span: Span) {
let hir_id = self.tcx.hir.node_to_hir_id(id); let hir_id = self.tcx.hir().node_to_hir_id(id);
let stab = self.tcx.stability().local_stability(hir_id); let stab = self.tcx.stability().local_stability(hir_id);
let is_error = !self.tcx.sess.opts.test && let is_error = !self.tcx.sess.opts.test &&
stab.is_none() && stab.is_none() &&
@ -346,7 +346,7 @@ impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
fn visit_item(&mut self, i: &'tcx Item) { fn visit_item(&mut self, i: &'tcx Item) {
@ -369,7 +369,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
} }
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) { fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
let impl_def_id = self.tcx.hir.local_def_id(self.tcx.hir.get_parent(ii.id)); let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent(ii.id));
if self.tcx.impl_trait_ref(impl_def_id).is_none() { if self.tcx.impl_trait_ref(impl_def_id).is_none() {
self.check_missing_stability(ii.id, ii.span); self.check_missing_stability(ii.id, ii.span);
} }
@ -416,7 +416,7 @@ impl<'a, 'tcx> Index<'tcx> {
index.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect(); index.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect();
{ {
let krate = tcx.hir.krate(); let krate = tcx.hir().krate();
let mut annotator = Annotator { let mut annotator = Annotator {
tcx, tcx,
index: &mut index, index: &mut index,
@ -470,7 +470,7 @@ impl<'a, 'tcx> Index<'tcx> {
/// features and possibly prints errors. /// features and possibly prints errors.
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut checker = Checker { tcx }; let mut checker = Checker { tcx };
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor()); tcx.hir().krate().visit_all_item_likes(&mut checker.as_deep_visitor());
} }
/// Check whether an item marked with `deprecated(since="X")` is currently /// Check whether an item marked with `deprecated(since="X")` is currently
@ -591,7 +591,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
false false
}; };
let parent_def_id = self.hir.local_def_id(self.hir.get_parent(id)); let parent_def_id = self.hir().local_def_id(self.hir().get_parent(id));
let skip = deprecated_in_future_version || let skip = deprecated_in_future_version ||
self.lookup_deprecation_entry(parent_def_id) self.lookup_deprecation_entry(parent_def_id)
.map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry)); .map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry));
@ -717,7 +717,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
/// nested items in the context of the outer item, so enable /// nested items in the context of the outer item, so enable
/// deep-walking. /// deep-walking.
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
fn visit_item(&mut self, item: &'tcx hir::Item) { fn visit_item(&mut self, item: &'tcx hir::Item) {
@ -726,7 +726,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
// compiler-generated `extern crate` items have a dummy span. // compiler-generated `extern crate` items have a dummy span.
if item.span.is_dummy() { return } if item.span.is_dummy() { return }
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
let cnum = match self.tcx.extern_mod_stmt_cnum(def_id) { let cnum = match self.tcx.extern_mod_stmt_cnum(def_id) {
Some(cnum) => cnum, Some(cnum) => cnum,
None => return, None => return,
@ -741,7 +741,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
hir::ItemKind::Impl(.., Some(ref t), _, ref impl_item_refs) => { hir::ItemKind::Impl(.., Some(ref t), _, ref impl_item_refs) => {
if let Def::Trait(trait_did) = t.path.def { if let Def::Trait(trait_did) = t.path.def {
for impl_item_ref in impl_item_refs { for impl_item_ref in impl_item_refs {
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
let trait_item_def_id = self.tcx.associated_items(trait_did) let trait_item_def_id = self.tcx.associated_items(trait_did)
.find(|item| item.ident.name == impl_item.ident.name) .find(|item| item.ident.name == impl_item.ident.name)
.map(|item| item.def_id); .map(|item| item.def_id);
@ -756,7 +756,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
// There's no good place to insert stability check for non-Copy unions, // There's no good place to insert stability check for non-Copy unions,
// so semi-randomly perform it here in stability.rs // so semi-randomly perform it here in stability.rs
hir::ItemKind::Union(..) if !self.tcx.features().untagged_unions => { hir::ItemKind::Union(..) if !self.tcx.features().untagged_unions => {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
let adt_def = self.tcx.adt_def(def_id); let adt_def = self.tcx.adt_def(def_id);
let ty = self.tcx.type_of(def_id); let ty = self.tcx.type_of(def_id);
@ -780,7 +780,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
} }
fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) { fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) {
let id = self.tcx.hir.hir_to_node_id(id); let id = self.tcx.hir().hir_to_node_id(id);
if let Some(def_id) = path.def.opt_def_id() { if let Some(def_id) = path.def.opt_def_id() {
self.tcx.check_stability(def_id, Some(id), path.span) self.tcx.check_stability(def_id, Some(id), path.span)
} }
@ -801,7 +801,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
if tcx.stability().staged_api[&LOCAL_CRATE] { if tcx.stability().staged_api[&LOCAL_CRATE] {
let krate = tcx.hir.krate(); let krate = tcx.hir().krate();
let mut missing = MissingStabilityAnnotations { let mut missing = MissingStabilityAnnotations {
tcx, tcx,
access_levels, access_levels,

View file

@ -49,7 +49,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
{ {
let mut cx = Context { tcx, items }; let mut cx = Context { tcx, items };
tcx.hir.krate().visit_all_item_likes(&mut cx.as_deep_visitor()); tcx.hir().krate().visit_all_item_likes(&mut cx.as_deep_visitor());
} }
verify(tcx, items); verify(tcx, items);
} }

View file

@ -2376,17 +2376,17 @@ impl<'tcx> Debug for Rvalue<'tcx> {
} }
AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| { AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
let name = if tcx.sess.opts.debugging_opts.span_free_formats { let name = if tcx.sess.opts.debugging_opts.span_free_formats {
format!("[closure@{:?}]", node_id) format!("[closure@{:?}]", node_id)
} else { } else {
format!("[closure@{:?}]", tcx.hir.span(node_id)) format!("[closure@{:?}]", tcx.hir().span(node_id))
}; };
let mut struct_fmt = fmt.debug_struct(&name); let mut struct_fmt = fmt.debug_struct(&name);
tcx.with_freevars(node_id, |freevars| { tcx.with_freevars(node_id, |freevars| {
for (freevar, place) in freevars.iter().zip(places) { for (freevar, place) in freevars.iter().zip(places) {
let var_name = tcx.hir.name(freevar.var_id()); let var_name = tcx.hir().name(freevar.var_id());
struct_fmt.field(&var_name.as_str(), place); struct_fmt.field(&var_name.as_str(), place);
} }
}); });
@ -2398,13 +2398,13 @@ impl<'tcx> Debug for Rvalue<'tcx> {
}), }),
AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| { AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
let name = format!("[generator@{:?}]", tcx.hir.span(node_id)); let name = format!("[generator@{:?}]", tcx.hir().span(node_id));
let mut struct_fmt = fmt.debug_struct(&name); let mut struct_fmt = fmt.debug_struct(&name);
tcx.with_freevars(node_id, |freevars| { tcx.with_freevars(node_id, |freevars| {
for (freevar, place) in freevars.iter().zip(places) { for (freevar, place) in freevars.iter().zip(places) {
let var_name = tcx.hir.name(freevar.var_id()); let var_name = tcx.hir().name(freevar.var_id());
struct_fmt.field(&var_name.as_str(), place); struct_fmt.field(&var_name.as_str(), place);
} }
struct_fmt.field("$state", &places[freevars.len()]); struct_fmt.field("$state", &places[freevars.len()]);

View file

@ -580,7 +580,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg); let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg);
if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) { if let Some(trait_item_span) = self.tcx.hir().span_if_local(trait_item_def_id) {
let span = self.tcx.sess.source_map().def_span(trait_item_span); let span = self.tcx.sess.source_map().def_span(trait_item_span);
err.span_label(span, format!("definition of `{}` from trait", item_name)); err.span_label(span, format!("definition of `{}` from trait", item_name));
} }
@ -765,8 +765,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => { ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
let found_kind = self.closure_kind(closure_def_id, closure_substs).unwrap(); let found_kind = self.closure_kind(closure_def_id, closure_substs).unwrap();
let closure_span = self.tcx.sess.source_map() let closure_span = self.tcx.sess.source_map()
.def_span(self.tcx.hir.span_if_local(closure_def_id).unwrap()); .def_span(self.tcx.hir().span_if_local(closure_def_id).unwrap());
let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap(); let node_id = self.tcx.hir().as_local_node_id(closure_def_id).unwrap();
let mut err = struct_span_err!( let mut err = struct_span_err!(
self.tcx.sess, closure_span, E0525, self.tcx.sess, closure_span, E0525,
"expected a closure that implements the `{}` trait, \ "expected a closure that implements the `{}` trait, \
@ -785,7 +785,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// a particular trait. // a particular trait.
if let Some(tables) = self.in_progress_tables { if let Some(tables) = self.in_progress_tables {
let tables = tables.borrow(); let tables = tables.borrow();
let closure_hir_id = self.tcx.hir.node_to_hir_id(node_id); let closure_hir_id = self.tcx.hir().node_to_hir_id(node_id);
match (found_kind, tables.closure_kind_origins().get(closure_hir_id)) { match (found_kind, tables.closure_kind_origins().get(closure_hir_id)) {
(ty::ClosureKind::FnOnce, Some((span, name))) => { (ty::ClosureKind::FnOnce, Some((span, name))) => {
err.span_label(*span, format!( err.span_label(*span, format!(
@ -841,7 +841,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}; };
let found_span = found_did.and_then(|did| let found_span = found_did.and_then(|did|
self.tcx.hir.span_if_local(did) self.tcx.hir().span_if_local(did)
).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def ).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def
let found = match found_trait_ref.skip_binder().substs.type_at(1).sty { let found = match found_trait_ref.skip_binder().substs.type_at(1).sty {
@ -862,7 +862,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
expected_trait_ref) expected_trait_ref)
} else { } else {
let (closure_span, found) = found_did let (closure_span, found) = found_did
.and_then(|did| self.tcx.hir.get_if_local(did)) .and_then(|did| self.tcx.hir().get_if_local(did))
.map(|node| { .map(|node| {
let (found_span, found) = self.get_fn_like_arguments(node); let (found_span, found) = self.get_fn_like_arguments(node);
(Some(found_span), found) (Some(found_span), found)
@ -901,8 +901,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
code: &ObligationCauseCode<'tcx>, code: &ObligationCauseCode<'tcx>,
err: &mut DiagnosticBuilder<'tcx>) { err: &mut DiagnosticBuilder<'tcx>) {
if let &ObligationCauseCode::VariableType(node_id) = code { if let &ObligationCauseCode::VariableType(node_id) = code {
let parent_node = self.tcx.hir.get_parent_node(node_id); let parent_node = self.tcx.hir().get_parent_node(node_id);
if let Some(Node::Local(ref local)) = self.tcx.hir.find(parent_node) { if let Some(Node::Local(ref local)) = self.tcx.hir().find(parent_node) {
if let Some(ref expr) = local.init { if let Some(ref expr) = local.init {
if let hir::ExprKind::Index(_, _) = expr.node { if let hir::ExprKind::Index(_, _) = expr.node {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
@ -976,7 +976,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
node: hir::ExprKind::Closure(_, ref _decl, id, span, _), node: hir::ExprKind::Closure(_, ref _decl, id, span, _),
.. ..
}) => { }) => {
(self.tcx.sess.source_map().def_span(span), self.tcx.hir.body(id).arguments.iter() (self.tcx.sess.source_map().def_span(span), self.tcx.hir().body(id).arguments.iter()
.map(|arg| { .map(|arg| {
if let hir::Pat { if let hir::Pat {
node: hir::PatKind::Tuple(args, _), node: hir::PatKind::Tuple(args, _),
@ -1037,7 +1037,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
).collect::<Vec<_>>()) ).collect::<Vec<_>>())
} }
Node::StructCtor(ref variant_data) => { Node::StructCtor(ref variant_data) => {
(self.tcx.sess.source_map().def_span(self.tcx.hir.span(variant_data.id())), (self.tcx.sess.source_map().def_span(self.tcx.hir().span(variant_data.id())),
vec![ArgKind::empty(); variant_data.fields().len()]) vec![ArgKind::empty(); variant_data.fields().len()])
} }
_ => panic!("non-FnLike node found: {:?}", node), _ => panic!("non-FnLike node found: {:?}", node),
@ -1236,7 +1236,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
-> DiagnosticBuilder<'tcx> -> DiagnosticBuilder<'tcx>
{ {
assert!(type_def_id.is_local()); assert!(type_def_id.is_local());
let span = self.hir.span_if_local(type_def_id).unwrap(); let span = self.hir().span_if_local(type_def_id).unwrap();
let span = self.sess.source_map().def_span(span); let span = self.sess.source_map().def_span(span);
let mut err = struct_span_err!(self.sess, span, E0072, let mut err = struct_span_err!(self.sess, span, E0072,
"recursive type `{}` has infinite size", "recursive type `{}` has infinite size",
@ -1482,7 +1482,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let item_name = tcx.item_path_str(item_def_id); let item_name = tcx.item_path_str(item_def_id);
let msg = format!("required by `{}`", item_name); let msg = format!("required by `{}`", item_name);
if let Some(sp) = tcx.hir.span_if_local(item_def_id) { if let Some(sp) = tcx.hir().span_if_local(item_def_id) {
let sp = tcx.sess.source_map().def_span(sp); let sp = tcx.sess.source_map().def_span(sp);
err.span_note(sp, &msg); err.span_note(sp, &msg);
} else { } else {

View file

@ -337,7 +337,7 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
let mut err = if used_to_be_allowed { let mut err = if used_to_be_allowed {
tcx.struct_span_lint_node( tcx.struct_span_lint_node(
lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS, lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS,
tcx.hir.as_local_node_id(impl_def_id).unwrap(), tcx.hir().as_local_node_id(impl_def_id).unwrap(),
impl_span, impl_span,
&msg) &msg)
} else { } else {

View file

@ -535,9 +535,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
pub fn impl_is_default(self, node_item_def_id: DefId) -> bool { pub fn impl_is_default(self, node_item_def_id: DefId) -> bool {
match self.hir.as_local_node_id(node_item_def_id) { match self.hir().as_local_node_id(node_item_def_id) {
Some(node_id) => { Some(node_id) => {
let item = self.hir.expect_item(node_id); let item = self.hir().expect_item(node_id);
if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node { if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node {
defaultness.is_default() defaultness.is_default()
} else { } else {

View file

@ -67,10 +67,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
/// only checks whether the function has a `const` modifier /// only checks whether the function has a `const` modifier
fn is_const_fn_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool { fn is_const_fn_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
let node_id = tcx.hir.as_local_node_id(def_id) let node_id = tcx.hir().as_local_node_id(def_id)
.expect("Non-local call to local provider is_const_fn"); .expect("Non-local call to local provider is_const_fn");
if let Some(fn_like) = FnLikeNode::from_node(tcx.hir.get(node_id)) { if let Some(fn_like) = FnLikeNode::from_node(tcx.hir().get(node_id)) {
fn_like.constness() == hir::Constness::Const fn_like.constness() == hir::Constness::Const
} else { } else {
false false

View file

@ -250,11 +250,11 @@ fn validate_hir_id_for_typeck_tables(local_id_root: Option<DefId>,
if let Some(local_id_root) = local_id_root { if let Some(local_id_root) = local_id_root {
if hir_id.owner != local_id_root.index { if hir_id.owner != local_id_root.index {
ty::tls::with(|tcx| { ty::tls::with(|tcx| {
let node_id = tcx.hir.hir_to_node_id(hir_id); let node_id = tcx.hir().hir_to_node_id(hir_id);
bug!("node {} with HirId::owner {:?} cannot be placed in \ bug!("node {} with HirId::owner {:?} cannot be placed in \
TypeckTables with local_id_root {:?}", TypeckTables with local_id_root {:?}",
tcx.hir.node_to_string(node_id), tcx.hir().node_to_string(node_id),
DefId::local(hir_id.owner), DefId::local(hir_id.owner),
local_id_root) local_id_root)
}); });
@ -530,8 +530,8 @@ impl<'tcx> TypeckTables<'tcx> {
self.node_id_to_type_opt(id).unwrap_or_else(|| self.node_id_to_type_opt(id).unwrap_or_else(||
bug!("node_id_to_type: no type for node `{}`", bug!("node_id_to_type: no type for node `{}`",
tls::with(|tcx| { tls::with(|tcx| {
let id = tcx.hir.hir_to_node_id(id); let id = tcx.hir().hir_to_node_id(id);
tcx.hir.node_to_string(id) tcx.hir().node_to_string(id)
})) }))
) )
} }
@ -903,7 +903,7 @@ pub struct GlobalCtxt<'tcx> {
/// Export map produced by name resolution. /// Export map produced by name resolution.
export_map: FxHashMap<DefId, Lrc<Vec<Export>>>, export_map: FxHashMap<DefId, Lrc<Vec<Export>>>,
pub hir: hir_map::Map<'tcx>, hir_map: hir_map::Map<'tcx>,
/// A map from DefPathHash -> DefId. Includes DefIds from the local crate /// A map from DefPathHash -> DefId. Includes DefIds from the local crate
/// as well as all upstream crates. Only populated in incremental mode. /// as well as all upstream crates. Only populated in incremental mode.
@ -971,6 +971,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
} }
#[inline(always)]
pub fn hir(self) -> &'a hir_map::Map<'gcx> {
&self.hir_map
}
pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics { pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics {
self.global_arenas.generics.alloc(generics) self.global_arenas.generics.alloc(generics)
} }
@ -1186,7 +1191,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
.map(|(id, sp)| (hir.local_def_id(id), sp)) .map(|(id, sp)| (hir.local_def_id(id), sp))
.collect(), .collect(),
extern_prelude: resolutions.extern_prelude, extern_prelude: resolutions.extern_prelude,
hir, hir_map: hir,
def_path_hash_to_def_id, def_path_hash_to_def_id,
queries: query::Queries::new( queries: query::Queries::new(
providers, providers,
@ -1272,7 +1277,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn def_key(self, id: DefId) -> hir_map::DefKey { pub fn def_key(self, id: DefId) -> hir_map::DefKey {
if id.is_local() { if id.is_local() {
self.hir.def_key(id) self.hir().def_key(id)
} else { } else {
self.cstore.def_key(id) self.cstore.def_key(id)
} }
@ -1285,7 +1290,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// be a non-local `DefPath`. /// be a non-local `DefPath`.
pub fn def_path(self, id: DefId) -> hir_map::DefPath { pub fn def_path(self, id: DefId) -> hir_map::DefPath {
if id.is_local() { if id.is_local() {
self.hir.def_path(id) self.hir().def_path(id)
} else { } else {
self.cstore.def_path(id) self.cstore.def_path(id)
} }
@ -1294,7 +1299,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
#[inline] #[inline]
pub fn def_path_hash(self, def_id: DefId) -> hir_map::DefPathHash { pub fn def_path_hash(self, def_id: DefId) -> hir_map::DefPathHash {
if def_id.is_local() { if def_id.is_local() {
self.hir.definitions().def_path_hash(def_id.index) self.hir().definitions().def_path_hash(def_id.index)
} else { } else {
self.cstore.def_path_hash(def_id) self.cstore.def_path_hash(def_id)
} }
@ -1332,11 +1337,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
pub fn create_stable_hashing_context(self) -> StableHashingContext<'a> { pub fn create_stable_hashing_context(self) -> StableHashingContext<'a> {
let krate = self.dep_graph.with_ignore(|| self.gcx.hir.krate()); let krate = self.dep_graph.with_ignore(|| self.hir().krate());
StableHashingContext::new(self.sess, StableHashingContext::new(self.sess,
krate, krate,
self.hir.definitions(), self.hir().definitions(),
self.cstore) self.cstore)
} }
@ -1524,10 +1529,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
_ => return None, // not a free region _ => return None, // not a free region
}; };
let node_id = self.hir let node_id = self.hir()
.as_local_node_id(suitable_region_binding_scope) .as_local_node_id(suitable_region_binding_scope)
.unwrap(); .unwrap();
let is_impl_item = match self.hir.find(node_id) { let is_impl_item = match self.hir().find(node_id) {
Some(Node::Item(..)) | Some(Node::TraitItem(..)) => false, Some(Node::Item(..)) | Some(Node::TraitItem(..)) => false,
Some(Node::ImplItem(..)) => { Some(Node::ImplItem(..)) => {
self.is_bound_region_in_impl_item(suitable_region_binding_scope) self.is_bound_region_in_impl_item(suitable_region_binding_scope)
@ -1547,8 +1552,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
scope_def_id: DefId, scope_def_id: DefId,
) -> Option<Ty<'tcx>> { ) -> Option<Ty<'tcx>> {
// HACK: `type_of_def_id()` will fail on these (#55796), so return None // HACK: `type_of_def_id()` will fail on these (#55796), so return None
let node_id = self.hir.as_local_node_id(scope_def_id).unwrap(); let node_id = self.hir().as_local_node_id(scope_def_id).unwrap();
match self.hir.get(node_id) { match self.hir().get(node_id) {
Node::Item(item) => { Node::Item(item) => {
match item.node { match item.node {
ItemKind::Fn(..) => { /* type_of_def_id() will work */ } ItemKind::Fn(..) => { /* type_of_def_id() will work */ }
@ -2895,11 +2900,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self.dep_graph.with_ignore(|| { self.dep_graph.with_ignore(|| {
let sets = self.lint_levels(LOCAL_CRATE); let sets = self.lint_levels(LOCAL_CRATE);
loop { loop {
let hir_id = self.hir.definitions().node_to_hir_id(id); let hir_id = self.hir().definitions().node_to_hir_id(id);
if let Some(pair) = sets.level_and_source(lint, hir_id, self.sess) { if let Some(pair) = sets.level_and_source(lint, hir_id, self.sess) {
return pair return pair
} }
let next = self.hir.get_parent_node(id); let next = self.hir().get_parent_node(id);
if next == id { if next == id {
bug!("lint traversal reached the root of the crate"); bug!("lint traversal reached the root of the crate");
} }
@ -2915,7 +2920,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
msg: &str) msg: &str)
-> DiagnosticBuilder<'tcx> -> DiagnosticBuilder<'tcx>
{ {
let node_id = self.hir.hir_to_node_id(hir_id); let node_id = self.hir().hir_to_node_id(hir_id);
let (level, src) = self.lint_level_at_node(lint, node_id); let (level, src) = self.lint_level_at_node(lint, node_id);
lint::struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg) lint::struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg)
} }
@ -3039,16 +3044,16 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
}; };
providers.lookup_stability = |tcx, id| { providers.lookup_stability = |tcx, id| {
assert_eq!(id.krate, LOCAL_CRATE); assert_eq!(id.krate, LOCAL_CRATE);
let id = tcx.hir.definitions().def_index_to_hir_id(id.index); let id = tcx.hir().definitions().def_index_to_hir_id(id.index);
tcx.stability().local_stability(id) tcx.stability().local_stability(id)
}; };
providers.lookup_deprecation_entry = |tcx, id| { providers.lookup_deprecation_entry = |tcx, id| {
assert_eq!(id.krate, LOCAL_CRATE); assert_eq!(id.krate, LOCAL_CRATE);
let id = tcx.hir.definitions().def_index_to_hir_id(id.index); let id = tcx.hir().definitions().def_index_to_hir_id(id.index);
tcx.stability().local_deprecation_entry(id) tcx.stability().local_deprecation_entry(id)
}; };
providers.extern_mod_stmt_cnum = |tcx, id| { providers.extern_mod_stmt_cnum = |tcx, id| {
let id = tcx.hir.as_local_node_id(id).unwrap(); let id = tcx.hir().as_local_node_id(id).unwrap();
tcx.cstore.extern_mod_stmt_cnum_untracked(id) tcx.cstore.extern_mod_stmt_cnum_untracked(id)
}; };
providers.all_crate_nums = |tcx, cnum| { providers.all_crate_nums = |tcx, cnum| {
@ -3069,10 +3074,10 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
}; };
providers.is_panic_runtime = |tcx, cnum| { providers.is_panic_runtime = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE); assert_eq!(cnum, LOCAL_CRATE);
attr::contains_name(tcx.hir.krate_attrs(), "panic_runtime") attr::contains_name(tcx.hir().krate_attrs(), "panic_runtime")
}; };
providers.is_compiler_builtins = |tcx, cnum| { providers.is_compiler_builtins = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE); assert_eq!(cnum, LOCAL_CRATE);
attr::contains_name(tcx.hir.krate_attrs(), "compiler_builtins") attr::contains_name(tcx.hir().krate_attrs(), "compiler_builtins")
}; };
} }

View file

@ -43,7 +43,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest {
/// crate. /// crate.
#[inline] #[inline]
pub fn full(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest { pub fn full(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest {
let crate_id = tcx.hir.local_def_id(CRATE_NODE_ID); let crate_id = tcx.hir().local_def_id(CRATE_NODE_ID);
DefIdForest::from_id(crate_id) DefIdForest::from_id(crate_id)
} }

View file

@ -83,7 +83,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Returns a string identifying this local node-id. /// Returns a string identifying this local node-id.
pub fn node_path_str(self, id: ast::NodeId) -> String { pub fn node_path_str(self, id: ast::NodeId) -> String {
self.item_path_str(self.hir.local_def_id(id)) self.item_path_str(self.hir().local_def_id(id))
} }
/// Returns a string identifying this def-id. This string is /// Returns a string identifying this def-id. This string is
@ -464,8 +464,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// only occur very early in the compiler pipeline. // only occur very early in the compiler pipeline.
let parent_def_id = self.parent_def_id(impl_def_id).unwrap(); let parent_def_id = self.parent_def_id(impl_def_id).unwrap();
self.push_item_path(buffer, parent_def_id, pushed_prelude_crate); self.push_item_path(buffer, parent_def_id, pushed_prelude_crate);
let node_id = self.hir.as_local_node_id(impl_def_id).unwrap(); let node_id = self.hir().as_local_node_id(impl_def_id).unwrap();
let item = self.hir.expect_item(node_id); let item = self.hir().expect_item(node_id);
let span_str = self.sess.source_map().span_to_string(item.span); let span_str = self.sess.source_map().span_to_string(item.span);
buffer.push(&format!("<impl at {}>", span_str)); buffer.push(&format!("<impl at {}>", span_str));
} }

View file

@ -289,7 +289,7 @@ impl Visibility {
def => Visibility::Restricted(def.def_id()), def => Visibility::Restricted(def.def_id()),
}, },
hir::VisibilityKind::Inherited => { hir::VisibilityKind::Inherited => {
Visibility::Restricted(tcx.hir.get_module_parent(id)) Visibility::Restricted(tcx.hir().get_module_parent(id))
} }
} }
} }
@ -2619,29 +2619,29 @@ impl<'gcx> ::std::ops::Deref for Attributes<'gcx> {
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> { pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> {
self.typeck_tables_of(self.hir.body_owner_def_id(body)) self.typeck_tables_of(self.hir().body_owner_def_id(body))
} }
/// Returns an iterator of the def-ids for all body-owners in this /// Returns an iterator of the def-ids for all body-owners in this
/// crate. If you would prefer to iterate over the bodies /// crate. If you would prefer to iterate over the bodies
/// themselves, you can do `self.hir.krate().body_ids.iter()`. /// themselves, you can do `self.hir().krate().body_ids.iter()`.
pub fn body_owners( pub fn body_owners(
self, self,
) -> impl Iterator<Item = DefId> + Captures<'tcx> + Captures<'gcx> + 'a { ) -> impl Iterator<Item = DefId> + Captures<'tcx> + Captures<'gcx> + 'a {
self.hir.krate() self.hir().krate()
.body_ids .body_ids
.iter() .iter()
.map(move |&body_id| self.hir.body_owner_def_id(body_id)) .map(move |&body_id| self.hir().body_owner_def_id(body_id))
} }
pub fn par_body_owners<F: Fn(DefId) + sync::Sync + sync::Send>(self, f: F) { pub fn par_body_owners<F: Fn(DefId) + sync::Sync + sync::Send>(self, f: F) {
par_iter(&self.hir.krate().body_ids).for_each(|&body_id| { par_iter(&self.hir().krate().body_ids).for_each(|&body_id| {
f(self.hir.body_owner_def_id(body_id)) f(self.hir().body_owner_def_id(body_id))
}); });
} }
pub fn expr_span(self, id: NodeId) -> Span { pub fn expr_span(self, id: NodeId) -> Span {
match self.hir.find(id) { match self.hir().find(id) {
Some(Node::Expr(e)) => { Some(Node::Expr(e)) => {
e.span e.span
} }
@ -2667,8 +2667,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
pub fn opt_associated_item(self, def_id: DefId) -> Option<AssociatedItem> { pub fn opt_associated_item(self, def_id: DefId) -> Option<AssociatedItem> {
let is_associated_item = if let Some(node_id) = self.hir.as_local_node_id(def_id) { let is_associated_item = if let Some(node_id) = self.hir().as_local_node_id(def_id) {
match self.hir.get(node_id) { match self.hir().get(node_id) {
Node::TraitItem(_) | Node::ImplItem(_) => true, Node::TraitItem(_) | Node::ImplItem(_) => true,
_ => false, _ => false,
} }
@ -2691,7 +2691,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
parent_vis: &hir::Visibility, parent_vis: &hir::Visibility,
trait_item_ref: &hir::TraitItemRef) trait_item_ref: &hir::TraitItemRef)
-> AssociatedItem { -> AssociatedItem {
let def_id = self.hir.local_def_id(trait_item_ref.id.node_id); let def_id = self.hir().local_def_id(trait_item_ref.id.node_id);
let (kind, has_self) = match trait_item_ref.kind { let (kind, has_self) = match trait_item_ref.kind {
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false), hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
hir::AssociatedItemKind::Method { has_self } => { hir::AssociatedItemKind::Method { has_self } => {
@ -2717,7 +2717,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
parent_def_id: DefId, parent_def_id: DefId,
impl_item_ref: &hir::ImplItemRef) impl_item_ref: &hir::ImplItemRef)
-> AssociatedItem { -> AssociatedItem {
let def_id = self.hir.local_def_id(impl_item_ref.id.node_id); let def_id = self.hir().local_def_id(impl_item_ref.id.node_id);
let (kind, has_self) = match impl_item_ref.kind { let (kind, has_self) = match impl_item_ref.kind {
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false), hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
hir::AssociatedItemKind::Method { has_self } => { hir::AssociatedItemKind::Method { has_self } => {
@ -2740,7 +2740,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
pub fn field_index(self, node_id: NodeId, tables: &TypeckTables<'_>) -> usize { pub fn field_index(self, node_id: NodeId, tables: &TypeckTables<'_>) -> usize {
let hir_id = self.hir.node_to_hir_id(node_id); let hir_id = self.hir().node_to_hir_id(node_id);
tables.field_indices().get(hir_id).cloned().expect("no index for a field") tables.field_indices().get(hir_id).cloned().expect("no index for a field")
} }
@ -2878,8 +2878,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Get the attributes of a definition. /// Get the attributes of a definition.
pub fn get_attrs(self, did: DefId) -> Attributes<'gcx> { pub fn get_attrs(self, did: DefId) -> Attributes<'gcx> {
if let Some(id) = self.hir.as_local_node_id(did) { if let Some(id) = self.hir().as_local_node_id(did) {
Attributes::Borrowed(self.hir.attrs(id)) Attributes::Borrowed(self.hir().attrs(id))
} else { } else {
Attributes::Owned(self.item_attrs(did)) Attributes::Owned(self.item_attrs(did))
} }
@ -2930,8 +2930,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// with the name of the crate containing the impl. /// with the name of the crate containing the impl.
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> { pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
if impl_did.is_local() { if impl_did.is_local() {
let node_id = self.hir.as_local_node_id(impl_did).unwrap(); let node_id = self.hir().as_local_node_id(impl_did).unwrap();
Ok(self.hir.span(node_id)) Ok(self.hir().span(node_id))
} else { } else {
Err(self.crate_name(impl_did.krate)) Err(self.crate_name(impl_did.krate))
} }
@ -2947,14 +2947,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn adjust_ident(self, mut ident: Ident, scope: DefId, block: NodeId) -> (Ident, DefId) { pub fn adjust_ident(self, mut ident: Ident, scope: DefId, block: NodeId) -> (Ident, DefId) {
ident = ident.modern(); ident = ident.modern();
let target_expansion = match scope.krate { let target_expansion = match scope.krate {
LOCAL_CRATE => self.hir.definitions().expansion_that_defined(scope.index), LOCAL_CRATE => self.hir().definitions().expansion_that_defined(scope.index),
_ => Mark::root(), _ => Mark::root(),
}; };
let scope = match ident.span.adjust(target_expansion) { let scope = match ident.span.adjust(target_expansion) {
Some(actual_expansion) => Some(actual_expansion) =>
self.hir.definitions().parent_module_of_macro_def(actual_expansion), self.hir().definitions().parent_module_of_macro_def(actual_expansion),
None if block == DUMMY_NODE_ID => DefId::local(CRATE_DEF_INDEX), // Dummy DefId None if block == DUMMY_NODE_ID => DefId::local(CRATE_DEF_INDEX), // Dummy DefId
None => self.hir.get_module_parent(block), None => self.hir().get_module_parent(block),
}; };
(ident, scope) (ident, scope)
} }
@ -2980,7 +2980,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn with_freevars<T, F>(self, fid: NodeId, f: F) -> T where pub fn with_freevars<T, F>(self, fid: NodeId, f: F) -> T where
F: FnOnce(&[hir::Freevar]) -> T, F: FnOnce(&[hir::Freevar]) -> T,
{ {
let def_id = self.hir.local_def_id(fid); let def_id = self.hir().local_def_id(fid);
match self.freevars(def_id) { match self.freevars(def_id) {
None => f(&[]), None => f(&[]),
Some(d) => f(&d), Some(d) => f(&d),
@ -2989,10 +2989,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssociatedItem { fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssociatedItem {
let id = tcx.hir.as_local_node_id(def_id).unwrap(); let id = tcx.hir().as_local_node_id(def_id).unwrap();
let parent_id = tcx.hir.get_parent(id); let parent_id = tcx.hir().get_parent(id);
let parent_def_id = tcx.hir.local_def_id(parent_id); let parent_def_id = tcx.hir().local_def_id(parent_id);
let parent_item = tcx.hir.expect_item(parent_id); let parent_item = tcx.hir().expect_item(parent_id);
match parent_item.node { match parent_item.node {
hir::ItemKind::Impl(.., ref impl_item_refs) => { hir::ItemKind::Impl(.., ref impl_item_refs) => {
if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.node_id == id) { if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.node_id == id) {
@ -3049,19 +3049,19 @@ fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId) def_id: DefId)
-> Lrc<Vec<DefId>> { -> Lrc<Vec<DefId>> {
let id = tcx.hir.as_local_node_id(def_id).unwrap(); let id = tcx.hir().as_local_node_id(def_id).unwrap();
let item = tcx.hir.expect_item(id); let item = tcx.hir().expect_item(id);
let vec: Vec<_> = match item.node { let vec: Vec<_> = match item.node {
hir::ItemKind::Trait(.., ref trait_item_refs) => { hir::ItemKind::Trait(.., ref trait_item_refs) => {
trait_item_refs.iter() trait_item_refs.iter()
.map(|trait_item_ref| trait_item_ref.id) .map(|trait_item_ref| trait_item_ref.id)
.map(|id| tcx.hir.local_def_id(id.node_id)) .map(|id| tcx.hir().local_def_id(id.node_id))
.collect() .collect()
} }
hir::ItemKind::Impl(.., ref impl_item_refs) => { hir::ItemKind::Impl(.., ref impl_item_refs) => {
impl_item_refs.iter() impl_item_refs.iter()
.map(|impl_item_ref| impl_item_ref.id) .map(|impl_item_ref| impl_item_ref.id)
.map(|id| tcx.hir.local_def_id(id.node_id)) .map(|id| tcx.hir().local_def_id(id.node_id))
.collect() .collect()
} }
hir::ItemKind::TraitAlias(..) => vec![], hir::ItemKind::TraitAlias(..) => vec![],
@ -3071,7 +3071,7 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
} }
fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span { fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span {
tcx.hir.span_if_local(def_id).unwrap() tcx.hir().span_if_local(def_id).unwrap()
} }
/// If the given def ID describes an item belonging to a trait, /// If the given def ID describes an item belonging to a trait,
@ -3089,8 +3089,8 @@ fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option
/// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition. /// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition.
pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option<DefId> { pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option<DefId> {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
if let Node::Item(item) = tcx.hir.get(node_id) { if let Node::Item(item) = tcx.hir().get(node_id) {
if let hir::ItemKind::Existential(ref exist_ty) = item.node { if let hir::ItemKind::Existential(ref exist_ty) = item.node {
return exist_ty.impl_trait_fn; return exist_ty.impl_trait_fn;
} }
@ -3101,8 +3101,8 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option<DefI
/// Returns `true` if `def_id` is a trait alias. /// Returns `true` if `def_id` is a trait alias.
pub fn is_trait_alias(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> bool { pub fn is_trait_alias(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> bool {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
if let Node::Item(item) = tcx.hir.get(node_id) { if let Node::Item(item) = tcx.hir().get(node_id) {
if let hir::ItemKind::TraitAlias(..) = item.node { if let hir::ItemKind::TraitAlias(..) = item.node {
return true; return true;
} }
@ -3140,8 +3140,8 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let unnormalized_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates), let unnormalized_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates),
traits::Reveal::UserFacing); traits::Reveal::UserFacing);
let body_id = tcx.hir.as_local_node_id(def_id).map_or(DUMMY_NODE_ID, |id| { let body_id = tcx.hir().as_local_node_id(def_id).map_or(DUMMY_NODE_ID, |id| {
tcx.hir.maybe_body_owned_by(id).map_or(id, |body| body.node_id) tcx.hir().maybe_body_owned_by(id).map_or(id, |body| body.node_id)
}); });
let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id); let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id);
traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause) traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause)
@ -3163,7 +3163,7 @@ fn crate_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
crate_num: CrateNum) crate_num: CrateNum)
-> Svh { -> Svh {
assert_eq!(crate_num, LOCAL_CRATE); assert_eq!(crate_num, LOCAL_CRATE);
tcx.hir.crate_hash tcx.hir().crate_hash
} }
fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

View file

@ -227,9 +227,9 @@ impl<'tcx> QueryDescription<'tcx> for queries::erase_regions_ty<'tcx> {
impl<'tcx> QueryDescription<'tcx> for queries::type_param_predicates<'tcx> { impl<'tcx> QueryDescription<'tcx> for queries::type_param_predicates<'tcx> {
fn describe(tcx: TyCtxt<'_, '_, '_>, (_, def_id): (DefId, DefId)) -> Cow<'static, str> { fn describe(tcx: TyCtxt<'_, '_, '_>, (_, def_id): (DefId, DefId)) -> Cow<'static, str> {
let id = tcx.hir.as_local_node_id(def_id).unwrap(); let id = tcx.hir().as_local_node_id(def_id).unwrap();
format!("computing the bounds for type parameter `{}`", format!("computing the bounds for type parameter `{}`",
tcx.hir.ty_param_name(id)).into() tcx.hir().ty_param_name(id)).into()
} }
} }

View file

@ -725,7 +725,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder<NodeId> for CacheDecoder<'a, 'tcx, 'x> {
#[inline] #[inline]
fn specialized_decode(&mut self) -> Result<NodeId, Self::Error> { fn specialized_decode(&mut self) -> Result<NodeId, Self::Error> {
let hir_id = hir::HirId::decode(self)?; let hir_id = hir::HirId::decode(self)?;
Ok(self.tcx().hir.hir_to_node_id(hir_id)) Ok(self.tcx().hir().hir_to_node_id(hir_id))
} }
} }
@ -926,7 +926,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<hir::HirId> for CacheEncoder<'enc, 'a
local_id, local_id,
} = *id; } = *id;
let def_path_hash = self.tcx.hir.definitions().def_path_hash(owner); let def_path_hash = self.tcx.hir().definitions().def_path_hash(owner);
def_path_hash.encode(self)?; def_path_hash.encode(self)?;
local_id.encode(self) local_id.encode(self)
@ -968,7 +968,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'enc, 'a, 't
{ {
#[inline] #[inline]
fn specialized_encode(&mut self, node_id: &NodeId) -> Result<(), Self::Error> { fn specialized_encode(&mut self, node_id: &NodeId) -> Result<(), Self::Error> {
let hir_id = self.tcx.hir.node_to_hir_id(*node_id); let hir_id = self.tcx.hir().node_to_hir_id(*node_id);
hir_id.encode(self) hir_id.encode(self)
} }
} }

View file

@ -189,8 +189,8 @@ pub(super) fn trait_impls_of_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
} }
} }
for &node_id in tcx.hir.trait_impls(trait_id) { for &node_id in tcx.hir().trait_impls(trait_id) {
add_impl(tcx.hir.local_def_id(node_id)); add_impl(tcx.hir().local_def_id(node_id));
} }
} }

View file

@ -601,7 +601,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Return whether the node pointed to by def_id is a static item, and its mutability /// Return whether the node pointed to by def_id is a static item, and its mutability
pub fn is_static(&self, def_id: DefId) -> Option<hir::Mutability> { pub fn is_static(&self, def_id: DefId) -> Option<hir::Mutability> {
if let Some(node) = self.hir.get_if_local(def_id) { if let Some(node) = self.hir().get_if_local(def_id) {
match node { match node {
Node::Item(&hir::Item { Node::Item(&hir::Item {
node: hir::ItemKind::Static(_, mutbl, _), .. node: hir::ItemKind::Static(_, mutbl, _), ..
@ -711,7 +711,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
// Find non representable fields with their spans // Find non representable fields with their spans
fold_repr(def.all_fields().map(|field| { fold_repr(def.all_fields().map(|field| {
let ty = field.ty(tcx, substs); let ty = field.ty(tcx, substs);
let span = tcx.hir.span_if_local(field.did).unwrap_or(sp); let span = tcx.hir().span_if_local(field.did).unwrap_or(sp);
match is_type_structurally_recursive(tcx, span, seen, match is_type_structurally_recursive(tcx, span, seen,
representable_cache, ty) representable_cache, ty)
{ {

View file

@ -523,7 +523,7 @@ impl PrintContext {
} }
}; };
let _ = write!(f, "{}", name); let _ = write!(f, "{}", name);
ty::BrNamed(tcx.hir.local_def_id(CRATE_NODE_ID), name) ty::BrNamed(tcx.hir().local_def_id(CRATE_NODE_ID), name)
} }
}; };
tcx.mk_region(ty::ReLateBound(ty::INNERMOST, br)) tcx.mk_region(ty::ReLateBound(ty::INNERMOST, br))
@ -679,7 +679,7 @@ impl fmt::Debug for ty::UpvarId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "UpvarId({:?};`{}`;{:?})", write!(f, "UpvarId({:?};`{}`;{:?})",
self.var_path.hir_id, self.var_path.hir_id,
ty::tls::with(|tcx| tcx.hir.name(tcx.hir.hir_to_node_id(self.var_path.hir_id))), ty::tls::with(|tcx| tcx.hir().name(tcx.hir().hir_to_node_id(self.var_path.hir_id))),
self.closure_expr_id) self.closure_expr_id)
} }
} }
@ -1208,15 +1208,15 @@ define_print! {
write!(f, "[static generator")?; write!(f, "[static generator")?;
} }
if let Some(node_id) = tcx.hir.as_local_node_id(did) { if let Some(node_id) = tcx.hir().as_local_node_id(did) {
write!(f, "@{:?}", tcx.hir.span(node_id))?; write!(f, "@{:?}", tcx.hir().span(node_id))?;
let mut sep = " "; let mut sep = " ";
tcx.with_freevars(node_id, |freevars| { tcx.with_freevars(node_id, |freevars| {
for (freevar, upvar_ty) in freevars.iter().zip(upvar_tys) { for (freevar, upvar_ty) in freevars.iter().zip(upvar_tys) {
print!(f, cx, print!(f, cx,
write("{}{}:", write("{}{}:",
sep, sep,
tcx.hir.name(freevar.var_id())), tcx.hir().name(freevar.var_id())),
print(upvar_ty))?; print(upvar_ty))?;
sep = ", "; sep = ", ";
} }
@ -1244,11 +1244,11 @@ define_print! {
let upvar_tys = substs.upvar_tys(did, tcx); let upvar_tys = substs.upvar_tys(did, tcx);
write!(f, "[closure")?; write!(f, "[closure")?;
if let Some(node_id) = tcx.hir.as_local_node_id(did) { if let Some(node_id) = tcx.hir().as_local_node_id(did) {
if tcx.sess.opts.debugging_opts.span_free_formats { if tcx.sess.opts.debugging_opts.span_free_formats {
write!(f, "@{:?}", node_id)?; write!(f, "@{:?}", node_id)?;
} else { } else {
write!(f, "@{:?}", tcx.hir.span(node_id))?; write!(f, "@{:?}", tcx.hir().span(node_id))?;
} }
let mut sep = " "; let mut sep = " ";
tcx.with_freevars(node_id, |freevars| { tcx.with_freevars(node_id, |freevars| {
@ -1256,7 +1256,7 @@ define_print! {
print!(f, cx, print!(f, cx,
write("{}{}:", write("{}{}:",
sep, sep,
tcx.hir.name(freevar.var_id())), tcx.hir().name(freevar.var_id())),
print(upvar_ty))?; print(upvar_ty))?;
sep = ", "; sep = ", ";
} }

View file

@ -105,7 +105,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
debug!("consume(consume_id={}, cmt={:?}, mode={:?})", debug!("consume(consume_id={}, cmt={:?}, mode={:?})",
consume_id, cmt, mode); consume_id, cmt, mode);
let hir_id = self.tcx().hir.node_to_hir_id(consume_id); let hir_id = self.tcx().hir().node_to_hir_id(consume_id);
self.consume_common(hir_id.local_id, consume_span, cmt, mode); self.consume_common(hir_id.local_id, consume_span, cmt, mode);
} }
@ -139,7 +139,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
borrow_id, cmt, loan_region, borrow_id, cmt, loan_region,
bk, loan_cause); bk, loan_cause);
let hir_id = self.tcx().hir.node_to_hir_id(borrow_id); let hir_id = self.tcx().hir().node_to_hir_id(borrow_id);
if let Some(lp) = opt_loan_path(cmt) { if let Some(lp) = opt_loan_path(cmt) {
let moved_value_use_kind = match loan_cause { let moved_value_use_kind = match loan_cause {
euv::ClosureCapture(_) => MovedInCapture, euv::ClosureCapture(_) => MovedInCapture,
@ -185,7 +185,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
} }
} }
} }
self.check_assignment(self.tcx().hir.node_to_hir_id(assignment_id).local_id, self.check_assignment(self.tcx().hir().node_to_hir_id(assignment_id).local_id,
assignment_span, assignee_cmt); assignment_span, assignee_cmt);
} }
@ -199,10 +199,10 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
body: &hir::Body) { body: &hir::Body) {
debug!("check_loans(body id={})", body.value.id); debug!("check_loans(body id={})", body.value.id);
let def_id = bccx.tcx.hir.body_owner_def_id(body.id()); let def_id = bccx.tcx.hir().body_owner_def_id(body.id());
let node_id = bccx.tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = bccx.tcx.hir().as_local_node_id(def_id).unwrap();
let movable_generator = !match bccx.tcx.hir.get(node_id) { let movable_generator = !match bccx.tcx.hir().get(node_id) {
Node::Expr(&hir::Expr { Node::Expr(&hir::Expr {
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
.. ..
@ -907,7 +907,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
let lp = opt_loan_path(assignee_cmt).unwrap(); let lp = opt_loan_path(assignee_cmt).unwrap();
self.move_data.each_assignment_of(assignment_id, &lp, |assign| { self.move_data.each_assignment_of(assignment_id, &lp, |assign| {
if assignee_cmt.mutbl.is_mutable() { if assignee_cmt.mutbl.is_mutable() {
let hir_id = self.bccx.tcx.hir.node_to_hir_id(local_id); let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id);
self.bccx.used_mut_nodes.borrow_mut().insert(hir_id); self.bccx.used_mut_nodes.borrow_mut().insert(hir_id);
} else { } else {
self.bccx.report_reassigned_immutable_variable( self.bccx.report_reassigned_immutable_variable(

View file

@ -57,9 +57,9 @@ pub enum PatternSource<'tcx> {
/// with a reference to the let /// with a reference to the let
fn get_pattern_source<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &Pat) -> PatternSource<'tcx> { fn get_pattern_source<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &Pat) -> PatternSource<'tcx> {
let parent = tcx.hir.get_parent_node(pat.id); let parent = tcx.hir().get_parent_node(pat.id);
match tcx.hir.get(parent) { match tcx.hir().get(parent) {
Node::Expr(ref e) => { Node::Expr(ref e) => {
// the enclosing expression must be a `match` or something else // the enclosing expression must be a `match` or something else
assert!(match e.node { assert!(match e.node {
@ -79,7 +79,7 @@ pub fn gather_decl<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
var_id: ast::NodeId, var_id: ast::NodeId,
var_ty: Ty<'tcx>) { var_ty: Ty<'tcx>) {
let loan_path = Rc::new(LoanPath::new(LpVar(var_id), var_ty)); let loan_path = Rc::new(LoanPath::new(LpVar(var_id), var_ty));
let hir_id = bccx.tcx.hir.node_to_hir_id(var_id); let hir_id = bccx.tcx.hir().node_to_hir_id(var_id);
move_data.add_move(bccx.tcx, loan_path, hir_id.local_id, Declared); move_data.add_move(bccx.tcx, loan_path, hir_id.local_id, Declared);
} }

View file

@ -114,7 +114,7 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
self.bccx.tcx.mk_region(ty::ReScope(self.item_scope)) self.bccx.tcx.mk_region(ty::ReScope(self.item_scope))
} }
Categorization::Local(local_id) => { Categorization::Local(local_id) => {
let hir_id = self.bccx.tcx.hir.node_to_hir_id(local_id); let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id);
self.bccx.tcx.mk_region(ty::ReScope( self.bccx.tcx.mk_region(ty::ReScope(
self.bccx.region_scope_tree.var_scope(hir_id.local_id))) self.bccx.region_scope_tree.var_scope(hir_id.local_id)))
} }

View file

@ -38,13 +38,13 @@ mod move_error;
pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
body: hir::BodyId) body: hir::BodyId)
-> (Vec<Loan<'tcx>>, move_data::MoveData<'tcx>) { -> (Vec<Loan<'tcx>>, move_data::MoveData<'tcx>) {
let def_id = bccx.tcx.hir.body_owner_def_id(body); let def_id = bccx.tcx.hir().body_owner_def_id(body);
let param_env = bccx.tcx.param_env(def_id); let param_env = bccx.tcx.param_env(def_id);
let mut glcx = GatherLoanCtxt { let mut glcx = GatherLoanCtxt {
bccx, bccx,
all_loans: Vec::new(), all_loans: Vec::new(),
item_ub: region::Scope { item_ub: region::Scope {
id: bccx.tcx.hir.body(body).value.hir_id.local_id, id: bccx.tcx.hir().body(body).value.hir_id.local_id,
data: region::ScopeData::Node data: region::ScopeData::Node
}, },
move_data: MoveData::default(), move_data: MoveData::default(),
@ -88,7 +88,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
euv::Move(move_reason) => { euv::Move(move_reason) => {
gather_moves::gather_move_from_expr( gather_moves::gather_move_from_expr(
self.bccx, &self.move_data, &mut self.move_error_collector, self.bccx, &self.move_data, &mut self.move_error_collector,
self.bccx.tcx.hir.node_to_hir_id(consume_id).local_id, cmt, move_reason); self.bccx.tcx.hir().node_to_hir_id(consume_id).local_id, cmt, move_reason);
} }
euv::Copy => { } euv::Copy => { }
} }
@ -135,7 +135,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
bk={:?}, loan_cause={:?})", bk={:?}, loan_cause={:?})",
borrow_id, cmt, loan_region, borrow_id, cmt, loan_region,
bk, loan_cause); bk, loan_cause);
let hir_id = self.bccx.tcx.hir.node_to_hir_id(borrow_id); let hir_id = self.bccx.tcx.hir().node_to_hir_id(borrow_id);
self.guarantee_valid(hir_id.local_id, self.guarantee_valid(hir_id.local_id,
borrow_span, borrow_span,
cmt, cmt,
@ -158,7 +158,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
fn decl_without_init(&mut self, id: ast::NodeId, _span: Span) { fn decl_without_init(&mut self, id: ast::NodeId, _span: Span) {
let ty = self.bccx let ty = self.bccx
.tables .tables
.node_id_to_type(self.bccx.tcx.hir.node_to_hir_id(id)); .node_id_to_type(self.bccx.tcx.hir().node_to_hir_id(id));
gather_moves::gather_decl(self.bccx, &self.move_data, id, ty); gather_moves::gather_decl(self.bccx, &self.move_data, id, ty);
} }
} }
@ -280,7 +280,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
self.mark_loan_path_as_mutated(&lp); self.mark_loan_path_as_mutated(&lp);
} }
gather_moves::gather_assignment(self.bccx, &self.move_data, gather_moves::gather_assignment(self.bccx, &self.move_data,
self.bccx.tcx.hir.node_to_hir_id(assignment_id) self.bccx.tcx.hir().node_to_hir_id(assignment_id)
.local_id, .local_id,
assignment_span, assignment_span,
lp); lp);
@ -448,7 +448,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
wrapped_path = match current_path.kind { wrapped_path = match current_path.kind {
LpVar(local_id) => { LpVar(local_id) => {
if !through_borrow { if !through_borrow {
let hir_id = self.bccx.tcx.hir.node_to_hir_id(local_id); let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id);
self.bccx.used_mut_nodes.borrow_mut().insert(hir_id); self.bccx.used_mut_nodes.borrow_mut().insert(hir_id);
} }
None None

View file

@ -97,8 +97,8 @@ 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); let var_node_id = bccx.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
err.span_label(bccx.tcx.hir.span(var_node_id), err.span_label(bccx.tcx.hir().span(var_node_id),
"captured outer variable"); "captured outer variable");
} }
err.emit(); err.emit();

View file

@ -93,9 +93,9 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
debug!("borrowck(body_owner_def_id={:?})", owner_def_id); debug!("borrowck(body_owner_def_id={:?})", owner_def_id);
let owner_id = tcx.hir.as_local_node_id(owner_def_id).unwrap(); let owner_id = tcx.hir().as_local_node_id(owner_def_id).unwrap();
match tcx.hir.get(owner_id) { match tcx.hir().get(owner_id) {
Node::StructCtor(_) | Node::StructCtor(_) |
Node::Variant(_) => { Node::Variant(_) => {
// We get invoked with anything that has MIR, but some of // We get invoked with anything that has MIR, but some of
@ -110,10 +110,10 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
_ => { } _ => { }
} }
let body_id = tcx.hir.body_owned_by(owner_id); let body_id = tcx.hir().body_owned_by(owner_id);
let tables = tcx.typeck_tables_of(owner_def_id); let tables = tcx.typeck_tables_of(owner_def_id);
let region_scope_tree = tcx.region_scope_tree(owner_def_id); let region_scope_tree = tcx.region_scope_tree(owner_def_id);
let body = tcx.hir.body(body_id); let body = tcx.hir().body(body_id);
let mut bccx = BorrowckCtxt { let mut bccx = BorrowckCtxt {
tcx, tcx,
tables, tables,
@ -169,7 +169,7 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
// Check the body of fn items. // Check the body of fn items.
let tcx = this.tcx; let tcx = this.tcx;
let id_range = { let id_range = {
let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.hir); let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.hir());
visitor.visit_body(this.body); visitor.visit_body(this.body);
visitor.result() visitor.result()
}; };
@ -224,11 +224,11 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
cfg: &cfg::CFG) cfg: &cfg::CFG)
-> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'a, 'tcx>) -> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'a, 'tcx>)
{ {
let owner_id = tcx.hir.body_owner(body_id); let owner_id = tcx.hir().body_owner(body_id);
let owner_def_id = tcx.hir.local_def_id(owner_id); let owner_def_id = tcx.hir().local_def_id(owner_id);
let tables = tcx.typeck_tables_of(owner_def_id); let tables = tcx.typeck_tables_of(owner_def_id);
let region_scope_tree = tcx.region_scope_tree(owner_def_id); let region_scope_tree = tcx.region_scope_tree(owner_def_id);
let body = tcx.hir.body(body_id); let body = tcx.hir().body(body_id);
let mut bccx = BorrowckCtxt { let mut bccx = BorrowckCtxt {
tcx, tcx,
tables, tables,
@ -418,8 +418,8 @@ pub enum LoanPathElem<'tcx> {
fn closure_to_block(closure_id: LocalDefId, fn closure_to_block(closure_id: LocalDefId,
tcx: TyCtxt) -> ast::NodeId { tcx: TyCtxt) -> ast::NodeId {
let closure_id = tcx.hir.local_def_id_to_node_id(closure_id); let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
match tcx.hir.get(closure_id) { match tcx.hir().get(closure_id) {
Node::Expr(expr) => match expr.node { Node::Expr(expr) => match expr.node {
hir::ExprKind::Closure(.., body_id, _, _) => { hir::ExprKind::Closure(.., body_id, _, _) => {
body_id.node_id body_id.node_id
@ -436,12 +436,12 @@ impl<'a, 'tcx> LoanPath<'tcx> {
pub fn kill_scope(&self, bccx: &BorrowckCtxt<'a, 'tcx>) -> region::Scope { pub fn kill_scope(&self, bccx: &BorrowckCtxt<'a, 'tcx>) -> region::Scope {
match self.kind { match self.kind {
LpVar(local_id) => { LpVar(local_id) => {
let hir_id = bccx.tcx.hir.node_to_hir_id(local_id); let hir_id = bccx.tcx.hir().node_to_hir_id(local_id);
bccx.region_scope_tree.var_scope(hir_id.local_id) bccx.region_scope_tree.var_scope(hir_id.local_id)
} }
LpUpvar(upvar_id) => { LpUpvar(upvar_id) => {
let block_id = closure_to_block(upvar_id.closure_expr_id, bccx.tcx); let block_id = closure_to_block(upvar_id.closure_expr_id, bccx.tcx);
let hir_id = bccx.tcx.hir.node_to_hir_id(block_id); let hir_id = bccx.tcx.hir().node_to_hir_id(block_id);
region::Scope { id: hir_id.local_id, data: region::ScopeData::Node } region::Scope { id: hir_id.local_id, data: region::ScopeData::Node }
} }
LpDowncast(ref base, _) | LpDowncast(ref base, _) |
@ -700,8 +700,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
Origin::Ast); Origin::Ast);
let need_note = match lp.ty.sty { let need_note = match lp.ty.sty {
ty::Closure(id, _) => { ty::Closure(id, _) => {
let node_id = self.tcx.hir.as_local_node_id(id).unwrap(); let node_id = self.tcx.hir().as_local_node_id(id).unwrap();
let hir_id = self.tcx.hir.node_to_hir_id(node_id); let hir_id = self.tcx.hir().node_to_hir_id(node_id);
if let Some((span, name)) = self.tables.closure_kind_origins().get(hir_id) { if let Some((span, name)) = self.tables.closure_kind_origins().get(hir_id) {
err.span_note(*span, &format!( err.span_note(*span, &format!(
"closure cannot be invoked more than once because \ "closure cannot be invoked more than once because \
@ -721,7 +721,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
// 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 node_id = self.tcx.hir().hir_to_node_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
}); });
@ -731,10 +731,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
} }
move_data::MoveExpr | move_data::MoveExpr |
move_data::MovePat => (self.tcx.hir.span(node_id), ""), move_data::MovePat => (self.tcx.hir().span(node_id), ""),
move_data::Captured => move_data::Captured =>
(match self.tcx.hir.expect_expr(node_id).node { (match self.tcx.hir().expect_expr(node_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),
@ -846,8 +846,8 @@ impl<'a, 'tcx> BorrowckCtxt<'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 node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
let sp = self.tcx.hir.span(node_id); let sp = self.tcx.hir().span(node_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) {
@ -916,8 +916,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
// to implement two traits for "one operator" is not very intuitive for // to implement two traits for "one operator" is not very intuitive for
// many programmers. // many programmers.
if err.cmt.note == mc::NoteIndex { if err.cmt.note == mc::NoteIndex {
let node_id = self.tcx.hir.hir_to_node_id(err.cmt.hir_id); let node_id = self.tcx.hir().hir_to_node_id(err.cmt.hir_id);
let node = self.tcx.hir.get(node_id); let node = self.tcx.hir().get(node_id);
// This pattern probably always matches. // This pattern probably always matches.
if let Node::Expr( if let Node::Expr(
@ -937,7 +937,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
self.note_immutability_blame( self.note_immutability_blame(
&mut db, &mut db,
err.cmt.immutability_blame(), err.cmt.immutability_blame(),
self.tcx.hir.hir_to_node_id(err.cmt.hir_id) self.tcx.hir().hir_to_node_id(err.cmt.hir_id)
); );
db.emit(); db.emit();
self.signal_error(); self.signal_error();
@ -1043,7 +1043,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
if let ty::ReScope(scope) = *super_scope { if let ty::ReScope(scope) = *super_scope {
let node_id = scope.node_id(self.tcx, &self.region_scope_tree); let node_id = scope.node_id(self.tcx, &self.region_scope_tree);
match self.tcx.hir.find(node_id) { match self.tcx.hir().find(node_id) {
Some(Node::Stmt(_)) => { Some(Node::Stmt(_)) => {
if *sub_scope != ty::ReStatic { if *sub_scope != ty::ReStatic {
db.note("consider using a `let` binding to increase its lifetime"); db.note("consider using a `let` binding to increase its lifetime");
@ -1138,8 +1138,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
} 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 node_id = self.tcx.hir().local_def_id_to_node_id(id);
let help_span = self.tcx.hir.span(node_id); let help_span = self.tcx.hir().span(node_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),
@ -1153,7 +1153,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
self.note_immutability_blame( self.note_immutability_blame(
&mut err, &mut err,
blame, blame,
self.tcx.hir.hir_to_node_id(cmt.hir_id) self.tcx.hir().hir_to_node_id(cmt.hir_id)
); );
if is_closure { if is_closure {
@ -1194,7 +1194,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
} }
fn local_binding_mode(&self, node_id: ast::NodeId) -> ty::BindingMode { fn local_binding_mode(&self, node_id: ast::NodeId) -> ty::BindingMode {
let pat = match self.tcx.hir.get(node_id) { let pat = match self.tcx.hir().get(node_id) {
Node::Binding(pat) => pat, Node::Binding(pat) => pat,
node => bug!("bad node for local: {:?}", node) node => bug!("bad node for local: {:?}", node)
}; };
@ -1211,13 +1211,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
} }
fn local_ty(&self, node_id: ast::NodeId) -> (Option<&hir::Ty>, bool) { fn local_ty(&self, node_id: ast::NodeId) -> (Option<&hir::Ty>, bool) {
let parent = self.tcx.hir.get_parent_node(node_id); let parent = self.tcx.hir().get_parent_node(node_id);
let parent_node = self.tcx.hir.get(parent); let parent_node = self.tcx.hir().get(parent);
// The parent node is like a fn // The parent node is like a fn
if let Some(fn_like) = FnLikeNode::from_node(parent_node) { if let Some(fn_like) = FnLikeNode::from_node(parent_node) {
// `nid`'s parent's `Body` // `nid`'s parent's `Body`
let fn_body = self.tcx.hir.body(fn_like.body()); let fn_body = self.tcx.hir().body(fn_like.body());
// Get the position of `node_id` in the arguments list // Get the position of `node_id` in the arguments list
let arg_pos = fn_body.arguments.iter().position(|arg| arg.pat.id == node_id); let arg_pos = fn_body.arguments.iter().position(|arg| arg.pat.id == node_id);
if let Some(i) = arg_pos { if let Some(i) = arg_pos {
@ -1245,7 +1245,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
Some(ImmutabilityBlame::LocalDeref(node_id)) => { Some(ImmutabilityBlame::LocalDeref(node_id)) => {
match self.local_binding_mode(node_id) { match self.local_binding_mode(node_id) {
ty::BindByReference(..) => { ty::BindByReference(..) => {
let let_span = self.tcx.hir.span(node_id); let let_span = self.tcx.hir().span(node_id);
let suggestion = suggest_ref_mut(self.tcx, let_span); let suggestion = suggest_ref_mut(self.tcx, let_span);
if let Some(replace_str) = suggestion { if let Some(replace_str) = suggestion {
db.span_suggestion_with_applicability( db.span_suggestion_with_applicability(
@ -1272,12 +1272,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
} }
} }
Some(ImmutabilityBlame::AdtFieldDeref(_, field)) => { Some(ImmutabilityBlame::AdtFieldDeref(_, field)) => {
let node_id = match self.tcx.hir.as_local_node_id(field.did) { let node_id = match self.tcx.hir().as_local_node_id(field.did) {
Some(node_id) => node_id, Some(node_id) => node_id,
None => return None => return
}; };
if let Node::Field(ref field) = self.tcx.hir.get(node_id) { if let Node::Field(ref field) = self.tcx.hir().get(node_id) {
if let Some(msg) = self.suggest_mut_for_immutable(&field.ty, false) { if let Some(msg) = self.suggest_mut_for_immutable(&field.ty, false) {
db.span_label(field.ty.span, msg); db.span_label(field.ty.span, msg);
} }
@ -1293,7 +1293,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
db: &mut DiagnosticBuilder, db: &mut DiagnosticBuilder,
borrowed_node_id: ast::NodeId, borrowed_node_id: ast::NodeId,
binding_node_id: ast::NodeId) { binding_node_id: ast::NodeId) {
let let_span = self.tcx.hir.span(binding_node_id); let let_span = self.tcx.hir().span(binding_node_id);
if let ty::BindByValue(..) = self.local_binding_mode(binding_node_id) { if let ty::BindByValue(..) = self.local_binding_mode(binding_node_id) {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(let_span) { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(let_span) {
let (ty, is_implicit_self) = self.local_ty(binding_node_id); let (ty, is_implicit_self) = self.local_ty(binding_node_id);
@ -1309,9 +1309,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}, },
)) = ty.map(|t| &t.node) )) = ty.map(|t| &t.node)
{ {
let borrow_expr_id = self.tcx.hir.get_parent_node(borrowed_node_id); let borrow_expr_id = self.tcx.hir().get_parent_node(borrowed_node_id);
db.span_suggestion_with_applicability( db.span_suggestion_with_applicability(
self.tcx.hir.span(borrow_expr_id), self.tcx.hir().span(borrow_expr_id),
"consider removing the `&mut`, as it is an \ "consider removing the `&mut`, as it is an \
immutable binding to a mutable reference", immutable binding to a mutable reference",
snippet, snippet,
@ -1381,8 +1381,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}; };
if *kind == ty::ClosureKind::Fn { if *kind == ty::ClosureKind::Fn {
let closure_node_id = let closure_node_id =
self.tcx.hir.local_def_id_to_node_id(upvar_id.closure_expr_id); self.tcx.hir().local_def_id_to_node_id(upvar_id.closure_expr_id);
db.span_help(self.tcx.hir.span(closure_node_id), db.span_help(self.tcx.hir().span(closure_node_id),
"consider changing this closure to take \ "consider changing this closure to take \
self by mutable reference"); self by mutable reference");
} }
@ -1391,7 +1391,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
if let Categorization::Deref(..) = err.cmt.cat { if let Categorization::Deref(..) = err.cmt.cat {
db.span_label(*error_span, "cannot borrow as mutable"); db.span_label(*error_span, "cannot borrow as mutable");
} else if let Categorization::Local(local_id) = err.cmt.cat { } else if let Categorization::Local(local_id) = err.cmt.cat {
let span = self.tcx.hir.span(local_id); let span = self.tcx.hir().span(local_id);
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") { if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") {
db.span_label(*error_span, "cannot reborrow mutably"); db.span_label(*error_span, "cannot reborrow mutably");
@ -1416,10 +1416,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, '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(self.tcx.hir().hir_to_node_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());
} }
LpDowncast(ref lp_base, variant_def_id) => { LpDowncast(ref lp_base, variant_def_id) => {
@ -1530,13 +1530,13 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.kind { match self.kind {
LpVar(id) => { LpVar(id) => {
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir.node_to_string(id))) write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id)))
} }
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath {hir_id: var_id}, closure_expr_id }) => { LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath {hir_id: var_id}, closure_expr_id }) => {
let s = ty::tls::with(|tcx| { let s = ty::tls::with(|tcx| {
let var_node_id = tcx.hir.hir_to_node_id(var_id); let var_node_id = tcx.hir().hir_to_node_id(var_id);
tcx.hir.node_to_string(var_node_id) tcx.hir().node_to_string(var_node_id)
}); });
write!(f, "$({} captured by id={:?})", s, closure_expr_id) write!(f, "$({} captured by id={:?})", s, closure_expr_id)
} }
@ -1565,13 +1565,13 @@ impl<'tcx> fmt::Display for LoanPath<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.kind { match self.kind {
LpVar(id) => { LpVar(id) => {
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir.node_to_user_string(id))) write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_user_string(id)))
} }
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath { hir_id }, closure_expr_id: _ }) => { LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath { hir_id }, closure_expr_id: _ }) => {
let s = ty::tls::with(|tcx| { let s = ty::tls::with(|tcx| {
let var_node_id = tcx.hir.hir_to_node_id(hir_id); let var_node_id = tcx.hir().hir_to_node_id(hir_id);
tcx.hir.node_to_string(var_node_id) tcx.hir().node_to_string(var_node_id)
}); });
write!(f, "$({} captured by closure)", s) write!(f, "$({} captured by closure)", s)
} }

View file

@ -100,7 +100,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for UnusedMutCx<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for UnusedMutCx<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir) NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir())
} }
fn visit_arm(&mut self, arm: &hir::Arm) { fn visit_arm(&mut self, arm: &hir::Arm) {
@ -114,12 +114,12 @@ impl<'a, 'tcx> Visitor<'tcx> for UnusedMutCx<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for UsedMutFinder<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for UsedMutFinder<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir) NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir())
} }
fn visit_nested_body(&mut self, id: hir::BodyId) { fn visit_nested_body(&mut self, id: hir::BodyId) {
let def_id = self.bccx.tcx.hir.body_owner_def_id(id); let def_id = self.bccx.tcx.hir().body_owner_def_id(id);
self.set.extend(self.bccx.tcx.borrowck(def_id).used_mut_nodes.iter().cloned()); self.set.extend(self.bccx.tcx.borrowck(def_id).used_mut_nodes.iter().cloned());
self.visit_body(self.bccx.tcx.hir.body(id)); self.visit_body(self.bccx.tcx.hir().body(id));
} }
} }

View file

@ -111,7 +111,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O> { impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O> {
fn nested(&self, state: &mut pprust::State, nested: pprust::Nested) -> io::Result<()> { fn nested(&self, state: &mut pprust::State, nested: pprust::Nested) -> io::Result<()> {
pprust::PpAnn::nested(&self.tcx.hir, state, nested) pprust::PpAnn::nested(self.tcx.hir(), state, nested)
} }
fn pre(&self, fn pre(&self,
ps: &mut pprust::State, ps: &mut pprust::State,

View file

@ -223,10 +223,10 @@ impl CodegenCx<'ll, 'tcx> {
debug!("get_static: sym={} instance={:?}", sym, instance); debug!("get_static: sym={} instance={:?}", sym, instance);
let g = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) { let g = if let Some(id) = self.tcx.hir().as_local_node_id(def_id) {
let llty = self.layout_of(ty).llvm_type(self); let llty = self.layout_of(ty).llvm_type(self);
let (g, attrs) = match self.tcx.hir.get(id) { let (g, attrs) = match self.tcx.hir().get(id) {
Node::Item(&hir::Item { Node::Item(&hir::Item {
ref attrs, span, node: hir::ItemKind::Static(..), .. ref attrs, span, node: hir::ItemKind::Static(..), ..
}) => { }) => {

View file

@ -76,7 +76,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>)
pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool { pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool {
let omit_gdb_pretty_printer_section = let omit_gdb_pretty_printer_section =
attr::contains_name(&cx.tcx.hir.krate_attrs(), attr::contains_name(&cx.tcx.hir().krate_attrs(),
"omit_gdb_pretty_printer_section"); "omit_gdb_pretty_printer_section");
!omit_gdb_pretty_printer_section && !omit_gdb_pretty_printer_section &&

View file

@ -300,7 +300,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
let mut flags = DIFlags::FlagPrototyped; let mut flags = DIFlags::FlagPrototyped;
let local_id = self.tcx().hir.as_local_node_id(def_id); let local_id = self.tcx().hir().as_local_node_id(def_id);
if let Some((id, _, _)) = *self.sess().entry_fn.borrow() { if let Some((id, _, _)) = *self.sess().entry_fn.borrow() {
if local_id == Some(id) { if local_id == Some(id) {
flags |= DIFlags::FlagMainSubprogram; flags |= DIFlags::FlagMainSubprogram;

View file

@ -93,9 +93,9 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// //
// As a result, if this id is an FFI item (foreign item) then we only // As a result, if this id is an FFI item (foreign item) then we only
// let it through if it's included statically. // let it through if it's included statically.
match tcx.hir.get(node_id) { match tcx.hir().get(node_id) {
Node::ForeignItem(..) => { Node::ForeignItem(..) => {
let def_id = tcx.hir.local_def_id(node_id); let def_id = tcx.hir().local_def_id(node_id);
if tcx.is_statically_included_foreign_item(def_id) { if tcx.is_statically_included_foreign_item(def_id) {
Some(def_id) Some(def_id)
} else { } else {
@ -115,7 +115,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
node: hir::ImplItemKind::Method(..), node: hir::ImplItemKind::Method(..),
.. ..
}) => { }) => {
let def_id = tcx.hir.local_def_id(node_id); let def_id = tcx.hir().local_def_id(node_id);
let generics = tcx.generics_of(def_id); let generics = tcx.generics_of(def_id);
if !generics.requires_monomorphization(tcx) && if !generics.requires_monomorphization(tcx) &&
// Functions marked with #[inline] are only ever codegened // Functions marked with #[inline] are only ever codegened
@ -158,12 +158,12 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
.collect(); .collect();
if let Some(id) = *tcx.sess.proc_macro_decls_static.get() { if let Some(id) = *tcx.sess.proc_macro_decls_static.get() {
let def_id = tcx.hir.local_def_id(id); let def_id = tcx.hir().local_def_id(id);
reachable_non_generics.insert(def_id, SymbolExportLevel::C); reachable_non_generics.insert(def_id, SymbolExportLevel::C);
} }
if let Some(id) = *tcx.sess.plugin_registrar_fn.get() { if let Some(id) = *tcx.sess.plugin_registrar_fn.get() {
let def_id = tcx.hir.local_def_id(id); let def_id = tcx.hir().local_def_id(id);
reachable_non_generics.insert(def_id, SymbolExportLevel::C); reachable_non_generics.insert(def_id, SymbolExportLevel::C);
} }
@ -355,7 +355,7 @@ fn upstream_monomorphizations_for_provider<'a, 'tcx>(
} }
fn is_unreachable_local_definition_provider(tcx: TyCtxt, def_id: DefId) -> bool { fn is_unreachable_local_definition_provider(tcx: TyCtxt, def_id: DefId) -> bool {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
!tcx.reachable_set(LOCAL_CRATE).0.contains(&node_id) !tcx.reachable_set(LOCAL_CRATE).0.contains(&node_id)
} else { } else {
bug!("is_unreachable_local_definition called with non-local DefId: {:?}", bug!("is_unreachable_local_definition called with non-local DefId: {:?}",
@ -393,7 +393,7 @@ fn symbol_export_level(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportLevel {
if let Some(Node::Item(&hir::Item { if let Some(Node::Item(&hir::Item {
node: hir::ItemKind::Static(..), node: hir::ItemKind::Static(..),
.. ..
})) = tcx.hir.get_if_local(sym_def_id) { })) = tcx.hir().get_if_local(sym_def_id) {
return SymbolExportLevel::Rust; return SymbolExportLevel::Rust;
} }
} }

View file

@ -313,8 +313,8 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
let sess = tcx.sess; let sess = tcx.sess;
let crate_name = tcx.crate_name(LOCAL_CRATE); let crate_name = tcx.crate_name(LOCAL_CRATE);
let crate_hash = tcx.crate_hash(LOCAL_CRATE); let crate_hash = tcx.crate_hash(LOCAL_CRATE);
let no_builtins = attr::contains_name(&tcx.hir.krate().attrs, "no_builtins"); let no_builtins = attr::contains_name(&tcx.hir().krate().attrs, "no_builtins");
let subsystem = attr::first_attr_value_str_by_name(&tcx.hir.krate().attrs, let subsystem = attr::first_attr_value_str_by_name(&tcx.hir().krate().attrs,
"windows_subsystem"); "windows_subsystem");
let windows_subsystem = subsystem.map(|subsystem| { let windows_subsystem = subsystem.map(|subsystem| {
if subsystem != "windows" && subsystem != "console" { if subsystem != "windows" && subsystem != "console" {

View file

@ -453,7 +453,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
) { ) {
let (main_def_id, span) = match *cx.sess().entry_fn.borrow() { let (main_def_id, span) = match *cx.sess().entry_fn.borrow() {
Some((id, span, _)) => { Some((id, span, _)) => {
(cx.tcx().hir.local_def_id(id), span) (cx.tcx().hir().local_def_id(id), span)
} }
None => return, None => return,
}; };

View file

@ -42,7 +42,7 @@ pub trait MonoItemExt<'a, 'tcx: 'a>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> {
cx.codegen_static(def_id, is_mutable); cx.codegen_static(def_id, is_mutable);
} }
MonoItem::GlobalAsm(node_id) => { MonoItem::GlobalAsm(node_id) => {
let item = cx.tcx().hir.expect_item(node_id); let item = cx.tcx().hir().expect_item(node_id);
if let hir::ItemKind::GlobalAsm(ref ga) = item.node { if let hir::ItemKind::GlobalAsm(ref ga) = item.node {
cx.codegen_global_asm(ga); cx.codegen_global_asm(ga);
} else { } else {

View file

@ -53,7 +53,7 @@ pub mod symbol_names_test;
/// reporting an error. /// reporting an error.
pub fn check_for_rustc_errors_attr(tcx: TyCtxt) { pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
if let Some((id, span, _)) = *tcx.sess.entry_fn.borrow() { if let Some((id, span, _)) = *tcx.sess.entry_fn.borrow() {
let main_def_id = tcx.hir.local_def_id(id); let main_def_id = tcx.hir().local_def_id(id);
if tcx.has_attr(main_def_id, "rustc_error") { if tcx.has_attr(main_def_id, "rustc_error") {
tcx.sess.span_fatal(span, "compilation successful"); tcx.sess.span_fatal(span, "compilation successful");

View file

@ -250,7 +250,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
debug!("symbol_name(def_id={:?}, substs={:?})", def_id, substs); debug!("symbol_name(def_id={:?}, substs={:?})", def_id, substs);
let node_id = tcx.hir.as_local_node_id(def_id); let node_id = tcx.hir().as_local_node_id(def_id);
if let Some(id) = node_id { if let Some(id) = node_id {
if *tcx.sess.plugin_registrar_fn.get() == Some(id) { if *tcx.sess.plugin_registrar_fn.get() == Some(id) {
@ -265,7 +265,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance
// FIXME(eddyb) Precompute a custom symbol name based on attributes. // FIXME(eddyb) Precompute a custom symbol name based on attributes.
let is_foreign = if let Some(id) = node_id { let is_foreign = if let Some(id) = node_id {
match tcx.hir.get(id) { match tcx.hir().get(id) {
Node::ForeignItem(_) => true, Node::ForeignItem(_) => true,
_ => false, _ => false,
} }

View file

@ -33,7 +33,7 @@ pub fn report_symbol_names<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
tcx.dep_graph.with_ignore(|| { tcx.dep_graph.with_ignore(|| {
let mut visitor = SymbolNamesTest { tcx }; let mut visitor = SymbolNamesTest { tcx };
tcx.hir.krate().visit_all_item_likes(&mut visitor); tcx.hir().krate().visit_all_item_likes(&mut visitor);
}) })
} }
@ -45,7 +45,7 @@ impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
fn process_attrs(&mut self, fn process_attrs(&mut self,
node_id: ast::NodeId) { node_id: ast::NodeId) {
let tcx = self.tcx; let tcx = self.tcx;
let def_id = tcx.hir.local_def_id(node_id); let def_id = tcx.hir().local_def_id(node_id);
for attr in tcx.get_attrs(def_id).iter() { for attr in tcx.get_attrs(def_id).iter() {
if attr.check_name(SYMBOL_NAME) { if attr.check_name(SYMBOL_NAME) {
// for now, can only use on monomorphic names // for now, can only use on monomorphic names

View file

@ -305,7 +305,7 @@ pub fn compile_input(
outdir, outdir,
output, output,
opt_crate, opt_crate,
tcx.hir.krate(), tcx.hir().krate(),
&analysis, &analysis,
tcx, tcx,
&crate_name, &crate_name,

View file

@ -495,7 +495,7 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
} }
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> { fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> {
Some(&self.tcx.hir) Some(&self.tcx.hir())
} }
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn { fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn {
@ -514,7 +514,7 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
if let pprust_hir::Nested::Body(id) = nested { if let pprust_hir::Nested::Body(id) = nested {
self.tables.set(self.tcx.body_tables(id)); self.tables.set(self.tcx.body_tables(id));
} }
pprust_hir::PpAnn::nested(&self.tcx.hir, state, nested)?; pprust_hir::PpAnn::nested(self.tcx.hir(), state, nested)?;
self.tables.set(old_tables); self.tables.set(old_tables);
Ok(()) Ok(())
} }
@ -851,18 +851,18 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
// Find the function this expression is from. // Find the function this expression is from.
let mut node_id = expr.id; let mut node_id = expr.id;
loop { loop {
let node = tcx.hir.get(node_id); let node = tcx.hir().get(node_id);
if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) { if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) {
break n.body(); break n.body();
} }
let parent = tcx.hir.get_parent_node(node_id); let parent = tcx.hir().get_parent_node(node_id);
assert_ne!(node_id, parent); assert_ne!(node_id, parent);
node_id = parent; node_id = parent;
} }
} }
blocks::Code::FnLike(fn_like) => fn_like.body(), blocks::Code::FnLike(fn_like) => fn_like.body(),
}; };
let body = tcx.hir.body(body_id); let body = tcx.hir().body(body_id);
let cfg = cfg::CFG::new(tcx, &body); let cfg = cfg::CFG::new(tcx, &body);
let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges; let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges;
let lcfg = LabelledCFG { let lcfg = LabelledCFG {
@ -1164,7 +1164,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
match ppm { match ppm {
PpmMir | PpmMirCFG => { PpmMir | PpmMirCFG => {
if let Some(nodeid) = nodeid { if let Some(nodeid) = nodeid {
let def_id = tcx.hir.local_def_id(nodeid); let def_id = tcx.hir().local_def_id(nodeid);
match ppm { match ppm {
PpmMir => write_mir_pretty(tcx, Some(def_id), &mut out), PpmMir => write_mir_pretty(tcx, Some(def_id), &mut out),
PpmMirCFG => write_mir_graphviz(tcx, Some(def_id), &mut out), PpmMirCFG => write_mir_graphviz(tcx, Some(def_id), &mut out),
@ -1183,11 +1183,11 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
let nodeid = let nodeid =
nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or unique path \ nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or unique path \
suffix (b::c::d)"); suffix (b::c::d)");
let node = tcx.hir.find(nodeid).unwrap_or_else(|| { let node = tcx.hir().find(nodeid).unwrap_or_else(|| {
tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid)) tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid))
}); });
match blocks::Code::from_node(&tcx.hir, nodeid) { match blocks::Code::from_node(&tcx.hir(), nodeid) {
Some(code) => { Some(code) => {
let variants = gather_flowgraph_variants(tcx.sess); let variants = gather_flowgraph_variants(tcx.sess);
@ -1200,7 +1200,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
got {:?}", got {:?}",
node); node);
tcx.sess.span_fatal(tcx.hir.span(nodeid), &message) tcx.sess.span_fatal(tcx.hir().span(nodeid), &message)
} }
} }
} }

View file

@ -186,7 +186,7 @@ fn test_env_with_pool<F>(
param_env: param_env, param_env: param_env,
}); });
let outlives_env = OutlivesEnvironment::new(param_env); let outlives_env = OutlivesEnvironment::new(param_env);
let def_id = tcx.hir.local_def_id(ast::CRATE_NODE_ID); let def_id = tcx.hir().local_def_id(ast::CRATE_NODE_ID);
infcx.resolve_regions_and_report_errors( infcx.resolve_regions_and_report_errors(
def_id, def_id,
&region_scope_tree, &region_scope_tree,
@ -256,7 +256,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
#[allow(dead_code)] // this seems like it could be useful, even if we don't use it now #[allow(dead_code)] // this seems like it could be useful, even if we don't use it now
pub fn lookup_item(&self, names: &[String]) -> ast::NodeId { pub fn lookup_item(&self, names: &[String]) -> ast::NodeId {
return match search_mod(self, &self.infcx.tcx.hir.krate().module, 0, names) { return match search_mod(self, &self.infcx.tcx.hir().krate().module, 0, names) {
Some(id) => id, Some(id) => id,
None => { None => {
panic!("no item found: `{}`", names.join("::")); panic!("no item found: `{}`", names.join("::"));
@ -271,7 +271,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
) -> Option<ast::NodeId> { ) -> Option<ast::NodeId> {
assert!(idx < names.len()); assert!(idx < names.len());
for item in &m.item_ids { for item in &m.item_ids {
let item = this.infcx.tcx.hir.expect_item(item.id); let item = this.infcx.tcx.hir().expect_item(item.id);
if item.name.to_string() == names[idx] { if item.name.to_string() == names[idx] {
return search(this, item, idx + 1, names); return search(this, item, idx + 1, names);
} }
@ -364,7 +364,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
self.infcx self.infcx
.tcx .tcx
.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion { .mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
def_id: self.infcx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), def_id: self.infcx.tcx.hir().local_def_id(ast::CRATE_NODE_ID),
index, index,
name, name,
})) }))
@ -410,7 +410,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
pub fn re_free(&self, id: u32) -> ty::Region<'tcx> { pub fn re_free(&self, id: u32) -> ty::Region<'tcx> {
self.infcx.tcx.mk_region(ty::ReFree(ty::FreeRegion { self.infcx.tcx.mk_region(ty::ReFree(ty::FreeRegion {
scope: self.infcx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), scope: self.infcx.tcx.hir().local_def_id(ast::CRATE_NODE_ID),
bound_region: ty::BrAnon(id), bound_region: ty::BrAnon(id),
})) }))
} }

View file

@ -79,8 +79,8 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut visitor = IfThisChanged { tcx, let mut visitor = IfThisChanged { tcx,
if_this_changed: vec![], if_this_changed: vec![],
then_this_would_need: vec![] }; then_this_would_need: vec![] };
visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir.krate().attrs); visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir().krate().attrs);
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
(visitor.if_this_changed, visitor.then_this_would_need) (visitor.if_this_changed, visitor.then_this_would_need)
}; };
@ -121,7 +121,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
} }
fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) { fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) {
let def_id = self.tcx.hir.local_def_id(node_id); let def_id = self.tcx.hir().local_def_id(node_id);
let def_path_hash = self.tcx.def_path_hash(def_id); let def_path_hash = self.tcx.def_path_hash(def_id);
for attr in attrs { for attr in attrs {
if attr.check_name(ATTR_IF_THIS_CHANGED) { if attr.check_name(ATTR_IF_THIS_CHANGED) {
@ -170,7 +170,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for IfThisChanged<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for IfThisChanged<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
fn visit_item(&mut self, item: &'tcx hir::Item) { fn visit_item(&mut self, item: &'tcx hir::Item) {

View file

@ -62,7 +62,7 @@ pub fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
available_cgus available_cgus
}; };
for attr in &tcx.hir.krate().attrs { for attr in &tcx.hir().krate().attrs {
ams.check_attr(attr); ams.check_attr(attr);
} }
}) })

View file

@ -223,7 +223,7 @@ pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
} }
tcx.dep_graph.with_ignore(|| { tcx.dep_graph.with_ignore(|| {
let krate = tcx.hir.krate(); let krate = tcx.hir().krate();
let mut dirty_clean_visitor = DirtyCleanVisitor { let mut dirty_clean_visitor = DirtyCleanVisitor {
tcx, tcx,
checked_attrs: Default::default(), checked_attrs: Default::default(),
@ -333,7 +333,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
/// Return all DepNode labels that should be asserted for this item. /// Return all DepNode labels that should be asserted for this item.
/// index=0 is the "name" used for error messages /// index=0 is the "name" used for error messages
fn auto_labels(&mut self, item_id: ast::NodeId, attr: &Attribute) -> (&'static str, Labels) { fn auto_labels(&mut self, item_id: ast::NodeId, attr: &Attribute) -> (&'static str, Labels) {
let node = self.tcx.hir.get(item_id); let node = self.tcx.hir().get(item_id);
let (name, labels) = match node { let (name, labels) = match node {
HirNode::Item(item) => { HirNode::Item(item) => {
match item.node { match item.node {
@ -511,7 +511,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
} }
fn check_item(&mut self, item_id: ast::NodeId, item_span: Span) { fn check_item(&mut self, item_id: ast::NodeId, item_span: Span) {
let def_id = self.tcx.hir.local_def_id(item_id); let def_id = self.tcx.hir().local_def_id(item_id);
for attr in self.tcx.get_attrs(def_id).iter() { for attr in self.tcx.get_attrs(def_id).iter() {
let assertion = match self.assertion_maybe(item_id, attr) { let assertion = match self.assertion_maybe(item_id, attr) {
Some(a) => a, Some(a) => a,
@ -630,7 +630,7 @@ impl<'a, 'tcx> FindAllAttrs<'a, 'tcx> {
impl<'a, 'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'a, 'tcx> { impl<'a, 'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
intravisit::NestedVisitorMap::All(&self.tcx.hir) intravisit::NestedVisitorMap::All(&self.tcx.hir())
} }
fn visit_attribute(&mut self, attr: &'tcx Attribute) { fn visit_attribute(&mut self, attr: &'tcx Attribute) {

View file

@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
hir::ItemKind::Enum(..) | hir::ItemKind::Enum(..) |
hir::ItemKind::Struct(..) | hir::ItemKind::Struct(..) |
hir::ItemKind::Union(..) => { hir::ItemKind::Union(..) => {
let def_id = cx.tcx.hir.local_def_id(it.id); let def_id = cx.tcx.hir().local_def_id(it.id);
self.check_heap_type(cx, it.span, cx.tcx.type_of(def_id)) self.check_heap_type(cx, it.span, cx.tcx.type_of(def_id))
} }
_ => () _ => ()
@ -142,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemKind::Union(ref struct_def, _) => { hir::ItemKind::Union(ref struct_def, _) => {
for struct_field in struct_def.fields() { for struct_field in struct_def.fields() {
let def_id = cx.tcx.hir.local_def_id(struct_field.id); let def_id = cx.tcx.hir().local_def_id(struct_field.id);
self.check_heap_type(cx, struct_field.span, self.check_heap_type(cx, struct_field.span,
cx.tcx.type_of(def_id)); cx.tcx.type_of(def_id));
} }
@ -424,8 +424,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
// If the trait is private, add the impl items to private_traits so they don't get // If the trait is private, add the impl items to private_traits so they don't get
// reported for missing docs. // reported for missing docs.
let real_trait = trait_ref.path.def.def_id(); let real_trait = trait_ref.path.def.def_id();
if let Some(node_id) = cx.tcx.hir.as_local_node_id(real_trait) { if let Some(node_id) = cx.tcx.hir().as_local_node_id(real_trait) {
match cx.tcx.hir.find(node_id) { match cx.tcx.hir().find(node_id) {
Some(Node::Item(item)) => { Some(Node::Item(item)) => {
if let hir::VisibilityKind::Inherited = item.vis.node { if let hir::VisibilityKind::Inherited = item.vis.node {
for impl_item_ref in impl_item_refs { for impl_item_ref in impl_item_refs {
@ -527,21 +527,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
if !ast_generics.params.is_empty() { if !ast_generics.params.is_empty() {
return; return;
} }
let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.id));
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
} }
hir::ItemKind::Union(_, ref ast_generics) => { hir::ItemKind::Union(_, ref ast_generics) => {
if !ast_generics.params.is_empty() { if !ast_generics.params.is_empty() {
return; return;
} }
let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.id));
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
} }
hir::ItemKind::Enum(_, ref ast_generics) => { hir::ItemKind::Enum(_, ref ast_generics) => {
if !ast_generics.params.is_empty() { if !ast_generics.params.is_empty() {
return; return;
} }
let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.id));
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
} }
_ => return, _ => return,
@ -606,7 +606,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
let mut impls = NodeSet::default(); let mut impls = NodeSet::default();
cx.tcx.for_each_impl(debug, |d| { cx.tcx.for_each_impl(debug, |d| {
if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() { if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() {
if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def.did) { if let Some(node_id) = cx.tcx.hir().as_local_node_id(ty_def.did) {
impls.insert(node_id); impls.insert(node_id);
} }
} }
@ -871,7 +871,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
_ => return, _ => return,
}; };
let def_id = cx.tcx.hir.local_def_id(it.id); let def_id = cx.tcx.hir().local_def_id(it.id);
let prfn = match cx.tcx.extern_mod_stmt_cnum(def_id) { let prfn = match cx.tcx.extern_mod_stmt_cnum(def_id) {
Some(cnum) => cx.tcx.plugin_registrar_fn(cnum), Some(cnum) => cx.tcx.plugin_registrar_fn(cnum),
None => { None => {
@ -1073,7 +1073,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) { fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) {
if let hir::ItemKind::Union(ref vdata, _) = item.node { if let hir::ItemKind::Union(ref vdata, _) = item.node {
for field in vdata.fields() { for field in vdata.fields() {
let field_ty = ctx.tcx.type_of(ctx.tcx.hir.local_def_id(field.id)); let field_ty = ctx.tcx.type_of(ctx.tcx.hir().local_def_id(field.id));
if field_ty.needs_drop(ctx.tcx, ctx.param_env) { if field_ty.needs_drop(ctx.tcx, ctx.param_env) {
ctx.span_lint(UNIONS_WITH_DROP_FIELDS, ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
field.span, field.span,
@ -1275,7 +1275,7 @@ impl LintPass for UnusedBrokenConst {
} }
} }
fn check_const(cx: &LateContext, body_id: hir::BodyId) { fn check_const(cx: &LateContext, body_id: hir::BodyId) {
let def_id = cx.tcx.hir.body_owner_def_id(body_id); let def_id = cx.tcx.hir().body_owner_def_id(body_id);
let is_static = cx.tcx.is_static(def_id).is_some(); let is_static = cx.tcx.is_static(def_id).is_some();
let param_env = if is_static { let param_env = if is_static {
// Use the same param_env as `codegen_static_initializer`, to reuse the cache. // Use the same param_env as `codegen_static_initializer`, to reuse the cache.
@ -1332,7 +1332,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints {
if cx.tcx.features().trivial_bounds { if cx.tcx.features().trivial_bounds {
let def_id = cx.tcx.hir.local_def_id(item.id); let def_id = cx.tcx.hir().local_def_id(item.id);
let predicates = cx.tcx.predicates_of(def_id); let predicates = cx.tcx.predicates_of(def_id);
for &(predicate, span) in &predicates.predicates { for &(predicate, span) in &predicates.predicates {
let predicate_kind_name = match predicate { let predicate_kind_name = match predicate {
@ -1746,7 +1746,7 @@ impl ExplicitOutlivesRequirements {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
let infer_static = cx.tcx.features().infer_static_outlives_requirements; let infer_static = cx.tcx.features().infer_static_outlives_requirements;
let def_id = cx.tcx.hir.local_def_id(item.id); let def_id = cx.tcx.hir().local_def_id(item.id);
if let hir::ItemKind::Struct(_, ref generics) = item.node { if let hir::ItemKind::Struct(_, ref generics) = item.node {
let mut bound_count = 0; let mut bound_count = 0;
let mut lint_spans = Vec::new(); let mut lint_spans = Vec::new();

View file

@ -29,7 +29,7 @@ pub enum MethodLateContext {
} }
pub fn method_context(cx: &LateContext, id: ast::NodeId) -> MethodLateContext { pub fn method_context(cx: &LateContext, id: ast::NodeId) -> MethodLateContext {
let def_id = cx.tcx.hir.local_def_id(id); let def_id = cx.tcx.hir().local_def_id(id);
let item = cx.tcx.associated_item(def_id); let item = cx.tcx.associated_item(def_id);
match item.container { match item.container {
ty::TraitContainer(..) => MethodLateContext::TraitAutoImpl, ty::TraitContainer(..) => MethodLateContext::TraitAutoImpl,

View file

@ -139,8 +139,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
_ => bug!(), _ => bug!(),
}; };
if lit_val < min || lit_val > max { if lit_val < min || lit_val > max {
let parent_id = cx.tcx.hir.get_parent_node(e.id); let parent_id = cx.tcx.hir().get_parent_node(e.id);
if let Node::Expr(parent_expr) = cx.tcx.hir.get(parent_id) { if let Node::Expr(parent_expr) = cx.tcx.hir().get(parent_id) {
if let hir::ExprKind::Cast(..) = parent_expr.node { if let hir::ExprKind::Cast(..) = parent_expr.node {
if let ty::Char = cx.tables.expr_ty(parent_expr).sty { if let ty::Char = cx.tables.expr_ty(parent_expr).sty {
let mut err = cx.struct_span_lint( let mut err = cx.struct_span_lint(
@ -756,7 +756,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
diag.help(s); diag.help(s);
} }
if let ty::Adt(def, _) = unsafe_ty.sty { if let ty::Adt(def, _) = unsafe_ty.sty {
if let Some(sp) = self.cx.tcx.hir.span_if_local(def.did) { if let Some(sp) = self.cx.tcx.hir().span_if_local(def.did) {
diag.span_note(sp, "type defined here"); diag.span_note(sp, "type defined here");
} }
} }
@ -766,7 +766,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
} }
fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) { fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) {
let def_id = self.cx.tcx.hir.local_def_id(id); let def_id = self.cx.tcx.hir().local_def_id(id);
let sig = self.cx.tcx.fn_sig(def_id); let sig = self.cx.tcx.fn_sig(def_id);
let sig = self.cx.tcx.erase_late_bound_regions(&sig); let sig = self.cx.tcx.erase_late_bound_regions(&sig);
@ -783,7 +783,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
} }
fn check_foreign_static(&mut self, id: ast::NodeId, span: Span) { fn check_foreign_static(&mut self, id: ast::NodeId, span: Span) {
let def_id = self.cx.tcx.hir.local_def_id(id); let def_id = self.cx.tcx.hir().local_def_id(id);
let ty = self.cx.tcx.type_of(def_id); let ty = self.cx.tcx.type_of(def_id);
self.check_type_for_ffi_and_report_errors(span, ty); self.check_type_for_ffi_and_report_errors(span, ty);
} }
@ -801,7 +801,7 @@ impl LintPass for ImproperCTypes {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
fn check_foreign_item(&mut self, cx: &LateContext, it: &hir::ForeignItem) { fn check_foreign_item(&mut self, cx: &LateContext, it: &hir::ForeignItem) {
let mut vis = ImproperCTypesVisitor { cx }; let mut vis = ImproperCTypesVisitor { cx };
let abi = cx.tcx.hir.get_foreign_abi(it.id); let abi = cx.tcx.hir().get_foreign_abi(it.id);
if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic { if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic {
match it.node { match it.node {
hir::ForeignItemKind::Fn(ref decl, _, _) => { hir::ForeignItemKind::Fn(ref decl, _, _) => {
@ -827,7 +827,7 @@ impl LintPass for VariantSizeDifferences {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
if let hir::ItemKind::Enum(ref enum_definition, _) = it.node { if let hir::ItemKind::Enum(ref enum_definition, _) = it.node {
let item_def_id = cx.tcx.hir.local_def_id(it.id); let item_def_id = cx.tcx.hir().local_def_id(it.id);
let t = cx.tcx.type_of(item_def_id); let t = cx.tcx.type_of(item_def_id);
let ty = cx.tcx.erase_regions(&t); let ty = cx.tcx.erase_regions(&t);
match cx.layout_of(ty) { match cx.layout_of(ty) {

View file

@ -61,7 +61,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
let t = cx.tables.expr_ty(&expr); let t = cx.tables.expr_ty(&expr);
let type_permits_lack_of_use = if t.is_unit() let type_permits_lack_of_use = if t.is_unit()
|| cx.tcx.is_ty_uninhabited_from(cx.tcx.hir.get_module_parent(expr.id), t) { || cx.tcx.is_ty_uninhabited_from(cx.tcx.hir().get_module_parent(expr.id), t) {
true true
} else { } else {
match t.sty { match t.sty {

View file

@ -318,7 +318,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
} }
fn encode_info_for_items(&mut self) -> Index { fn encode_info_for_items(&mut self) -> Index {
let krate = self.tcx.hir.krate(); let krate = self.tcx.hir().krate();
let mut index = IndexBuilder::new(self); let mut index = IndexBuilder::new(self);
let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityKind::Public }; let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityKind::Public };
index.record(DefId::local(CRATE_DEF_INDEX), index.record(DefId::local(CRATE_DEF_INDEX),
@ -333,7 +333,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
} }
fn encode_def_path_table(&mut self) -> Lazy<DefPathTable> { fn encode_def_path_table(&mut self) -> Lazy<DefPathTable> {
let definitions = self.tcx.hir.definitions(); let definitions = self.tcx.hir().definitions();
self.lazy(definitions.def_path_table()) self.lazy(definitions.def_path_table())
} }
@ -475,7 +475,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
let index = items.write_index(&mut self.opaque); let index = items.write_index(&mut self.opaque);
let index_bytes = self.position() - i; let index_bytes = self.position() - i;
let attrs = tcx.hir.krate_attrs(); let attrs = tcx.hir().krate_attrs();
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateType::ProcMacro); let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateType::ProcMacro);
let has_default_lib_allocator = attr::contains_name(&attrs, "default_lib_allocator"); let has_default_lib_allocator = attr::contains_name(&attrs, "default_lib_allocator");
let has_global_allocator = *tcx.sess.has_global_allocator.get(); let has_global_allocator = *tcx.sess.has_global_allocator.get();
@ -495,10 +495,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
plugin_registrar_fn: tcx.sess plugin_registrar_fn: tcx.sess
.plugin_registrar_fn .plugin_registrar_fn
.get() .get()
.map(|id| tcx.hir.local_def_id(id).index), .map(|id| tcx.hir().local_def_id(id).index),
proc_macro_decls_static: if is_proc_macro { proc_macro_decls_static: if is_proc_macro {
let id = tcx.sess.proc_macro_decls_static.get().unwrap(); let id = tcx.sess.proc_macro_decls_static.get().unwrap();
Some(tcx.hir.local_def_id(id).index) Some(tcx.hir().local_def_id(id).index)
} else { } else {
None None
}, },
@ -600,8 +600,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
} }
}; };
let enum_id = tcx.hir.as_local_node_id(enum_did).unwrap(); let enum_id = tcx.hir().as_local_node_id(enum_did).unwrap();
let enum_vis = &tcx.hir.expect_item(enum_id).vis; let enum_vis = &tcx.hir().expect_item(enum_id).vis;
Entry { Entry {
kind: EntryKind::Variant(self.lazy(&data)), kind: EntryKind::Variant(self.lazy(&data)),
@ -636,7 +636,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
&hir::Visibility)>) &hir::Visibility)>)
-> Entry<'tcx> { -> Entry<'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
let def_id = tcx.hir.local_def_id(id); let def_id = tcx.hir().local_def_id(id);
debug!("IsolatedEncoder::encode_info_for_mod({:?})", def_id); debug!("IsolatedEncoder::encode_info_for_mod({:?})", def_id);
let data = ModData { let data = ModData {
@ -652,7 +652,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
span: self.lazy(&tcx.def_span(def_id)), span: self.lazy(&tcx.def_span(def_id)),
attributes: self.encode_attributes(attrs), attributes: self.encode_attributes(attrs),
children: self.lazy_seq(md.item_ids.iter().map(|item_id| { children: self.lazy_seq(md.item_ids.iter().map(|item_id| {
tcx.hir.local_def_id(item_id.id).index tcx.hir().local_def_id(item_id.id).index
})), })),
stability: self.encode_stability(def_id), stability: self.encode_stability(def_id),
deprecation: self.encode_deprecation(def_id), deprecation: self.encode_deprecation(def_id),
@ -686,8 +686,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
let def_id = field.did; let def_id = field.did;
debug!("IsolatedEncoder::encode_field({:?})", def_id); debug!("IsolatedEncoder::encode_field({:?})", def_id);
let variant_id = tcx.hir.as_local_node_id(variant.did).unwrap(); let variant_id = tcx.hir().as_local_node_id(variant.did).unwrap();
let variant_data = tcx.hir.expect_variant_data(variant_id); let variant_data = tcx.hir().expect_variant_data(variant_id);
Entry { Entry {
kind: EntryKind::Field, kind: EntryKind::Field,
@ -726,8 +726,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
} }
}; };
let struct_id = tcx.hir.as_local_node_id(adt_def_id).unwrap(); let struct_id = tcx.hir().as_local_node_id(adt_def_id).unwrap();
let struct_vis = &tcx.hir.expect_item(struct_id).vis; let struct_vis = &tcx.hir().expect_item(struct_id).vis;
let mut ctor_vis = ty::Visibility::from_hir(struct_vis, struct_id, tcx); let mut ctor_vis = ty::Visibility::from_hir(struct_vis, struct_id, tcx);
for field in &variant.fields { for field in &variant.fields {
if ctor_vis.is_at_least(field.vis, tcx) { if ctor_vis.is_at_least(field.vis, tcx) {
@ -791,8 +791,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
debug!("IsolatedEncoder::encode_info_for_trait_item({:?})", def_id); debug!("IsolatedEncoder::encode_info_for_trait_item({:?})", def_id);
let tcx = self.tcx; let tcx = self.tcx;
let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
let ast_item = tcx.hir.expect_trait_item(node_id); let ast_item = tcx.hir().expect_trait_item(node_id);
let trait_item = tcx.associated_item(def_id); let trait_item = tcx.associated_item(def_id);
let container = match trait_item.defaultness { let container = match trait_item.defaultness {
@ -814,7 +814,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
}; };
let rendered = let rendered =
hir::print::to_string(&self.tcx.hir, |s| s.print_trait_item(ast_item)); hir::print::to_string(self.tcx.hir(), |s| s.print_trait_item(ast_item));
let rendered_const = self.lazy(&RenderedConst(rendered)); let rendered_const = self.lazy(&RenderedConst(rendered));
EntryKind::AssociatedConst(container, const_qualif, rendered_const) EntryKind::AssociatedConst(container, const_qualif, rendered_const)
@ -891,7 +891,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
} }
fn const_qualif(&self, mir: u8, body_id: hir::BodyId) -> ConstQualif { fn const_qualif(&self, mir: u8, body_id: hir::BodyId) -> ConstQualif {
let body_owner_def_id = self.tcx.hir.body_owner_def_id(body_id); let body_owner_def_id = self.tcx.hir().body_owner_def_id(body_id);
let ast_promotable = self.tcx.const_is_rvalue_promotable_to_static(body_owner_def_id); let ast_promotable = self.tcx.const_is_rvalue_promotable_to_static(body_owner_def_id);
ConstQualif { mir, ast_promotable } ConstQualif { mir, ast_promotable }
@ -901,8 +901,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
debug!("IsolatedEncoder::encode_info_for_impl_item({:?})", def_id); debug!("IsolatedEncoder::encode_info_for_impl_item({:?})", def_id);
let tcx = self.tcx; let tcx = self.tcx;
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = self.tcx.hir().as_local_node_id(def_id).unwrap();
let ast_item = self.tcx.hir.expect_impl_item(node_id); let ast_item = self.tcx.hir().expect_impl_item(node_id);
let impl_item = self.tcx.associated_item(def_id); let impl_item = self.tcx.associated_item(def_id);
let container = match impl_item.defaultness { let container = match impl_item.defaultness {
@ -987,7 +987,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
fn encode_fn_arg_names_for_body(&mut self, body_id: hir::BodyId) fn encode_fn_arg_names_for_body(&mut self, body_id: hir::BodyId)
-> LazySeq<ast::Name> { -> LazySeq<ast::Name> {
self.tcx.dep_graph.with_ignore(|| { self.tcx.dep_graph.with_ignore(|| {
let body = self.tcx.hir.body(body_id); let body = self.tcx.hir().body(body_id);
self.lazy_seq(body.arguments.iter().map(|arg| { self.lazy_seq(body.arguments.iter().map(|arg| {
match arg.pat.node { match arg.pat.node {
PatKind::Binding(_, _, ident, _) => ident.name, PatKind::Binding(_, _, ident, _) => ident.name,
@ -1036,8 +1036,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
} }
fn encode_rendered_const_for_body(&mut self, body_id: hir::BodyId) -> Lazy<RenderedConst> { fn encode_rendered_const_for_body(&mut self, body_id: hir::BodyId) -> Lazy<RenderedConst> {
let body = self.tcx.hir.body(body_id); let body = self.tcx.hir().body(body_id);
let rendered = hir::print::to_string(&self.tcx.hir, |s| s.print_expr(&body.value)); let rendered = hir::print::to_string(self.tcx.hir(), |s| s.print_expr(&body.value));
let rendered_const = &RenderedConst(rendered); let rendered_const = &RenderedConst(rendered);
self.lazy(rendered_const) self.lazy(rendered_const)
} }
@ -1081,7 +1081,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
// for methods, write all the stuff get_trait_method // for methods, write all the stuff get_trait_method
// needs to know // needs to know
let struct_ctor = if !struct_def.is_struct() { let struct_ctor = if !struct_def.is_struct() {
Some(tcx.hir.local_def_id(struct_def.id()).index) Some(tcx.hir().local_def_id(struct_def.id()).index)
} else { } else {
None None
}; };
@ -1167,7 +1167,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
hir::ItemKind::ForeignMod(ref fm) => { hir::ItemKind::ForeignMod(ref fm) => {
self.lazy_seq(fm.items self.lazy_seq(fm.items
.iter() .iter()
.map(|foreign_item| tcx.hir.local_def_id(foreign_item.id).index)) .map(|foreign_item| tcx.hir().local_def_id(foreign_item.id).index))
} }
hir::ItemKind::Enum(..) => { hir::ItemKind::Enum(..) => {
let def = self.tcx.adt_def(def_id); let def = self.tcx.adt_def(def_id);
@ -1282,7 +1282,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
/// Serialize the text of exported macros /// Serialize the text of exported macros
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> { fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> {
use syntax::print::pprust; use syntax::print::pprust;
let def_id = self.tcx.hir.local_def_id(macro_def.id); let def_id = self.tcx.hir().local_def_id(macro_def.id);
Entry { Entry {
kind: EntryKind::MacroDef(self.lazy(&MacroDef { kind: EntryKind::MacroDef(self.lazy(&MacroDef {
body: pprust::tts_to_string(&macro_def.body.trees().collect::<Vec<_>>()), body: pprust::tts_to_string(&macro_def.body.trees().collect::<Vec<_>>()),
@ -1339,8 +1339,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
let tables = self.tcx.typeck_tables_of(def_id); let tables = self.tcx.typeck_tables_of(def_id);
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = self.tcx.hir().as_local_node_id(def_id).unwrap();
let hir_id = self.tcx.hir.node_to_hir_id(node_id); let hir_id = self.tcx.hir().node_to_hir_id(node_id);
let kind = match tables.node_id_to_type(hir_id).sty { let kind = match tables.node_id_to_type(hir_id).sty {
ty::Generator(def_id, ..) => { ty::Generator(def_id, ..) => {
let layout = self.tcx.generator_layout(def_id); let layout = self.tcx.generator_layout(def_id);
@ -1382,8 +1382,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
fn encode_info_for_anon_const(&mut self, def_id: DefId) -> Entry<'tcx> { fn encode_info_for_anon_const(&mut self, def_id: DefId) -> Entry<'tcx> {
debug!("IsolatedEncoder::encode_info_for_anon_const({:?})", def_id); debug!("IsolatedEncoder::encode_info_for_anon_const({:?})", def_id);
let tcx = self.tcx; let tcx = self.tcx;
let id = tcx.hir.as_local_node_id(def_id).unwrap(); let id = tcx.hir().as_local_node_id(def_id).unwrap();
let body_id = tcx.hir.body_owned_by(id); let body_id = tcx.hir().body_owned_by(id);
let const_data = self.encode_rendered_const_for_body(body_id); let const_data = self.encode_rendered_const_for_body(body_id);
let mir = tcx.mir_const_qualif(def_id).0; let mir = tcx.mir_const_qualif(def_id).0;
@ -1491,7 +1491,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
tcx, tcx,
impls: FxHashMap::default(), impls: FxHashMap::default(),
}; };
tcx.hir.krate().visit_all_item_likes(&mut visitor); tcx.hir().krate().visit_all_item_likes(&mut visitor);
let mut all_impls: Vec<_> = visitor.impls.into_iter().collect(); let mut all_impls: Vec<_> = visitor.impls.into_iter().collect();
@ -1505,7 +1505,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
.map(|(trait_def_id, mut impls)| { .map(|(trait_def_id, mut impls)| {
// Bring everything into deterministic order for hashing // Bring everything into deterministic order for hashing
impls.sort_by_cached_key(|&def_index| { impls.sort_by_cached_key(|&def_index| {
tcx.hir.definitions().def_path_hash(def_index) tcx.hir().definitions().def_path_hash(def_index)
}); });
TraitImpls { TraitImpls {
@ -1617,7 +1617,7 @@ struct EncodeVisitor<'a, 'b: 'a, 'tcx: 'b> {
impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> { impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.index.tcx.hir) NestedVisitorMap::OnlyBodies(&self.index.tcx.hir())
} }
fn visit_expr(&mut self, ex: &'tcx hir::Expr) { fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
intravisit::walk_expr(self, ex); intravisit::walk_expr(self, ex);
@ -1625,7 +1625,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
} }
fn visit_item(&mut self, item: &'tcx hir::Item) { fn visit_item(&mut self, item: &'tcx hir::Item) {
intravisit::walk_item(self, item); intravisit::walk_item(self, item);
let def_id = self.index.tcx.hir.local_def_id(item.id); let def_id = self.index.tcx.hir().local_def_id(item.id);
match item.node { match item.node {
hir::ItemKind::ExternCrate(_) | hir::ItemKind::ExternCrate(_) |
hir::ItemKind::Use(..) => (), // ignore these hir::ItemKind::Use(..) => (), // ignore these
@ -1635,7 +1635,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
} }
fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem) { fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem) {
intravisit::walk_foreign_item(self, ni); intravisit::walk_foreign_item(self, ni);
let def_id = self.index.tcx.hir.local_def_id(ni.id); let def_id = self.index.tcx.hir().local_def_id(ni.id);
self.index.record(def_id, self.index.record(def_id,
IsolatedEncoder::encode_info_for_foreign_item, IsolatedEncoder::encode_info_for_foreign_item,
(def_id, ni)); (def_id, ni));
@ -1647,7 +1647,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
intravisit::walk_variant(self, v, g, id); intravisit::walk_variant(self, v, g, id);
if let Some(ref discr) = v.node.disr_expr { if let Some(ref discr) = v.node.disr_expr {
let def_id = self.index.tcx.hir.local_def_id(discr.id); let def_id = self.index.tcx.hir().local_def_id(discr.id);
self.index.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id); self.index.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id);
} }
} }
@ -1660,7 +1660,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
self.index.encode_info_for_ty(ty); self.index.encode_info_for_ty(ty);
} }
fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef) { fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef) {
let def_id = self.index.tcx.hir.local_def_id(macro_def.id); let def_id = self.index.tcx.hir().local_def_id(macro_def.id);
self.index.record(def_id, IsolatedEncoder::encode_info_for_macro_def, macro_def); self.index.record(def_id, IsolatedEncoder::encode_info_for_macro_def, macro_def);
} }
} }
@ -1682,7 +1682,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
match param.kind { match param.kind {
hir::GenericParamKind::Lifetime { .. } => {} hir::GenericParamKind::Lifetime { .. } => {}
hir::GenericParamKind::Type { ref default, .. } => { hir::GenericParamKind::Type { ref default, .. } => {
let def_id = self.tcx.hir.local_def_id(param.id); let def_id = self.tcx.hir().local_def_id(param.id);
let has_default = Untracked(default.is_some()); let has_default = Untracked(default.is_some());
let encode_info = IsolatedEncoder::encode_info_for_ty_param; let encode_info = IsolatedEncoder::encode_info_for_ty_param;
self.record(def_id, encode_info, (def_id, has_default)); self.record(def_id, encode_info, (def_id, has_default));
@ -1694,7 +1694,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
fn encode_info_for_ty(&mut self, ty: &hir::Ty) { fn encode_info_for_ty(&mut self, ty: &hir::Ty) {
match ty.node { match ty.node {
hir::TyKind::Array(_, ref length) => { hir::TyKind::Array(_, ref length) => {
let def_id = self.tcx.hir.local_def_id(length.id); let def_id = self.tcx.hir().local_def_id(length.id);
self.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id); self.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id);
} }
_ => {} _ => {}
@ -1704,7 +1704,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
fn encode_info_for_expr(&mut self, expr: &hir::Expr) { fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
match expr.node { match expr.node {
hir::ExprKind::Closure(..) => { hir::ExprKind::Closure(..) => {
let def_id = self.tcx.hir.local_def_id(expr.id); let def_id = self.tcx.hir().local_def_id(expr.id);
self.record(def_id, IsolatedEncoder::encode_info_for_closure, def_id); self.record(def_id, IsolatedEncoder::encode_info_for_closure, def_id);
} }
_ => {} _ => {}
@ -1716,7 +1716,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
/// so it's easier to do that here then to wait until we would encounter /// so it's easier to do that here then to wait until we would encounter
/// normally in the visitor walk. /// normally in the visitor walk.
fn encode_addl_info_for_item(&mut self, item: &hir::Item) { fn encode_addl_info_for_item(&mut self, item: &hir::Item) {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
match item.node { match item.node {
hir::ItemKind::Static(..) | hir::ItemKind::Static(..) |
hir::ItemKind::Const(..) | hir::ItemKind::Const(..) |
@ -1746,7 +1746,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
// If the struct has a constructor, encode it. // If the struct has a constructor, encode it.
if !struct_def.is_struct() { if !struct_def.is_struct() {
let ctor_def_id = self.tcx.hir.local_def_id(struct_def.id()); let ctor_def_id = self.tcx.hir().local_def_id(struct_def.id());
self.record(ctor_def_id, self.record(ctor_def_id,
IsolatedEncoder::encode_struct_ctor, IsolatedEncoder::encode_struct_ctor,
(def_id, ctor_def_id)); (def_id, ctor_def_id));
@ -1781,7 +1781,7 @@ struct ImplVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) { fn visit_item(&mut self, item: &hir::Item) {
if let hir::ItemKind::Impl(..) = item.node { if let hir::ItemKind::Impl(..) = item.node {
let impl_id = self.tcx.hir.local_def_id(item.id); let impl_id = self.tcx.hir().local_def_id(item.id);
if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) { if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) {
self.impls self.impls
.entry(trait_ref.def_id) .entry(trait_ref.def_id)

View file

@ -18,7 +18,7 @@ pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec<ForeignModule> {
tcx, tcx,
modules: Vec::new(), modules: Vec::new(),
}; };
tcx.hir.krate().visit_all_item_likes(&mut collector); tcx.hir().krate().visit_all_item_likes(&mut collector);
return collector.modules return collector.modules
} }
@ -35,11 +35,11 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> {
}; };
let foreign_items = fm.items.iter() let foreign_items = fm.items.iter()
.map(|it| self.tcx.hir.local_def_id(it.id)) .map(|it| self.tcx.hir().local_def_id(it.id))
.collect(); .collect();
self.modules.push(ForeignModule { self.modules.push(ForeignModule {
foreign_items, foreign_items,
def_id: self.tcx.hir.local_def_id(it.id), def_id: self.tcx.hir().local_def_id(it.id),
}); });
} }

View file

@ -90,7 +90,7 @@ impl<'a, 'b, 'tcx> DerefMut for IndexBuilder<'a, 'b, 'tcx> {
impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
pub fn new(ecx: &'a mut EncodeContext<'b, 'tcx>) -> Self { pub fn new(ecx: &'a mut EncodeContext<'b, 'tcx>) -> Self {
IndexBuilder { IndexBuilder {
items: Index::new(ecx.tcx.hir.definitions().def_index_counts_lo_hi()), items: Index::new(ecx.tcx.hir().definitions().def_index_counts_lo_hi()),
ecx, ecx,
} }
} }
@ -195,7 +195,7 @@ macro_rules! read_hir {
($t:ty) => { ($t:ty) => {
impl<'tcx> DepGraphRead for &'tcx $t { impl<'tcx> DepGraphRead for &'tcx $t {
fn read(&self, tcx: TyCtxt) { fn read(&self, tcx: TyCtxt) {
tcx.hir.read(self.id); tcx.hir().read(self.id);
} }
} }
} }
@ -229,6 +229,6 @@ pub struct FromId<T>(pub ast::NodeId, pub T);
impl<T> DepGraphRead for FromId<T> { impl<T> DepGraphRead for FromId<T> {
fn read(&self, tcx: TyCtxt) { fn read(&self, tcx: TyCtxt) {
tcx.hir.read(self.0); tcx.hir().read(self.0);
} }
} }

View file

@ -17,9 +17,9 @@ pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec<String> {
let mut collector = Collector { let mut collector = Collector {
args: Vec::new(), args: Vec::new(),
}; };
tcx.hir.krate().visit_all_item_likes(&mut collector); tcx.hir().krate().visit_all_item_likes(&mut collector);
for attr in tcx.hir.krate().attrs.iter() { for attr in tcx.hir().krate().attrs.iter() {
if attr.path == "link_args" { if attr.path == "link_args" {
if let Some(linkarg) = attr.value_str() { if let Some(linkarg) = attr.value_str() {
collector.add_link_args(&linkarg.as_str()); collector.add_link_args(&linkarg.as_str());

View file

@ -25,7 +25,7 @@ pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec<NativeLibrary> {
tcx, tcx,
libs: Vec::new(), libs: Vec::new(),
}; };
tcx.hir.krate().visit_all_item_likes(&mut collector); tcx.hir().krate().visit_all_item_likes(&mut collector);
collector.process_command_line(); collector.process_command_line();
return collector.libs return collector.libs
} }
@ -65,7 +65,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> {
name: None, name: None,
kind: cstore::NativeUnknown, kind: cstore::NativeUnknown,
cfg: None, cfg: None,
foreign_module: Some(self.tcx.hir.local_def_id(it.id)), foreign_module: Some(self.tcx.hir().local_def_id(it.id)),
wasm_import_module: None, wasm_import_module: None,
}; };
let mut kind_specified = false; let mut kind_specified = false;

View file

@ -195,8 +195,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
let needs_note = match ty.sty { let needs_note = match ty.sty {
ty::Closure(id, _) => { ty::Closure(id, _) => {
let tables = self.infcx.tcx.typeck_tables_of(id); let tables = self.infcx.tcx.typeck_tables_of(id);
let node_id = self.infcx.tcx.hir.as_local_node_id(id).unwrap(); let node_id = self.infcx.tcx.hir().as_local_node_id(id).unwrap();
let hir_id = self.infcx.tcx.hir.node_to_hir_id(node_id); let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id);
tables.closure_kind_origins().get(hir_id).is_none() tables.closure_kind_origins().get(hir_id).is_none()
} }
@ -720,13 +720,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
format!("`{}` would have to be valid for `{}`...", name, region_name), format!("`{}` would have to be valid for `{}`...", name, region_name),
); );
if let Some(fn_node_id) = self.infcx.tcx.hir.as_local_node_id(self.mir_def_id) { if let Some(fn_node_id) = self.infcx.tcx.hir().as_local_node_id(self.mir_def_id) {
err.span_label( err.span_label(
drop_span, drop_span,
format!( format!(
"...but `{}` will be dropped here, when the function `{}` returns", "...but `{}` will be dropped here, when the function `{}` returns",
name, name,
self.infcx.tcx.hir.name(fn_node_id), self.infcx.tcx.hir().name(fn_node_id),
), ),
); );
@ -1064,7 +1064,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
let escapes_from = if tcx.is_closure(self.mir_def_id) { let escapes_from = if tcx.is_closure(self.mir_def_id) {
let tables = tcx.typeck_tables_of(self.mir_def_id); let tables = tcx.typeck_tables_of(self.mir_def_id);
let mir_hir_id = tcx.hir.def_index_to_hir_id(self.mir_def_id.index); let mir_hir_id = tcx.hir().def_index_to_hir_id(self.mir_def_id.index);
match tables.node_id_to_type(mir_hir_id).sty { match tables.node_id_to_type(mir_hir_id).sty {
ty::Closure(..) => "closure", ty::Closure(..) => "closure",
ty::Generator(..) => "generator", ty::Generator(..) => "generator",
@ -1412,11 +1412,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
); );
if let ty::TyKind::Closure(did, _substs) = self.mir.local_decls[closure].ty.sty { if let ty::TyKind::Closure(did, _substs) = self.mir.local_decls[closure].ty.sty {
let node_id = match self.infcx.tcx.hir.as_local_node_id(did) { let node_id = match self.infcx.tcx.hir().as_local_node_id(did) {
Some(node_id) => node_id, Some(node_id) => node_id,
_ => return, _ => return,
}; };
let hir_id = self.infcx.tcx.hir.node_to_hir_id(node_id); let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id);
if let Some(( if let Some((
span, name span, name
@ -1654,12 +1654,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
// the local code in the current crate, so this returns an `Option` in case // the local code in the current crate, so this returns an `Option` in case
// the closure comes from another crate. But in that case we wouldn't // the closure comes from another crate. But in that case we wouldn't
// be borrowck'ing it, so we can just unwrap: // be borrowck'ing it, so we can just unwrap:
let node_id = self.infcx.tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = self.infcx.tcx.hir().as_local_node_id(def_id).unwrap();
let freevar = self.infcx let freevar = self.infcx
.tcx .tcx
.with_freevars(node_id, |fv| fv[field.index()]); .with_freevars(node_id, |fv| fv[field.index()]);
self.infcx.tcx.hir.name(freevar.var_id()).to_string() self.infcx.tcx.hir().name(freevar.var_id()).to_string()
} }
_ => { _ => {
// Might need a revision when the fields in trait RFC is implemented // Might need a revision when the fields in trait RFC is implemented
@ -1980,8 +1980,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
) -> Option<AnnotatedBorrowFnSignature> { ) -> Option<AnnotatedBorrowFnSignature> {
debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig); debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
let is_closure = self.infcx.tcx.is_closure(did); let is_closure = self.infcx.tcx.is_closure(did);
let fn_node_id = self.infcx.tcx.hir.as_local_node_id(did)?; let fn_node_id = self.infcx.tcx.hir().as_local_node_id(did)?;
let fn_decl = self.infcx.tcx.hir.fn_decl(fn_node_id)?; let fn_decl = self.infcx.tcx.hir().fn_decl(fn_node_id)?;
// We need to work out which arguments to highlight. We do this by looking // We need to work out which arguments to highlight. We do this by looking
// at the return type, where there are three cases: // at the return type, where there are three cases:
@ -2423,8 +2423,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
"closure_span: def_id={:?} target_place={:?} places={:?}", "closure_span: def_id={:?} target_place={:?} places={:?}",
def_id, target_place, places def_id, target_place, places
); );
let node_id = self.infcx.tcx.hir.as_local_node_id(def_id)?; let node_id = self.infcx.tcx.hir().as_local_node_id(def_id)?;
let expr = &self.infcx.tcx.hir.expect_expr(node_id).node; let expr = &self.infcx.tcx.hir().expect_expr(node_id).node;
debug!("closure_span: node_id={:?} expr={:?}", node_id, expr); debug!("closure_span: node_id={:?} expr={:?}", node_id, expr);
if let hir::ExprKind::Closure( if let hir::ExprKind::Closure(
.., args_span, _ .., args_span, _

View file

@ -137,7 +137,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
let attributes = tcx.get_attrs(def_id); let attributes = tcx.get_attrs(def_id);
let param_env = tcx.param_env(def_id); let param_env = tcx.param_env(def_id);
let id = tcx let id = tcx
.hir .hir()
.as_local_node_id(def_id) .as_local_node_id(def_id)
.expect("do_mir_borrowck: non-local DefId"); .expect("do_mir_borrowck: non-local DefId");
@ -173,7 +173,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]), |bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
)); ));
let locals_are_invalidated_at_exit = match tcx.hir.body_owner_kind(id) { let locals_are_invalidated_at_exit = match tcx.hir().body_owner_kind(id) {
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => false, hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => false,
hir::BodyOwnerKind::Fn => true, hir::BodyOwnerKind::Fn => true,
}; };
@ -229,7 +229,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]), |bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
)); ));
let movable_generator = match tcx.hir.get(id) { let movable_generator = match tcx.hir().get(id) {
Node::Expr(&hir::Expr { Node::Expr(&hir::Expr {
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
.. ..

View file

@ -319,8 +319,8 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
let upvar_hir_id = let upvar_hir_id =
upvar_decl.var_hir_id.assert_crate_local(); upvar_decl.var_hir_id.assert_crate_local();
let upvar_node_id = let upvar_node_id =
self.infcx.tcx.hir.hir_to_node_id(upvar_hir_id); self.infcx.tcx.hir().hir_to_node_id(upvar_hir_id);
let upvar_span = self.infcx.tcx.hir.span(upvar_node_id); let upvar_span = self.infcx.tcx.hir().span(upvar_node_id);
diag.span_label(upvar_span, "captured outer variable"); diag.span_label(upvar_span, "captured outer variable");
break; break;
} }

View file

@ -317,8 +317,8 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
let upvar_hir_id = self.mir.upvar_decls[upvar_index.index()] let upvar_hir_id = self.mir.upvar_decls[upvar_index.index()]
.var_hir_id .var_hir_id
.assert_crate_local(); .assert_crate_local();
let upvar_node_id = self.infcx.tcx.hir.hir_to_node_id(upvar_hir_id); let upvar_node_id = self.infcx.tcx.hir().hir_to_node_id(upvar_hir_id);
if let Some(Node::Binding(pat)) = self.infcx.tcx.hir.find(upvar_node_id) { if let Some(Node::Binding(pat)) = self.infcx.tcx.hir().find(upvar_node_id) {
if let hir::PatKind::Binding( if let hir::PatKind::Binding(
hir::BindingAnnotation::Unannotated, hir::BindingAnnotation::Unannotated,
_, _,
@ -641,8 +641,8 @@ fn annotate_struct_field(
if let ty::TyKind::Adt(def, _) = ty.sty { if let ty::TyKind::Adt(def, _) = ty.sty {
let field = def.all_fields().nth(field.index())?; let field = def.all_fields().nth(field.index())?;
// Use the HIR types to construct the diagnostic message. // Use the HIR types to construct the diagnostic message.
let node_id = tcx.hir.as_local_node_id(field.did)?; let node_id = tcx.hir().as_local_node_id(field.did)?;
let node = tcx.hir.find(node_id)?; let node = tcx.hir().find(node_id)?;
// Now we're dealing with the actual struct that we're going to suggest a change to, // Now we're dealing with the actual struct that we're going to suggest a change to,
// we can expect a field that is an immutable reference to a type. // we can expect a field that is an immutable reference to a type.
if let hir::Node::Field(field) = node { if let hir::Node::Field(field) = node {

View file

@ -176,7 +176,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
// Dump facts if requested. // Dump facts if requested.
let polonius_output = all_facts.and_then(|all_facts| { let polonius_output = all_facts.and_then(|all_facts| {
if infcx.tcx.sess.opts.debugging_opts.nll_facts { if infcx.tcx.sess.opts.debugging_opts.nll_facts {
let def_path = infcx.tcx.hir.def_path(def_id); let def_path = infcx.tcx.hir().def_path(def_id);
let dir_path = let dir_path =
PathBuf::from("nll-facts").join(def_path.to_filename_friendly_no_crate()); PathBuf::from("nll-facts").join(def_path.to_filename_friendly_no_crate());
all_facts.write_to_dir(dir_path, location_table).unwrap(); all_facts.write_to_dir(dir_path, location_table).unwrap();

View file

@ -226,12 +226,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}, },
ty::BoundRegion::BrEnv => { ty::BoundRegion::BrEnv => {
let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir"); let mir_node_id = tcx.hir()
.as_local_node_id(mir_def_id)
.expect("non-local mir");
let def_ty = self.universal_regions.defining_ty; let def_ty = self.universal_regions.defining_ty;
if let DefiningTy::Closure(def_id, substs) = def_ty { if let DefiningTy::Closure(def_id, substs) = def_ty {
let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) = let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) =
tcx.hir.expect_expr(mir_node_id).node tcx.hir().expect_expr(mir_node_id).node
{ {
span span
} else { } else {
@ -302,10 +304,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
name: &InternedString, name: &InternedString,
) -> Span { ) -> Span {
let scope = error_region.free_region_binding_scope(tcx); let scope = error_region.free_region_binding_scope(tcx);
let node = tcx.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID); let node = tcx.hir().as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
let span = tcx.sess.source_map().def_span(tcx.hir.span(node)); let span = tcx.sess.source_map().def_span(tcx.hir().span(node));
if let Some(param) = tcx.hir if let Some(param) = tcx.hir()
.get_generics(scope) .get_generics(scope)
.and_then(|generics| generics.get_named(name)) .and_then(|generics| generics.get_named(name))
{ {
@ -361,8 +363,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
argument_index: usize, argument_index: usize,
counter: &mut usize, counter: &mut usize,
) -> Option<RegionName> { ) -> Option<RegionName> {
let mir_node_id = infcx.tcx.hir.as_local_node_id(mir_def_id)?; let mir_node_id = infcx.tcx.hir().as_local_node_id(mir_def_id)?;
let fn_decl = infcx.tcx.hir.fn_decl(mir_node_id)?; let fn_decl = infcx.tcx.hir().fn_decl(mir_node_id)?;
let argument_hir_ty: &hir::Ty = &fn_decl.inputs[argument_index]; let argument_hir_ty: &hir::Ty = &fn_decl.inputs[argument_index];
match argument_hir_ty.node { match argument_hir_ty.node {
// This indicates a variable with no type annotation, like // This indicates a variable with no type annotation, like
@ -685,9 +687,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let type_name = with_highlight_region_for_regionvid( let type_name = with_highlight_region_for_regionvid(
fr, *counter, || infcx.extract_type_name(&return_ty)); fr, *counter, || infcx.extract_type_name(&return_ty));
let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir"); let mir_node_id = tcx.hir().as_local_node_id(mir_def_id).expect("non-local mir");
let (return_span, mir_description) = match tcx.hir.get(mir_node_id) { let (return_span, mir_description) = match tcx.hir().get(mir_node_id) {
hir::Node::Expr(hir::Expr { hir::Node::Expr(hir::Expr {
node: hir::ExprKind::Closure(_, _, _, span, gen_move), node: hir::ExprKind::Closure(_, _, _, span, gen_move),
.. ..

View file

@ -81,11 +81,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
upvar_index: usize, upvar_index: usize,
) -> (Symbol, Span) { ) -> (Symbol, Span) {
let upvar_hir_id = mir.upvar_decls[upvar_index].var_hir_id.assert_crate_local(); let upvar_hir_id = mir.upvar_decls[upvar_index].var_hir_id.assert_crate_local();
let upvar_node_id = tcx.hir.hir_to_node_id(upvar_hir_id); let upvar_node_id = tcx.hir().hir_to_node_id(upvar_hir_id);
debug!("get_upvar_name_and_span_for_region: upvar_node_id={:?}", upvar_node_id); debug!("get_upvar_name_and_span_for_region: upvar_node_id={:?}", upvar_node_id);
let upvar_name = tcx.hir.name(upvar_node_id); let upvar_name = tcx.hir().name(upvar_node_id);
let upvar_span = tcx.hir.span(upvar_node_id); let upvar_span = tcx.hir().span(upvar_node_id);
debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}", debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}",
upvar_name, upvar_span); upvar_name, upvar_span);

View file

@ -210,8 +210,8 @@ impl<'tcx> UniversalRegions<'tcx> {
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
) -> Self { ) -> Self {
let tcx = infcx.tcx; let tcx = infcx.tcx;
let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).unwrap(); let mir_node_id = tcx.hir().as_local_node_id(mir_def_id).unwrap();
let mir_hir_id = tcx.hir.node_to_hir_id(mir_node_id); let mir_hir_id = tcx.hir().node_to_hir_id(mir_node_id);
UniversalRegionsBuilder { UniversalRegionsBuilder {
infcx, infcx,
mir_def_id, mir_def_id,
@ -485,7 +485,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id); let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id);
match tcx.hir.body_owner_kind(self.mir_node_id) { match tcx.hir().body_owner_kind(self.mir_node_id) {
BodyOwnerKind::Fn => { BodyOwnerKind::Fn => {
let defining_ty = if self.mir_def_id == closure_base_def_id { let defining_ty = if self.mir_def_id == closure_base_def_id {
tcx.type_of(closure_base_def_id) tcx.type_of(closure_base_def_id)
@ -780,9 +780,9 @@ fn for_each_late_bound_region_defined_on<'tcx>(
owner: fn_def_id.index, owner: fn_def_id.index,
local_id: *late_bound, local_id: *late_bound,
}; };
let region_node_id = tcx.hir.hir_to_node_id(hir_id); let region_node_id = tcx.hir().hir_to_node_id(hir_id);
let name = tcx.hir.name(region_node_id).as_interned_str(); let name = tcx.hir().name(region_node_id).as_interned_str();
let region_def_id = tcx.hir.local_def_id(region_node_id); let region_def_id = tcx.hir().local_def_id(region_node_id);
let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion { let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
scope: fn_def_id, scope: fn_def_id,
bound_region: ty::BoundRegion::BrNamed(region_def_id, name), bound_region: ty::BoundRegion::BrNamed(region_def_id, name),

View file

@ -470,7 +470,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
); );
let place = Place::Local(local_id); let place = Place::Local(local_id);
let var_ty = self.local_decls[local_id].ty; let var_ty = self.local_decls[local_id].ty;
let hir_id = self.hir.tcx().hir.node_to_hir_id(var); let hir_id = self.hir.tcx().hir().node_to_hir_id(var);
let region_scope = self.hir.region_scope_tree.var_scope(hir_id.local_id); let region_scope = self.hir.region_scope_tree.var_scope(hir_id.local_id);
self.schedule_drop(span, region_scope, &place, var_ty, DropKind::Storage); self.schedule_drop(span, region_scope, &place, var_ty, DropKind::Storage);
place place
@ -479,7 +479,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
pub fn schedule_drop_for_binding(&mut self, var: NodeId, span: Span, for_guard: ForGuard) { pub fn schedule_drop_for_binding(&mut self, var: NodeId, span: Span, for_guard: ForGuard) {
let local_id = self.var_local_id(var, for_guard); let local_id = self.var_local_id(var, for_guard);
let var_ty = self.local_decls[local_id].ty; let var_ty = self.local_decls[local_id].ty;
let hir_id = self.hir.tcx().hir.node_to_hir_id(var); let hir_id = self.hir.tcx().hir().node_to_hir_id(var);
let region_scope = self.hir.region_scope_tree.var_scope(hir_id.local_id); let region_scope = self.hir.region_scope_tree.var_scope(hir_id.local_id);
self.schedule_drop( self.schedule_drop(
span, span,

View file

@ -39,10 +39,10 @@ use super::lints;
/// Construct the MIR for a given def-id. /// Construct the MIR for a given def-id.
pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'tcx> { pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'tcx> {
let id = tcx.hir.as_local_node_id(def_id).unwrap(); let id = tcx.hir().as_local_node_id(def_id).unwrap();
// Figure out what primary body this item has. // Figure out what primary body this item has.
let (body_id, return_ty_span) = match tcx.hir.get(id) { let (body_id, return_ty_span) = match tcx.hir().get(id) {
Node::Variant(variant) => Node::Variant(variant) =>
return create_constructor_shim(tcx, id, &variant.node.data), return create_constructor_shim(tcx, id, &variant.node.data),
Node::StructCtor(ctor) => Node::StructCtor(ctor) =>
@ -76,10 +76,10 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
(*body_id, ty.span) (*body_id, ty.span)
} }
Node::AnonConst(hir::AnonConst { body, id, .. }) => { Node::AnonConst(hir::AnonConst { body, id, .. }) => {
(*body, tcx.hir.span(*id)) (*body, tcx.hir().span(*id))
} }
_ => span_bug!(tcx.hir.span(id), "can't build MIR for {:?}", def_id), _ => span_bug!(tcx.hir().span(id), "can't build MIR for {:?}", def_id),
}; };
tcx.infer_ctxt().enter(|infcx| { tcx.infer_ctxt().enter(|infcx| {
@ -89,9 +89,9 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
} else if let hir::BodyOwnerKind::Fn = cx.body_owner_kind { } else if let hir::BodyOwnerKind::Fn = cx.body_owner_kind {
// fetch the fully liberated fn signature (that is, all bound // fetch the fully liberated fn signature (that is, all bound
// types/lifetimes replaced) // types/lifetimes replaced)
let fn_hir_id = tcx.hir.node_to_hir_id(id); let fn_hir_id = tcx.hir().node_to_hir_id(id);
let fn_sig = cx.tables().liberated_fn_sigs()[fn_hir_id].clone(); let fn_sig = cx.tables().liberated_fn_sigs()[fn_hir_id].clone();
let fn_def_id = tcx.hir.local_def_id(id); let fn_def_id = tcx.hir().local_def_id(id);
let ty = tcx.type_of(fn_def_id); let ty = tcx.type_of(fn_def_id);
let mut abi = fn_sig.abi; let mut abi = fn_sig.abi;
@ -121,18 +121,18 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
hir::Unsafety::Unsafe => Safety::FnUnsafe, hir::Unsafety::Unsafe => Safety::FnUnsafe,
}; };
let body = tcx.hir.body(body_id); let body = tcx.hir().body(body_id);
let explicit_arguments = let explicit_arguments =
body.arguments body.arguments
.iter() .iter()
.enumerate() .enumerate()
.map(|(index, arg)| { .map(|(index, arg)| {
let owner_id = tcx.hir.body_owner(body_id); let owner_id = tcx.hir().body_owner(body_id);
let opt_ty_info; let opt_ty_info;
let self_arg; let self_arg;
if let Some(ref fn_decl) = tcx.hir.fn_decl(owner_id) { if let Some(ref fn_decl) = tcx.hir().fn_decl(owner_id) {
let ty_hir_id = fn_decl.inputs[index].hir_id; let ty_hir_id = fn_decl.inputs[index].hir_id;
let ty_span = tcx.hir.span(tcx.hir.hir_to_node_id(ty_hir_id)); let ty_span = tcx.hir().span(tcx.hir().hir_to_node_id(ty_hir_id));
opt_ty_info = Some(ty_span); opt_ty_info = Some(ty_span);
self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() { self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() {
match fn_decl.implicit_self { match fn_decl.implicit_self {
@ -159,7 +159,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
ty::Generator(gen_def_id, gen_substs, ..) => ty::Generator(gen_def_id, gen_substs, ..) =>
gen_substs.sig(gen_def_id, tcx), gen_substs.sig(gen_def_id, tcx),
_ => _ =>
span_bug!(tcx.hir.span(id), "generator w/o generator type: {:?}", ty), span_bug!(tcx.hir().span(id), "generator w/o generator type: {:?}", ty),
}; };
(Some(gen_sig.yield_ty), gen_sig.return_ty) (Some(gen_sig.yield_ty), gen_sig.return_ty)
} else { } else {
@ -246,7 +246,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
v: &'tcx hir::VariantData) v: &'tcx hir::VariantData)
-> Mir<'tcx> -> Mir<'tcx>
{ {
let span = tcx.hir.span(ctor_id); let span = tcx.hir().span(ctor_id);
if let hir::VariantData::Tuple(ref fields, ctor_id) = *v { if let hir::VariantData::Tuple(ref fields, ctor_id) = *v {
tcx.infer_ctxt().enter(|infcx| { tcx.infer_ctxt().enter(|infcx| {
let mut mir = shim::build_adt_ctor(&infcx, ctor_id, fields, span); let mut mir = shim::build_adt_ctor(&infcx, ctor_id, fields, span);
@ -263,7 +263,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}; };
mir_util::dump_mir(tcx, None, "mir_map", &0, mir_util::dump_mir(tcx, None, "mir_map", &0,
MirSource::item(tcx.hir.local_def_id(ctor_id)), MirSource::item(tcx.hir().local_def_id(ctor_id)),
&mir, |_, _| Ok(()) ); &mir, |_, _| Ok(()) );
mir mir
@ -280,7 +280,7 @@ fn liberated_closure_env_ty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
closure_expr_id: ast::NodeId, closure_expr_id: ast::NodeId,
body_id: hir::BodyId) body_id: hir::BodyId)
-> Ty<'tcx> { -> Ty<'tcx> {
let closure_expr_hir_id = tcx.hir.node_to_hir_id(closure_expr_id); let closure_expr_hir_id = tcx.hir().node_to_hir_id(closure_expr_id);
let closure_ty = tcx.body_tables(body_id).node_id_to_type(closure_expr_hir_id); let closure_ty = tcx.body_tables(body_id).node_id_to_type(closure_expr_hir_id);
let (closure_def_id, closure_substs) = match closure_ty.sty { let (closure_def_id, closure_substs) = match closure_ty.sty {
@ -662,14 +662,14 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
let arguments: Vec<_> = arguments.collect(); let arguments: Vec<_> = arguments.collect();
let tcx = hir.tcx(); let tcx = hir.tcx();
let span = tcx.hir.span(fn_id); let span = tcx.hir().span(fn_id);
// Gather the upvars of a closure, if any. // Gather the upvars of a closure, if any.
let upvar_decls: Vec<_> = tcx.with_freevars(fn_id, |freevars| { let upvar_decls: Vec<_> = tcx.with_freevars(fn_id, |freevars| {
freevars.iter().map(|fv| { freevars.iter().map(|fv| {
let var_id = fv.var_id(); let var_id = fv.var_id();
let var_hir_id = tcx.hir.node_to_hir_id(var_id); let var_hir_id = tcx.hir().node_to_hir_id(var_id);
let closure_expr_id = tcx.hir.local_def_id(fn_id); let closure_expr_id = tcx.hir().local_def_id(fn_id);
let capture = hir.tables().upvar_capture(ty::UpvarId { let capture = hir.tables().upvar_capture(ty::UpvarId {
var_path: ty::UpvarPath {hir_id: var_hir_id}, var_path: ty::UpvarPath {hir_id: var_hir_id},
closure_expr_id: LocalDefId::from_def_id(closure_expr_id), closure_expr_id: LocalDefId::from_def_id(closure_expr_id),
@ -684,7 +684,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
by_ref, by_ref,
mutability: Mutability::Not, mutability: Mutability::Not,
}; };
if let Some(Node::Binding(pat)) = tcx.hir.find(var_id) { if let Some(Node::Binding(pat)) = tcx.hir().find(var_id) {
if let hir::PatKind::Binding(_, _, ident, _) = pat.node { if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
decl.debug_name = ident.name; decl.debug_name = ident.name;
@ -711,7 +711,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
return_ty_span, return_ty_span,
upvar_decls); upvar_decls);
let fn_def_id = tcx.hir.local_def_id(fn_id); let fn_def_id = tcx.hir().local_def_id(fn_id);
let call_site_scope = region::Scope { let call_site_scope = region::Scope {
id: body.value.hir_id.local_id, id: body.value.hir_id.local_id,
data: region::ScopeData::CallSite data: region::ScopeData::CallSite
@ -754,7 +754,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
// RustCall pseudo-ABI untuples the last argument. // RustCall pseudo-ABI untuples the last argument.
spread_arg = Some(Local::new(arguments.len())); spread_arg = Some(Local::new(arguments.len()));
} }
let closure_expr_id = tcx.hir.local_def_id(fn_id); let closure_expr_id = tcx.hir().local_def_id(fn_id);
info!("fn_id {:?} has attrs {:?}", closure_expr_id, info!("fn_id {:?} has attrs {:?}", closure_expr_id,
tcx.get_attrs(closure_expr_id)); tcx.get_attrs(closure_expr_id));
@ -769,10 +769,10 @@ fn construct_const<'a, 'gcx, 'tcx>(
ty_span: Span, ty_span: Span,
) -> Mir<'tcx> { ) -> Mir<'tcx> {
let tcx = hir.tcx(); let tcx = hir.tcx();
let ast_expr = &tcx.hir.body(body_id).value; let ast_expr = &tcx.hir().body(body_id).value;
let ty = hir.tables().expr_ty_adjusted(ast_expr); let ty = hir.tables().expr_ty_adjusted(ast_expr);
let owner_id = tcx.hir.body_owner(body_id); let owner_id = tcx.hir().body_owner(body_id);
let span = tcx.hir.span(owner_id); let span = tcx.hir().span(owner_id);
let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, ty_span,vec![]); let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, ty_span,vec![]);
let mut block = START_BLOCK; let mut block = START_BLOCK;
@ -798,8 +798,8 @@ fn construct_const<'a, 'gcx, 'tcx>(
fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>, fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>,
body_id: hir::BodyId) body_id: hir::BodyId)
-> Mir<'tcx> { -> Mir<'tcx> {
let owner_id = hir.tcx().hir.body_owner(body_id); let owner_id = hir.tcx().hir().body_owner(body_id);
let span = hir.tcx().hir.span(owner_id); let span = hir.tcx().hir().span(owner_id);
let ty = hir.tcx().types.err; let ty = hir.tcx().types.err;
let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, span, vec![]); let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, span, vec![]);
let source_info = builder.source_info(span); let source_info = builder.source_info(span);

View file

@ -322,11 +322,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
let same_lint_scopes = tcx.dep_graph.with_ignore(|| { let same_lint_scopes = tcx.dep_graph.with_ignore(|| {
let sets = tcx.lint_levels(LOCAL_CRATE); let sets = tcx.lint_levels(LOCAL_CRATE);
let parent_hir_id = let parent_hir_id =
tcx.hir.definitions().node_to_hir_id( tcx.hir().definitions().node_to_hir_id(
self.source_scope_local_data[source_scope].lint_root self.source_scope_local_data[source_scope].lint_root
); );
let current_hir_id = let current_hir_id =
tcx.hir.definitions().node_to_hir_id(node_id); tcx.hir().definitions().node_to_hir_id(node_id);
sets.lint_level_set(parent_hir_id) == sets.lint_level_set(parent_hir_id) ==
sets.lint_level_set(current_hir_id) sets.lint_level_set(current_hir_id)
}); });

View file

@ -664,7 +664,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
let cid = key.value; let cid = key.value;
let def_id = cid.instance.def.def_id(); let def_id = cid.instance.def.def_id();
if let Some(id) = tcx.hir.as_local_node_id(def_id) { if let Some(id) = tcx.hir().as_local_node_id(def_id) {
let tables = tcx.typeck_tables_of(def_id); let tables = tcx.typeck_tables_of(def_id);
// Do match-check before building MIR // Do match-check before building MIR
@ -672,7 +672,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
return Err(ErrorHandled::Reported) return Err(ErrorHandled::Reported)
} }
if let hir::BodyOwnerKind::Const = tcx.hir.body_owner_kind(id) { if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind(id) {
tcx.mir_const_qualif(def_id); tcx.mir_const_qualif(def_id);
} }
@ -708,7 +708,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
// because any code that existed before validation could not have failed validation // because any code that existed before validation could not have failed validation
// thus preventing such a hard error from being a backwards compatibility hazard // thus preventing such a hard error from being a backwards compatibility hazard
Some(Def::Const(_)) | Some(Def::AssociatedConst(_)) => { Some(Def::Const(_)) | Some(Def::AssociatedConst(_)) => {
let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
err.report_as_lint( err.report_as_lint(
tcx.at(tcx.def_span(def_id)), tcx.at(tcx.def_span(def_id)),
"any use of this value will cause an error", "any use of this value will cause an error",
@ -728,7 +728,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
err.report_as_lint( err.report_as_lint(
tcx.at(span), tcx.at(span),
"reaching this expression at runtime will panic or abort", "reaching this expression at runtime will panic or abort",
tcx.hir.as_local_node_id(def_id).unwrap(), tcx.hir().as_local_node_id(def_id).unwrap(),
) )
} }
// anything else (array lengths, enum initializers, constant patterns) are reported // anything else (array lengths, enum initializers, constant patterns) are reported

View file

@ -55,9 +55,9 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
-> Vec<StmtRef<'tcx>> { -> Vec<StmtRef<'tcx>> {
let mut result = vec![]; let mut result = vec![];
for (index, stmt) in stmts.iter().enumerate() { for (index, stmt) in stmts.iter().enumerate() {
let hir_id = cx.tcx.hir.node_to_hir_id(stmt.node.id()); let hir_id = cx.tcx.hir().node_to_hir_id(stmt.node.id());
let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id); let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id);
let stmt_span = StatementSpan(cx.tcx.hir.span(stmt.node.id())); let stmt_span = StatementSpan(cx.tcx.hir().span(stmt.node.id()));
match stmt.node { match stmt.node {
hir::StmtKind::Expr(ref expr, _) | hir::StmtKind::Expr(ref expr, _) |
hir::StmtKind::Semi(ref expr, _) => { hir::StmtKind::Semi(ref expr, _) => {

View file

@ -556,7 +556,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
// Now comes the rote stuff: // Now comes the rote stuff:
hir::ExprKind::Repeat(ref v, ref count) => { hir::ExprKind::Repeat(ref v, ref count) => {
let def_id = cx.tcx.hir.local_def_id(count.id); let def_id = cx.tcx.hir().local_def_id(count.id);
let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id); let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id);
let instance = ty::Instance::resolve( let instance = ty::Instance::resolve(
cx.tcx.global_tcx(), cx.tcx.global_tcx(),
@ -588,7 +588,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
match dest.target_id { match dest.target_id {
Ok(target_id) => ExprKind::Break { Ok(target_id) => ExprKind::Break {
label: region::Scope { label: region::Scope {
id: cx.tcx.hir.node_to_hir_id(target_id).local_id, id: cx.tcx.hir().node_to_hir_id(target_id).local_id,
data: region::ScopeData::Node data: region::ScopeData::Node
}, },
value: value.to_ref(), value: value.to_ref(),
@ -600,7 +600,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
match dest.target_id { match dest.target_id {
Ok(loop_id) => ExprKind::Continue { Ok(loop_id) => ExprKind::Continue {
label: region::Scope { label: region::Scope {
id: cx.tcx.hir.node_to_hir_id(loop_id).local_id, id: cx.tcx.hir().node_to_hir_id(loop_id).local_id,
data: region::ScopeData::Node data: region::ScopeData::Node
}, },
}, },
@ -974,17 +974,17 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
var_id, var_id,
index, index,
closure_expr_id); closure_expr_id);
let var_hir_id = cx.tcx.hir.node_to_hir_id(var_id); let var_hir_id = cx.tcx.hir().node_to_hir_id(var_id);
let var_ty = cx.tables().node_id_to_type(var_hir_id); let var_ty = cx.tables().node_id_to_type(var_hir_id);
// FIXME free regions in closures are not right // FIXME free regions in closures are not right
let closure_ty = cx.tables() let closure_ty = cx.tables()
.node_id_to_type(cx.tcx.hir.node_to_hir_id(closure_expr_id)); .node_id_to_type(cx.tcx.hir().node_to_hir_id(closure_expr_id));
// FIXME we're just hard-coding the idea that the // FIXME we're just hard-coding the idea that the
// signature will be &self or &mut self and hence will // signature will be &self or &mut self and hence will
// have a bound region with number 0 // have a bound region with number 0
let closure_def_id = cx.tcx.hir.local_def_id(closure_expr_id); let closure_def_id = cx.tcx.hir().local_def_id(closure_expr_id);
let region = ty::ReFree(ty::FreeRegion { let region = ty::ReFree(ty::FreeRegion {
scope: closure_def_id, scope: closure_def_id,
bound_region: ty::BoundRegion::BrAnon(0), bound_region: ty::BoundRegion::BrAnon(0),
@ -1176,10 +1176,10 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
freevar: &hir::Freevar, freevar: &hir::Freevar,
freevar_ty: Ty<'tcx>) freevar_ty: Ty<'tcx>)
-> ExprRef<'tcx> { -> ExprRef<'tcx> {
let var_hir_id = cx.tcx.hir.node_to_hir_id(freevar.var_id()); let var_hir_id = cx.tcx.hir().node_to_hir_id(freevar.var_id());
let upvar_id = ty::UpvarId { let upvar_id = ty::UpvarId {
var_path: ty::UpvarPath { hir_id: var_hir_id }, var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: cx.tcx.hir.local_def_id(closure_expr.id).to_local(), closure_expr_id: cx.tcx.hir().local_def_id(closure_expr.id).to_local(),
}; };
let upvar_capture = cx.tables().upvar_capture(upvar_id); let upvar_capture = cx.tables().upvar_capture(upvar_id);
let temp_lifetime = cx.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id); let temp_lifetime = cx.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id);

View file

@ -62,8 +62,8 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
src_id: ast::NodeId) -> Cx<'a, 'gcx, 'tcx> { src_id: ast::NodeId) -> Cx<'a, 'gcx, 'tcx> {
let tcx = infcx.tcx; let tcx = infcx.tcx;
let src_def_id = tcx.hir.local_def_id(src_id); let src_def_id = tcx.hir().local_def_id(src_id);
let body_owner_kind = tcx.hir.body_owner_kind(src_id); let body_owner_kind = tcx.hir().body_owner_kind(src_id);
let constness = match body_owner_kind { let constness = match body_owner_kind {
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Const |
@ -71,7 +71,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
hir::BodyOwnerKind::Fn => hir::Constness::NotConst, hir::BodyOwnerKind::Fn => hir::Constness::NotConst,
}; };
let attrs = tcx.hir.attrs(src_id); let attrs = tcx.hir().attrs(src_id);
// Some functions always have overflow checks enabled, // Some functions always have overflow checks enabled,
// however, they may not get codegen'd, depending on // however, they may not get codegen'd, depending on
@ -157,7 +157,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> { pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> {
let tcx = self.tcx.global_tcx(); let tcx = self.tcx.global_tcx();
let p = match tcx.hir.get(p.id) { let p = match tcx.hir().get(p.id) {
Node::Pat(p) | Node::Binding(p) => p, Node::Pat(p) | Node::Binding(p) => p,
node => bug!("pattern became {:?}", node) node => bug!("pattern became {:?}", node)
}; };
@ -202,7 +202,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
} }
fn lint_level_of(&self, node_id: ast::NodeId) -> LintLevel { fn lint_level_of(&self, node_id: ast::NodeId) -> LintLevel {
let hir_id = self.tcx.hir.definitions().node_to_hir_id(node_id); let hir_id = self.tcx.hir().definitions().node_to_hir_id(node_id);
let has_lint_level = self.tcx.dep_graph.with_ignore(|| { let has_lint_level = self.tcx.dep_graph.with_ignore(|| {
self.tcx.lint_levels(LOCAL_CRATE).lint_level_set(hir_id).is_some() self.tcx.lint_levels(LOCAL_CRATE).lint_level_set(hir_id).is_some()
}); });
@ -253,11 +253,11 @@ fn lint_level_for_hir_id(tcx: TyCtxt, mut id: ast::NodeId) -> ast::NodeId {
tcx.dep_graph.with_ignore(|| { tcx.dep_graph.with_ignore(|| {
let sets = tcx.lint_levels(LOCAL_CRATE); let sets = tcx.lint_levels(LOCAL_CRATE);
loop { loop {
let hir_id = tcx.hir.definitions().node_to_hir_id(id); let hir_id = tcx.hir().definitions().node_to_hir_id(id);
if sets.lint_level_set(hir_id).is_some() { if sets.lint_level_set(hir_id).is_some() {
return id return id
} }
let next = tcx.hir.get_parent_node(id); let next = tcx.hir().get_parent_node(id);
if next == id { if next == id {
bug!("lint traversal reached the root of the crate"); bug!("lint traversal reached the root of the crate");
} }

View file

@ -41,18 +41,18 @@ struct OuterVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx> }
impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }
fn visit_body(&mut self, body: &'tcx hir::Body) { fn visit_body(&mut self, body: &'tcx hir::Body) {
intravisit::walk_body(self, body); intravisit::walk_body(self, body);
let def_id = self.tcx.hir.body_owner_def_id(body.id()); let def_id = self.tcx.hir().body_owner_def_id(body.id());
let _ = self.tcx.check_match(def_id); let _ = self.tcx.check_match(def_id);
} }
} }
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
tcx.hir.krate().visit_all_item_likes(&mut OuterVisitor { tcx }.as_deep_visitor()); tcx.hir().krate().visit_all_item_likes(&mut OuterVisitor { tcx }.as_deep_visitor());
tcx.sess.abort_if_errors(); tcx.sess.abort_if_errors();
} }
@ -60,8 +60,8 @@ pub(crate) fn check_match<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId, def_id: DefId,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorReported> {
let body_id = if let Some(id) = tcx.hir.as_local_node_id(def_id) { let body_id = if let Some(id) = tcx.hir().as_local_node_id(def_id) {
tcx.hir.body_owned_by(id) tcx.hir().body_owned_by(id)
} else { } else {
return Ok(()); return Ok(());
}; };
@ -73,7 +73,7 @@ pub(crate) fn check_match<'a, 'tcx>(
region_scope_tree: &tcx.region_scope_tree(def_id), region_scope_tree: &tcx.region_scope_tree(def_id),
param_env: tcx.param_env(def_id), param_env: tcx.param_env(def_id),
identity_substs: Substs::identity_for_item(tcx, def_id), identity_substs: Substs::identity_for_item(tcx, def_id),
}.visit_body(tcx.hir.body(body_id)); }.visit_body(tcx.hir().body(body_id));
}) })
} }
@ -192,7 +192,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
} }
} }
let module = self.tcx.hir.get_module_parent(scrut.id); let module = self.tcx.hir().get_module_parent(scrut.id);
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| { MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
let mut have_errors = false; let mut have_errors = false;
@ -224,7 +224,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
// Then, if the match has no arms, check whether the scrutinee // Then, if the match has no arms, check whether the scrutinee
// is uninhabited. // is uninhabited.
let pat_ty = self.tables.node_id_to_type(scrut.hir_id); let pat_ty = self.tables.node_id_to_type(scrut.hir_id);
let module = self.tcx.hir.get_module_parent(scrut.id); let module = self.tcx.hir().get_module_parent(scrut.id);
if inlined_arms.is_empty() { if inlined_arms.is_empty() {
let scrutinee_is_uninhabited = if self.tcx.features().exhaustive_patterns { let scrutinee_is_uninhabited = if self.tcx.features().exhaustive_patterns {
self.tcx.is_ty_uninhabited_from(module, pat_ty) self.tcx.is_ty_uninhabited_from(module, pat_ty)
@ -267,7 +267,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
} }
fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) { fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
let module = self.tcx.hir.get_module_parent(pat.id); let module = self.tcx.hir().get_module_parent(pat.id);
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| { MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
let mut patcx = PatternContext::new(self.tcx, let mut patcx = PatternContext::new(self.tcx,
self.param_env.and(self.identity_substs), self.param_env.and(self.identity_substs),

View file

@ -954,7 +954,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
}; };
let kind = match cv.ty.sty { let kind = match cv.ty.sty {
ty::Float(_) => { ty::Float(_) => {
let id = self.tcx.hir.hir_to_node_id(id); let id = self.tcx.hir().hir_to_node_id(id);
self.tcx.lint_node( self.tcx.lint_node(
::rustc::lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN, ::rustc::lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
id, id,

View file

@ -20,9 +20,9 @@ use rustc::ty::subst::Substs;
pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>, pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>,
mir: &Mir<'tcx>, mir: &Mir<'tcx>,
def_id: DefId) { def_id: DefId) {
let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir.get(node_id)) { if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir().get(node_id)) {
check_fn_for_unconditional_recursion(tcx, fn_like_node.kind(), mir, def_id); check_fn_for_unconditional_recursion(tcx, fn_like_node.kind(), mir, def_id);
} }
} }
@ -139,8 +139,8 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// no break */ }`) shouldn't be linted unless it actually // no break */ }`) shouldn't be linted unless it actually
// recurs. // recurs.
if !reached_exit_without_self_call && !self_call_locations.is_empty() { if !reached_exit_without_self_call && !self_call_locations.is_empty() {
let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
let sp = tcx.sess.source_map().def_span(tcx.hir.span(node_id)); let sp = tcx.sess.source_map().def_span(tcx.hir().span(node_id));
let mut db = tcx.struct_span_lint_node(UNCONDITIONAL_RECURSION, let mut db = tcx.struct_span_lint_node(UNCONDITIONAL_RECURSION,
node_id, node_id,
sp, sp,

View file

@ -332,7 +332,7 @@ fn collect_roots<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
{ {
let entry_fn = tcx.sess.entry_fn.borrow().map(|(node_id, _, _)| { let entry_fn = tcx.sess.entry_fn.borrow().map(|(node_id, _, _)| {
tcx.hir.local_def_id(node_id) tcx.hir().local_def_id(node_id)
}); });
debug!("collect_roots: entry_fn = {:?}", entry_fn); debug!("collect_roots: entry_fn = {:?}", entry_fn);
@ -344,7 +344,7 @@ fn collect_roots<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
output: &mut roots, output: &mut roots,
}; };
tcx.hir.krate().visit_all_item_likes(&mut visitor); tcx.hir().krate().visit_all_item_likes(&mut visitor);
visitor.push_extra_entry_roots(); visitor.push_extra_entry_roots();
} }
@ -462,8 +462,8 @@ fn check_recursion_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
if recursion_depth > *tcx.sess.recursion_limit.get() { if recursion_depth > *tcx.sess.recursion_limit.get() {
let error = format!("reached the recursion limit while instantiating `{}`", let error = format!("reached the recursion limit while instantiating `{}`",
instance); instance);
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
tcx.sess.span_fatal(tcx.hir.span(node_id), &error); tcx.sess.span_fatal(tcx.hir().span(node_id), &error);
} else { } else {
tcx.sess.fatal(&error); tcx.sess.fatal(&error);
} }
@ -494,8 +494,8 @@ fn check_type_length_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let instance_name = instance.to_string(); let instance_name = instance.to_string();
let msg = format!("reached the type-length limit while instantiating `{:.64}...`", let msg = format!("reached the type-length limit while instantiating `{:.64}...`",
instance_name); instance_name);
let mut diag = if let Some(node_id) = tcx.hir.as_local_node_id(instance.def_id()) { let mut diag = if let Some(node_id) = tcx.hir().as_local_node_id(instance.def_id()) {
tcx.sess.struct_span_fatal(tcx.hir.span(node_id), &msg) tcx.sess.struct_span_fatal(tcx.hir().span(node_id), &msg)
} else { } else {
tcx.sess.struct_fatal(&msg) tcx.sess.struct_fatal(&msg)
}; };
@ -961,7 +961,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
hir::ItemKind::Union(_, ref generics) => { hir::ItemKind::Union(_, ref generics) => {
if generics.params.is_empty() { if generics.params.is_empty() {
if self.mode == MonoItemCollectionMode::Eager { if self.mode == MonoItemCollectionMode::Eager {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
debug!("RootCollector: ADT drop-glue for {}", debug!("RootCollector: ADT drop-glue for {}",
def_id_to_string(self.tcx, def_id)); def_id_to_string(self.tcx, def_id));
@ -973,11 +973,11 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
hir::ItemKind::GlobalAsm(..) => { hir::ItemKind::GlobalAsm(..) => {
debug!("RootCollector: ItemKind::GlobalAsm({})", debug!("RootCollector: ItemKind::GlobalAsm({})",
def_id_to_string(self.tcx, def_id_to_string(self.tcx,
self.tcx.hir.local_def_id(item.id))); self.tcx.hir().local_def_id(item.id)));
self.output.push(MonoItem::GlobalAsm(item.id)); self.output.push(MonoItem::GlobalAsm(item.id));
} }
hir::ItemKind::Static(..) => { hir::ItemKind::Static(..) => {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
debug!("RootCollector: ItemKind::Static({})", debug!("RootCollector: ItemKind::Static({})",
def_id_to_string(self.tcx, def_id)); def_id_to_string(self.tcx, def_id));
self.output.push(MonoItem::Static(def_id)); self.output.push(MonoItem::Static(def_id));
@ -987,7 +987,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
// actually used somewhere. Just declaring them is insufficient. // actually used somewhere. Just declaring them is insufficient.
// but even just declaring them must collect the items they refer to // but even just declaring them must collect the items they refer to
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
let instance = Instance::mono(self.tcx, def_id); let instance = Instance::mono(self.tcx, def_id);
let cid = GlobalId { let cid = GlobalId {
@ -1001,7 +1001,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
} }
} }
hir::ItemKind::Fn(..) => { hir::ItemKind::Fn(..) => {
let def_id = self.tcx.hir.local_def_id(item.id); let def_id = self.tcx.hir().local_def_id(item.id);
self.push_if_root(def_id); self.push_if_root(def_id);
} }
} }
@ -1015,7 +1015,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) { fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
match ii.node { match ii.node {
hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => { hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
let def_id = self.tcx.hir.local_def_id(ii.id); let def_id = self.tcx.hir().local_def_id(ii.id);
self.push_if_root(def_id); self.push_if_root(def_id);
} }
_ => { /* Nothing to do here */ } _ => { /* Nothing to do here */ }
@ -1108,7 +1108,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
} }
} }
let impl_def_id = tcx.hir.local_def_id(item.id); let impl_def_id = tcx.hir().local_def_id(item.id);
debug!("create_mono_items_for_default_impls(item={})", debug!("create_mono_items_for_default_impls(item={})",
def_id_to_string(tcx, impl_def_id)); def_id_to_string(tcx, impl_def_id));

View file

@ -68,7 +68,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug {
tcx.symbol_name(Instance::mono(tcx, def_id)) tcx.symbol_name(Instance::mono(tcx, def_id))
} }
MonoItem::GlobalAsm(node_id) => { MonoItem::GlobalAsm(node_id) => {
let def_id = tcx.hir.local_def_id(node_id); let def_id = tcx.hir().local_def_id(node_id);
ty::SymbolName { ty::SymbolName {
name: Symbol::intern(&format!("global_asm_{:?}", def_id)).as_interned_str() name: Symbol::intern(&format!("global_asm_{:?}", def_id)).as_interned_str()
} }
@ -86,7 +86,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug {
match *self.as_mono_item() { match *self.as_mono_item() {
MonoItem::Fn(ref instance) => { MonoItem::Fn(ref instance) => {
let entry_def_id = let entry_def_id =
tcx.sess.entry_fn.borrow().map(|(id, _, _)| tcx.hir.local_def_id(id)); tcx.sess.entry_fn.borrow().map(|(id, _, _)| tcx.hir().local_def_id(id));
// If this function isn't inlined or otherwise has explicit // If this function isn't inlined or otherwise has explicit
// linkage, then we'll be creating a globally shared version. // linkage, then we'll be creating a globally shared version.
if self.explicit_linkage(tcx).is_some() || if self.explicit_linkage(tcx).is_some() ||
@ -199,15 +199,15 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug {
fn local_span(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Span> { fn local_span(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Span> {
match *self.as_mono_item() { match *self.as_mono_item() {
MonoItem::Fn(Instance { def, .. }) => { MonoItem::Fn(Instance { def, .. }) => {
tcx.hir.as_local_node_id(def.def_id()) tcx.hir().as_local_node_id(def.def_id())
} }
MonoItem::Static(def_id) => { MonoItem::Static(def_id) => {
tcx.hir.as_local_node_id(def_id) tcx.hir().as_local_node_id(def_id)
} }
MonoItem::GlobalAsm(node_id) => { MonoItem::GlobalAsm(node_id) => {
Some(node_id) Some(node_id)
} }
}.map(|node_id| tcx.hir.span(node_id)) }.map(|node_id| tcx.hir().span(node_id))
} }
} }

View file

@ -184,7 +184,7 @@ pub trait CodegenUnitExt<'tcx> {
// the codegen tests and can even make item order // the codegen tests and can even make item order
// unstable. // unstable.
InstanceDef::Item(def_id) => { InstanceDef::Item(def_id) => {
tcx.hir.as_local_node_id(def_id) tcx.hir().as_local_node_id(def_id)
} }
InstanceDef::VtableShim(..) | InstanceDef::VtableShim(..) |
InstanceDef::Intrinsic(..) | InstanceDef::Intrinsic(..) |
@ -198,7 +198,7 @@ pub trait CodegenUnitExt<'tcx> {
} }
} }
MonoItem::Static(def_id) => { MonoItem::Static(def_id) => {
tcx.hir.as_local_node_id(def_id) tcx.hir().as_local_node_id(def_id)
} }
MonoItem::GlobalAsm(node_id) => { MonoItem::GlobalAsm(node_id) => {
Some(node_id) Some(node_id)
@ -415,7 +415,7 @@ fn mono_item_visibility(
}; };
} }
MonoItem::GlobalAsm(node_id) => { MonoItem::GlobalAsm(node_id) => {
let def_id = tcx.hir.local_def_id(*node_id); let def_id = tcx.hir().local_def_id(*node_id);
return if tcx.is_reachable_non_generic(def_id) { return if tcx.is_reachable_non_generic(def_id) {
*can_be_internalized = false; *can_be_internalized = false;
default_visibility(tcx, def_id, false) default_visibility(tcx, def_id, false)
@ -799,7 +799,7 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Some(def_id) Some(def_id)
} }
MonoItem::Static(def_id) => Some(def_id), MonoItem::Static(def_id) => Some(def_id),
MonoItem::GlobalAsm(node_id) => Some(tcx.hir.local_def_id(node_id)), MonoItem::GlobalAsm(node_id) => Some(tcx.hir().local_def_id(node_id)),
} }
} }

View file

@ -860,7 +860,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
{ {
let tcx = infcx.tcx; let tcx = infcx.tcx;
let gcx = tcx.global_tcx(); let gcx = tcx.global_tcx();
let def_id = tcx.hir.local_def_id(ctor_id); let def_id = tcx.hir().local_def_id(ctor_id);
let param_env = gcx.param_env(def_id); let param_env = gcx.param_env(def_id);
// Normalize the sig. // Normalize the sig.

View file

@ -473,8 +473,8 @@ fn check_unused_unsafe<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
unsafe_blocks: &'a mut Vec<(ast::NodeId, bool)>) unsafe_blocks: &'a mut Vec<(ast::NodeId, bool)>)
{ {
let body_id = let body_id =
tcx.hir.as_local_node_id(def_id).and_then(|node_id| { tcx.hir().as_local_node_id(def_id).and_then(|node_id| {
tcx.hir.maybe_body_owned_by(node_id) tcx.hir().maybe_body_owned_by(node_id)
}); });
let body_id = match body_id { let body_id = match body_id {
@ -484,7 +484,7 @@ fn check_unused_unsafe<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
return return
} }
}; };
let body = tcx.hir.body(body_id); let body = tcx.hir().body(body_id);
debug!("check_unused_unsafe({:?}, body={:?}, used_unsafe={:?})", debug!("check_unused_unsafe({:?}, body={:?}, used_unsafe={:?})",
def_id, body, used_unsafe); def_id, body, used_unsafe);
@ -526,7 +526,7 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
} }
fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
let lint_node_id = match tcx.hir.as_local_node_id(def_id) { let lint_node_id = match tcx.hir().as_local_node_id(def_id) {
Some(node_id) => node_id, Some(node_id) => node_id,
None => bug!("checking unsafety for non-local def id {:?}", def_id) None => bug!("checking unsafety for non-local def id {:?}", def_id)
}; };
@ -550,14 +550,14 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
fn is_enclosed(tcx: TyCtxt, fn is_enclosed(tcx: TyCtxt,
used_unsafe: &FxHashSet<ast::NodeId>, used_unsafe: &FxHashSet<ast::NodeId>,
id: ast::NodeId) -> Option<(String, ast::NodeId)> { id: ast::NodeId) -> Option<(String, ast::NodeId)> {
let parent_id = tcx.hir.get_parent_node(id); let parent_id = tcx.hir().get_parent_node(id);
if parent_id != id { if parent_id != id {
if used_unsafe.contains(&parent_id) { if used_unsafe.contains(&parent_id) {
Some(("block".to_string(), parent_id)) Some(("block".to_string(), parent_id))
} else if let Some(Node::Item(&hir::Item { } else if let Some(Node::Item(&hir::Item {
node: hir::ItemKind::Fn(_, header, _, _), node: hir::ItemKind::Fn(_, header, _, _),
.. ..
})) = tcx.hir.find(parent_id) { })) = tcx.hir().find(parent_id) {
match header.unsafety { match header.unsafety {
hir::Unsafety::Unsafe => Some(("fn".to_string(), parent_id)), hir::Unsafety::Unsafe => Some(("fn".to_string(), parent_id)),
hir::Unsafety::Normal => None, hir::Unsafety::Normal => None,
@ -571,12 +571,12 @@ fn is_enclosed(tcx: TyCtxt,
} }
fn report_unused_unsafe(tcx: TyCtxt, used_unsafe: &FxHashSet<ast::NodeId>, id: ast::NodeId) { fn report_unused_unsafe(tcx: TyCtxt, used_unsafe: &FxHashSet<ast::NodeId>, id: ast::NodeId) {
let span = tcx.sess.source_map().def_span(tcx.hir.span(id)); let span = tcx.sess.source_map().def_span(tcx.hir().span(id));
let msg = "unnecessary `unsafe` block"; let msg = "unnecessary `unsafe` block";
let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg); let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg);
db.span_label(span, msg); db.span_label(span, msg);
if let Some((kind, id)) = is_enclosed(tcx, used_unsafe, id) { if let Some((kind, id)) = is_enclosed(tcx, used_unsafe, id) {
db.span_label(tcx.sess.source_map().def_span(tcx.hir.span(id)), db.span_label(tcx.sess.source_map().def_span(tcx.hir().span(id)),
format!("because it's nested under this `unsafe` {}", kind)); format!("because it's nested under this `unsafe` {}", kind));
} }
db.emit(); db.emit();

View file

@ -47,10 +47,10 @@ impl MirPass for ConstProp {
} }
use rustc::hir::map::blocks::FnLikeNode; use rustc::hir::map::blocks::FnLikeNode;
let node_id = tcx.hir.as_local_node_id(source.def_id) let node_id = tcx.hir().as_local_node_id(source.def_id)
.expect("Non-local call to local provider is_const_fn"); .expect("Non-local call to local provider is_const_fn");
let is_fn_like = FnLikeNode::from_node(tcx.hir.get(node_id)).is_some(); let is_fn_like = FnLikeNode::from_node(tcx.hir().get(node_id)).is_some();
let is_assoc_const = match tcx.describe_def(source.def_id) { let is_assoc_const = match tcx.describe_def(source.def_id) {
Some(Def::AssociatedConst(_)) => true, Some(Def::AssociatedConst(_)) => true,
_ => false, _ => false,
@ -618,7 +618,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
.span; .span;
let node_id = self let node_id = self
.tcx .tcx
.hir .hir()
.as_local_node_id(self.source.def_id) .as_local_node_id(self.source.def_id)
.expect("some part of a failing const eval must be local"); .expect("some part of a failing const eval must be local");
use rustc::mir::interpret::EvalErrorKind::*; use rustc::mir::interpret::EvalErrorKind::*;

View file

@ -38,7 +38,7 @@ impl MirPass for ElaborateDrops {
{ {
debug!("elaborate_drops({:?} @ {:?})", src, mir.span); debug!("elaborate_drops({:?} @ {:?})", src, mir.span);
let id = tcx.hir.as_local_node_id(src.def_id).unwrap(); let id = tcx.hir().as_local_node_id(src.def_id).unwrap();
let param_env = tcx.param_env(src.def_id).with_reveal_all(); let param_env = tcx.param_env(src.def_id).with_reveal_all();
let move_data = match MoveData::gather_moves(mir, tcx) { let move_data = match MoveData::gather_moves(mir, tcx) {
Ok(move_data) => move_data, Ok(move_data) => move_data,

Some files were not shown because too many files have changed in this diff Show more