1
Fork 0

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

@ -1314,7 +1314,7 @@ fn check_enum<'tcx>(
let variant_i = tcx.hir().expect_variant(variant_i_hir_id);
let i_span = match variant_i.disr_expr {
Some(ref expr) => tcx.hir().span(expr.hir_id),
None => tcx.hir().span(variant_i_hir_id),
None => tcx.def_span(variant_did),
};
let span = match v.disr_expr {
Some(ref expr) => tcx.hir().span(expr.hir_id),

View file

@ -435,10 +435,18 @@ fn check_region_bounds_on_impl_item<'tcx>(
if trait_params != impl_params {
let item_kind = assoc_item_kind_str(impl_m);
let def_span = tcx.sess.source_map().guess_head_span(span);
let span = tcx.hir().get_generics(impl_m.def_id).map_or(def_span, |g| g.span);
let span = impl_m
.def_id
.as_local()
.and_then(|did| tcx.hir().get_generics(did))
.map_or(def_span, |g| g.span);
let generics_span = tcx.hir().span_if_local(trait_m.def_id).map(|sp| {
let def_sp = tcx.sess.source_map().guess_head_span(sp);
tcx.hir().get_generics(trait_m.def_id).map_or(def_sp, |g| g.span)
trait_m
.def_id
.as_local()
.and_then(|did| tcx.hir().get_generics(did))
.map_or(def_sp, |g| g.span)
});
tcx.sess.emit_err(LifetimesOrBoundsMismatchOnTrait {

View file

@ -184,8 +184,6 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
// absent. So we report an error that the Drop impl injected a
// predicate that is not present on the struct definition.
let self_type_hir_id = tcx.hir().local_def_id_to_hir_id(self_type_did);
// We can assume the predicates attached to struct/enum definition
// hold.
let generic_assumptions = tcx.predicates_of(self_type_did);
@ -252,7 +250,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
};
if !assumptions_in_impl_context.iter().copied().any(predicate_matches_closure) {
let item_span = tcx.hir().span(self_type_hir_id);
let item_span = tcx.def_span(self_type_did);
let self_descr = tcx.def_kind(self_type_did).descr(self_type_did.to_def_id());
struct_span_err!(
tcx.sess,

View file

@ -787,9 +787,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
}
};
if traits::search_for_structural_match_violation(param.hir_id, param.span, tcx, ty)
.is_some()
{
if traits::search_for_structural_match_violation(param.span, tcx, ty).is_some() {
// We use the same error code in both branches, because this is really the same
// issue: we just special-case the message for type parameters to make it
// clearer.