Reduce use of local_def_id_to_hir_id.

This commit is contained in:
Camille GILLOT 2021-10-20 20:59:15 +02:00
parent ebcc847369
commit 67727aa7c3
39 changed files with 182 additions and 237 deletions

View file

@ -99,12 +99,7 @@ fn are_inner_types_recursive<'tcx>(
// Find non representable fields with their spans
fold_repr(def.all_fields().map(|field| {
let ty = field.ty(tcx, substs);
let span = match field
.did
.as_local()
.map(|id| tcx.hir().local_def_id_to_hir_id(id))
.and_then(|id| tcx.hir().find(id))
{
let span = match field.did.as_local().and_then(|id| tcx.hir().find_by_def_id(id)) {
Some(hir::Node::Field(field)) => field.ty.span,
_ => sp,
};

View file

@ -279,8 +279,7 @@ fn well_formed_types_in_env<'tcx>(
if !def_id.is_local() {
return ty::List::empty();
}
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let node = tcx.hir().get(hir_id);
let node = tcx.hir().get_by_def_id(def_id.expect_local());
enum NodeKind {
TraitImpl,
@ -436,9 +435,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
/// Check if a function is async.
fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync {
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let node = tcx.hir().get(hir_id);
let node = tcx.hir().get_by_def_id(def_id.expect_local());
let fn_kind = node.fn_kind().unwrap_or_else(|| {
bug!("asyncness: expected fn-like node but got `{:?}`", def_id);