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;
// 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 mut cfg_builder = CFGBuilder {
@ -109,7 +109,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
}
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 {
hir::StmtKind::Decl(ref decl, _) => {
let exit = self.decl(&decl, pred);
@ -588,9 +588,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
match destination.target_id {
Ok(loop_id) => {
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 {
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
};
return (scope, match scope_cf_kind {
@ -600,9 +600,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
}
}
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 {
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
};
return (scope, match scope_cf_kind {

View file

@ -32,11 +32,11 @@ pub struct LabelledCFG<'a, 'tcx: 'a> {
impl<'a, 'tcx> LabelledCFG<'a, 'tcx> {
fn local_id_to_string(&self, local_id: hir::ItemLocalId) -> String {
assert!(self.cfg.owner_def_id.is_local());
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,
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,
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,
// 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
// distinct from the krate module). This is basically a hash of
// 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
// `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
// suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain
// 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;
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 {

View file

@ -65,7 +65,7 @@ impl<M: DepTrackingMapConfig> MemoizationMap for RefCell<DepTrackingMap<M>> {
///
/// ```
/// 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.dep_graph.read(DepNode::Hir(item_def_id)); // (*)
/// compute_type_of_item(ccx, item)

View file

@ -100,7 +100,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
/// Check any attribute.
fn check_attributes(&self, item: &hir::Item, target: Target) {
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")) {
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to 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> {
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) {
@ -375,7 +375,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckAttrVisitor<'a, 'tcx> {
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, '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 {

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.
/// - 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.
/// - Con: Don't get information about nesting
/// - Con: Don't have methods for specific bits of HIR, like "on
@ -29,7 +29,7 @@ use super::intravisit::Visitor;
/// within one another.
/// - Example: Examine each expression to look for its type and do some check or other.
/// - 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
/// `visit_expr()`; don't forget to invoke
/// `intravisit::walk_visit_expr()` to keep walking the subparts.
@ -43,7 +43,7 @@ use super::intravisit::Visitor;
/// - How: Implement `intravisit::Visitor` and override the
/// `nested_visit_map()` methods to return
/// `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: Preserves nesting information
/// - 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> {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
tcx.hir.describe_def(node_id)
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
tcx.hir().describe_def(node_id)
} else {
bug!("Calling local describe_def query provider for upstream DefId: {:?}",
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 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::Expr(expr)) => match expr.node {
hir::ExprKind::Call(..) => "call",
@ -190,8 +190,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let cm = self.sess.source_map();
let scope = region.free_region_binding_scope(self);
let node = self.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
let tag = match self.hir.find(node) {
let node = self.hir().as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
let tag = match self.hir().find(node) {
Some(Node::Block(_)) | Some(Node::Expr(_)) => "body",
Some(Node::Item(it)) => Self::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 {
ty::ReEarlyBound(ref br) => {
let mut sp = cm.def_span(self.hir.span(node));
if let Some(param) = self.hir
let mut sp = cm.def_span(self.hir().span(node));
if let Some(param) = self.hir()
.get_generics(scope)
.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),
..
}) => {
let mut sp = cm.def_span(self.hir.span(node));
if let Some(param) = self.hir
let mut sp = cm.def_span(self.hir().span(node));
if let Some(param) = self.hir()
.get_generics(scope)
.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::BrAnon(idx) => (
format!("the anonymous lifetime #{} defined on", idx + 1),
self.hir.span(node),
self.hir().span(node),
),
ty::BrFresh(_) => (
"an anonymous lifetime defined on".to_owned(),
self.hir.span(node),
self.hir().span(node),
),
_ => (
format!("the lifetime {} as defined on", fr.bound_region),
cm.def_span(self.hir.span(node)),
cm.def_span(self.hir().span(node)),
),
},
_ => bug!(),
@ -1083,7 +1083,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// the expected type argument.
if !param.is_self() {
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| {
// 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`,
@ -1315,8 +1315,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
format!(" for lifetime parameter `{}` in coherence check", name)
}
infer::UpvarRegion(ref upvar_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_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);
format!(" for capture of `{}` by closure", var_name)
}
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 {
infcx: &self,
target_ty: &ty,
hir_map: &self.tcx.hir,
hir_map: &self.tcx.hir(),
found_local_pattern: None,
found_arg_pattern: None,
};
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);
}

View file

@ -38,8 +38,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
) -> Option<(&hir::Ty, &hir::FnDecl)> {
if let Some(anon_reg) = self.tcx.is_suitable_region(region) {
let def_id = anon_reg.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) {
if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
let fndecl = match self.tcx.hir().get(node_id) {
Node::Item(&hir::Item {
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> {
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) {
@ -124,7 +124,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
hir::TyKind::Rptr(ref lifetime, _) => {
// 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) {
// Find the index of the anonymous region that was part of the
// 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
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
debug!(
"EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \
"EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
def_id={:?}",
id,
def_id
@ -172,7 +172,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
"FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
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);
if debruijn_index == self.current_index && id == def_id {
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> {
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) {
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) {
// the lifetime of the TyPath!
(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, _)) => {
debug!(
"EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \
"EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
def_id={:?}",
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.
if let (&SubregionOrigin::BindingTypeIsNotValidAtDecl(ref external_span),
&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 Node::Expr(Expr {
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
};
let hir = &self.tcx.hir;
let hir = &self.tcx.hir();
if let Some(node_id) = hir.as_local_node_id(id) {
if let Some(body_id) = hir.maybe_body_owned_by(node_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");
}
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_name = self.tcx.hir.name(var_node_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);
err.span_note(span,
&format!("...so that closure can access `{}`", var_name));
}
@ -61,7 +61,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
err.span_note(span,
&format!("...so that captured variable `{}` does not outlive the \
enclosing closure",
self.tcx.hir.name(id)));
self.tcx.hir().name(id)));
}
infer::IndexSlice(span) => {
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
}
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_name = self.tcx.hir.name(var_node_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 mut err = struct_span_err!(self.tcx.sess,
span,
E0313,
@ -232,7 +232,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
E0474,
"captured variable `{}` does not outlive the \
enclosing closure",
self.tcx.hir.name(id));
self.tcx.hir().name(id));
self.tcx.note_and_explain_region(region_scope_tree, &mut err,
"captured variable is valid for ", sup, "");
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`
// }
// ```
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 def_scope_default = || {
let opaque_parent_node_id = tcx.hir.get_parent(opaque_node_id);
parent_def_id == tcx.hir.local_def_id(opaque_parent_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)
};
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 {
// impl trait
hir::ItemKind::Existential(hir::ExistTy {
@ -725,7 +725,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
},
_ => bug!(
"expected (impl) item, found {}",
tcx.hir.node_to_string(opaque_node_id),
tcx.hir().node_to_string(opaque_node_id),
),
};
if in_definition_scope {
@ -848,16 +848,16 @@ pub fn may_define_existential_type(
opaque_node_id: ast::NodeId,
) -> bool {
let mut node_id = tcx
.hir
.hir()
.as_local_node_id(def_id)
.unwrap();
// named existential types can be defined by any siblings or
// 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
// of the opaque type
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
node_id == mod_id

View file

@ -774,7 +774,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
where F: FnOnce(&mut Self),
{
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);
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
/// deep-walking.
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) {
let old_tables = self.tables;
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.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.
let old_tables = self.tables;
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);
hir_visit::walk_fn(self, fk, decl, body_id, 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>) {
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 = {

View file

@ -643,7 +643,7 @@ fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum)
levels: LintLevelSets::builder(tcx.sess),
tcx: tcx,
};
let krate = tcx.hir.krate();
let krate = tcx.hir().krate();
builder.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |builder| {
intravisit::walk_crate(builder, krate);
@ -665,7 +665,7 @@ impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> {
where F: FnOnce(&mut Self)
{
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);
self.levels.pop(push);
}
@ -673,7 +673,7 @@ impl<'a, 'tcx> 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> {
intravisit::NestedVisitorMap::All(&self.tcx.hir)
intravisit::NestedVisitorMap::All(&self.tcx.hir())
}
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.
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
node_id: ast::NodeId) -> bool {
match tcx.hir.find(node_id) {
match tcx.hir().find(node_id) {
Some(Node::Item(..)) |
Some(Node::ImplItem(..)) |
Some(Node::ForeignItem(..)) |
@ -59,7 +59,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
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) {
self.worklist.push(node_id);
}
@ -68,7 +68,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
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));
self.live_symbols.insert(node_id);
}
@ -137,7 +137,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
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.visit_node(node);
}
@ -153,7 +153,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
Node::Item(item) => {
match item.node {
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);
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) {
let old_tables = self.tables;
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.tables = old_tables;
}
@ -307,7 +307,7 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
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);
// #[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 {
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()
&& !self.symbol_is_live(field.id, None)
&& !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
// method of a private type is used, but the type itself is never
// 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);
for &impl_did in inherent_impls.iter() {
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) {
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
/// this is how the code is setup and it seems harmless enough.
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) {
@ -648,7 +648,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
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 mut visitor = DeadVisitor {
tcx,

View file

@ -622,7 +622,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
match local.init {
None => {
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);
})
}
@ -935,8 +935,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.tcx().with_freevars(closure_expr.id, |freevars| {
for freevar in freevars {
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 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 upvar_id = ty::UpvarId {
var_path: ty::UpvarPath { hir_id: var_hir_id },
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>> {
// Create the cmt for the variable being borrowed, from the
// 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)?;
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 {
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> {
@ -134,8 +134,8 @@ impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> {
}
fn visit_nested_body(&mut self, body_id: hir::BodyId) {
let owner_def_id = self.tcx.hir.body_owner_def_id(body_id);
let body = self.tcx.hir.body(body_id);
let owner_def_id = self.tcx.hir().body_owner_def_id(body_id);
let body = self.tcx.hir().body(body_id);
let param_env = self.tcx.param_env(owner_def_id);
let tables = self.tcx.typeck_tables_of(owner_def_id);
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() {
// Known lang item with attribute on correct 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);
},
// 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 original_def_id != item_def_id {
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!(
self.tcx.sess,
span,
@ -183,7 +183,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
self.tcx.crate_name(item_def_id.krate),
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.");
} else {
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);
}
}
tcx.hir.krate().visit_all_item_likes(&mut collector);
tcx.hir().krate().visit_all_item_likes(&mut collector);
let LanguageItemCollector { mut items, .. } = collector;
weak_lang_items::check_crate(tcx, &mut items);
items

View file

@ -140,7 +140,7 @@ impl<'a, 'tcx> LibFeatureCollector<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for LibFeatureCollector<'a, '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) {
@ -152,6 +152,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LibFeatureCollector<'a, 'tcx> {
pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LibFeatures {
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
}

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> {
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,
@ -190,7 +190,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, '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();
}
@ -362,8 +362,8 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
// Don't run unused pass for #[derive()]
if let FnKind::Method(..) = fk {
let parent = ir.tcx.hir.get_parent(id);
if let Some(Node::Item(i)) = ir.tcx.hir.find(parent) {
let parent = ir.tcx.hir().get_parent(id);
if let Some(Node::Item(i)) = ir.tcx.hir().find(parent) {
if i.attrs.iter().any(|a| a.check_name("automatically_derived")) {
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<'_, '_>);
let body = ir.tcx.hir.body(body_id);
let body = ir.tcx.hir().body(body_id);
for arg in &body.arguments {
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| {
if let Def::Local(rv) = fv.def {
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 })
} else {
None
@ -924,7 +924,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// effectively a return---this only occurs in `for` loops,
// 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;
@ -1021,7 +1021,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn propagate_through_expr(&mut self, expr: &Expr, succ: 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 {
// Interesting cases with control flow or which gen/kill
@ -1035,7 +1035,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
hir::ExprKind::Closure(.., blk_id, _, _) => {
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
// 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);
if acc != 0 {
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);
self.acc(ln, var, acc);
}
@ -1413,7 +1413,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}
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 cont_ln = ln;
@ -1547,7 +1547,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// mutable, then check for a reassignment to flag the mutability
// as being used.
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);
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<'_>,
id: ast::NodeId) -> MutabilityCategory {
let ret = match tcx.hir.get(id) {
let ret = match tcx.hir().get(id) {
Node::Binding(p) => match p.node {
PatKind::Binding(..) => {
let bm = *tables.pat_binding_modes()
@ -362,7 +362,7 @@ impl MutabilityCategory {
}
_ => 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={:?}) => {:?}",
"from_local", id, ret);
@ -495,9 +495,9 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
// FIXME
None if self.is_tainted_by_errors() => Err(()),
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",
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)
-> 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
// `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),
};
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 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 upvar_id = ty::UpvarId {
var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: closure_expr_def_id.to_local(),
@ -1504,7 +1504,7 @@ impl<'tcx> cmt_<'tcx> {
"non-place".into()
}
Categorization::Local(vid) => {
if tcx.hir.is_argument(vid) {
if tcx.hir().is_argument(vid) {
"argument"
} else {
"local variable"

View file

@ -47,7 +47,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>,
match item.node {
hir::ItemKind::Impl(..) |
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)
}
_ => false,
@ -58,12 +58,12 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_item: &hir::ImplItem,
impl_src: DefId) -> bool {
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) {
return true
}
if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) {
match tcx.hir.find(impl_node_id) {
if let Some(impl_node_id) = tcx.hir().as_local_node_id(impl_src) {
match tcx.hir().find(impl_node_id) {
Some(Node::Item(item)) =>
item_might_be_inlined(tcx, &item, codegen_fn_attrs),
Some(..) | None =>
@ -96,7 +96,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
fn visit_nested_body(&mut self, body: hir::BodyId) {
let old_tables = self.tables;
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.tables = old_tables;
}
@ -118,7 +118,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
}
Some(def) => {
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) {
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
// eligible for inlining and false otherwise.
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,
None => { return false; }
};
match self.tcx.hir.find(node_id) {
match self.tcx.hir().find(node_id) {
Some(Node::Item(item)) => {
match item.node {
hir::ItemKind::Fn(..) =>
@ -182,13 +182,13 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
true
} else {
let impl_did = self.tcx
.hir
.hir()
.get_parent_did(node_id);
// Check the impl. If the generics on the self
// type of the impl require inlining, this method
// does too.
let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap();
match self.tcx.hir.expect_item(impl_node_id).node {
let impl_node_id = self.tcx.hir().as_local_node_id(impl_did).unwrap();
match self.tcx.hir().expect_item(impl_node_id).node {
hir::ItemKind::Impl(..) => {
let generics = self.tcx.generics_of(impl_did);
generics.requires_monomorphization(self.tcx)
@ -214,7 +214,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
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);
}
}
@ -231,7 +231,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
} else {
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 is_extern = codegen_attrs.contains_extern_indicator();
let std_internal = codegen_attrs.flags.contains(
@ -252,7 +252,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
Node::Item(item) => {
match item.node {
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,
&item,
self.tcx.codegen_fn_attrs(def_id)) {
@ -305,7 +305,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
self.visit_nested_body(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) {
self.visit_nested_body(body)
}
@ -326,7 +326,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
Node::MacroDef(_) => {}
_ => {
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
// matter where it is in the crate, along with "special std 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);
if codegen_attrs.contains_extern_indicator() ||
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());
for default_method in provided_trait_methods {
let node_id = self.tcx
.hir
.hir()
.as_local_node_id(default_method.def_id)
.unwrap();
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));
for item in tcx.lang_items().items().iter() {
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);
}
}
@ -433,7 +433,7 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) ->
access_levels,
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.

View file

@ -181,7 +181,7 @@ impl Scope {
pub fn node_id(&self, tcx: TyCtxt<'_, '_, '_>, scope_tree: &ScopeTree) -> ast::NodeId {
match scope_tree.root_body {
Some(hir_id) => {
tcx.hir.hir_to_node_id(hir::HirId {
tcx.hir().hir_to_node_id(hir::HirId {
owner: hir_id.owner,
local_id: self.item_local_id()
})
@ -198,9 +198,9 @@ impl Scope {
if node_id == ast::DUMMY_NODE_ID {
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 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
// indexed statement and ending at end of
// `blk`; reuse span of `blk` and shift `lo`
@ -660,9 +660,9 @@ impl<'tcx> ScopeTree {
-> Scope {
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 scope = tcx.hir.maybe_body_owned_by(param_owner_id).map(|body_id| {
tcx.hir.body(body_id).value.hir_id.local_id
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| {
tcx.hir().body(body_id).value.hir_id.local_id
}).unwrap_or_else(|| {
// The lifetime was defined on node that doesn't own a body,
// 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 \
region scope tree for {:?} / {:?}",
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)));
// 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.
assert_eq!(param_owner, fr.scope);
let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap();
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 }
let param_owner_id = tcx.hir().as_local_node_id(param_owner).unwrap();
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 }
}
/// 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) {
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);
// 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
// case of nested bodies that share the parent environment.
hir::ExprKind::Closure(.., body, _, _) => {
let body = visitor.tcx.hir.body(body);
let body = visitor.tcx.hir().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) {
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={:?})",
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.
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);
} else {
// 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);
}
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 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 mut visitor = RegionResolutionVisitor {
tcx,
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(),
};
let body = tcx.hir.body(body_id);
let body = tcx.hir().body(body_id);
visitor.scope_tree.root_body = Some(body.value.hir_id);
// If the item is an associated const or a method,
// record its impl/trait parent, as it can also have
// lifetime parameters free in this body.
match tcx.hir.get(id) {
match tcx.hir().get(id) {
Node::ImplItem(_) |
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();
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();
Lrc::get_mut(map).unwrap().insert(hir_id.local_id, v);
}
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
.entry(hir_id.owner_local_def_id())
.or_default();
Lrc::get_mut(map).unwrap().insert(hir_id.local_id);
}
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
.entry(hir_id.owner_local_def_id())
.or_default();
@ -423,7 +423,7 @@ fn resolve_lifetimes<'tcx>(
}
fn krate<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> NamedRegionMap {
let krate = tcx.hir.krate();
let krate = tcx.hir().krate();
let mut map = NamedRegionMap {
defs: 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> {
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.
@ -469,7 +469,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
fn visit_nested_body(&mut self, body: hir::BodyId) {
// Each body has their own set of labels, save labels.
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);
self.with(
Scope::Body {
@ -545,7 +545,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter()
.filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {
Some(Region::early(&self.tcx.hir, &mut index, param))
Some(Region::early(&self.tcx.hir(), &mut index, param))
}
GenericParamKind::Type { .. } => {
type_count += 1;
@ -596,7 +596,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter()
.filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {
Some(Region::late(&self.tcx.hir, param))
Some(Region::late(&self.tcx.hir(), param))
}
_ => None,
})
@ -655,7 +655,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
// `abstract type MyAnonTy<'b>: MyTrait<'b>;`
// ^ ^ this gets resolved in the scope of
// 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
// this arm is for `impl Trait` in the types of statics, constants and locals
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.
let def = self.map.defs.get(&lifetime.id).cloned();
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
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_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)
|| krate.impl_items.contains_key(&parent_impl_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 {
match param.kind {
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 param_name.name == keywords::UnderscoreLifetime.name() {
// Pick the elided lifetime "definition" if one exists
@ -790,7 +790,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
Method(ref sig, _) => {
let tcx = self.tcx;
self.visit_early_late(
Some(tcx.hir.get_parent(trait_item.id)),
Some(tcx.hir().get_parent(trait_item.id)),
&sig.decl,
&trait_item.generics,
|this| intravisit::walk_trait_item(this, trait_item),
@ -806,7 +806,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter()
.filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {
Some(Region::early(&self.tcx.hir, &mut index, param))
Some(Region::early(&self.tcx.hir(), &mut index, param))
}
GenericParamKind::Type { .. } => {
type_count += 1;
@ -845,7 +845,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
Method(ref sig, _) => {
let tcx = self.tcx;
self.visit_early_late(
Some(tcx.hir.get_parent(impl_item.id)),
Some(tcx.hir().get_parent(impl_item.id)),
&sig.decl,
&impl_item.generics,
|this| intravisit::walk_impl_item(this, impl_item),
@ -861,7 +861,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter()
.filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {
Some(Region::early(&self.tcx.hir, &mut index, param))
Some(Region::early(&self.tcx.hir(), &mut index, param))
}
GenericParamKind::Type { .. } => {
next_early_index += 1;
@ -891,7 +891,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter()
.filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {
Some(Region::early(&self.tcx.hir, &mut index, param))
Some(Region::early(&self.tcx.hir(), &mut index, param))
}
GenericParamKind::Type { .. } => {
next_early_index += 1;
@ -976,7 +976,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter()
.filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {
Some(Region::late(&self.tcx.hir, param))
Some(Region::late(&self.tcx.hir(), param))
}
_ => None,
})
@ -1051,7 +1051,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
.iter()
.filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {
Some(Region::late(&self.tcx.hir, param))
Some(Region::late(&self.tcx.hir(), param))
}
_ => None,
})
@ -1258,12 +1258,12 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
} => {
// FIXME (#24278): non-hygienic comparison
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(
tcx,
label.name,
original_lifetime(tcx.hir.span(node_id)),
original_lifetime(tcx.hir().span(node_id)),
shadower_label(label.span),
);
return;
@ -1279,7 +1279,7 @@ fn compute_object_lifetime_defaults(
tcx: TyCtxt<'_, '_, '_>,
) -> NodeMap<Vec<ObjectLifetimeDefault>> {
let mut map = NodeMap::default();
for item in tcx.hir.krate().items.values() {
for item in tcx.hir().krate().items.values() {
match item.node {
hir::ItemKind::Struct(_, ref generics)
| hir::ItemKind::Union(_, ref generics)
@ -1355,7 +1355,7 @@ fn object_lifetime_defaults_for_item(
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 {
// Look for `type: ...` where clauses.
let data = match *predicate {
@ -1399,7 +1399,7 @@ fn object_lifetime_defaults_for_item(
.enumerate()
.find(|&(_, (_, lt_name, _))| lt_name == name)
.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))
})
}
@ -1492,7 +1492,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let name = lifetime.name.ident();
let mut remove_decl = None;
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);
}
}
@ -1513,8 +1513,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
}
};
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 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)) {
match parent {
Node::Item(item) => {
if let hir::ItemKind::Fn(decl, _, _, _) = &item.node {
@ -1590,9 +1590,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
match lifetimeuseset {
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);
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((
hir_lifetime.id,
hir_lifetime.span,
@ -1631,8 +1631,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
debug!("Not one use lifetime");
}
None => {
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) {
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) {
Node::Lifetime(hir_lifetime) => Some((
hir_lifetime.id,
hir_lifetime.span,
@ -1651,7 +1651,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
&format!("lifetime parameter `{}` never used", name),
);
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);
if let Some(span) = unused_lt_span {
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.
let mut index = 0;
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) {
index += 1; // Self comes before lifetimes
}
@ -1722,9 +1722,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
.filter_map(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {
if self.map.late_bound.contains(&param.id) {
Some(Region::late(&self.tcx.hir, param))
Some(Region::late(&self.tcx.hir(), param))
} else {
Some(Region::early(&self.tcx.hir, &mut index, param))
Some(Region::early(&self.tcx.hir(), &mut index, param))
}
}
GenericParamKind::Type { .. } => {
@ -1837,8 +1837,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
if let Region::EarlyBound(..) = def {
// Do not free early-bound regions, only late-bound ones.
} else if let Some(body_id) = outermost_body {
let fn_id = self.tcx.hir.body_owner(body_id);
match self.tcx.hir.get(fn_id) {
let fn_id = self.tcx.hir().body_owner(body_id);
match self.tcx.hir().get(fn_id) {
Node::Item(&hir::Item {
node: hir::ItemKind::Fn(..),
..
@ -1851,7 +1851,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
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());
}
_ => {}
@ -1967,7 +1967,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
};
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]
} else {
let tcx = self.tcx;
@ -2061,8 +2061,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
// and whether there's a `self` argument (treated specially).
let mut assoc_item_kind = None;
let mut impl_self = None;
let parent = self.tcx.hir.get_parent_node(output.id);
let body = match self.tcx.hir.get(parent) {
let parent = self.tcx.hir().get_parent_node(output.id);
let body = match self.tcx.hir().get(parent) {
// `fn` definitions and methods.
Node::Item(&hir::Item {
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
.hir
.expect_item(self.tcx.hir.get_parent(parent))
.hir()
.expect_item(self.tcx.hir().get_parent(parent))
.node
{
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
.hir
.expect_item(self.tcx.hir.get_parent(parent))
.hir()
.expect_item(self.tcx.hir().get_parent(parent))
.node
{
impl_self = Some(self_ty);
@ -2396,8 +2396,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
} = info;
let help_name = if let Some(body) = parent {
let arg = &self.tcx.hir.body(body).arguments[index];
format!("`{}`", self.tcx.hir.node_to_pretty_string(arg.pat.id))
let arg = &self.tcx.hir().body(body).arguments[index];
format!("`{}`", self.tcx.hir().node_to_pretty_string(arg.pat.id))
} else {
format!("argument {}", index + 1)
};
@ -2603,12 +2603,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
ref lifetimes, s, ..
} => {
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(
self.tcx,
param.name.ident().name,
original_lifetime(self.tcx.hir.span(node_id)),
original_lifetime(self.tcx.hir().span(node_id)),
shadower_lifetime(&param),
);
return;
@ -2675,7 +2675,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
debug!(
"insert_lifetime: {} resolved to {:?} span={:?}",
self.tcx.hir.node_to_string(lifetime_ref.id),
self.tcx.hir().node_to_string(lifetime_ref.id),
def,
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);
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);
if let Some(stab) = self.parent_stab {
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);
}
}
@ -219,7 +219,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
// -Zforce-unstable-if-unmarked is set.
if let Some(stab) = self.parent_stab {
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);
}
}
@ -230,7 +230,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
}
// `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);
self.index.depr_map.insert(hir_id, depr_entry.clone());
@ -239,7 +239,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
visit_children(self);
self.parent_depr = orig_parent_depr;
} 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);
visit_children(self);
} 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
/// deep-walking.
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) {
@ -333,7 +333,7 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
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 is_error = !self.tcx.sess.opts.test &&
stab.is_none() &&
@ -346,7 +346,7 @@ impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, '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) {
@ -369,7 +369,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
}
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() {
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();
{
let krate = tcx.hir.krate();
let krate = tcx.hir().krate();
let mut annotator = Annotator {
tcx,
index: &mut index,
@ -470,7 +470,7 @@ impl<'a, 'tcx> Index<'tcx> {
/// features and possibly prints errors.
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, '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
@ -591,7 +591,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
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 ||
self.lookup_deprecation_entry(parent_def_id)
.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
/// deep-walking.
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) {
@ -726,7 +726,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
// compiler-generated `extern crate` items have a dummy span.
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) {
Some(cnum) => cnum,
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) => {
if let Def::Trait(trait_did) = t.path.def {
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)
.find(|item| item.ident.name == impl_item.ident.name)
.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,
// so semi-randomly perform it here in stability.rs
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 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) {
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() {
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);
if tcx.stability().staged_api[&LOCAL_CRATE] {
let krate = tcx.hir.krate();
let krate = tcx.hir().krate();
let mut missing = MissingStabilityAnnotations {
tcx,
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 };
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);
}

View file

@ -2376,17 +2376,17 @@ impl<'tcx> Debug for Rvalue<'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 {
format!("[closure@{:?}]", node_id)
} else {
format!("[closure@{:?}]", tcx.hir.span(node_id))
format!("[closure@{:?}]", tcx.hir().span(node_id))
};
let mut struct_fmt = fmt.debug_struct(&name);
tcx.with_freevars(node_id, |freevars| {
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);
}
});
@ -2398,13 +2398,13 @@ impl<'tcx> Debug for Rvalue<'tcx> {
}),
AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| {
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
let name = format!("[generator@{:?}]", tcx.hir.span(node_id));
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
let name = format!("[generator@{:?}]", tcx.hir().span(node_id));
let mut struct_fmt = fmt.debug_struct(&name);
tcx.with_freevars(node_id, |freevars| {
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("$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);
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);
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) => {
let found_kind = self.closure_kind(closure_def_id, closure_substs).unwrap();
let closure_span = self.tcx.sess.source_map()
.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();
.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 mut err = struct_span_err!(
self.tcx.sess, closure_span, E0525,
"expected a closure that implements the `{}` trait, \
@ -785,7 +785,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// a particular trait.
if let Some(tables) = self.in_progress_tables {
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)) {
(ty::ClosureKind::FnOnce, Some((span, name))) => {
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|
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
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)
} else {
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| {
let (found_span, found) = self.get_fn_like_arguments(node);
(Some(found_span), found)
@ -901,8 +901,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
code: &ObligationCauseCode<'tcx>,
err: &mut DiagnosticBuilder<'tcx>) {
if let &ObligationCauseCode::VariableType(node_id) = code {
let parent_node = self.tcx.hir.get_parent_node(node_id);
if let Some(Node::Local(ref local)) = self.tcx.hir.find(parent_node) {
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(ref expr) = local.init {
if let hir::ExprKind::Index(_, _) = expr.node {
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, _),
..
}) => {
(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| {
if let hir::Pat {
node: hir::PatKind::Tuple(args, _),
@ -1037,7 +1037,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
).collect::<Vec<_>>())
}
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()])
}
_ => panic!("non-FnLike node found: {:?}", node),
@ -1236,7 +1236,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
-> DiagnosticBuilder<'tcx>
{
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 mut err = struct_span_err!(self.sess, span, E0072,
"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 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);
err.span_note(sp, &msg);
} 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 {
tcx.struct_span_lint_node(
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,
&msg)
} 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 {
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) => {
let item = self.hir.expect_item(node_id);
let item = self.hir().expect_item(node_id);
if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node {
defaultness.is_default()
} else {

View file

@ -67,10 +67,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
/// 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 {
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");
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
} else {
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 hir_id.owner != local_id_root.index {
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 \
TypeckTables with local_id_root {:?}",
tcx.hir.node_to_string(node_id),
tcx.hir().node_to_string(node_id),
DefId::local(hir_id.owner),
local_id_root)
});
@ -530,8 +530,8 @@ impl<'tcx> TypeckTables<'tcx> {
self.node_id_to_type_opt(id).unwrap_or_else(||
bug!("node_id_to_type: no type for node `{}`",
tls::with(|tcx| {
let id = tcx.hir.hir_to_node_id(id);
tcx.hir.node_to_string(id)
let id = tcx.hir().hir_to_node_id(id);
tcx.hir().node_to_string(id)
}))
)
}
@ -903,7 +903,7 @@ pub struct GlobalCtxt<'tcx> {
/// Export map produced by name resolution.
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
/// 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 {
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))
.collect(),
extern_prelude: resolutions.extern_prelude,
hir,
hir_map: hir,
def_path_hash_to_def_id,
queries: query::Queries::new(
providers,
@ -1272,7 +1277,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn def_key(self, id: DefId) -> hir_map::DefKey {
if id.is_local() {
self.hir.def_key(id)
self.hir().def_key(id)
} else {
self.cstore.def_key(id)
}
@ -1285,7 +1290,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// be a non-local `DefPath`.
pub fn def_path(self, id: DefId) -> hir_map::DefPath {
if id.is_local() {
self.hir.def_path(id)
self.hir().def_path(id)
} else {
self.cstore.def_path(id)
}
@ -1294,7 +1299,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
#[inline]
pub fn def_path_hash(self, def_id: DefId) -> hir_map::DefPathHash {
if def_id.is_local() {
self.hir.definitions().def_path_hash(def_id.index)
self.hir().definitions().def_path_hash(def_id.index)
} else {
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> {
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,
krate,
self.hir.definitions(),
self.hir().definitions(),
self.cstore)
}
@ -1524,10 +1529,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
_ => return None, // not a free region
};
let node_id = self.hir
let node_id = self.hir()
.as_local_node_id(suitable_region_binding_scope)
.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::ImplItem(..)) => {
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,
) -> Option<Ty<'tcx>> {
// 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();
match self.hir.get(node_id) {
let node_id = self.hir().as_local_node_id(scope_def_id).unwrap();
match self.hir().get(node_id) {
Node::Item(item) => {
match item.node {
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(|| {
let sets = self.lint_levels(LOCAL_CRATE);
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) {
return pair
}
let next = self.hir.get_parent_node(id);
let next = self.hir().get_parent_node(id);
if next == id {
bug!("lint traversal reached the root of the crate");
}
@ -2915,7 +2920,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
msg: &str)
-> 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);
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| {
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)
};
providers.lookup_deprecation_entry = |tcx, id| {
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)
};
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)
};
providers.all_crate_nums = |tcx, cnum| {
@ -3069,10 +3074,10 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
};
providers.is_panic_runtime = |tcx, cnum| {
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| {
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.
#[inline]
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)
}

View file

@ -83,7 +83,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Returns a string identifying this local node-id.
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
@ -464,8 +464,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// only occur very early in the compiler pipeline.
let parent_def_id = self.parent_def_id(impl_def_id).unwrap();
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 item = self.hir.expect_item(node_id);
let node_id = self.hir().as_local_node_id(impl_def_id).unwrap();
let item = self.hir().expect_item(node_id);
let span_str = self.sess.source_map().span_to_string(item.span);
buffer.push(&format!("<impl at {}>", span_str));
}

View file

@ -289,7 +289,7 @@ impl Visibility {
def => Visibility::Restricted(def.def_id()),
},
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> {
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
/// 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(
self,
) -> impl Iterator<Item = DefId> + Captures<'tcx> + Captures<'gcx> + 'a {
self.hir.krate()
.body_ids
.iter()
.map(move |&body_id| self.hir.body_owner_def_id(body_id))
self.hir().krate()
.body_ids
.iter()
.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) {
par_iter(&self.hir.krate().body_ids).for_each(|&body_id| {
f(self.hir.body_owner_def_id(body_id))
par_iter(&self.hir().krate().body_ids).for_each(|&body_id| {
f(self.hir().body_owner_def_id(body_id))
});
}
pub fn expr_span(self, id: NodeId) -> Span {
match self.hir.find(id) {
match self.hir().find(id) {
Some(Node::Expr(e)) => {
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> {
let is_associated_item = if let Some(node_id) = self.hir.as_local_node_id(def_id) {
match self.hir.get(node_id) {
let is_associated_item = if let Some(node_id) = self.hir().as_local_node_id(def_id) {
match self.hir().get(node_id) {
Node::TraitItem(_) | Node::ImplItem(_) => true,
_ => false,
}
@ -2691,7 +2691,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
parent_vis: &hir::Visibility,
trait_item_ref: &hir::TraitItemRef)
-> 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 {
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
hir::AssociatedItemKind::Method { has_self } => {
@ -2717,7 +2717,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
parent_def_id: DefId,
impl_item_ref: &hir::ImplItemRef)
-> 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 {
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
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 {
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")
}
@ -2878,8 +2878,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Get the attributes of a definition.
pub fn get_attrs(self, did: DefId) -> Attributes<'gcx> {
if let Some(id) = self.hir.as_local_node_id(did) {
Attributes::Borrowed(self.hir.attrs(id))
if let Some(id) = self.hir().as_local_node_id(did) {
Attributes::Borrowed(self.hir().attrs(id))
} else {
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.
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
if impl_did.is_local() {
let node_id = self.hir.as_local_node_id(impl_did).unwrap();
Ok(self.hir.span(node_id))
let node_id = self.hir().as_local_node_id(impl_did).unwrap();
Ok(self.hir().span(node_id))
} else {
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) {
ident = ident.modern();
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(),
};
let scope = match ident.span.adjust(target_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 => self.hir.get_module_parent(block),
None => self.hir().get_module_parent(block),
};
(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
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) {
None => f(&[]),
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 {
let id = tcx.hir.as_local_node_id(def_id).unwrap();
let parent_id = tcx.hir.get_parent(id);
let parent_def_id = tcx.hir.local_def_id(parent_id);
let parent_item = tcx.hir.expect_item(parent_id);
let id = tcx.hir().as_local_node_id(def_id).unwrap();
let parent_id = tcx.hir().get_parent(id);
let parent_def_id = tcx.hir().local_def_id(parent_id);
let parent_item = tcx.hir().expect_item(parent_id);
match parent_item.node {
hir::ItemKind::Impl(.., ref impl_item_refs) => {
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>,
def_id: DefId)
-> Lrc<Vec<DefId>> {
let id = tcx.hir.as_local_node_id(def_id).unwrap();
let item = tcx.hir.expect_item(id);
let id = tcx.hir().as_local_node_id(def_id).unwrap();
let item = tcx.hir().expect_item(id);
let vec: Vec<_> = match item.node {
hir::ItemKind::Trait(.., ref trait_item_refs) => {
trait_item_refs.iter()
.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()
}
hir::ItemKind::Impl(.., ref impl_item_refs) => {
impl_item_refs.iter()
.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()
}
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 {
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,
@ -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.
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 Node::Item(item) = tcx.hir.get(node_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 hir::ItemKind::Existential(ref exist_ty) = item.node {
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.
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 Node::Item(item) = tcx.hir.get(node_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 hir::ItemKind::TraitAlias(..) = item.node {
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),
traits::Reveal::UserFacing);
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)
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)
});
let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id);
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)
-> Svh {
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>,

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> {
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 `{}`",
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]
fn specialized_decode(&mut self) -> Result<NodeId, Self::Error> {
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,
} = *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)?;
local_id.encode(self)
@ -968,7 +968,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'enc, 'a, 't
{
#[inline]
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)
}
}

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) {
add_impl(tcx.hir.local_def_id(node_id));
for &node_id in tcx.hir().trait_impls(trait_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
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 {
Node::Item(&hir::Item {
node: hir::ItemKind::Static(_, mutbl, _), ..
@ -711,7 +711,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
// Find non representable fields with their spans
fold_repr(def.all_fields().map(|field| {
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,
representable_cache, ty)
{

View file

@ -523,7 +523,7 @@ impl PrintContext {
}
};
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))
@ -679,7 +679,7 @@ impl fmt::Debug for ty::UpvarId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "UpvarId({:?};`{}`;{:?})",
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)
}
}
@ -1208,15 +1208,15 @@ define_print! {
write!(f, "[static generator")?;
}
if let Some(node_id) = tcx.hir.as_local_node_id(did) {
write!(f, "@{:?}", tcx.hir.span(node_id))?;
if let Some(node_id) = tcx.hir().as_local_node_id(did) {
write!(f, "@{:?}", tcx.hir().span(node_id))?;
let mut sep = " ";
tcx.with_freevars(node_id, |freevars| {
for (freevar, upvar_ty) in freevars.iter().zip(upvar_tys) {
print!(f, cx,
write("{}{}:",
sep,
tcx.hir.name(freevar.var_id())),
tcx.hir().name(freevar.var_id())),
print(upvar_ty))?;
sep = ", ";
}
@ -1244,11 +1244,11 @@ define_print! {
let upvar_tys = substs.upvar_tys(did, tcx);
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 {
write!(f, "@{:?}", node_id)?;
} else {
write!(f, "@{:?}", tcx.hir.span(node_id))?;
write!(f, "@{:?}", tcx.hir().span(node_id))?;
}
let mut sep = " ";
tcx.with_freevars(node_id, |freevars| {
@ -1256,7 +1256,7 @@ define_print! {
print!(f, cx,
write("{}{}:",
sep,
tcx.hir.name(freevar.var_id())),
tcx.hir().name(freevar.var_id())),
print(upvar_ty))?;
sep = ", ";
}

View file

@ -105,7 +105,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
debug!("consume(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);
}
@ -139,7 +139,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
borrow_id, cmt, loan_region,
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) {
let moved_value_use_kind = match loan_cause {
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);
}
@ -199,10 +199,10 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
body: &hir::Body) {
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 movable_generator = !match bccx.tcx.hir.get(node_id) {
let node_id = bccx.tcx.hir().as_local_node_id(def_id).unwrap();
let movable_generator = !match bccx.tcx.hir().get(node_id) {
Node::Expr(&hir::Expr {
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();
self.move_data.each_assignment_of(assignment_id, &lp, |assign| {
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);
} else {
self.bccx.report_reassigned_immutable_variable(

View file

@ -57,9 +57,9 @@ pub enum PatternSource<'tcx> {
/// with a reference to the let
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) => {
// the enclosing expression must be a `match` or something else
assert!(match e.node {
@ -79,7 +79,7 @@ pub fn gather_decl<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
var_id: ast::NodeId,
var_ty: Ty<'tcx>) {
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);
}

View file

@ -114,7 +114,7 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
self.bccx.tcx.mk_region(ty::ReScope(self.item_scope))
}
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.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>,
body: hir::BodyId)
-> (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 mut glcx = GatherLoanCtxt {
bccx,
all_loans: Vec::new(),
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
},
move_data: MoveData::default(),
@ -88,7 +88,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
euv::Move(move_reason) => {
gather_moves::gather_move_from_expr(
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 => { }
}
@ -135,7 +135,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
bk={:?}, loan_cause={:?})",
borrow_id, cmt, loan_region,
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,
borrow_span,
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) {
let ty = self.bccx
.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);
}
}
@ -280,7 +280,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
self.mark_loan_path_as_mutated(&lp);
}
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,
assignment_span,
lp);
@ -448,7 +448,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
wrapped_path = match current_path.kind {
LpVar(local_id) => {
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);
}
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 {
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),
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),
"captured outer variable");
}
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);
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::Variant(_) => {
// 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 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 {
tcx,
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.
let tcx = this.tcx;
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.result()
};
@ -224,11 +224,11 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
cfg: &cfg::CFG)
-> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'a, 'tcx>)
{
let owner_id = tcx.hir.body_owner(body_id);
let owner_def_id = tcx.hir.local_def_id(owner_id);
let owner_id = tcx.hir().body_owner(body_id);
let owner_def_id = tcx.hir().local_def_id(owner_id);
let tables = tcx.typeck_tables_of(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 {
tcx,
tables,
@ -418,8 +418,8 @@ pub enum LoanPathElem<'tcx> {
fn closure_to_block(closure_id: LocalDefId,
tcx: TyCtxt) -> ast::NodeId {
let closure_id = tcx.hir.local_def_id_to_node_id(closure_id);
match tcx.hir.get(closure_id) {
let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
match tcx.hir().get(closure_id) {
Node::Expr(expr) => match expr.node {
hir::ExprKind::Closure(.., body_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 {
match self.kind {
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)
}
LpUpvar(upvar_id) => {
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 }
}
LpDowncast(ref base, _) |
@ -700,8 +700,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
Origin::Ast);
let need_note = match lp.ty.sty {
ty::Closure(id, _) => {
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 node_id = self.tcx.hir().as_local_node_id(id).unwrap();
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) {
err.span_note(*span, &format!(
"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
// 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,
local_id: the_move.id
});
@ -731,10 +731,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
move_data::MoveExpr |
move_data::MovePat => (self.tcx.hir.span(node_id), ""),
move_data::MovePat => (self.tcx.hir().span(node_id), ""),
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,
ref r => bug!("Captured({:?}) maps to non-closure: {:?}",
the_move.id, r),
@ -846,8 +846,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
MutabilityViolation => {
let mut db = self.cannot_assign(error_span, &descr, Origin::Ast);
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 sp = self.tcx.hir.span(node_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 fn_closure_msg = "`Fn` closures cannot capture their enclosing \
environment for modifications";
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
// many programmers.
if err.cmt.note == mc::NoteIndex {
let node_id = self.tcx.hir.hir_to_node_id(err.cmt.hir_id);
let node = self.tcx.hir.get(node_id);
let node_id = self.tcx.hir().hir_to_node_id(err.cmt.hir_id);
let node = self.tcx.hir().get(node_id);
// This pattern probably always matches.
if let Node::Expr(
@ -937,7 +937,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
self.note_immutability_blame(
&mut db,
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();
self.signal_error();
@ -1043,7 +1043,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
if let ty::ReScope(scope) = *super_scope {
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(_)) => {
if *sub_scope != ty::ReStatic {
db.note("consider using a `let` binding to increase its lifetime");
@ -1138,8 +1138,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
} else {
"consider changing this closure to take self by mutable reference"
};
let node_id = self.tcx.hir.local_def_id_to_node_id(id);
let help_span = self.tcx.hir.span(node_id);
let node_id = self.tcx.hir().local_def_id_to_node_id(id);
let help_span = self.tcx.hir().span(node_id);
self.cannot_act_on_capture_in_sharable_fn(span,
prefix,
(help_span, help_msg),
@ -1153,7 +1153,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
self.note_immutability_blame(
&mut err,
blame,
self.tcx.hir.hir_to_node_id(cmt.hir_id)
self.tcx.hir().hir_to_node_id(cmt.hir_id)
);
if is_closure {
@ -1194,7 +1194,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
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 => 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) {
let parent = self.tcx.hir.get_parent_node(node_id);
let parent_node = self.tcx.hir.get(parent);
let parent = self.tcx.hir().get_parent_node(node_id);
let parent_node = self.tcx.hir().get(parent);
// The parent node is like a fn
if let Some(fn_like) = FnLikeNode::from_node(parent_node) {
// `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
let arg_pos = fn_body.arguments.iter().position(|arg| arg.pat.id == node_id);
if let Some(i) = arg_pos {
@ -1245,7 +1245,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
Some(ImmutabilityBlame::LocalDeref(node_id)) => {
match self.local_binding_mode(node_id) {
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);
if let Some(replace_str) = suggestion {
db.span_suggestion_with_applicability(
@ -1272,12 +1272,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
}
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,
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) {
db.span_label(field.ty.span, msg);
}
@ -1293,7 +1293,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
db: &mut DiagnosticBuilder,
borrowed_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 Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(let_span) {
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)
{
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(
self.tcx.hir.span(borrow_expr_id),
self.tcx.hir().span(borrow_expr_id),
"consider removing the `&mut`, as it is an \
immutable binding to a mutable reference",
snippet,
@ -1381,8 +1381,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
};
if *kind == ty::ClosureKind::Fn {
let closure_node_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),
self.tcx.hir().local_def_id_to_node_id(upvar_id.closure_expr_id);
db.span_help(self.tcx.hir().span(closure_node_id),
"consider changing this closure to take \
self by mutable reference");
}
@ -1391,7 +1391,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
if let Categorization::Deref(..) = err.cmt.cat {
db.span_label(*error_span, "cannot borrow as mutable");
} 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 snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") {
db.span_label(*error_span, "cannot reborrow mutably");
@ -1416,10 +1416,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
out: &mut String) {
match loan_path.kind {
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) => {
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) => {
@ -1530,13 +1530,13 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.kind {
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 }) => {
let s = ty::tls::with(|tcx| {
let var_node_id = tcx.hir.hir_to_node_id(var_id);
tcx.hir.node_to_string(var_node_id)
let var_node_id = tcx.hir().hir_to_node_id(var_id);
tcx.hir().node_to_string(var_node_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 {
match self.kind {
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: _ }) => {
let s = ty::tls::with(|tcx| {
let var_node_id = tcx.hir.hir_to_node_id(hir_id);
tcx.hir.node_to_string(var_node_id)
let var_node_id = tcx.hir().hir_to_node_id(hir_id);
tcx.hir().node_to_string(var_node_id)
});
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> {
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) {
@ -114,12 +114,12 @@ impl<'a, 'tcx> Visitor<'tcx> for UnusedMutCx<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for UsedMutFinder<'a, '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) {
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.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> {
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,
ps: &mut pprust::State,

View file

@ -223,10 +223,10 @@ impl CodegenCx<'ll, 'tcx> {
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 (g, attrs) = match self.tcx.hir.get(id) {
let (g, attrs) = match self.tcx.hir().get(id) {
Node::Item(&hir::Item {
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 {
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 &&

View file

@ -300,7 +300,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
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 local_id == Some(id) {
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
// let it through if it's included statically.
match tcx.hir.get(node_id) {
match tcx.hir().get(node_id) {
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) {
Some(def_id)
} else {
@ -115,7 +115,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
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);
if !generics.requires_monomorphization(tcx) &&
// 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();
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);
}
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);
}
@ -355,7 +355,7 @@ fn upstream_monomorphizations_for_provider<'a, 'tcx>(
}
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)
} else {
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 {
node: hir::ItemKind::Static(..),
..
})) = tcx.hir.get_if_local(sym_def_id) {
})) = tcx.hir().get_if_local(sym_def_id) {
return SymbolExportLevel::Rust;
}
}

View file

@ -313,8 +313,8 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
let sess = tcx.sess;
let crate_name = tcx.crate_name(LOCAL_CRATE);
let crate_hash = tcx.crate_hash(LOCAL_CRATE);
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 no_builtins = attr::contains_name(&tcx.hir().krate().attrs, "no_builtins");
let subsystem = attr::first_attr_value_str_by_name(&tcx.hir().krate().attrs,
"windows_subsystem");
let windows_subsystem = subsystem.map(|subsystem| {
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() {
Some((id, span, _)) => {
(cx.tcx().hir.local_def_id(id), span)
(cx.tcx().hir().local_def_id(id), span)
}
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);
}
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 {
cx.codegen_global_asm(ga);
} else {

View file

@ -53,7 +53,7 @@ pub mod symbol_names_test;
/// reporting an error.
pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
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") {
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);
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 *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.
let is_foreign = if let Some(id) = node_id {
match tcx.hir.get(id) {
match tcx.hir().get(id) {
Node::ForeignItem(_) => true,
_ => false,
}

View file

@ -33,7 +33,7 @@ pub fn report_symbol_names<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
tcx.dep_graph.with_ignore(|| {
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,
node_id: ast::NodeId) {
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() {
if attr.check_name(SYMBOL_NAME) {
// for now, can only use on monomorphic names

View file

@ -305,7 +305,7 @@ pub fn compile_input(
outdir,
output,
opt_crate,
tcx.hir.krate(),
tcx.hir().krate(),
&analysis,
tcx,
&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>> {
Some(&self.tcx.hir)
Some(&self.tcx.hir())
}
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 {
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);
Ok(())
}
@ -851,18 +851,18 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
// Find the function this expression is from.
let mut node_id = expr.id;
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) {
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);
node_id = parent;
}
}
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 labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges;
let lcfg = LabelledCFG {
@ -1164,7 +1164,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
match ppm {
PpmMir | PpmMirCFG => {
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 {
PpmMir => write_mir_pretty(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 =
nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or unique path \
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))
});
match blocks::Code::from_node(&tcx.hir, nodeid) {
match blocks::Code::from_node(&tcx.hir(), nodeid) {
Some(code) => {
let variants = gather_flowgraph_variants(tcx.sess);
@ -1200,7 +1200,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
got {:?}",
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,
});
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(
def_id,
&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
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,
None => {
panic!("no item found: `{}`", names.join("::"));
@ -271,7 +271,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
) -> Option<ast::NodeId> {
assert!(idx < names.len());
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] {
return search(this, item, idx + 1, names);
}
@ -364,7 +364,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
self.infcx
.tcx
.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,
name,
}))
@ -410,7 +410,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
pub fn re_free(&self, id: u32) -> ty::Region<'tcx> {
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),
}))
}

View file

@ -79,8 +79,8 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut visitor = IfThisChanged { tcx,
if_this_changed: vec![],
then_this_would_need: vec![] };
visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir.krate().attrs);
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir().krate().attrs);
tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
(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]) {
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);
for attr in attrs {
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> {
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) {

View file

@ -62,7 +62,7 @@ pub fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
available_cgus
};
for attr in &tcx.hir.krate().attrs {
for attr in &tcx.hir().krate().attrs {
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(|| {
let krate = tcx.hir.krate();
let krate = tcx.hir().krate();
let mut dirty_clean_visitor = DirtyCleanVisitor {
tcx,
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.
/// index=0 is the "name" used for error messages
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 {
HirNode::Item(item) => {
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) {
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() {
let assertion = match self.assertion_maybe(item_id, attr) {
Some(a) => a,
@ -630,7 +630,7 @@ impl<'a, 'tcx> 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> {
intravisit::NestedVisitorMap::All(&self.tcx.hir)
intravisit::NestedVisitorMap::All(&self.tcx.hir())
}
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::Struct(..) |
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))
}
_ => ()
@ -142,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemKind::Union(ref struct_def, _) => {
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,
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
// reported for missing docs.
let real_trait = trait_ref.path.def.def_id();
if let Some(node_id) = cx.tcx.hir.as_local_node_id(real_trait) {
match cx.tcx.hir.find(node_id) {
if let Some(node_id) = cx.tcx.hir().as_local_node_id(real_trait) {
match cx.tcx.hir().find(node_id) {
Some(Node::Item(item)) => {
if let hir::VisibilityKind::Inherited = item.vis.node {
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() {
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(&[])))
}
hir::ItemKind::Union(_, ref ast_generics) => {
if !ast_generics.params.is_empty() {
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(&[])))
}
hir::ItemKind::Enum(_, ref ast_generics) => {
if !ast_generics.params.is_empty() {
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(&[])))
}
_ => return,
@ -606,7 +606,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
let mut impls = NodeSet::default();
cx.tcx.for_each_impl(debug, |d| {
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);
}
}
@ -871,7 +871,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
_ => 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) {
Some(cnum) => cx.tcx.plugin_registrar_fn(cnum),
None => {
@ -1073,7 +1073,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) {
if let hir::ItemKind::Union(ref vdata, _) = item.node {
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) {
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
field.span,
@ -1275,7 +1275,7 @@ impl LintPass for UnusedBrokenConst {
}
}
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 param_env = if is_static {
// 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 {
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);
for &(predicate, span) in &predicates.predicates {
let predicate_kind_name = match predicate {
@ -1746,7 +1746,7 @@ impl ExplicitOutlivesRequirements {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
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 {
let mut bound_count = 0;
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 {
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);
match item.container {
ty::TraitContainer(..) => MethodLateContext::TraitAutoImpl,

View file

@ -139,8 +139,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
_ => bug!(),
};
if lit_val < min || lit_val > max {
let parent_id = cx.tcx.hir.get_parent_node(e.id);
if let Node::Expr(parent_expr) = cx.tcx.hir.get(parent_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 hir::ExprKind::Cast(..) = parent_expr.node {
if let ty::Char = cx.tables.expr_ty(parent_expr).sty {
let mut err = cx.struct_span_lint(
@ -756,7 +756,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
diag.help(s);
}
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");
}
}
@ -766,7 +766,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
}
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.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) {
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);
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 {
fn check_foreign_item(&mut self, cx: &LateContext, it: &hir::ForeignItem) {
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 {
match it.node {
hir::ForeignItemKind::Fn(ref decl, _, _) => {
@ -827,7 +827,7 @@ impl LintPass for VariantSizeDifferences {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
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 ty = cx.tcx.erase_regions(&t);
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 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
} else {
match t.sty {

View file

@ -318,7 +318,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
}
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 vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityKind::Public };
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> {
let definitions = self.tcx.hir.definitions();
let definitions = self.tcx.hir().definitions();
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_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 has_default_lib_allocator = attr::contains_name(&attrs, "default_lib_allocator");
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
.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 {
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 {
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_vis = &tcx.hir.expect_item(enum_id).vis;
let enum_id = tcx.hir().as_local_node_id(enum_did).unwrap();
let enum_vis = &tcx.hir().expect_item(enum_id).vis;
Entry {
kind: EntryKind::Variant(self.lazy(&data)),
@ -636,7 +636,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
&hir::Visibility)>)
-> Entry<'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);
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)),
attributes: self.encode_attributes(attrs),
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),
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;
debug!("IsolatedEncoder::encode_field({:?})", def_id);
let variant_id = tcx.hir.as_local_node_id(variant.did).unwrap();
let variant_data = tcx.hir.expect_variant_data(variant_id);
let variant_id = tcx.hir().as_local_node_id(variant.did).unwrap();
let variant_data = tcx.hir().expect_variant_data(variant_id);
Entry {
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_vis = &tcx.hir.expect_item(struct_id).vis;
let struct_id = tcx.hir().as_local_node_id(adt_def_id).unwrap();
let struct_vis = &tcx.hir().expect_item(struct_id).vis;
let mut ctor_vis = ty::Visibility::from_hir(struct_vis, struct_id, tcx);
for field in &variant.fields {
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);
let tcx = self.tcx;
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
let ast_item = tcx.hir.expect_trait_item(node_id);
let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
let ast_item = tcx.hir().expect_trait_item(node_id);
let trait_item = tcx.associated_item(def_id);
let container = match trait_item.defaultness {
@ -814,7 +814,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
};
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));
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 {
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);
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);
let tcx = self.tcx;
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 node_id = self.tcx.hir().as_local_node_id(def_id).unwrap();
let ast_item = self.tcx.hir().expect_impl_item(node_id);
let impl_item = self.tcx.associated_item(def_id);
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)
-> LazySeq<ast::Name> {
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| {
match arg.pat.node {
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> {
let body = self.tcx.hir.body(body_id);
let rendered = hir::print::to_string(&self.tcx.hir, |s| s.print_expr(&body.value));
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_const = &RenderedConst(rendered);
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
// needs to know
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 {
None
};
@ -1167,7 +1167,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
hir::ItemKind::ForeignMod(ref fm) => {
self.lazy_seq(fm.items
.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(..) => {
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
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> {
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 {
kind: EntryKind::MacroDef(self.lazy(&MacroDef {
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 tables = self.tcx.typeck_tables_of(def_id);
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 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 kind = match tables.node_id_to_type(hir_id).sty {
ty::Generator(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> {
debug!("IsolatedEncoder::encode_info_for_anon_const({:?})", def_id);
let tcx = self.tcx;
let id = tcx.hir.as_local_node_id(def_id).unwrap();
let body_id = tcx.hir.body_owned_by(id);
let id = tcx.hir().as_local_node_id(def_id).unwrap();
let body_id = tcx.hir().body_owned_by(id);
let const_data = self.encode_rendered_const_for_body(body_id);
let mir = tcx.mir_const_qualif(def_id).0;
@ -1491,7 +1491,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
tcx,
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();
@ -1505,7 +1505,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
.map(|(trait_def_id, mut impls)| {
// Bring everything into deterministic order for hashing
impls.sort_by_cached_key(|&def_index| {
tcx.hir.definitions().def_path_hash(def_index)
tcx.hir().definitions().def_path_hash(def_index)
});
TraitImpls {
@ -1617,7 +1617,7 @@ struct EncodeVisitor<'a, 'b: 'a, 'tcx: 'b> {
impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, '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) {
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) {
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 {
hir::ItemKind::ExternCrate(_) |
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) {
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,
IsolatedEncoder::encode_info_for_foreign_item,
(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);
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);
}
}
@ -1660,7 +1660,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
self.index.encode_info_for_ty(ty);
}
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);
}
}
@ -1682,7 +1682,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
match param.kind {
hir::GenericParamKind::Lifetime { .. } => {}
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 encode_info = IsolatedEncoder::encode_info_for_ty_param;
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) {
match ty.node {
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);
}
_ => {}
@ -1704,7 +1704,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
match expr.node {
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);
}
_ => {}
@ -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
/// normally in the visitor walk.
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 {
hir::ItemKind::Static(..) |
hir::ItemKind::Const(..) |
@ -1746,7 +1746,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
// If the struct has a constructor, encode it.
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,
IsolatedEncoder::encode_struct_ctor,
(def_id, ctor_def_id));
@ -1781,7 +1781,7 @@ struct ImplVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> {
fn visit_item(&mut self, item: &hir::Item) {
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) {
self.impls
.entry(trait_ref.def_id)

View file

@ -18,7 +18,7 @@ pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec<ForeignModule> {
tcx,
modules: Vec::new(),
};
tcx.hir.krate().visit_all_item_likes(&mut collector);
tcx.hir().krate().visit_all_item_likes(&mut collector);
return collector.modules
}
@ -35,11 +35,11 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> {
};
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();
self.modules.push(ForeignModule {
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> {
pub fn new(ecx: &'a mut EncodeContext<'b, 'tcx>) -> Self {
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,
}
}
@ -195,7 +195,7 @@ macro_rules! read_hir {
($t:ty) => {
impl<'tcx> DepGraphRead for &'tcx $t {
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> {
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 {
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 let Some(linkarg) = attr.value_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,
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();
return collector.libs
}
@ -65,7 +65,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> {
name: None,
kind: cstore::NativeUnknown,
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,
};
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 {
ty::Closure(id, _) => {
let tables = self.infcx.tcx.typeck_tables_of(id);
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 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);
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),
);
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(
drop_span,
format!(
"...but `{}` will be dropped here, when the function `{}` returns",
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 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 {
ty::Closure(..) => "closure",
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 {
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,
_ => 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((
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 closure comes from another crate. But in that case we wouldn't
// 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
.tcx
.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
@ -1980,8 +1980,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
) -> Option<AnnotatedBorrowFnSignature> {
debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
let is_closure = self.infcx.tcx.is_closure(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_node_id = self.infcx.tcx.hir().as_local_node_id(did)?;
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
// 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={:?}",
def_id, target_place, places
);
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 node_id = self.infcx.tcx.hir().as_local_node_id(def_id)?;
let expr = &self.infcx.tcx.hir().expect_expr(node_id).node;
debug!("closure_span: node_id={:?} expr={:?}", node_id, expr);
if let hir::ExprKind::Closure(
.., args_span, _

View file

@ -137,7 +137,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
let attributes = tcx.get_attrs(def_id);
let param_env = tcx.param_env(def_id);
let id = tcx
.hir
.hir()
.as_local_node_id(def_id)
.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]),
));
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::Fn => true,
};
@ -229,7 +229,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|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: 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 =
upvar_decl.var_hir_id.assert_crate_local();
let upvar_node_id =
self.infcx.tcx.hir.hir_to_node_id(upvar_hir_id);
let upvar_span = self.infcx.tcx.hir.span(upvar_node_id);
self.infcx.tcx.hir().hir_to_node_id(upvar_hir_id);
let upvar_span = self.infcx.tcx.hir().span(upvar_node_id);
diag.span_label(upvar_span, "captured outer variable");
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()]
.var_hir_id
.assert_crate_local();
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) {
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 hir::PatKind::Binding(
hir::BindingAnnotation::Unannotated,
_,
@ -641,8 +641,8 @@ fn annotate_struct_field(
if let ty::TyKind::Adt(def, _) = ty.sty {
let field = def.all_fields().nth(field.index())?;
// Use the HIR types to construct the diagnostic message.
let node_id = tcx.hir.as_local_node_id(field.did)?;
let node = tcx.hir.find(node_id)?;
let node_id = tcx.hir().as_local_node_id(field.did)?;
let node = tcx.hir().find(node_id)?;
// 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.
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.
let polonius_output = all_facts.and_then(|all_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 =
PathBuf::from("nll-facts").join(def_path.to_filename_friendly_no_crate());
all_facts.write_to_dir(dir_path, location_table).unwrap();

View file

@ -226,12 +226,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
},
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;
if let DefiningTy::Closure(def_id, substs) = def_ty {
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
} else {
@ -302,10 +304,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
name: &InternedString,
) -> Span {
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));
if let Some(param) = tcx.hir
let span = tcx.sess.source_map().def_span(tcx.hir().span(node));
if let Some(param) = tcx.hir()
.get_generics(scope)
.and_then(|generics| generics.get_named(name))
{
@ -361,8 +363,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
argument_index: usize,
counter: &mut usize,
) -> Option<RegionName> {
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 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 argument_hir_ty: &hir::Ty = &fn_decl.inputs[argument_index];
match argument_hir_ty.node {
// 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(
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 {
node: hir::ExprKind::Closure(_, _, _, span, gen_move),
..

View file

@ -81,11 +81,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
upvar_index: usize,
) -> (Symbol, Span) {
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);
let upvar_name = tcx.hir.name(upvar_node_id);
let upvar_span = tcx.hir.span(upvar_node_id);
let upvar_name = tcx.hir().name(upvar_node_id);
let upvar_span = tcx.hir().span(upvar_node_id);
debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}",
upvar_name, upvar_span);

View file

@ -210,8 +210,8 @@ impl<'tcx> UniversalRegions<'tcx> {
param_env: ty::ParamEnv<'tcx>,
) -> Self {
let tcx = infcx.tcx;
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_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);
UniversalRegionsBuilder {
infcx,
mir_def_id,
@ -485,7 +485,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
let tcx = self.infcx.tcx;
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 => {
let defining_ty = if self.mir_def_id == 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,
local_id: *late_bound,
};
let region_node_id = tcx.hir.hir_to_node_id(hir_id);
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_node_id = tcx.hir().hir_to_node_id(hir_id);
let name = tcx.hir().name(region_node_id).as_interned_str();
let region_def_id = tcx.hir().local_def_id(region_node_id);
let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
scope: fn_def_id,
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 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);
self.schedule_drop(span, region_scope, &place, var_ty, DropKind::Storage);
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) {
let local_id = self.var_local_id(var, for_guard);
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);
self.schedule_drop(
span,

View file

@ -39,10 +39,10 @@ use super::lints;
/// Construct the MIR for a given def-id.
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.
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) =>
return create_constructor_shim(tcx, id, &variant.node.data),
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)
}
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| {
@ -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 {
// fetch the fully liberated fn signature (that is, all bound
// 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_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 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,
};
let body = tcx.hir.body(body_id);
let body = tcx.hir().body(body_id);
let explicit_arguments =
body.arguments
.iter()
.enumerate()
.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 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_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);
self_arg = if index == 0 && fn_decl.implicit_self.has_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, ..) =>
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)
} else {
@ -246,7 +246,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
v: &'tcx hir::VariantData)
-> 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 {
tcx.infer_ctxt().enter(|infcx| {
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,
MirSource::item(tcx.hir.local_def_id(ctor_id)),
MirSource::item(tcx.hir().local_def_id(ctor_id)),
&mir, |_, _| Ok(()) );
mir
@ -280,7 +280,7 @@ fn liberated_closure_env_ty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
closure_expr_id: ast::NodeId,
body_id: hir::BodyId)
-> 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_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 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.
let upvar_decls: Vec<_> = tcx.with_freevars(fn_id, |freevars| {
freevars.iter().map(|fv| {
let var_id = fv.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 var_hir_id = tcx.hir().node_to_hir_id(var_id);
let closure_expr_id = tcx.hir().local_def_id(fn_id);
let capture = hir.tables().upvar_capture(ty::UpvarId {
var_path: ty::UpvarPath {hir_id: var_hir_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,
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 {
decl.debug_name = ident.name;
@ -711,7 +711,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
return_ty_span,
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 {
id: body.value.hir_id.local_id,
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.
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,
tcx.get_attrs(closure_expr_id));
@ -769,10 +769,10 @@ fn construct_const<'a, 'gcx, 'tcx>(
ty_span: Span,
) -> Mir<'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 owner_id = tcx.hir.body_owner(body_id);
let span = tcx.hir.span(owner_id);
let owner_id = tcx.hir().body_owner(body_id);
let span = tcx.hir().span(owner_id);
let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, ty_span,vec![]);
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>,
body_id: hir::BodyId)
-> Mir<'tcx> {
let owner_id = hir.tcx().hir.body_owner(body_id);
let span = hir.tcx().hir.span(owner_id);
let owner_id = hir.tcx().hir().body_owner(body_id);
let span = hir.tcx().hir().span(owner_id);
let ty = hir.tcx().types.err;
let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, span, vec![]);
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 sets = tcx.lint_levels(LOCAL_CRATE);
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
);
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(current_hir_id)
});

View file

@ -664,7 +664,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
let cid = key.value;
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);
// Do match-check before building MIR
@ -672,7 +672,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
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);
}
@ -708,7 +708,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
// because any code that existed before validation could not have failed validation
// thus preventing such a hard error from being a backwards compatibility hazard
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(
tcx.at(tcx.def_span(def_id)),
"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(
tcx.at(span),
"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

View file

@ -55,9 +55,9 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
-> Vec<StmtRef<'tcx>> {
let mut result = vec![];
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 stmt_span = StatementSpan(cx.tcx.hir.span(stmt.node.id()));
let stmt_span = StatementSpan(cx.tcx.hir().span(stmt.node.id()));
match stmt.node {
hir::StmtKind::Expr(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:
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 instance = ty::Instance::resolve(
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 {
Ok(target_id) => ExprKind::Break {
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
},
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 {
Ok(loop_id) => ExprKind::Continue {
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
},
},
@ -974,17 +974,17 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
var_id,
index,
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);
// FIXME free regions in closures are not right
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
// signature will be &self or &mut self and hence will
// 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 {
scope: closure_def_id,
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_ty: Ty<'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 {
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 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>,
src_id: ast::NodeId) -> Cx<'a, 'gcx, 'tcx> {
let tcx = infcx.tcx;
let src_def_id = tcx.hir.local_def_id(src_id);
let body_owner_kind = tcx.hir.body_owner_kind(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 constness = match body_owner_kind {
hir::BodyOwnerKind::Const |
@ -71,7 +71,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
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,
// 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> {
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 => 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 {
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(|| {
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(|| {
let sets = tcx.lint_levels(LOCAL_CRATE);
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() {
return id
}
let next = tcx.hir.get_parent_node(id);
let next = tcx.hir().get_parent_node(id);
if next == id {
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> {
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) {
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);
}
}
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();
}
@ -60,8 +60,8 @@ pub(crate) fn check_match<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId,
) -> Result<(), ErrorReported> {
let body_id = if let Some(id) = tcx.hir.as_local_node_id(def_id) {
tcx.hir.body_owned_by(id)
let body_id = if let Some(id) = tcx.hir().as_local_node_id(def_id) {
tcx.hir().body_owned_by(id)
} else {
return Ok(());
};
@ -73,7 +73,7 @@ pub(crate) fn check_match<'a, 'tcx>(
region_scope_tree: &tcx.region_scope_tree(def_id),
param_env: tcx.param_env(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| {
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
// is uninhabited.
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() {
let scrutinee_is_uninhabited = if self.tcx.features().exhaustive_patterns {
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) {
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| {
let mut patcx = PatternContext::new(self.tcx,
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 {
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(
::rustc::lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
id,

View file

@ -20,9 +20,9 @@ use rustc::ty::subst::Substs;
pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>,
mir: &Mir<'tcx>,
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);
}
}
@ -139,8 +139,8 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// no break */ }`) shouldn't be linted unless it actually
// recurs.
if !reached_exit_without_self_call && !self_call_locations.is_empty() {
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 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 mut db = tcx.struct_span_lint_node(UNCONDITIONAL_RECURSION,
node_id,
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, _, _)| {
tcx.hir.local_def_id(node_id)
tcx.hir().local_def_id(node_id)
});
debug!("collect_roots: entry_fn = {:?}", entry_fn);
@ -344,7 +344,7 @@ fn collect_roots<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
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();
}
@ -462,8 +462,8 @@ fn check_recursion_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
if recursion_depth > *tcx.sess.recursion_limit.get() {
let error = format!("reached the recursion limit while instantiating `{}`",
instance);
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
tcx.sess.span_fatal(tcx.hir.span(node_id), &error);
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
tcx.sess.span_fatal(tcx.hir().span(node_id), &error);
} else {
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 msg = format!("reached the type-length limit while instantiating `{:.64}...`",
instance_name);
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)
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)
} else {
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) => {
if generics.params.is_empty() {
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 {}",
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(..) => {
debug!("RootCollector: ItemKind::GlobalAsm({})",
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));
}
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({})",
def_id_to_string(self.tcx, 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.
// 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 cid = GlobalId {
@ -1001,7 +1001,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
}
}
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);
}
}
@ -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) {
match ii.node {
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);
}
_ => { /* 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={})",
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))
}
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 {
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() {
MonoItem::Fn(ref instance) => {
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
// linkage, then we'll be creating a globally shared version.
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> {
match *self.as_mono_item() {
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) => {
tcx.hir.as_local_node_id(def_id)
tcx.hir().as_local_node_id(def_id)
}
MonoItem::GlobalAsm(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
// unstable.
InstanceDef::Item(def_id) => {
tcx.hir.as_local_node_id(def_id)
tcx.hir().as_local_node_id(def_id)
}
InstanceDef::VtableShim(..) |
InstanceDef::Intrinsic(..) |
@ -198,7 +198,7 @@ pub trait CodegenUnitExt<'tcx> {
}
}
MonoItem::Static(def_id) => {
tcx.hir.as_local_node_id(def_id)
tcx.hir().as_local_node_id(def_id)
}
MonoItem::GlobalAsm(node_id) => {
Some(node_id)
@ -415,7 +415,7 @@ fn mono_item_visibility(
};
}
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) {
*can_be_internalized = 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)
}
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 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);
// 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)>)
{
let body_id =
tcx.hir.as_local_node_id(def_id).and_then(|node_id| {
tcx.hir.maybe_body_owned_by(node_id)
tcx.hir().as_local_node_id(def_id).and_then(|node_id| {
tcx.hir().maybe_body_owned_by(node_id)
});
let body_id = match body_id {
@ -484,7 +484,7 @@ fn check_unused_unsafe<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
return
}
};
let body = tcx.hir.body(body_id);
let body = tcx.hir().body(body_id);
debug!("check_unused_unsafe({:?}, 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) {
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,
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,
used_unsafe: &FxHashSet<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 used_unsafe.contains(&parent_id) {
Some(("block".to_string(), parent_id))
} else if let Some(Node::Item(&hir::Item {
node: hir::ItemKind::Fn(_, header, _, _),
..
})) = tcx.hir.find(parent_id) {
})) = tcx.hir().find(parent_id) {
match header.unsafety {
hir::Unsafety::Unsafe => Some(("fn".to_string(), parent_id)),
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) {
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 mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg);
db.span_label(span, msg);
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));
}
db.emit();

View file

@ -47,10 +47,10 @@ impl MirPass for ConstProp {
}
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");
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) {
Some(Def::AssociatedConst(_)) => true,
_ => false,
@ -618,7 +618,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
.span;
let node_id = self
.tcx
.hir
.hir()
.as_local_node_id(self.source.def_id)
.expect("some part of a failing const eval must be local");
use rustc::mir::interpret::EvalErrorKind::*;

View file

@ -38,7 +38,7 @@ impl MirPass for ElaborateDrops {
{
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 move_data = match MoveData::gather_moves(mir, tcx) {
Ok(move_data) => move_data,

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