diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-11-02 22:32:05 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-02 22:32:05 +0530 |
| commit | 031293547383b305beed135c4edcafad4fd5f0f6 (patch) | |
| tree | 7fe2abae17f814352d1b0e5831eff5534c545163 | |
| parent | cd9173ec40f261994e68c111a582951ab6ba45cd (diff) | |
| parent | a9881f52131a2ed745c188ccdecf37a2e2430fe7 (diff) | |
| download | rust-031293547383b305beed135c4edcafad4fd5f0f6.tar.gz rust-031293547383b305beed135c4edcafad4fd5f0f6.zip | |
Rollup merge of #103862 - compiler-errors:ocx-in-fully-normalize, r=spastorino
Use `ObligationCtxt` in `fully_normalize` Simplifies the implementation a bit
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/mod.rs | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 0bf54c096cd..9ee6e0a2bf3 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -390,6 +390,7 @@ pub fn normalize_param_env_or_error<'tcx>( } /// Normalize a type and process all resulting obligations, returning any errors +#[instrument(skip_all)] pub fn fully_normalize<'tcx, T>( infcx: &InferCtxt<'tcx>, cause: ObligationCause<'tcx>, @@ -399,28 +400,18 @@ pub fn fully_normalize<'tcx, T>( where T: TypeFoldable<'tcx>, { - debug!("fully_normalize_with_fulfillcx(value={:?})", value); - let selcx = &mut SelectionContext::new(infcx); - let Normalized { value: normalized_value, obligations } = - project::normalize(selcx, param_env, cause, value); - debug!( - "fully_normalize: normalized_value={:?} obligations={:?}", - normalized_value, obligations - ); - - let mut fulfill_cx = FulfillmentContext::new(); - for obligation in obligations { - fulfill_cx.register_predicate_obligation(infcx, obligation); - } - - debug!("fully_normalize: select_all_or_error start"); - let errors = fulfill_cx.select_all_or_error(infcx); + let ocx = ObligationCtxt::new(infcx); + debug!(?value); + let normalized_value = ocx.normalize(cause, param_env, value); + debug!(?normalized_value); + debug!("select_all_or_error start"); + let errors = ocx.select_all_or_error(); if !errors.is_empty() { return Err(errors); } - debug!("fully_normalize: select_all_or_error complete"); + debug!("select_all_or_error complete"); let resolved_value = infcx.resolve_vars_if_possible(normalized_value); - debug!("fully_normalize: resolved_value={:?}", resolved_value); + debug!(?resolved_value); Ok(resolved_value) } |
