Skip to content

Commit 0312935

Browse files
authored
Rollup merge of rust-lang#103862 - compiler-errors:ocx-in-fully-normalize, r=spastorino
Use `ObligationCtxt` in `fully_normalize` Simplifies the implementation a bit
2 parents cd9173e + a9881f5 commit 0312935

File tree

1 file changed

+9
-18
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+9
-18
lines changed

compiler/rustc_trait_selection/src/traits/mod.rs

+9-18
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ pub fn normalize_param_env_or_error<'tcx>(
390390
}
391391

392392
/// Normalize a type and process all resulting obligations, returning any errors
393+
#[instrument(skip_all)]
393394
pub fn fully_normalize<'tcx, T>(
394395
infcx: &InferCtxt<'tcx>,
395396
cause: ObligationCause<'tcx>,
@@ -399,28 +400,18 @@ pub fn fully_normalize<'tcx, T>(
399400
where
400401
T: TypeFoldable<'tcx>,
401402
{
402-
debug!("fully_normalize_with_fulfillcx(value={:?})", value);
403-
let selcx = &mut SelectionContext::new(infcx);
404-
let Normalized { value: normalized_value, obligations } =
405-
project::normalize(selcx, param_env, cause, value);
406-
debug!(
407-
"fully_normalize: normalized_value={:?} obligations={:?}",
408-
normalized_value, obligations
409-
);
410-
411-
let mut fulfill_cx = FulfillmentContext::new();
412-
for obligation in obligations {
413-
fulfill_cx.register_predicate_obligation(infcx, obligation);
414-
}
415-
416-
debug!("fully_normalize: select_all_or_error start");
417-
let errors = fulfill_cx.select_all_or_error(infcx);
403+
let ocx = ObligationCtxt::new(infcx);
404+
debug!(?value);
405+
let normalized_value = ocx.normalize(cause, param_env, value);
406+
debug!(?normalized_value);
407+
debug!("select_all_or_error start");
408+
let errors = ocx.select_all_or_error();
418409
if !errors.is_empty() {
419410
return Err(errors);
420411
}
421-
debug!("fully_normalize: select_all_or_error complete");
412+
debug!("select_all_or_error complete");
422413
let resolved_value = infcx.resolve_vars_if_possible(normalized_value);
423-
debug!("fully_normalize: resolved_value={:?}", resolved_value);
414+
debug!(?resolved_value);
424415
Ok(resolved_value)
425416
}
426417

0 commit comments

Comments
 (0)