Revert "Auto merge of #102417 - oli-obk:opaque_lifetimes2, r=jackh726"

This reverts commit cb9467515b, reversing
changes made to 57781b24c5.
This commit is contained in:
Oli Scherer 2023-08-08 08:35:38 +00:00
parent 61efe9d298
commit e0a60f0740
22 changed files with 71 additions and 80 deletions

View file

@ -129,7 +129,15 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
// By default, RPIT are invariant wrt type and const generics, but they are bivariant wrt
// lifetime generics.
let mut variances: Vec<_> = std::iter::repeat(ty::Invariant).take(generics.count()).collect();
let variances = std::iter::repeat(ty::Invariant).take(generics.count());
let mut variances: Vec<_> = match tcx.opaque_type_origin(item_def_id) {
rustc_hir::OpaqueTyOrigin::FnReturn(_) | rustc_hir::OpaqueTyOrigin::AsyncFn(_) => {
variances.collect()
}
// But TAIT are invariant for all generics
rustc_hir::OpaqueTyOrigin::TyAlias { .. } => return tcx.arena.alloc_from_iter(variances),
};
// Mark all lifetimes from parent generics as unused (Bivariant).
// This will be overridden later if required.