Skip to content

Commit f5af266

Browse files
Address nits
1 parent fe89475 commit f5af266

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ pub fn normalize_param_env_or_error<'tcx>(
378378
)
379379
}
380380

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

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

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

438+
/// Process a bound (and any nested obligations that come from it) to completion.
439+
/// This is a convenience function for traits that have no generic arguments, such
440+
/// as auto traits, and builtin traits like Copy or Sized.
433441
pub fn fully_solve_bound<'a, 'tcx>(
434442
infcx: &InferCtxt<'a, 'tcx>,
435443
cause: ObligationCause<'tcx>,

Diff for: compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
707707
&mut self,
708708
ty: Ty<'tcx>,
709709
param_env: ty::ParamEnv<'tcx>,
710+
cause: &ObligationCause<'tcx>,
710711
) -> Option<(Ty<'tcx>, DefId)> {
711712
let tcx = self.tcx();
712713
if tcx.features().trait_upcasting {
@@ -720,7 +721,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
720721
};
721722

722723
let obligation = traits::Obligation::new(
723-
ObligationCause::dummy(),
724+
cause.clone(),
724725
param_env,
725726
ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
726727
);
@@ -735,7 +736,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
735736
item_def_id: tcx.lang_items().deref_target()?,
736737
substs: trait_ref.substs,
737738
},
738-
ObligationCause::dummy(),
739+
cause.clone(),
739740
0,
740741
// We're *intentionally* throwing these away,
741742
// since we don't actually use them.
@@ -809,7 +810,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
809810
let target_trait_did = principal_def_id_b.unwrap();
810811
let source_trait_ref = principal_a.with_self_ty(self.tcx(), source);
811812
if let Some((deref_output_ty, deref_output_trait_did)) = self
812-
.need_migrate_deref_output_trait_object(source, obligation.param_env)
813+
.need_migrate_deref_output_trait_object(
814+
source,
815+
obligation.param_env,
816+
&obligation.cause,
817+
)
813818
{
814819
if deref_output_trait_did == target_trait_did {
815820
self.tcx().struct_span_lint_hir(

0 commit comments

Comments
 (0)