More tracing instrumentation
This commit is contained in:
parent
83f147b3ba
commit
9b5aa063d8
39 changed files with 252 additions and 323 deletions
|
@ -517,6 +517,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
debug!(?id_substs);
|
||||
let map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>> =
|
||||
substs.iter().enumerate().map(|(index, subst)| (subst, id_substs[index])).collect();
|
||||
debug!("map = {:#?}", map);
|
||||
|
||||
// Convert the type from the function into a type valid outside
|
||||
// the function, by replacing invalid regions with 'static,
|
||||
|
@ -672,6 +673,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
|
|||
self.tcx
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
|
||||
match r {
|
||||
// Ignore bound regions and `'static` regions that appear in the
|
||||
|
@ -1098,18 +1100,17 @@ fn may_define_opaque_type(tcx: TyCtxt<'_>, def_id: LocalDefId, opaque_hir_id: hi
|
|||
///
|
||||
/// Requires that trait definitions have been processed so that we can
|
||||
/// elaborate predicates and walk supertraits.
|
||||
#[instrument(skip(tcx, predicates), level = "debug")]
|
||||
crate fn required_region_bounds(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
erased_self_ty: Ty<'tcx>,
|
||||
predicates: impl Iterator<Item = ty::Predicate<'tcx>>,
|
||||
) -> Vec<ty::Region<'tcx>> {
|
||||
debug!("required_region_bounds(erased_self_ty={:?})", erased_self_ty);
|
||||
|
||||
assert!(!erased_self_ty.has_escaping_bound_vars());
|
||||
|
||||
traits::elaborate_predicates(tcx, predicates)
|
||||
.filter_map(|obligation| {
|
||||
debug!("required_region_bounds(obligation={:?})", obligation);
|
||||
debug!(?obligation);
|
||||
match obligation.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::Trait(..)
|
||||
|
|
|
@ -1195,13 +1195,13 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
false
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn report_fulfillment_error(
|
||||
&self,
|
||||
error: &FulfillmentError<'tcx>,
|
||||
body_id: Option<hir::BodyId>,
|
||||
fallback_has_occurred: bool,
|
||||
) {
|
||||
debug!("report_fulfillment_error({:?})", error);
|
||||
match error.code {
|
||||
FulfillmentErrorCode::CodeSelectionError(ref selection_error) => {
|
||||
self.report_selection_error(
|
||||
|
@ -1528,6 +1528,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
)
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn maybe_report_ambiguity(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
|
@ -1542,8 +1543,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let span = obligation.cause.span;
|
||||
|
||||
debug!(
|
||||
"maybe_report_ambiguity(predicate={:?}, obligation={:?} body_id={:?}, code={:?})",
|
||||
predicate, obligation, body_id, obligation.cause.code,
|
||||
?predicate, ?obligation.cause.code,
|
||||
);
|
||||
|
||||
// Ambiguity errors are often caused as fallout from earlier
|
||||
|
@ -1556,7 +1556,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let mut err = match bound_predicate.skip_binder() {
|
||||
ty::PredicateKind::Trait(data) => {
|
||||
let trait_ref = bound_predicate.rebind(data.trait_ref);
|
||||
debug!("trait_ref {:?}", trait_ref);
|
||||
debug!(?trait_ref);
|
||||
|
||||
if predicate.references_error() {
|
||||
return;
|
||||
|
|
|
@ -220,6 +220,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.filter_impls(candidates.pop().unwrap().candidate, stack.obligation)
|
||||
}
|
||||
|
||||
#[instrument(skip(self, stack), level = "debug")]
|
||||
pub(super) fn assemble_candidates<'o>(
|
||||
&mut self,
|
||||
stack: &TraitObligationStack<'o, 'tcx>,
|
||||
|
|
|
@ -601,12 +601,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
Ok(ImplSourceGeneratorData { generator_def_id, substs, nested: obligations })
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn confirm_closure_candidate(
|
||||
&mut self,
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
) -> Result<ImplSourceClosureData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
|
||||
debug!(?obligation, "confirm_closure_candidate");
|
||||
|
||||
let kind = self
|
||||
.tcx()
|
||||
.fn_trait_kind_from_lang_item(obligation.predicate.def_id())
|
||||
|
@ -680,6 +679,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
/// because these output type parameters should not affect the
|
||||
/// selection of the impl. Therefore, if there is a mismatch, we
|
||||
/// report an error to the user.
|
||||
#[instrument(skip(self), level = "trace")]
|
||||
fn confirm_poly_trait_refs(
|
||||
&mut self,
|
||||
obligation_cause: ObligationCause<'tcx>,
|
||||
|
|
|
@ -451,6 +451,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
/// Evaluates the predicates in `predicates` recursively. Note that
|
||||
/// this applies projections in the predicates, and therefore
|
||||
/// is run within an inference probe.
|
||||
#[instrument(skip(self, stack), level = "debug")]
|
||||
fn evaluate_predicates_recursively<'o, I>(
|
||||
&mut self,
|
||||
stack: TraitObligationStackList<'o, 'tcx>,
|
||||
|
@ -460,7 +461,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
I: IntoIterator<Item = PredicateObligation<'tcx>> + std::fmt::Debug,
|
||||
{
|
||||
let mut result = EvaluatedToOk;
|
||||
debug!(?predicates, "evaluate_predicates_recursively");
|
||||
for obligation in predicates {
|
||||
let eval = self.evaluate_predicate_recursively(stack, obligation.clone())?;
|
||||
if let EvaluatedToErr = eval {
|
||||
|
@ -683,13 +683,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
result
|
||||
}
|
||||
|
||||
#[instrument(skip(self, previous_stack), level = "debug")]
|
||||
fn evaluate_trait_predicate_recursively<'o>(
|
||||
&mut self,
|
||||
previous_stack: TraitObligationStackList<'o, 'tcx>,
|
||||
mut obligation: TraitObligation<'tcx>,
|
||||
) -> Result<EvaluationResult, OverflowError> {
|
||||
debug!(?obligation, "evaluate_trait_predicate_recursively");
|
||||
|
||||
if !self.intercrate
|
||||
&& obligation.is_global(self.tcx())
|
||||
&& obligation
|
||||
|
@ -701,7 +700,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// If a param env has no global bounds, global obligations do not
|
||||
// depend on its particular value in order to work, so we can clear
|
||||
// out the param env and get better caching.
|
||||
debug!("evaluate_trait_predicate_recursively - in global");
|
||||
debug!("in global");
|
||||
obligation.param_env = obligation.param_env.without_caller_bounds();
|
||||
}
|
||||
|
||||
|
@ -753,7 +752,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
} else {
|
||||
debug!(?result, "PROVISIONAL");
|
||||
debug!(
|
||||
"evaluate_trait_predicate_recursively: caching provisionally because {:?} \
|
||||
"caching provisionally because {:?} \
|
||||
is a cycle participant (at depth {}, reached depth {})",
|
||||
fresh_trait_ref, stack.depth, reached_depth,
|
||||
);
|
||||
|
@ -2124,13 +2123,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
/// Returns `Ok` if `poly_trait_ref` being true implies that the
|
||||
/// obligation is satisfied.
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn match_poly_trait_ref(
|
||||
&mut self,
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
poly_trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
) -> Result<Vec<PredicateObligation<'tcx>>, ()> {
|
||||
debug!(?obligation, ?poly_trait_ref, "match_poly_trait_ref");
|
||||
|
||||
self.infcx
|
||||
.at(&obligation.cause, obligation.param_env)
|
||||
.sup(obligation.predicate.to_poly_trait_ref(), poly_trait_ref)
|
||||
|
@ -2174,12 +2172,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn closure_trait_ref_unnormalized(
|
||||
&mut self,
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
substs: SubstsRef<'tcx>,
|
||||
) -> ty::PolyTraitRef<'tcx> {
|
||||
debug!(?obligation, ?substs, "closure_trait_ref_unnormalized");
|
||||
let closure_sig = substs.as_closure().sig();
|
||||
|
||||
debug!(?closure_sig);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue