Skip to content

Commit

Permalink
Get rid of manual Trace calls
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed May 28, 2024
1 parent f989d2f commit 89f3651
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let (a_sig, b_sig) = self.normalize(new.span, (a_sig, b_sig));
let sig = self
.at(cause, self.param_env)
.trace(prev_ty, new_ty)
.lub(DefineOpaqueTypes::Yes, a_sig, b_sig)
.map(|ok| self.register_infer_ok_obligations(ok))?;

Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_infer/src/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,23 @@ impl<'a, 'tcx> At<'a, 'tcx> {
self.trace(expected, actual).eq(define_opaque_types, expected, actual)
}

/// Equates `expected` and `found` while structurally relating aliases.
/// This should only be used inside of the next generation trait solver
/// when relating rigid aliases.
pub fn eq_structurally_relating_aliases<T>(
self,
expected: T,
actual: T,
) -> InferResult<'tcx, ()>
where
T: ToTrace<'tcx>,
{
self.trace(expected, actual).eq_structurally_relating_aliases(
expected,
actual,
)
}

pub fn relate<T>(
self,
define_opaque_types: DefineOpaqueTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
for (&orig, response) in iter::zip(original_values, var_values.var_values) {
let InferOk { value: (), obligations } = infcx
.at(&cause, param_env)
.trace(orig, response)
.eq_structurally_relating_aliases(orig, response)
.unwrap();
assert!(obligations.is_empty());
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,6 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
let InferOk { value: (), obligations } = self
.infcx
.at(&ObligationCause::dummy(), param_env)
.trace(term, ctor_term)
.eq_structurally_relating_aliases(term, ctor_term)?;
debug_assert!(obligations.is_empty());
self.relate(param_env, alias, variance, rigid_ctor)
Expand All @@ -794,11 +793,8 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
rhs: T,
) -> Result<(), NoSolution> {
let cause = ObligationCause::dummy();
let InferOk { value: (), obligations } = self
.infcx
.at(&cause, param_env)
.trace(lhs, rhs)
.eq_structurally_relating_aliases(lhs, rhs)?;
let InferOk { value: (), obligations } =
self.infcx.at(&cause, param_env).eq_structurally_relating_aliases(lhs, rhs)?;
assert!(obligations.is_empty());
Ok(())
}
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,13 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
{
if let Ok(new_obligations) = infcx
.at(&obligation.cause, obligation.param_env)
.trace(c1, c2)
// Can define opaque types as this is only reachable with
// `generic_const_exprs`
.eq(DefineOpaqueTypes::Yes, a.args, b.args)
.eq(
DefineOpaqueTypes::Yes,
ty::AliasTerm::from(a),
ty::AliasTerm::from(b),
)
{
return ProcessResult::Changed(mk_pending(
new_obligations.into_obligations(),
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,10 +910,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
if let Ok(InferOk { obligations, value: () }) = self
.infcx
.at(&obligation.cause, obligation.param_env)
.trace(c1, c2)
// Can define opaque types as this is only reachable with
// `generic_const_exprs`
.eq(DefineOpaqueTypes::Yes, a.args, b.args)
.eq(
DefineOpaqueTypes::Yes,
ty::AliasTerm::from(a),
ty::AliasTerm::from(b),
)
{
return self.evaluate_predicates_recursively(
previous_stack,
Expand Down

0 comments on commit 89f3651

Please sign in to comment.