1
Fork 0

Rollup merge of #126354 - compiler-errors:variance, r=lcnr

Use `Variance` glob imported variants everywhere

Fully commit to using the globbed variance. Could be convinced the other way, and change this PR to not use the globbed variants anywhere, but I'd rather we do one or the other.

r? lcnr
This commit is contained in:
Matthias Krüger 2024-06-15 10:56:40 +02:00 committed by GitHub
commit 335e320baa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 74 additions and 111 deletions

View file

@ -699,7 +699,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// exactly `T` (i.e., with invariance). The variance field, in
// contrast, is intended to be used to relate `T` to the type of
// `<expr>`.
ty::Variance::Invariant,
ty::Invariant,
),
},
);

View file

@ -92,7 +92,7 @@ impl<'tcx> Cx<'tcx> {
kind: PatKind::AscribeUserType {
ascription: Ascription {
annotation,
variance: ty::Variance::Covariant,
variance: ty::Covariant,
},
subpattern: pattern,
},

View file

@ -525,7 +525,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
};
kind = PatKind::AscribeUserType {
subpattern: Box::new(Pat { span, ty, kind }),
ascription: Ascription { annotation, variance: ty::Variance::Covariant },
ascription: Ascription { annotation, variance: ty::Covariant },
};
}
@ -612,7 +612,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
annotation,
// Note that use `Contravariant` here. See the
// `variance` field documentation for details.
variance: ty::Variance::Contravariant,
variance: ty::Contravariant,
},
},
ty: const_.ty(),