fn visit_lifetime(&mut self, lifetime: &'v Lifetime) {
walk_lifetime(self, lifetime)
}
- fn visit_qpath(&mut self, qpath: &'v QPath, id: NodeId, span: Span) {
+ fn visit_qpath(&mut self, qpath: &'v QPath, id: HirId, span: Span) {
walk_qpath(self, qpath, id, span)
}
- fn visit_path(&mut self, path: &'v Path, _id: NodeId) {
+ fn visit_path(&mut self, path: &'v Path, _id: HirId) {
walk_path(self, path)
}
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) {
where V: Visitor<'v>
{
visitor.visit_id(trait_ref.ref_id);
- visitor.visit_path(&trait_ref.path, trait_ref.ref_id)
+ visitor.visit_path(&trait_ref.path, trait_ref.hir_ref_id)
}
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
}
ItemKind::Use(ref path, _) => {
visitor.visit_id(item.id);
- visitor.visit_path(path, item.id);
+ visitor.visit_path(path, item.hir_id);
}
ItemKind::Static(ref typ, _, body) |
ItemKind::Const(ref typ, body) => {
visitor.visit_fn_decl(&function_declaration.decl);
}
TyKind::Path(ref qpath) => {
- visitor.visit_qpath(qpath, typ.id, typ.span);
+ visitor.visit_qpath(qpath, typ.hir_id, typ.span);
}
TyKind::Array(ref ty, ref length) => {
visitor.visit_ty(ty);
}
}
-pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath, id: NodeId, span: Span) {
+pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath, id: HirId, span: Span) {
match *qpath {
QPath::Resolved(ref maybe_qself, ref path) => {
if let Some(ref qself) = *maybe_qself {
visitor.visit_id(pattern.id);
match pattern.node {
PatKind::TupleStruct(ref qpath, ref children, _) => {
- visitor.visit_qpath(qpath, pattern.id, pattern.span);
+ visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
walk_list!(visitor, visit_pat, children);
}
PatKind::Path(ref qpath) => {
- visitor.visit_qpath(qpath, pattern.id, pattern.span);
+ visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
}
PatKind::Struct(ref qpath, ref fields, _) => {
- visitor.visit_qpath(qpath, pattern.id, pattern.span);
+ visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
for field in fields {
visitor.visit_id(field.node.id);
visitor.visit_ident(field.node.ident);
visitor.visit_anon_const(count)
}
ExprKind::Struct(ref qpath, ref fields, ref optional_base) => {
- visitor.visit_qpath(qpath, expression.id, expression.span);
+ visitor.visit_qpath(qpath, expression.hir_id, expression.span);
for field in fields {
visitor.visit_id(field.id);
visitor.visit_ident(field.ident);
visitor.visit_expr(index_expression)
}
ExprKind::Path(ref qpath) => {
- visitor.visit_qpath(qpath, expression.id, expression.span);
+ visitor.visit_qpath(qpath, expression.hir_id, expression.span);
}
ExprKind::Break(ref destination, ref opt_expr) => {
if let Some(ref label) = destination.label {
}
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
- if let VisibilityKind::Restricted { ref path, id } = vis.node {
+ if let VisibilityKind::Restricted { ref path, id, hir_id } = vis.node {
visitor.visit_id(id);
- visitor.visit_path(path, id)
+ visitor.visit_path(path, hir_id)
}
}
let future_path =
this.std_path(span, &["future", "Future"], Some(future_params), false);
+ let LoweredNodeId { node_id, hir_id } = this.next_id();
let mut bounds = vec![
hir::GenericBound::Trait(
hir::PolyTraitRef {
trait_ref: hir::TraitRef {
path: future_path,
- ref_id: this.next_id().node_id,
+ ref_id: node_id,
+ hir_ref_id: hir_id,
},
bound_generic_params: hir_vec![],
span,
hir::QPath::Resolved(None, path) => path.and_then(|path| path),
qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
};
+ let LoweredNodeId { node_id, hir_id } = self.lower_node_id(p.ref_id);
hir::TraitRef {
path,
- ref_id: self.lower_node_id(p.ref_id).node_id,
+ ref_id: node_id,
+ hir_ref_id: hir_id,
}
}
hir::VisibilityKind::Public => hir::VisibilityKind::Public,
hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
- hir::VisibilityKind::Restricted { ref path, id: _ } => {
+ hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
+ let id = this.next_id();
hir::VisibilityKind::Restricted {
path: path.clone(),
// We are allocating a new NodeId here
- id: this.next_id().node_id,
+ id: id.node_id,
+ hir_id: id.hir_id,
}
}
};
hir::VisibilityKind::Public => hir::VisibilityKind::Public,
hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
- hir::VisibilityKind::Restricted { ref path, id: _ } => {
+ hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
+ let id = this.next_id();
hir::VisibilityKind::Restricted {
path: path.clone(),
// We are allocating a new NodeId here
- id: this.next_id().node_id,
+ id: id.node_id,
+ hir_id: id.hir_id,
}
}
};
let node = match v.node {
VisibilityKind::Public => hir::VisibilityKind::Public,
VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
- VisibilityKind::Restricted { ref path, id } => hir::VisibilityKind::Restricted {
- path: P(self.lower_path(id, path, ParamMode::Explicit)),
- id: if let Some(owner) = explicit_owner {
- self.lower_node_id_with_owner(id, owner).node_id
+ VisibilityKind::Restricted { ref path, id } => {
+ let lowered_id = if let Some(owner) = explicit_owner {
+ self.lower_node_id_with_owner(id, owner)
} else {
- self.lower_node_id(id).node_id
- },
+ self.lower_node_id(id)
+ };
+ hir::VisibilityKind::Restricted {
+ path: P(self.lower_path(id, path, ParamMode::Explicit)),
+ id: lowered_id.node_id,
+ hir_id: lowered_id.hir_id,
+ }
},
VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
};
trait_ref: hir::TraitRef {
path: path.and_then(|path| path),
ref_id: id.node_id,
+ hir_ref_id: id.hir_id,
},
span,
};
pub struct TraitRef {
pub path: Path,
pub ref_id: NodeId,
+ pub hir_ref_id: HirId,
}
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum VisibilityKind {
Public,
Crate(CrateSugar),
- Restricted { path: P<Path>, id: NodeId },
+ Restricted { path: P<Path>, id: NodeId, hir_id: HirId },
Inherited,
}
impl_stable_hash_for!(struct hir::TraitRef {
// Don't hash the ref_id. It is tracked via the thing it is used to access
ref_id -> _,
+ hir_ref_id -> _,
path,
});
hir::VisibilityKind::Crate(sugar) => {
sugar.hash_stable(hcx, hasher);
}
- hir::VisibilityKind::Restricted { ref path, id } => {
+ hir::VisibilityKind::Restricted { ref path, id, hir_id } => {
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
id.hash_stable(hcx, hasher);
+ hir_id.hash_stable(hcx, hasher);
});
path.hash_stable(hcx, hasher);
}
hir_visit::walk_lifetime(self, lt);
}
- fn visit_path(&mut self, p: &'tcx hir::Path, id: ast::NodeId) {
+ fn visit_path(&mut self, p: &'tcx hir::Path, id: hir::HirId) {
run_lints!(self, check_path, p, id);
hir_visit::walk_path(self, p);
}
fn check_variant(a: &$hir hir::Variant, b: &$hir hir::Generics);
fn check_variant_post(a: &$hir hir::Variant, b: &$hir hir::Generics);
fn check_lifetime(a: &$hir hir::Lifetime);
- fn check_path(a: &$hir hir::Path, b: ast::NodeId);
+ fn check_path(a: &$hir hir::Path, b: hir::HirId);
fn check_attribute(a: &$hir ast::Attribute);
/// Called when entering a syntax node that can have lint attributes such
self.in_pat = false;
}
- fn visit_path(&mut self, path: &'tcx hir::Path, _: ast::NodeId) {
+ fn visit_path(&mut self, path: &'tcx hir::Path, _: hir::HirId) {
self.handle_definition(path.def);
intravisit::walk_path(self, path);
}
self.resolve_lifetime_ref(lifetime_ref);
}
- fn visit_path(&mut self, path: &'tcx hir::Path, _: ast::NodeId) {
+ fn visit_path(&mut self, path: &'tcx hir::Path, _: hir::HirId) {
for (i, segment) in path.segments.iter().enumerate() {
let depth = path.segments.len() - i - 1;
if let Some(ref args) = segment.args {
intravisit::walk_item(self, item);
}
- fn visit_path(&mut self, path: &'tcx hir::Path, id: ast::NodeId) {
+ fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) {
+ let id = self.tcx.hir.hir_to_node_id(id);
match path.def {
Def::Local(..) | Def::Upvar(..) |
Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => {}
// We use a HIR visitor to walk the type.
use rustc::hir::intravisit::{self, Visitor};
- use syntax::ast::NodeId;
struct WalkAssocTypes<'a, 'db> where 'db: 'a {
err: &'a mut DiagnosticBuilder<'db>
}
intravisit::NestedVisitorMap::None
}
- fn visit_qpath(&mut self, qpath: &'v hir::QPath, id: NodeId, span: Span) {
+ fn visit_qpath(&mut self, qpath: &'v hir::QPath, id: hir::HirId, span: Span) {
if TypeAliasBounds::is_type_variable_assoc(qpath) {
self.err.span_help(span,
"use fully disambiguated paths (i.e., `<T as Trait>::Assoc`) to refer to \
self.record("Lifetime", Id::Node(lifetime.id), lifetime);
hir_visit::walk_lifetime(self, lifetime)
}
- fn visit_qpath(&mut self, qpath: &'v hir::QPath, id: NodeId, span: Span) {
+ fn visit_qpath(&mut self, qpath: &'v hir::QPath, id: hir::HirId, span: Span) {
self.record("QPath", Id::None, qpath);
hir_visit::walk_qpath(self, qpath, id, span)
}
- fn visit_path(&mut self, path: &'v hir::Path, _id: NodeId) {
+ fn visit_path(&mut self, path: &'v hir::Path, _id: hir::HirId) {
self.record("Path", Id::None, path);
hir_visit::walk_path(self, path)
}
// we prohibit access to private statics from other crates, this allows to give
// more code internal visibility at link time. (Access to private functions
// is already prohibited by type privacy for function types.)
- fn visit_qpath(&mut self, qpath: &'tcx hir::QPath, id: ast::NodeId, span: Span) {
+ fn visit_qpath(&mut self, qpath: &'tcx hir::QPath, id: hir::HirId, span: Span) {
let def = match *qpath {
hir::QPath::Resolved(_, ref path) => match path.def {
Def::Method(..) | Def::AssociatedConst(..) |
_ => None,
}
hir::QPath::TypeRelative(..) => {
- let hir_id = self.tcx.hir.node_to_hir_id(id);
- self.tables.type_dependent_defs().get(hir_id).cloned()
+ self.tables.type_dependent_defs().get(id).cloned()
}
};
if let Some(def) = def {
let trait_ = hir::TraitRef {
path: get_path_for_type(self.cx.tcx, trait_def_id, hir::def::Def::Trait),
ref_id: ast::DUMMY_NODE_ID,
+ hir_ref_id: hir::DUMMY_HIR_ID,
};
let polarity;
trait_def_id,
hir::def::Def::Trait),
ref_id: ast::DUMMY_NODE_ID,
+ hir_ref_id: hir::DUMMY_HIR_ID,
};
let provided_trait_methods =
infcx.tcx.provided_trait_methods(trait_def_id)