about summary refs log tree commit diff
path: root/compiler/rustc_traits/src/normalize_projection_ty.rs
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2023-03-21 01:46:52 +0100
committerLeón Orell Valerian Liehr <me@fmease.dev>2023-05-04 16:59:10 +0200
commite8139dfd5a747842a8303f33d8c842378913d594 (patch)
tree977f9a1bd7bc5c0e8efc36b3a23c911c64189cc3 /compiler/rustc_traits/src/normalize_projection_ty.rs
parent6f8c0557e0b73c73a8a7163a15f4a5a3feca7d5c (diff)
downloadrust-e8139dfd5a747842a8303f33d8c842378913d594.tar.gz
rust-e8139dfd5a747842a8303f33d8c842378913d594.zip
IAT: Introduce AliasKind::Inherent
Diffstat (limited to 'compiler/rustc_traits/src/normalize_projection_ty.rs')
-rw-r--r--compiler/rustc_traits/src/normalize_projection_ty.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/compiler/rustc_traits/src/normalize_projection_ty.rs b/compiler/rustc_traits/src/normalize_projection_ty.rs
index e805eb42821..36d80a06ee7 100644
--- a/compiler/rustc_traits/src/normalize_projection_ty.rs
+++ b/compiler/rustc_traits/src/normalize_projection_ty.rs
@@ -10,7 +10,7 @@ use rustc_trait_selection::traits::{self, ObligationCause, SelectionContext};
 use std::sync::atomic::Ordering;
 
 pub(crate) fn provide(p: &mut Providers) {
-    *p = Providers { normalize_projection_ty, ..*p };
+    *p = Providers { normalize_projection_ty, normalize_inherent_projection_ty, ..*p };
 }
 
 fn normalize_projection_ty<'tcx>(
@@ -42,3 +42,30 @@ fn normalize_projection_ty<'tcx>(
         },
     )
 }
+
+fn normalize_inherent_projection_ty<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    goal: CanonicalProjectionGoal<'tcx>,
+) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution> {
+    debug!("normalize_provider(goal={:#?})", goal);
+
+    tcx.infer_ctxt().enter_canonical_trait_query(
+        &goal,
+        |ocx, ParamEnvAnd { param_env, value: goal }| {
+            let selcx = &mut SelectionContext::new(ocx.infcx);
+            let cause = ObligationCause::dummy();
+            let mut obligations = vec![];
+            let answer = traits::normalize_inherent_projection(
+                selcx,
+                param_env,
+                goal,
+                cause,
+                0,
+                &mut obligations,
+            );
+            ocx.register_obligations(obligations);
+
+            Ok(NormalizationResult { normalized_ty: answer })
+        },
+    )
+}