Skip to content

Conversation

ChayimFriedman2
Copy link
Contributor

Continuation of #145377. I migrated the rest of the types, except aliases.

Aliases are problematic because opaques and associated types share the same type in the new solver. @jackh726, @lcnr, @ShoyuVanilla I'd like to hear ideas here. Anyway, even if we do nothing with them we already got a substantial improvement.

r? types

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Sep 2, 2025
self.found_non_local_ty(ty)
}
}
ty::Coroutine(did, ..) => {
Copy link
Contributor Author

@ChayimFriedman2 ChayimFriedman2 Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place in the PR I think there is a (slight) regression in code quality. The reason is that now the types of the variables are different. It's possible to avoid if we unify ClosureId, CoroutineId and CoroutineClosureId. This will be slightly worse for r-a and slightly better here. Given that the code duplicated is very small, and for r-a the effects of unifying them will be bigger, I decided to duplicate the code here, but I agree to reverse my decision if the reviewer disagrees.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do

(ty::Closure(did, ..) if let did = did.into()) |
...

I don't remember if this got implemented - being able to write guards for each pattern. (Even if it is, maybe you need a turbofish here, idk).

You could also remove the duplication by moving this into a closure and then calling check(did.into()) for each arm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem to work: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=33963a324a2ffe51340b0ca533c710ef.

I can extract to a closure if wanted, I just didn't because the duplicated code is really small.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so guard_patterns seems implemented? But doesn't support if let. Not sure if that's planned or not - sure seems possibly useful.

In this case, duplicating is probably fine, but again would defer to lcnr.

@jackh726
Copy link
Member

jackh726 commented Sep 2, 2025

Looking over this, seems fine to me modulo the one bit you already pointed out, if we're committing to this in principle (which I am not opposed to).

That being said, I would rather just punt this one over to lcnr
r? lcnr

@rustbot rustbot assigned lcnr and unassigned jackh726 Sep 2, 2025
@@ -152,20 +152,20 @@ where
}

ecx.probe_trait_candidate(CandidateSource::Impl(impl_def_id)).enter(|ecx| {
let impl_args = ecx.fresh_args_for_item(impl_def_id);
let impl_args = ecx.fresh_args_for_item(impl_def_id.into());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept Into<DefId>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a specific reason to want that? This will make the method generic, meaning monomorphization costs, and the into() is a very small cost to pay.

ecx.record_impl_args(impl_args);
let impl_trait_ref = impl_trait_ref.instantiate(cx, impl_args);

ecx.eq(goal.param_env, goal.predicate.trait_ref, impl_trait_ref)?;
let where_clause_bounds = cx
.predicates_of(impl_def_id)
.predicates_of(impl_def_id.into())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

.iter_instantiated(cx, impl_args)
.map(|pred| goal.with(cx, pred));
ecx.add_goals(GoalSource::ImplWhereBound, where_clause_bounds);

// For this impl to be `const`, we need to check its `[const]` bounds too.
let const_conditions = cx
.const_conditions(impl_def_id)
.const_conditions(impl_def_id.into())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants