1
Fork 0

Add opt_alias_variances and use it in outlives code

This commit is contained in:
Michael Goulet 2025-02-05 18:03:26 +00:00
parent 2f92f050e8
commit d17a4a7f9a
12 changed files with 117 additions and 50 deletions

View file

@ -284,7 +284,7 @@ where
return;
}
match ty.kind() {
match *ty.kind() {
ty::Closure(_, args) => {
// Skip lifetime parameters of the enclosing item(s)
@ -316,10 +316,12 @@ where
args.as_coroutine().resume_ty().visit_with(self);
}
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {
// Skip lifetime parameters that are not captures.
let variances = self.tcx.variances_of(*def_id);
ty::Alias(kind, ty::AliasTy { def_id, args, .. })
if let Some(variances) = self.tcx.opt_alias_variances(kind, def_id) =>
{
// Skip lifetime parameters that are not captured, since they do
// not need member constraints registered for them; we'll erase
// them (and hopefully in the future replace them with placeholders).
for (v, s) in std::iter::zip(variances, args.iter()) {
if *v != ty::Bivariant {
s.visit_with(self);