rm ItemKind::OpaqueTy

This introduce an additional collection of opaques on HIR, as they can no
longer be listed using the free item list.
This commit is contained in:
Noah Lev
2024-08-09 20:43:30 -07:00
committed by Camille GILLOT
parent 4ec7839afa
commit d6f247f3d5
45 changed files with 306 additions and 368 deletions

View File

@@ -56,7 +56,7 @@ use rustc_type_ir::lang_items::TraitSolverLangItem;
pub use rustc_type_ir::lift::Lift;
use rustc_type_ir::solve::SolverMode;
use rustc_type_ir::{CollectAndApply, Interner, TypeFlags, WithCachedTypeInfo, search_graph};
use tracing::{debug, instrument};
use tracing::{debug, trace};
use crate::arena::Arena;
use crate::dep_graph::{DepGraph, DepKindStruct};
@@ -2073,9 +2073,11 @@ impl<'tcx> TyCtxt<'tcx> {
}
/// Returns the origin of the opaque type `def_id`.
#[instrument(skip(self), level = "trace", ret)]
#[track_caller]
pub fn opaque_type_origin(self, def_id: LocalDefId) -> hir::OpaqueTyOrigin {
self.hir().expect_item(def_id).expect_opaque_ty().origin
let origin = self.hir().expect_opaque_ty(def_id).origin;
trace!("opaque_type_origin({def_id:?}) => {origin:?}");
origin
}
}
@@ -3031,8 +3033,7 @@ impl<'tcx> TyCtxt<'tcx> {
loop {
let parent = self.local_parent(opaque_lifetime_param_def_id);
let hir::OpaqueTy { lifetime_mapping, .. } =
self.hir_node_by_def_id(parent).expect_item().expect_opaque_ty();
let hir::OpaqueTy { lifetime_mapping, .. } = self.hir().expect_opaque_ty(parent);
let Some((lifetime, _)) = lifetime_mapping
.iter()

View File

@@ -507,14 +507,8 @@ impl<'v> hir::intravisit::Visitor<'v> for TraitObjectVisitor<'v> {
..
},
_,
) => {
self.0.push(ty);
}
hir::TyKind::OpaqueDef(item_id, _) => {
self.0.push(ty);
let item = self.1.item(item_id);
hir::intravisit::walk_item(self, item);
}
)
| hir::TyKind::OpaqueDef(..) => self.0.push(ty),
_ => {}
}
hir::intravisit::walk_ty(self, ty);

View File

@@ -21,6 +21,7 @@ use rustc_target::spec::abi;
use rustc_type_ir::TyKind::*;
use rustc_type_ir::visit::TypeVisitableExt;
use rustc_type_ir::{self as ir, BoundVar, CollectAndApply, DynKind};
use tracing::instrument;
use ty::util::{AsyncDropGlueMorphology, IntTypeExt};
use super::GenericParamDefKind;
@@ -500,6 +501,7 @@ impl<'tcx> Ty<'tcx> {
}
#[inline]
#[instrument(level = "debug", skip(tcx))]
pub fn new_opaque(tcx: TyCtxt<'tcx>, def_id: DefId, args: GenericArgsRef<'tcx>) -> Ty<'tcx> {
Ty::new_alias(tcx, ty::Opaque, AliasTy::new_from_args(tcx, def_id, args))
}