1
Fork 0

Change maybe_body_owned_by to take local def id

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
Miguel Guarniz 2022-07-15 23:13:04 -04:00
parent 3924dac7bb
commit 25bdc8965e
19 changed files with 50 additions and 47 deletions

View file

@ -207,9 +207,10 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
constness,
);
let body_id = hir_id.map_or(hir::CRATE_HIR_ID, |id| {
tcx.hir().maybe_body_owned_by(id).map_or(id, |body| body.hir_id)
});
let body_id = local_did
.and_then(|id| tcx.hir().maybe_body_owned_by(id).map(|body| body.hir_id))
.or(hir_id)
.map_or(hir::CRATE_HIR_ID, |did| did);
let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id);
traits::normalize_param_env_or_error(tcx, unnormalized_env, cause)
}