Skip to content

Commit 532bdb3

Browse files
committed
Some tracing to builtin fn candidates
1 parent d989ea9 commit 532bdb3

File tree

6 files changed

+21
-1
lines changed

6 files changed

+21
-1
lines changed

Diff for: compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,9 @@ where
429429
} else if cx.trait_is_alias(trait_def_id) {
430430
G::consider_trait_alias_candidate(self, goal)
431431
} else {
432-
match cx.as_lang_item(trait_def_id) {
432+
let lang_item = cx.as_lang_item(trait_def_id);
433+
tracing::trace!(?lang_item);
434+
match lang_item {
433435
Some(TraitSolverLangItem::Sized) => G::consider_builtin_sized_candidate(self, goal),
434436
Some(TraitSolverLangItem::Copy | TraitSolverLangItem::Clone) => {
435437
G::consider_builtin_copy_clone_candidate(self, goal)

Diff for: compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ where
260260
}
261261

262262
// Returns a binder of the tupled inputs types and output type from a builtin callable type.
263+
#[tracing::instrument(level = "trace", skip(cx), ret)]
263264
pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<
264265
Ir: RustIr<Interner = I>,
265266
I: Interner,

Diff for: compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ where
156156
self.trait_def_id(cx)
157157
}
158158

159+
#[instrument(level = "trace", skip(ecx, then))]
159160
fn probe_and_match_goal_against_assumption(
160161
ecx: &mut EvalCtxt<'_, D>,
161162
source: CandidateSource<I>,
@@ -164,17 +165,20 @@ where
164165
then: impl FnOnce(&mut EvalCtxt<'_, D>) -> QueryResult<I>,
165166
) -> Result<Candidate<I>, NoSolution> {
166167
if let Some(projection_pred) = assumption.as_projection_clause() {
168+
tracing::trace!("assumption is projection clause");
167169
if projection_pred.projection_def_id() == goal.predicate.clone().def_id() {
168170
let cx = ecx.cx();
169171
if !DeepRejectCtxt::relate_rigid_rigid(cx.interner()).args_may_unify(
170172
goal.predicate.alias.args.clone(),
171173
projection_pred.clone().skip_binder().projection_term.args,
172174
) {
175+
tracing::trace!("args will not unify");
173176
return Err(NoSolution);
174177
}
175178
ecx.probe_trait_candidate(source).enter(|ecx| {
176179
let assumption_projection_pred =
177180
ecx.instantiate_binder_with_infer(projection_pred);
181+
tracing::trace!(?assumption_projection_pred);
178182
ecx.eq(
179183
goal.param_env.clone(),
180184
goal.predicate.alias.clone(),
@@ -334,6 +338,8 @@ where
334338
kind => panic!("expected projection, found {kind:?}"),
335339
};
336340

341+
tracing::trace!(?term);
342+
337343
ecx.instantiate_normalizes_to_term(goal, term.instantiate(cx.interner(), target_args));
338344
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
339345
})
@@ -384,6 +390,7 @@ where
384390
panic!("`FnPtr` does not have an associated type: {:?}", goal);
385391
}
386392

393+
#[tracing::instrument(level = "trace", skip(ecx), ret)]
387394
fn consider_builtin_fn_trait_candidates(
388395
ecx: &mut EvalCtxt<'_, D>,
389396
goal: Goal<I, Self>,
@@ -418,6 +425,8 @@ where
418425
})
419426
.upcast(cx.interner());
420427

428+
tracing::trace!(?pred);
429+
421430
Self::probe_and_consider_implied_clause(
422431
ecx,
423432
CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),

Diff for: compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

+6
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ where
129129
.enter(|ecx| ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes))
130130
}
131131

132+
#[instrument(level = "trace", skip(ecx, then))]
132133
fn probe_and_match_goal_against_assumption(
133134
ecx: &mut EvalCtxt<'_, D>,
134135
source: CandidateSource<I>,
@@ -137,13 +138,16 @@ where
137138
then: impl FnOnce(&mut EvalCtxt<'_, D>) -> QueryResult<I>,
138139
) -> Result<Candidate<I>, NoSolution> {
139140
if let Some(trait_clause) = assumption.as_trait_clause() {
141+
trace!("assumption is trait_clause");
140142
if trait_clause.clone().def_id() == goal.predicate.clone().def_id()
141143
&& trait_clause.clone().polarity() == goal.predicate.polarity
142144
{
145+
trace!("trait and polarity match");
143146
if !DeepRejectCtxt::relate_rigid_rigid(ecx.cx().interner()).args_may_unify(
144147
goal.predicate.trait_ref.args.clone(),
145148
trait_clause.clone().skip_binder().trait_ref.args,
146149
) {
150+
trace!("args may not unify");
147151
return Err(NoSolution);
148152
}
149153

@@ -306,6 +310,7 @@ where
306310
)? {
307311
Some(a) => a,
308312
None => {
313+
trace!("Unable to extract inputs and output");
309314
return ecx.forced_ambiguity(MaybeCause::Ambiguity);
310315
}
311316
};
@@ -324,6 +329,7 @@ where
324329
])
325330
})
326331
.upcast(cx.interner());
332+
trace!(?pred);
327333
Self::probe_and_consider_implied_clause(
328334
ecx,
329335
CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),

Diff for: compiler/rustc_type_ir/src/fast_reject.rs

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ impl<I: Interner, const INSTANTIATE_LHS_WITH_INFER: bool, const INSTANTIATE_RHS_
236236
})
237237
}
238238

239+
#[tracing::instrument(level = "trace", skip(self), ret)]
239240
pub fn types_may_unify(self, lhs: I::Ty, rhs: I::Ty) -> bool {
240241
match rhs.clone().kind() {
241242
// Start by checking whether the `rhs` type may unify with

Diff for: compiler/rustc_type_ir/src/lang_items.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// Lang items used by the new trait solver. This can be mapped to whatever internal
22
/// representation of `LangItem`s used in the underlying compiler implementation.
3+
#[derive(Debug, PartialEq)]
34
pub enum TraitSolverLangItem {
45
// tidy-alphabetical-start
56
AsyncDestruct,

0 commit comments

Comments
 (0)