Remove DUMMY_HIR_ID
This commit is contained in:
parent
b9161ab880
commit
c15e13ae16
9 changed files with 13 additions and 64 deletions
|
@ -7,7 +7,6 @@
|
||||||
pub use crate::def_id::DefPathHash;
|
pub use crate::def_id::DefPathHash;
|
||||||
use crate::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
use crate::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||||
use crate::hir;
|
use crate::hir;
|
||||||
use crate::hir_id::DUMMY_HIR_ID;
|
|
||||||
|
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
use rustc_ast::crate_disambiguator::CrateDisambiguator;
|
use rustc_ast::crate_disambiguator::CrateDisambiguator;
|
||||||
|
@ -345,8 +344,7 @@ impl Definitions {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_local_hir_id(&self, def_id: DefId) -> Option<hir::HirId> {
|
pub fn as_local_hir_id(&self, def_id: DefId) -> Option<hir::HirId> {
|
||||||
if let Some(def_id) = def_id.as_local() {
|
if let Some(def_id) = def_id.as_local() {
|
||||||
let hir_id = self.local_def_id_to_hir_id(def_id);
|
Some(self.local_def_id_to_hir_id(def_id))
|
||||||
if hir_id != DUMMY_HIR_ID { Some(hir_id) } else { None }
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,4 @@ pub const CRATE_HIR_ID: HirId = HirId {
|
||||||
local_id: ItemLocalId::from_u32(0),
|
local_id: ItemLocalId::from_u32(0),
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const DUMMY_HIR_ID: HirId =
|
|
||||||
HirId { owner: LocalDefId { local_def_index: CRATE_DEF_INDEX }, local_id: DUMMY_ITEM_LOCAL_ID };
|
|
||||||
|
|
||||||
pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;
|
pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;
|
||||||
|
|
|
@ -250,23 +250,16 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
||||||
None => format!("{:?}", node),
|
None => format!("{:?}", node),
|
||||||
};
|
};
|
||||||
|
|
||||||
let forgot_str = if hir_id == hir::DUMMY_HIR_ID {
|
|
||||||
format!("\nMaybe you forgot to lower the node id {:?}?", node_id)
|
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
};
|
|
||||||
|
|
||||||
span_bug!(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
"inconsistent DepNode at `{:?}` for `{}`: \
|
"inconsistent DepNode at `{:?}` for `{}`: \
|
||||||
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?}){}",
|
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?})",
|
||||||
self.source_map.span_to_string(span),
|
self.source_map.span_to_string(span),
|
||||||
node_str,
|
node_str,
|
||||||
self.definitions.def_path(self.current_dep_node_owner).to_string_no_crate(),
|
self.definitions.def_path(self.current_dep_node_owner).to_string_no_crate(),
|
||||||
self.current_dep_node_owner,
|
self.current_dep_node_owner,
|
||||||
self.definitions.def_path(hir_id.owner).to_string_no_crate(),
|
self.definitions.def_path(hir_id.owner).to_string_no_crate(),
|
||||||
hir_id.owner,
|
hir_id.owner,
|
||||||
forgot_str,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,6 @@ fn late_report_deprecation(
|
||||||
suggestion: Option<Symbol>,
|
suggestion: Option<Symbol>,
|
||||||
lint: &'static Lint,
|
lint: &'static Lint,
|
||||||
span: Span,
|
span: Span,
|
||||||
def_id: DefId,
|
|
||||||
hir_id: HirId,
|
hir_id: HirId,
|
||||||
) {
|
) {
|
||||||
if span.in_derive_expansion() {
|
if span.in_derive_expansion() {
|
||||||
|
@ -229,9 +228,6 @@ fn late_report_deprecation(
|
||||||
}
|
}
|
||||||
diag.emit()
|
diag.emit()
|
||||||
});
|
});
|
||||||
if hir_id == hir::DUMMY_HIR_ID {
|
|
||||||
span_bug!(span, "emitted a {} lint with dummy HIR id: {:?}", lint.name, def_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Result of `TyCtxt::eval_stability`.
|
/// Result of `TyCtxt::eval_stability`.
|
||||||
|
@ -296,7 +292,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if !skip {
|
if !skip {
|
||||||
let (message, lint) =
|
let (message, lint) =
|
||||||
deprecation_message(&depr_entry.attr, &self.def_path_str(def_id));
|
deprecation_message(&depr_entry.attr, &self.def_path_str(def_id));
|
||||||
late_report_deprecation(self, &message, None, lint, span, def_id, id);
|
late_report_deprecation(self, &message, None, lint, span, id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -319,15 +315,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if let Some(depr) = &stability.rustc_depr {
|
if let Some(depr) = &stability.rustc_depr {
|
||||||
let (message, lint) =
|
let (message, lint) =
|
||||||
rustc_deprecation_message(depr, &self.def_path_str(def_id));
|
rustc_deprecation_message(depr, &self.def_path_str(def_id));
|
||||||
late_report_deprecation(
|
late_report_deprecation(self, &message, depr.suggestion, lint, span, id);
|
||||||
self,
|
|
||||||
&message,
|
|
||||||
depr.suggestion,
|
|
||||||
lint,
|
|
||||||
span,
|
|
||||||
def_id,
|
|
||||||
id,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,16 +143,6 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
|
||||||
fn visit_id(&mut self, hir_id: HirId) {
|
fn visit_id(&mut self, hir_id: HirId) {
|
||||||
let owner = self.owner.expect("no owner");
|
let owner = self.owner.expect("no owner");
|
||||||
|
|
||||||
if hir_id == hir::DUMMY_HIR_ID {
|
|
||||||
self.error(|| {
|
|
||||||
format!(
|
|
||||||
"HirIdValidator: HirId {:?} is invalid",
|
|
||||||
self.hir_map.node_to_string(hir_id)
|
|
||||||
)
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if owner != hir_id.owner {
|
if owner != hir_id.owner {
|
||||||
self.error(|| {
|
self.error(|| {
|
||||||
format!(
|
format!(
|
||||||
|
|
|
@ -2704,14 +2704,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime, def: Region) {
|
fn insert_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime, def: Region) {
|
||||||
if lifetime_ref.hir_id == hir::DUMMY_HIR_ID {
|
|
||||||
span_bug!(
|
|
||||||
lifetime_ref.span,
|
|
||||||
"lifetime reference not renumbered, \
|
|
||||||
probably a bug in rustc_ast::fold"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"insert_lifetime: {} resolved to {:?} span={:?}",
|
"insert_lifetime: {} resolved to {:?} span={:?}",
|
||||||
self.tcx.hir().node_to_string(lifetime_ref.hir_id),
|
self.tcx.hir().node_to_string(lifetime_ref.hir_id),
|
||||||
|
|
|
@ -860,9 +860,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
&mut self,
|
&mut self,
|
||||||
expr_hir_id: hir::HirId,
|
expr_hir_id: hir::HirId,
|
||||||
) -> Result<(), MethodError<'tcx>> {
|
) -> Result<(), MethodError<'tcx>> {
|
||||||
if expr_hir_id == hir::DUMMY_HIR_ID {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
let mut duplicates = FxHashSet::default();
|
let mut duplicates = FxHashSet::default();
|
||||||
let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id);
|
let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id);
|
||||||
if let Some(applicable_traits) = opt_applicable_traits {
|
if let Some(applicable_traits) = opt_applicable_traits {
|
||||||
|
|
|
@ -375,18 +375,16 @@ impl<'tcx> Clean<Option<Vec<GenericBound>>> for InternalSubsts<'tcx> {
|
||||||
|
|
||||||
impl Clean<Lifetime> for hir::Lifetime {
|
impl Clean<Lifetime> for hir::Lifetime {
|
||||||
fn clean(&self, cx: &DocContext<'_>) -> Lifetime {
|
fn clean(&self, cx: &DocContext<'_>) -> Lifetime {
|
||||||
if self.hir_id != hir::DUMMY_HIR_ID {
|
let def = cx.tcx.named_region(self.hir_id);
|
||||||
let def = cx.tcx.named_region(self.hir_id);
|
match def {
|
||||||
match def {
|
Some(rl::Region::EarlyBound(_, node_id, _))
|
||||||
Some(rl::Region::EarlyBound(_, node_id, _))
|
| Some(rl::Region::LateBound(_, node_id, _))
|
||||||
| Some(rl::Region::LateBound(_, node_id, _))
|
| Some(rl::Region::Free(_, node_id)) => {
|
||||||
| Some(rl::Region::Free(_, node_id)) => {
|
if let Some(lt) = cx.lt_substs.borrow().get(&node_id).cloned() {
|
||||||
if let Some(lt) = cx.lt_substs.borrow().get(&node_id).cloned() {
|
return lt;
|
||||||
return lt;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
Lifetime(self.name.ident().to_string())
|
Lifetime(self.name.ident().to_string())
|
||||||
}
|
}
|
||||||
|
|
|
@ -580,11 +580,7 @@ pub fn print_const_expr(cx: &DocContext<'_>, body: hir::BodyId) -> String {
|
||||||
|
|
||||||
/// Given a type Path, resolve it to a Type using the TyCtxt
|
/// Given a type Path, resolve it to a Type using the TyCtxt
|
||||||
pub fn resolve_type(cx: &DocContext<'_>, path: Path, id: hir::HirId) -> Type {
|
pub fn resolve_type(cx: &DocContext<'_>, path: Path, id: hir::HirId) -> Type {
|
||||||
if id == hir::DUMMY_HIR_ID {
|
debug!("resolve_type({:?},{:?})", path, id);
|
||||||
debug!("resolve_type({:?})", path);
|
|
||||||
} else {
|
|
||||||
debug!("resolve_type({:?},{:?})", path, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
let is_generic = match path.res {
|
let is_generic = match path.res {
|
||||||
Res::PrimTy(p) => return Primitive(PrimitiveType::from(p)),
|
Res::PrimTy(p) => return Primitive(PrimitiveType::from(p)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue