about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
diff options
context:
space:
mode:
authorMiguel Guarniz <mi9uel9@gmail.com>2022-07-15 23:13:04 -0400
committerMiguel Guarniz <mi9uel9@gmail.com>2022-07-29 18:25:58 -0400
commit25bdc8965e7a80cb3a72da79ca568953738fe433 (patch)
tree9e5c141b84918483db882f87c8d1bbb6b3702da1 /compiler/rustc_ty_utils/src
parent3924dac7bb29bc8eb348059c901e8f912399c857 (diff)
downloadrust-25bdc8965e7a80cb3a72da79ca568953738fe433.tar.gz
rust-25bdc8965e7a80cb3a72da79ca568953738fe433.zip
Change maybe_body_owned_by to take local def id
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
Diffstat (limited to 'compiler/rustc_ty_utils/src')
-rw-r--r--compiler/rustc_ty_utils/src/ty.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs
index d542a9b5997..f437eb98942 100644
--- a/compiler/rustc_ty_utils/src/ty.rs
+++ b/compiler/rustc_ty_utils/src/ty.rs
@@ -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)
 }