Remove DefId from EarlyParamRegion (type system)

This commit is contained in:
Boxy 2024-05-23 23:53:56 +01:00
parent b7b350cff7
commit bd6344d829
5 changed files with 38 additions and 44 deletions

View file

@ -5,11 +5,11 @@ use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_macros::LintDiagnostic;
use rustc_middle::bug;
use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
use rustc_middle::ty::{
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
};
use rustc_middle::{bug, span_bug};
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::{sym, BytePos, Span};
@ -303,20 +303,12 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for VisitOpaqueTypes<'tcx> {
ResolvedArg::EarlyBound(def_id) | ResolvedArg::LateBound(_, _, def_id),
) => {
if self.tcx.def_kind(self.tcx.parent(def_id)) == DefKind::OpaqueTy {
let (ty::ReEarlyParam(ty::EarlyParamRegion { def_id, .. })
| ty::ReLateParam(ty::LateParamRegion {
bound_region: ty::BoundRegionKind::BrNamed(def_id, _),
..
})) = self
let def_id = self
.tcx
.map_opaque_lifetime_to_parent_lifetime(def_id.expect_local())
.kind()
else {
span_bug!(
self.tcx.def_span(def_id),
"variable should have been duplicated from a parent"
);
};
.opt_param_def_id(self.tcx, self.parent_def_id.to_def_id())
.expect("variable should have been duplicated from parent");
explicitly_captured.insert(def_id);
} else {
explicitly_captured.insert(def_id);