}
pub fn hir_id(&self) -> hir::HirId {
- self.tcx.hir().as_local_hir_id(self.item_def_id.expect_local())
+ self.tcx.hir().local_def_id_to_hir_id(self.item_def_id.expect_local())
}
pub fn node(&self) -> hir::Node<'tcx> {
// written inline like `<T: Foo>` or in a where-clause like
// `where T: Foo`.
- let param_id = tcx.hir().as_local_hir_id(def_id);
+ let param_id = tcx.hir().local_def_id_to_hir_id(def_id);
let param_owner = tcx.hir().ty_param_owner(param_id);
let param_owner_def_id = tcx.hir().local_def_id(param_owner);
let generics = tcx.generics_of(param_owner_def_id);
.unwrap_or_default();
let mut extend = None;
- let item_hir_id = tcx.hir().as_local_hir_id(item_def_id.expect_local());
+ let item_hir_id = tcx.hir().local_def_id_to_hir_id(item_def_id.expect_local());
let ast_generics = match tcx.hir().get(item_hir_id) {
Node::TraitItem(item) => &item.generics,
parent_did: LocalDefId,
) -> ty::VariantDef {
let mut seen_fields: FxHashMap<Ident, Span> = Default::default();
- let hir_id = tcx.hir().as_local_hir_id(variant_did.unwrap_or(parent_did));
+ let hir_id = tcx.hir().local_def_id_to_hir_id(variant_did.unwrap_or(parent_did));
let fields = def
.fields()
.iter()
use rustc_hir::*;
let def_id = def_id.expect_local();
- let hir_id = tcx.hir().as_local_hir_id(def_id);
+ let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let item = match tcx.hir().get(hir_id) {
Node::Item(item) => item,
_ => bug!(),
/// the transitive super-predicates are converted.
fn super_predicates_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> ty::GenericPredicates<'_> {
debug!("super_predicates(trait_def_id={:?})", trait_def_id);
- let trait_hir_id = tcx.hir().as_local_hir_id(trait_def_id.expect_local());
+ let trait_hir_id = tcx.hir().local_def_id_to_hir_id(trait_def_id.expect_local());
let item = match tcx.hir().get(trait_hir_id) {
Node::Item(item) => item,
}
fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
- let hir_id = tcx.hir().as_local_hir_id(def_id.expect_local());
+ let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let item = tcx.hir().expect_item(hir_id);
let (is_auto, unsafety) = match item.kind {
fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
use rustc_hir::*;
- let hir_id = tcx.hir().as_local_hir_id(def_id.expect_local());
+ let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let node = tcx.hir().get(hir_id);
let parent_def_id = match node {
use rustc_hir::*;
let def_id = def_id.expect_local();
- let hir_id = tcx.hir().as_local_hir_id(def_id);
+ let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let icx = ItemCtxt::new(tcx, def_id.to_def_id());
fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::TraitRef<'_>> {
let icx = ItemCtxt::new(tcx, def_id);
- let hir_id = tcx.hir().as_local_hir_id(def_id.expect_local());
+ let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
match tcx.hir().expect_item(hir_id).kind {
hir::ItemKind::Impl { ref of_trait, .. } => of_trait.as_ref().map(|ast_trait_ref| {
let selfty = tcx.type_of(def_id);
}
fn impl_polarity(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ImplPolarity {
- let hir_id = tcx.hir().as_local_hir_id(def_id.expect_local());
+ let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let is_rustc_reservation = tcx.has_attr(def_id, sym::rustc_reservation_impl);
let item = tcx.hir().expect_item(hir_id);
match &item.kind {
}
}
- let hir_id = tcx.hir().as_local_hir_id(def_id.expect_local());
+ let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let node = tcx.hir().get(hir_id);
let mut is_trait = None;
if !codegen_fn_attrs.no_sanitize.is_empty() {
if codegen_fn_attrs.inline == InlineAttr::Always {
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
- let hir_id = tcx.hir().as_local_hir_id(id.expect_local());
+ let hir_id = tcx.hir().local_def_id_to_hir_id(id.expect_local());
tcx.struct_span_lint_hir(
lint::builtin::INLINE_NO_SANITIZE,
hir_id,
/// Checks the function annotated with `#[target_feature]` is not a safe
/// trait method implementation, reporting an error if it is.
fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_span: Span) {
- let hir_id = tcx.hir().as_local_hir_id(id);
+ let hir_id = tcx.hir().local_def_id_to_hir_id(id);
let node = tcx.hir().get(hir_id);
if let Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }) = node {
let parent_id = tcx.hir().get_parent_item(hir_id);