Skip to content

Commit

Permalink
Address nits
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Aug 4, 2022
1 parent fe89475 commit f5af266
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions compiler/rustc_trait_selection/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ pub fn normalize_param_env_or_error<'tcx>(
)
}

/// Normalize a type and process all resulting obligations, returning any errors
pub fn fully_normalize<'a, 'tcx, T>(
infcx: &InferCtxt<'a, 'tcx>,
cause: ObligationCause<'tcx>,
Expand Down Expand Up @@ -412,6 +413,8 @@ where
Ok(resolved_value)
}

/// Process an obligation (and any nested obligations that come from it) to
/// completion, returning any errors
pub fn fully_solve_obligation<'a, 'tcx>(
infcx: &InferCtxt<'a, 'tcx>,
obligation: PredicateObligation<'tcx>,
Expand All @@ -421,6 +424,8 @@ pub fn fully_solve_obligation<'a, 'tcx>(
engine.select_all_or_error(infcx)
}

/// Process a set of obligations (and any nested obligations that come from them)
/// to completion
pub fn fully_solve_obligations<'a, 'tcx>(
infcx: &InferCtxt<'a, 'tcx>,
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
Expand All @@ -430,6 +435,9 @@ pub fn fully_solve_obligations<'a, 'tcx>(
engine.select_all_or_error(infcx)
}

/// Process a bound (and any nested obligations that come from it) to completion.
/// This is a convenience function for traits that have no generic arguments, such
/// as auto traits, and builtin traits like Copy or Sized.
pub fn fully_solve_bound<'a, 'tcx>(
infcx: &InferCtxt<'a, 'tcx>,
cause: ObligationCause<'tcx>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
&mut self,
ty: Ty<'tcx>,
param_env: ty::ParamEnv<'tcx>,
cause: &ObligationCause<'tcx>,
) -> Option<(Ty<'tcx>, DefId)> {
let tcx = self.tcx();
if tcx.features().trait_upcasting {
Expand All @@ -720,7 +721,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
};

let obligation = traits::Obligation::new(
ObligationCause::dummy(),
cause.clone(),
param_env,
ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
);
Expand All @@ -735,7 +736,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
item_def_id: tcx.lang_items().deref_target()?,
substs: trait_ref.substs,
},
ObligationCause::dummy(),
cause.clone(),
0,
// We're *intentionally* throwing these away,
// since we don't actually use them.
Expand Down Expand Up @@ -809,7 +810,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let target_trait_did = principal_def_id_b.unwrap();
let source_trait_ref = principal_a.with_self_ty(self.tcx(), source);
if let Some((deref_output_ty, deref_output_trait_did)) = self
.need_migrate_deref_output_trait_object(source, obligation.param_env)
.need_migrate_deref_output_trait_object(
source,
obligation.param_env,
&obligation.cause,
)
{
if deref_output_trait_did == target_trait_did {
self.tcx().struct_span_lint_hir(
Expand Down

0 comments on commit f5af266

Please sign in to comment.