mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
hir: remove NodeId from Lifetime and Ty
This commit is contained in:
parent
904a91c496
commit
00b74e5eaf
@ -1350,9 +1350,8 @@ impl<'a> LoweringContext<'a> {
|
||||
TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
|
||||
};
|
||||
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(t.id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(t.id);
|
||||
hir::Ty {
|
||||
id: node_id,
|
||||
node: kind,
|
||||
span: t.span,
|
||||
hir_id,
|
||||
@ -1533,9 +1532,8 @@ impl<'a> LoweringContext<'a> {
|
||||
&& !self.already_defined_lifetimes.contains(&name) {
|
||||
self.already_defined_lifetimes.insert(name);
|
||||
|
||||
let LoweredNodeId { node_id, hir_id } = self.context.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.context.next_id();
|
||||
self.output_lifetimes.push(hir::GenericArg::Lifetime(hir::Lifetime {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span: lifetime.span,
|
||||
name,
|
||||
@ -1980,8 +1978,8 @@ impl<'a> LoweringContext<'a> {
|
||||
.map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed()))
|
||||
.collect();
|
||||
let mk_tup = |this: &mut Self, tys, span| {
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
hir::Ty { node: hir::TyKind::Tup(tys), id: node_id, hir_id, span }
|
||||
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
|
||||
hir::Ty { node: hir::TyKind::Tup(tys), hir_id, span }
|
||||
};
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
|
||||
@ -2318,9 +2316,8 @@ impl<'a> LoweringContext<'a> {
|
||||
this.lower_ty(ty, ImplTraitContext::Existential(Some(fn_def_id)))
|
||||
}
|
||||
FunctionRetTy::Default(span) => {
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
|
||||
P(hir::Ty {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::TyKind::Tup(hir_vec![]),
|
||||
span: *span,
|
||||
@ -2362,17 +2359,16 @@ impl<'a> LoweringContext<'a> {
|
||||
];
|
||||
|
||||
if let Some((name, span)) = bound_lifetime {
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
|
||||
bounds.push(hir::GenericBound::Outlives(
|
||||
hir::Lifetime { id: node_id, hir_id, name, span }));
|
||||
hir::Lifetime { hir_id, name, span }));
|
||||
}
|
||||
|
||||
hir::HirVec::from(bounds)
|
||||
});
|
||||
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
let impl_trait_ty = P(hir::Ty {
|
||||
id: node_id,
|
||||
node: impl_trait_ty,
|
||||
span,
|
||||
hir_id,
|
||||
@ -2431,10 +2427,9 @@ impl<'a> LoweringContext<'a> {
|
||||
span: Span,
|
||||
name: hir::LifetimeName,
|
||||
) -> hir::Lifetime {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::Lifetime {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span,
|
||||
name: name,
|
||||
@ -5108,7 +5103,6 @@ impl<'a> LoweringContext<'a> {
|
||||
_ => hir::TyKind::Path(qpath),
|
||||
};
|
||||
hir::Ty {
|
||||
id: id.node_id,
|
||||
hir_id: id.hir_id,
|
||||
node,
|
||||
span,
|
||||
@ -5124,9 +5118,8 @@ impl<'a> LoweringContext<'a> {
|
||||
// `'f`.
|
||||
AnonymousLifetimeMode::CreateParameter => {
|
||||
let fresh_name = self.collect_fresh_in_band_lifetime(span);
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
hir::Lifetime {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span,
|
||||
name: hir::LifetimeName::Param(fresh_name),
|
||||
@ -5227,10 +5220,9 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn new_implicit_lifetime(&mut self, span: Span) -> hir::Lifetime {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||
|
||||
hir::Lifetime {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span,
|
||||
name: hir::LifetimeName::Implicit,
|
||||
|
@ -151,7 +151,6 @@ pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Copy)]
|
||||
pub struct Lifetime {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
|
||||
@ -272,7 +271,7 @@ impl fmt::Debug for Lifetime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f,
|
||||
"lifetime({}: {})",
|
||||
self.id,
|
||||
self.hir_id,
|
||||
print::to_string(print::NO_ANN, |s| s.print_lifetime(self)))
|
||||
}
|
||||
}
|
||||
@ -417,10 +416,10 @@ impl GenericArg {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id(&self) -> NodeId {
|
||||
pub fn id(&self) -> HirId {
|
||||
match self {
|
||||
GenericArg::Lifetime(l) => l.id,
|
||||
GenericArg::Type(t) => t.id,
|
||||
GenericArg::Lifetime(l) => l.hir_id,
|
||||
GenericArg::Type(t) => t.hir_id,
|
||||
GenericArg::Const(c) => c.value.id,
|
||||
}
|
||||
}
|
||||
@ -1760,7 +1759,6 @@ pub struct TypeBinding {
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct Ty {
|
||||
pub id: NodeId,
|
||||
pub node: TyKind,
|
||||
pub span: Span,
|
||||
pub hir_id: HirId,
|
||||
|
@ -158,7 +158,6 @@ impl_stable_hash_for!(struct ast::Label {
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct hir::Lifetime {
|
||||
id,
|
||||
hir_id,
|
||||
span,
|
||||
name
|
||||
@ -318,7 +317,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
|
||||
hasher: &mut StableHasher<W>) {
|
||||
hcx.while_hashing_hir_bodies(true, |hcx| {
|
||||
let hir::Ty {
|
||||
id: _,
|
||||
hir_id: _,
|
||||
ref node,
|
||||
ref span,
|
||||
|
@ -101,7 +101,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
|
||||
|
||||
let (span_1, span_2, main_label, span_label) = match (sup_is_ret_type, sub_is_ret_type) {
|
||||
(None, None) => {
|
||||
let (main_label_1, span_label_1) = if ty_sup.id == ty_sub.id {
|
||||
let (main_label_1, span_label_1) = if ty_sup.hir_id == ty_sub.hir_id {
|
||||
(
|
||||
"this type is declared with multiple lifetimes...".to_owned(),
|
||||
"...but data with one lifetime flows into the other here".to_owned()
|
||||
|
@ -13,7 +13,7 @@ use crate::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt};
|
||||
|
||||
use crate::rustc::lint;
|
||||
use crate::session::Session;
|
||||
use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, NodeMap, NodeSet};
|
||||
use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, HirIdMap, NodeMap, NodeSet};
|
||||
use errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::borrow::Cow;
|
||||
@ -151,7 +151,7 @@ impl Region {
|
||||
if let Region::EarlyBound(index, _, _) = self {
|
||||
params
|
||||
.nth(index as usize)
|
||||
.and_then(|lifetime| map.defs.get(&lifetime.id).cloned())
|
||||
.and_then(|lifetime| map.defs.get(&lifetime.hir_id).cloned())
|
||||
} else {
|
||||
Some(self)
|
||||
}
|
||||
@ -195,7 +195,7 @@ pub type ObjectLifetimeDefault = Set1<Region>;
|
||||
struct NamedRegionMap {
|
||||
// maps from every use of a named (not anonymous) lifetime to a
|
||||
// `Region` describing how that region is bound
|
||||
pub defs: NodeMap<Region>,
|
||||
pub defs: HirIdMap<Region>,
|
||||
|
||||
// the set of lifetime def ids that are late-bound; a region can
|
||||
// be late-bound if (a) it does NOT appear in a where-clause and
|
||||
@ -385,8 +385,7 @@ 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);
|
||||
for (hir_id, v) in named_region_map.defs {
|
||||
let map = rl.defs.entry(hir_id.owner_local_def_id()).or_default();
|
||||
Lrc::get_mut(map).unwrap().insert(hir_id.local_id, v);
|
||||
}
|
||||
@ -570,7 +569,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
||||
debug!("visit_ty: id={:?} ty={:?}", ty.id, ty);
|
||||
debug!("visit_ty: id={:?} ty={:?}", ty.hir_id, ty);
|
||||
match ty.node {
|
||||
hir::TyKind::BareFn(ref c) => {
|
||||
let next_early_index = self.next_early_index();
|
||||
@ -629,7 +628,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
hir::TyKind::Rptr(ref lifetime_ref, ref mt) => {
|
||||
self.visit_lifetime(lifetime_ref);
|
||||
let scope = Scope::ObjectLifetimeDefault {
|
||||
lifetime: self.map.defs.get(&lifetime_ref.id).cloned(),
|
||||
lifetime: self.map.defs.get(&lifetime_ref.hir_id).cloned(),
|
||||
s: self.scope,
|
||||
};
|
||||
self.with(scope, |_, this| this.visit_ty(&mt.ty));
|
||||
@ -672,7 +671,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
// and ban them. Type variables instantiated inside binders aren't
|
||||
// well-supported at the moment, so this doesn't work.
|
||||
// In the future, this should be fixed and this error should be removed.
|
||||
let def = self.map.defs.get(&lifetime.id).cloned();
|
||||
let def = self.map.defs.get(&lifetime.hir_id).cloned();
|
||||
if let Some(Region::LateBound(_, def_id, _)) = def {
|
||||
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
|
||||
@ -1501,8 +1500,10 @@ 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_by_hir_id(lifetime.hir_id) {
|
||||
if let Some(parent) = self.tcx.hir().find_by_hir_id(
|
||||
self.tcx.hir().get_parent_item(hir_lifetime.hir_id))
|
||||
{
|
||||
match parent {
|
||||
Node::Item(item) => {
|
||||
if let hir::ItemKind::Fn(decl, _, _, _) = &item.node {
|
||||
@ -1582,22 +1583,22 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
debug!("node id first={:?}", 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.hir_id,
|
||||
hir_lifetime.span,
|
||||
hir_lifetime.name.ident(),
|
||||
)),
|
||||
Node::GenericParam(param) => {
|
||||
Some((param.id, param.span, param.name.ident()))
|
||||
Some((param.hir_id, param.span, param.name.ident()))
|
||||
}
|
||||
_ => None,
|
||||
} {
|
||||
debug!("id = {:?} span = {:?} name = {:?}", node_id, span, name);
|
||||
debug!("id = {:?} span = {:?} name = {:?}", id, span, name);
|
||||
|
||||
if name == keywords::UnderscoreLifetime.ident() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut err = self.tcx.struct_span_lint_node(
|
||||
let mut err = self.tcx.struct_span_lint_hir(
|
||||
lint::builtin::SINGLE_USE_LIFETIMES,
|
||||
id,
|
||||
span,
|
||||
@ -1622,17 +1623,17 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
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.hir_id,
|
||||
hir_lifetime.span,
|
||||
hir_lifetime.name.ident(),
|
||||
)),
|
||||
Node::GenericParam(param) => {
|
||||
Some((param.id, param.span, param.name.ident()))
|
||||
Some((param.hir_id, param.span, param.name.ident()))
|
||||
}
|
||||
_ => None,
|
||||
} {
|
||||
debug!("id ={:?} span = {:?} name = {:?}", node_id, span, name);
|
||||
let mut err = self.tcx.struct_span_lint_node(
|
||||
debug!("id ={:?} span = {:?} name = {:?}", id, span, name);
|
||||
let mut err = self.tcx.struct_span_lint_hir(
|
||||
lint::builtin::UNUSED_LIFETIMES,
|
||||
id,
|
||||
span,
|
||||
@ -2049,8 +2050,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_by_hir_id(output.hir_id);
|
||||
let body = match self.tcx.hir().get_by_hir_id(parent) {
|
||||
// `fn` definitions and methods.
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(.., body),
|
||||
@ -2063,12 +2064,13 @@ 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))
|
||||
.expect_item_by_hir_id(self.tcx.hir().get_parent_item(parent))
|
||||
.node
|
||||
{
|
||||
let parent_node_id = self.tcx.hir().hir_to_node_id(parent);
|
||||
assoc_item_kind = trait_items
|
||||
.iter()
|
||||
.find(|ti| ti.id.node_id == parent)
|
||||
.find(|ti| ti.id.node_id == parent_node_id)
|
||||
.map(|ti| ti.kind);
|
||||
}
|
||||
match *m {
|
||||
@ -2083,13 +2085,14 @@ 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))
|
||||
.expect_item_by_hir_id(self.tcx.hir().get_parent_item(parent))
|
||||
.node
|
||||
{
|
||||
impl_self = Some(self_ty);
|
||||
let parent_node_id = self.tcx.hir().hir_to_node_id(parent);
|
||||
assoc_item_kind = impl_items
|
||||
.iter()
|
||||
.find(|ii| ii.id.node_id == parent)
|
||||
.find(|ii| ii.id.node_id == parent_node_id)
|
||||
.map(|ii| ii.kind);
|
||||
}
|
||||
Some(body)
|
||||
@ -2143,7 +2146,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
if let hir::TyKind::Rptr(lifetime_ref, ref mt) = inputs[0].node {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node {
|
||||
if is_self_ty(path.def) {
|
||||
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.id) {
|
||||
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
|
||||
let scope = Scope::Elision {
|
||||
elide: Elide::Exact(lifetime),
|
||||
s: self.scope,
|
||||
@ -2262,7 +2265,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_lifetime(&mut self, lifetime_ref: &hir::Lifetime) {
|
||||
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.id) {
|
||||
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
|
||||
match lifetime {
|
||||
Region::LateBound(debruijn, _, _) | Region::LateBoundAnon(debruijn, _)
|
||||
if debruijn < self.outer_index =>
|
||||
@ -2653,7 +2656,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn insert_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime, def: Region) {
|
||||
if lifetime_ref.id == ast::DUMMY_NODE_ID {
|
||||
if lifetime_ref.hir_id == hir::DUMMY_HIR_ID {
|
||||
span_bug!(
|
||||
lifetime_ref.span,
|
||||
"lifetime reference not renumbered, \
|
||||
@ -2663,11 +2666,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
|
||||
debug!(
|
||||
"insert_lifetime: {} resolved to {:?} span={:?}",
|
||||
self.tcx.hir().node_to_string(lifetime_ref.id),
|
||||
self.tcx.hir().hir_to_string(lifetime_ref.hir_id),
|
||||
def,
|
||||
self.tcx.sess.source_map().span_to_string(lifetime_ref.span)
|
||||
);
|
||||
self.map.defs.insert(lifetime_ref.id, def);
|
||||
self.map.defs.insert(lifetime_ref.hir_id, def);
|
||||
|
||||
match def {
|
||||
Region::LateBoundAnon(..) | Region::Static => {
|
||||
@ -2699,7 +2702,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
/// error (esp. around impl trait). In that case, we remove the
|
||||
/// entry into `map.defs` so as not to confuse later code.
|
||||
fn uninsert_lifetime_on_error(&mut self, lifetime_ref: &'tcx hir::Lifetime, bad_def: Region) {
|
||||
let old_value = self.map.defs.remove(&lifetime_ref.id);
|
||||
let old_value = self.map.defs.remove(&lifetime_ref.hir_id);
|
||||
assert_eq!(old_value, Some(bad_def));
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
Some(Node::Item(item)) => match item.node {
|
||||
hir::ItemKind::Impl(.., ref ty, _) => {
|
||||
let mut qualname = String::from("<");
|
||||
qualname.push_str(&self.tcx.hir().node_to_pretty_string(ty.id));
|
||||
qualname.push_str(&self.tcx.hir().hir_to_pretty_string(ty.hir_id));
|
||||
|
||||
let trait_id = self.tcx.trait_id_of_impl(impl_id);
|
||||
let mut decl_id = None;
|
||||
|
@ -304,8 +304,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
} else {
|
||||
let mut multispan = MultiSpan::from_span(span);
|
||||
multispan.push_span_label(span_late, note.to_string());
|
||||
tcx.lint_node(lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS,
|
||||
args.args[0].id(), multispan, msg);
|
||||
tcx.lint_hir(lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS,
|
||||
args.args[0].id(), multispan, msg);
|
||||
return (false, None);
|
||||
}
|
||||
}
|
||||
@ -1267,7 +1267,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
// parameter or `Self`.
|
||||
pub fn associated_path_to_ty(
|
||||
&self,
|
||||
ref_id: ast::NodeId,
|
||||
hir_ref_id: hir::HirId,
|
||||
span: Span,
|
||||
qself_ty: Ty<'tcx>,
|
||||
qself_def: Def,
|
||||
@ -1276,6 +1276,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
) -> (Ty<'tcx>, Def) {
|
||||
let tcx = self.tcx();
|
||||
let assoc_ident = assoc_segment.ident;
|
||||
let ref_id = tcx.hir().hir_to_node_id(hir_ref_id);
|
||||
|
||||
debug!("associated_path_to_ty: {:?}::{}", qself_ty, assoc_ident);
|
||||
|
||||
@ -1370,7 +1371,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
};
|
||||
|
||||
let trait_did = bound.def_id();
|
||||
let hir_ref_id = self.tcx().hir().node_to_hir_id(ref_id);
|
||||
let (assoc_ident, def_scope) = tcx.adjust_ident(assoc_ident, trait_did, hir_ref_id);
|
||||
let item = tcx.associated_items(trait_did).find(|i| {
|
||||
Namespace::from(i.kind) == Namespace::Type &&
|
||||
@ -1388,9 +1388,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
tcx.check_stability(item.def_id, Some(ref_id), span);
|
||||
|
||||
if let Some(variant_def) = variant_resolution {
|
||||
let mut err = tcx.struct_span_lint_node(
|
||||
let mut err = tcx.struct_span_lint_hir(
|
||||
AMBIGUOUS_ASSOCIATED_ITEMS,
|
||||
ref_id,
|
||||
hir_ref_id,
|
||||
span,
|
||||
"ambiguous associated item",
|
||||
);
|
||||
@ -1742,7 +1742,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
/// internal notion of a type.
|
||||
pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
|
||||
debug!("ast_ty_to_ty(id={:?}, ast_ty={:?} ty_ty={:?})",
|
||||
ast_ty.id, ast_ty, ast_ty.node);
|
||||
ast_ty.hir_id, ast_ty, ast_ty.node);
|
||||
|
||||
let tcx = self.tcx();
|
||||
|
||||
@ -1795,7 +1795,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||
} else {
|
||||
Def::Err
|
||||
};
|
||||
self.associated_path_to_ty(ast_ty.id, ast_ty.span, ty, def, segment, false).0
|
||||
self.associated_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, def, segment, false).0
|
||||
}
|
||||
hir::TyKind::Array(ref ty, ref length) => {
|
||||
let length_def_id = tcx.hir().local_def_id(length.id);
|
||||
|
@ -4734,7 +4734,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
} else {
|
||||
Def::Err
|
||||
};
|
||||
let (ty, def) = AstConv::associated_path_to_ty(self, node_id, path_span,
|
||||
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
|
||||
let (ty, def) = AstConv::associated_path_to_ty(self, hir_id, path_span,
|
||||
ty, def, segment, true);
|
||||
|
||||
// Write back the new resolution.
|
||||
|
@ -2224,7 +2224,7 @@ fn compute_sig_of_foreign_fn_decl<'a, 'tcx>(
|
||||
&format!(
|
||||
"use of SIMD type `{}` in FFI is highly experimental and \
|
||||
may result in invalid code",
|
||||
tcx.hir().node_to_pretty_string(ast_ty.id)
|
||||
tcx.hir().hir_to_pretty_string(ast_ty.hir_id)
|
||||
),
|
||||
)
|
||||
.help("add #![feature(simd_ffi)] to the crate attributes to enable")
|
||||
|
@ -373,8 +373,8 @@ pub fn hir_ty_to_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_ty: &hir::Ty) ->
|
||||
// In case there are any projections etc, find the "environment"
|
||||
// def-id that will be used to determine the traits/predicates in
|
||||
// scope. This is derived from the enclosing item-like thing.
|
||||
let env_node_id = tcx.hir().get_parent(hir_ty.id);
|
||||
let env_def_id = tcx.hir().local_def_id(env_node_id);
|
||||
let env_node_id = tcx.hir().get_parent_item(hir_ty.hir_id);
|
||||
let env_def_id = tcx.hir().local_def_id_from_hir_id(env_node_id);
|
||||
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id);
|
||||
|
||||
astconv::AstConv::ast_ty_to_ty(&item_cx, hir_ty)
|
||||
|
@ -1219,7 +1219,7 @@ impl Lifetime {
|
||||
|
||||
impl Clean<Lifetime> for hir::Lifetime {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Lifetime {
|
||||
if self.id != ast::DUMMY_NODE_ID {
|
||||
if self.hir_id != hir::DUMMY_HIR_ID {
|
||||
let def = cx.tcx.named_region(self.hir_id);
|
||||
match def {
|
||||
Some(rl::Region::EarlyBound(_, node_id, _)) |
|
||||
@ -1986,7 +1986,7 @@ impl Clean<bool> for hir::IsAuto {
|
||||
|
||||
impl Clean<Type> for hir::TraitRef {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
|
||||
resolve_type(cx, self.path.clean(cx), self.ref_id)
|
||||
resolve_type(cx, self.path.clean(cx), self.hir_ref_id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2654,7 +2654,7 @@ impl Clean<Type> for hir::Ty {
|
||||
});
|
||||
return cx.enter_alias(ty_substs, lt_substs, const_substs, || ty.clean(cx));
|
||||
}
|
||||
resolve_type(cx, path.clean(cx), self.id)
|
||||
resolve_type(cx, path.clean(cx), self.hir_id)
|
||||
}
|
||||
TyKind::Path(hir::QPath::Resolved(Some(ref qself), ref p)) => {
|
||||
let mut segments: Vec<_> = p.segments.clone().into();
|
||||
@ -2667,7 +2667,7 @@ impl Clean<Type> for hir::Ty {
|
||||
Type::QPath {
|
||||
name: p.segments.last().expect("segments were empty").ident.name.clean(cx),
|
||||
self_type: box qself.clean(cx),
|
||||
trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
|
||||
trait_: box resolve_type(cx, trait_path.clean(cx), self.hir_id)
|
||||
}
|
||||
}
|
||||
TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => {
|
||||
@ -2684,7 +2684,7 @@ impl Clean<Type> for hir::Ty {
|
||||
Type::QPath {
|
||||
name: segment.ident.name.clean(cx),
|
||||
self_type: box qself.clean(cx),
|
||||
trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
|
||||
trait_: box resolve_type(cx, trait_path.clean(cx), self.hir_id)
|
||||
}
|
||||
}
|
||||
TyKind::TraitObject(ref bounds, ref lifetime) => {
|
||||
@ -3907,8 +3907,8 @@ fn print_const_expr(cx: &DocContext<'_, '_, '_>, body: hir::BodyId) -> String {
|
||||
/// Given a type Path, resolve it to a Type using the TyCtxt
|
||||
fn resolve_type(cx: &DocContext<'_, '_, '_>,
|
||||
path: Path,
|
||||
id: ast::NodeId) -> Type {
|
||||
if id == ast::DUMMY_NODE_ID {
|
||||
id: hir::HirId) -> Type {
|
||||
if id == hir::DUMMY_HIR_ID {
|
||||
debug!("resolve_type({:?})", path);
|
||||
} else {
|
||||
debug!("resolve_type({:?},{:?})", path, id);
|
||||
|
@ -193,7 +193,6 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
|
||||
};
|
||||
|
||||
hir::Ty {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: hir::TyKind::Path(hir::QPath::Resolved(None, P(new_path))),
|
||||
span: DUMMY_SP,
|
||||
hir_id: hir::DUMMY_HIR_ID,
|
||||
@ -213,7 +212,6 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
|
||||
};
|
||||
|
||||
args.push(hir::GenericArg::Lifetime(hir::Lifetime {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
hir_id: hir::DUMMY_HIR_ID,
|
||||
span: DUMMY_SP,
|
||||
name: hir::LifetimeName::Param(name),
|
||||
@ -235,7 +233,6 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
|
||||
pub fn ty_param_to_ty(&self, param: ty::GenericParamDef) -> hir::Ty {
|
||||
debug!("ty_param_to_ty({:?}) {:?}", param, param.def_id);
|
||||
hir::Ty {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: hir::TyKind::Path(hir::QPath::Resolved(
|
||||
None,
|
||||
P(hir::Path {
|
||||
|
@ -868,7 +868,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> {
|
||||
|
||||
fn visit_item(&mut self, item: &'hir hir::Item) {
|
||||
let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.node {
|
||||
self.map.node_to_pretty_string(ty.id)
|
||||
self.map.hir_to_pretty_string(ty.hir_id)
|
||||
} else {
|
||||
item.ident.to_string()
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user