1
Fork 0

Use a LocalDefId in ResolvedArg.

This commit is contained in:
Camille GILLOT 2024-08-22 01:17:01 +00:00
parent a32d4a0e82
commit c51f2d24d1
9 changed files with 58 additions and 55 deletions

View file

@ -2,7 +2,7 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{ItemLocalId, OwnerId};
use rustc_macros::{Decodable, Encodable, HashStable, TyDecodable, TyEncodable};
@ -11,9 +11,9 @@ use crate::ty;
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, HashStable)]
pub enum ResolvedArg {
StaticLifetime,
EarlyBound(/* decl */ DefId),
LateBound(ty::DebruijnIndex, /* late-bound index */ u32, /* decl */ DefId),
Free(DefId, /* lifetime decl */ DefId),
EarlyBound(/* decl */ LocalDefId),
LateBound(ty::DebruijnIndex, /* late-bound index */ u32, /* decl */ LocalDefId),
Free(LocalDefId, /* lifetime decl */ LocalDefId),
Error(ErrorGuaranteed),
}

View file

@ -3035,13 +3035,13 @@ impl<'tcx> TyCtxt<'tcx> {
match self.named_bound_var(lifetime.hir_id) {
Some(resolve_bound_vars::ResolvedArg::EarlyBound(ebv)) => {
let new_parent = self.parent(ebv);
let new_parent = self.local_parent(ebv);
// If we map to another opaque, then it should be a parent
// of the opaque we mapped from. Continue mapping.
if matches!(self.def_kind(new_parent), DefKind::OpaqueTy) {
debug_assert_eq!(self.parent(parent.to_def_id()), new_parent);
opaque_lifetime_param_def_id = ebv.expect_local();
debug_assert_eq!(self.local_parent(parent), new_parent);
opaque_lifetime_param_def_id = ebv;
continue;
}
@ -3050,20 +3050,20 @@ impl<'tcx> TyCtxt<'tcx> {
self,
ty::EarlyParamRegion {
index: generics
.param_def_id_to_index(self, ebv)
.param_def_id_to_index(self, ebv.to_def_id())
.expect("early-bound var should be present in fn generics"),
name: self.hir().name(self.local_def_id_to_hir_id(ebv.expect_local())),
name: self.item_name(ebv.to_def_id()),
},
);
}
Some(resolve_bound_vars::ResolvedArg::LateBound(_, _, lbv)) => {
let new_parent = self.parent(lbv);
let new_parent = self.local_parent(lbv);
return ty::Region::new_late_param(
self,
new_parent,
new_parent.to_def_id(),
ty::BoundRegionKind::BrNamed(
lbv,
self.hir().name(self.local_def_id_to_hir_id(lbv.expect_local())),
lbv.to_def_id(),
self.item_name(lbv.to_def_id()),
),
);
}