1
Fork 0

Use LocalDefId in ItemCtxt

This commit is contained in:
Michael Goulet 2023-03-13 19:06:41 +00:00
parent 2eb1c08e43
commit 979ef5981f
11 changed files with 110 additions and 112 deletions

View file

@ -75,7 +75,7 @@ pub trait AstConv<'tcx> {
fn get_type_parameter_bounds( fn get_type_parameter_bounds(
&self, &self,
span: Span, span: Span,
def_id: DefId, def_id: LocalDefId,
assoc_name: Ident, assoc_name: Ident,
) -> ty::GenericPredicates<'tcx>; ) -> ty::GenericPredicates<'tcx>;
@ -1773,9 +1773,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
ty_param_def_id, assoc_name, span, ty_param_def_id, assoc_name, span,
); );
let predicates = &self let predicates =
.get_type_parameter_bounds(span, ty_param_def_id.to_def_id(), assoc_name) &self.get_type_parameter_bounds(span, ty_param_def_id, assoc_name).predicates;
.predicates;
debug!("find_bound_for_assoc_item: predicates={:#?}", predicates); debug!("find_bound_for_assoc_item: predicates={:#?}", predicates);

View file

@ -1794,7 +1794,7 @@ fn check_variances_for_type_defn<'tcx>(
// Lazily calculated because it is only needed in case of an error. // Lazily calculated because it is only needed in case of an error.
let explicitly_bounded_params = LazyCell::new(|| { let explicitly_bounded_params = LazyCell::new(|| {
let icx = crate::collect::ItemCtxt::new(tcx, item.owner_id.to_def_id()); let icx = crate::collect::ItemCtxt::new(tcx, item.owner_id.def_id);
hir_generics hir_generics
.predicates .predicates
.iter() .iter()

View file

@ -113,7 +113,7 @@ pub fn provide(providers: &mut Providers) {
/// the AST (`hir::Generics`), recursively. /// the AST (`hir::Generics`), recursively.
pub struct ItemCtxt<'tcx> { pub struct ItemCtxt<'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
item_def_id: DefId, item_def_id: LocalDefId,
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -347,7 +347,7 @@ fn bad_placeholder<'tcx>(
} }
impl<'tcx> ItemCtxt<'tcx> { impl<'tcx> ItemCtxt<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, item_def_id: DefId) -> ItemCtxt<'tcx> { pub fn new(tcx: TyCtxt<'tcx>, item_def_id: LocalDefId) -> ItemCtxt<'tcx> {
ItemCtxt { tcx, item_def_id } ItemCtxt { tcx, item_def_id }
} }
@ -356,7 +356,7 @@ impl<'tcx> ItemCtxt<'tcx> {
} }
pub fn hir_id(&self) -> hir::HirId { pub fn hir_id(&self) -> hir::HirId {
self.tcx.hir().local_def_id_to_hir_id(self.item_def_id.expect_local()) self.tcx.hir().local_def_id_to_hir_id(self.item_def_id)
} }
pub fn node(&self) -> hir::Node<'tcx> { pub fn node(&self) -> hir::Node<'tcx> {
@ -370,20 +370,16 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
} }
fn item_def_id(&self) -> DefId { fn item_def_id(&self) -> DefId {
self.item_def_id self.item_def_id.to_def_id()
} }
fn get_type_parameter_bounds( fn get_type_parameter_bounds(
&self, &self,
span: Span, span: Span,
def_id: DefId, def_id: LocalDefId,
assoc_name: Ident, assoc_name: Ident,
) -> ty::GenericPredicates<'tcx> { ) -> ty::GenericPredicates<'tcx> {
self.tcx.at(span).type_param_predicates(( self.tcx.at(span).type_param_predicates((self.item_def_id, def_id, assoc_name))
self.item_def_id,
def_id.expect_local(),
assoc_name,
))
} }
fn re_infer(&self, _: Option<&ty::GenericParamDef>, _: Span) -> Option<ty::Region<'tcx>> { fn re_infer(&self, _: Option<&ty::GenericParamDef>, _: Span) -> Option<ty::Region<'tcx>> {
@ -1095,7 +1091,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<ty::PolyFnSig<
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let icx = ItemCtxt::new(tcx, def_id.to_def_id()); let icx = ItemCtxt::new(tcx, def_id);
let output = match tcx.hir().get(hir_id) { let output = match tcx.hir().get(hir_id) {
TraitItem(hir::TraitItem { TraitItem(hir::TraitItem {
@ -1136,7 +1132,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<ty::PolyFnSig<
ForeignItem(&hir::ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => { ForeignItem(&hir::ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => {
let abi = tcx.hir().get_foreign_abi(hir_id); let abi = tcx.hir().get_foreign_abi(hir_id);
compute_sig_of_foreign_fn_decl(tcx, def_id.to_def_id(), fn_decl, abi) compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi)
} }
Ctor(data) | Variant(hir::Variant { data, .. }) if data.ctor().is_some() => { Ctor(data) | Variant(hir::Variant { data, .. }) if data.ctor().is_some() => {
@ -1339,7 +1335,7 @@ fn impl_trait_ref(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
def_id: LocalDefId, def_id: LocalDefId,
) -> Option<ty::EarlyBinder<ty::TraitRef<'_>>> { ) -> Option<ty::EarlyBinder<ty::TraitRef<'_>>> {
let icx = ItemCtxt::new(tcx, def_id.to_def_id()); let icx = ItemCtxt::new(tcx, def_id);
let impl_ = tcx.hir().expect_item(def_id).expect_impl(); let impl_ = tcx.hir().expect_item(def_id).expect_impl();
impl_ impl_
.of_trait .of_trait
@ -1465,16 +1461,16 @@ fn predicates_defined_on(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicate
fn compute_sig_of_foreign_fn_decl<'tcx>( fn compute_sig_of_foreign_fn_decl<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def_id: DefId, def_id: LocalDefId,
decl: &'tcx hir::FnDecl<'tcx>, decl: &'tcx hir::FnDecl<'tcx>,
abi: abi::Abi, abi: abi::Abi,
) -> ty::PolyFnSig<'tcx> { ) -> ty::PolyFnSig<'tcx> {
let unsafety = if abi == abi::Abi::RustIntrinsic { let unsafety = if abi == abi::Abi::RustIntrinsic {
intrinsic_operation_unsafety(tcx, def_id) intrinsic_operation_unsafety(tcx, def_id.to_def_id())
} else { } else {
hir::Unsafety::Unsafe hir::Unsafety::Unsafe
}; };
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let fty = let fty =
ItemCtxt::new(tcx, def_id).astconv().ty_of_fn(hir_id, unsafety, abi, decl, None, None); ItemCtxt::new(tcx, def_id).astconv().ty_of_fn(hir_id, unsafety, abi, decl, None, None);

View file

@ -16,13 +16,13 @@ use rustc_span::Span;
/// `hr-associated-type-bound-1.rs`. /// `hr-associated-type-bound-1.rs`.
fn associated_type_bounds<'tcx>( fn associated_type_bounds<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
assoc_item_def_id: DefId, assoc_item_def_id: LocalDefId,
ast_bounds: &'tcx [hir::GenericBound<'tcx>], ast_bounds: &'tcx [hir::GenericBound<'tcx>],
span: Span, span: Span,
) -> &'tcx [(ty::Predicate<'tcx>, Span)] { ) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
let item_ty = tcx.mk_projection( let item_ty = tcx.mk_projection(
assoc_item_def_id, assoc_item_def_id.to_def_id(),
InternalSubsts::identity_for_item(tcx, assoc_item_def_id), InternalSubsts::identity_for_item(tcx, assoc_item_def_id.to_def_id()),
); );
let icx = ItemCtxt::new(tcx, assoc_item_def_id); let icx = ItemCtxt::new(tcx, assoc_item_def_id);
@ -30,8 +30,8 @@ fn associated_type_bounds<'tcx>(
// Associated types are implicitly sized unless a `?Sized` bound is found // Associated types are implicitly sized unless a `?Sized` bound is found
icx.astconv().add_implicitly_sized(&mut bounds, item_ty, ast_bounds, None, span); icx.astconv().add_implicitly_sized(&mut bounds, item_ty, ast_bounds, None, span);
let trait_def_id = tcx.parent(assoc_item_def_id); let trait_def_id = tcx.local_parent(assoc_item_def_id);
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id.expect_local()); let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| { let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
match pred.kind().skip_binder() { match pred.kind().skip_binder() {
@ -45,7 +45,11 @@ fn associated_type_bounds<'tcx>(
}); });
let all_bounds = tcx.arena.alloc_from_iter(bounds.predicates().chain(bounds_from_parent)); let all_bounds = tcx.arena.alloc_from_iter(bounds.predicates().chain(bounds_from_parent));
debug!("associated_type_bounds({}) = {:?}", tcx.def_path_str(assoc_item_def_id), all_bounds); debug!(
"associated_type_bounds({}) = {:?}",
tcx.def_path_str(assoc_item_def_id.to_def_id()),
all_bounds
);
all_bounds all_bounds
} }
@ -56,7 +60,7 @@ fn associated_type_bounds<'tcx>(
#[instrument(level = "trace", skip(tcx), ret)] #[instrument(level = "trace", skip(tcx), ret)]
fn opaque_type_bounds<'tcx>( fn opaque_type_bounds<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
opaque_def_id: DefId, opaque_def_id: LocalDefId,
ast_bounds: &'tcx [hir::GenericBound<'tcx>], ast_bounds: &'tcx [hir::GenericBound<'tcx>],
item_ty: Ty<'tcx>, item_ty: Ty<'tcx>,
span: Span, span: Span,
@ -84,7 +88,7 @@ pub(super) fn explicit_item_bounds(
let opaque_ty = item.expect_opaque_ty(); let opaque_ty = item.expect_opaque_ty();
return opaque_type_bounds( return opaque_type_bounds(
tcx, tcx,
opaque_def_id, opaque_def_id.expect_local(),
opaque_ty.bounds, opaque_ty.bounds,
tcx.mk_projection( tcx.mk_projection(
def_id.to_def_id(), def_id.to_def_id(),
@ -104,7 +108,7 @@ pub(super) fn explicit_item_bounds(
kind: hir::TraitItemKind::Type(bounds, _), kind: hir::TraitItemKind::Type(bounds, _),
span, span,
.. ..
}) => associated_type_bounds(tcx, def_id.to_def_id(), bounds, *span), }) => associated_type_bounds(tcx, def_id, bounds, *span),
hir::Node::Item(hir::Item { hir::Node::Item(hir::Item {
kind: hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, in_trait, .. }), kind: hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, in_trait, .. }),
span, span,
@ -116,7 +120,7 @@ pub(super) fn explicit_item_bounds(
} else { } else {
tcx.mk_opaque(def_id.to_def_id(), substs) tcx.mk_opaque(def_id.to_def_id(), substs)
}; };
opaque_type_bounds(tcx, def_id.to_def_id(), bounds, item_ty, *span) opaque_type_bounds(tcx, def_id, bounds, item_ty, *span)
} }
_ => bug!("item_bounds called on {:?}", def_id), _ => bug!("item_bounds called on {:?}", def_id),
} }

View file

@ -72,7 +72,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
let mut is_default_impl_trait = None; let mut is_default_impl_trait = None;
// FIXME: Should ItemCtxt take a LocalDefId? // FIXME: Should ItemCtxt take a LocalDefId?
let icx = ItemCtxt::new(tcx, def_id.to_def_id()); let icx = ItemCtxt::new(tcx, def_id);
const NO_GENERICS: &hir::Generics<'_> = hir::Generics::empty(); const NO_GENERICS: &hir::Generics<'_> = hir::Generics::empty();
@ -551,9 +551,15 @@ pub(super) fn super_predicates_that_define_assoc_type(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
(trait_def_id, assoc_name): (DefId, Option<Ident>), (trait_def_id, assoc_name): (DefId, Option<Ident>),
) -> ty::GenericPredicates<'_> { ) -> ty::GenericPredicates<'_> {
if trait_def_id.is_local() { let Some(trait_def_id) = trait_def_id.as_local() else {
// if `assoc_name` is None, then the query should've been redirected to an
// external provider
assert!(assoc_name.is_some());
return tcx.super_predicates_of(trait_def_id);
};
debug!("local trait"); debug!("local trait");
let trait_hir_id = tcx.hir().local_def_id_to_hir_id(trait_def_id.expect_local()); let trait_hir_id = tcx.hir().local_def_id_to_hir_id(trait_def_id);
let Node::Item(item) = tcx.hir().get(trait_hir_id) else { let Node::Item(item) = tcx.hir().get(trait_hir_id) else {
bug!("trait_node_id {} is not an item", trait_hir_id); bug!("trait_node_id {} is not an item", trait_hir_id);
@ -582,7 +588,7 @@ pub(super) fn super_predicates_that_define_assoc_type(
// In the case of trait aliases, however, we include all bounds in the where-clause, // In the case of trait aliases, however, we include all bounds in the where-clause,
// so e.g., `trait Foo = where u32: PartialEq<Self>` would include `u32: PartialEq<Self>` // so e.g., `trait Foo = where u32: PartialEq<Self>` would include `u32: PartialEq<Self>`
// as one of its "superpredicates". // as one of its "superpredicates".
let is_trait_alias = tcx.is_trait_alias(trait_def_id); let is_trait_alias = tcx.is_trait_alias(trait_def_id.to_def_id());
let superbounds2 = icx.type_parameter_bounds_in_generics( let superbounds2 = icx.type_parameter_bounds_in_generics(
generics, generics,
item.owner_id.def_id, item.owner_id.def_id,
@ -602,21 +608,13 @@ pub(super) fn super_predicates_that_define_assoc_type(
// which will, in turn, reach indirect supertraits. // which will, in turn, reach indirect supertraits.
for &(pred, span) in superbounds { for &(pred, span) in superbounds {
debug!("superbound: {:?}", pred); debug!("superbound: {:?}", pred);
if let ty::PredicateKind::Clause(ty::Clause::Trait(bound)) = if let ty::PredicateKind::Clause(ty::Clause::Trait(bound)) = pred.kind().skip_binder() {
pred.kind().skip_binder()
{
tcx.at(span).super_predicates_of(bound.def_id()); tcx.at(span).super_predicates_of(bound.def_id());
} }
} }
} }
ty::GenericPredicates { parent: None, predicates: superbounds } ty::GenericPredicates { parent: None, predicates: superbounds }
} else {
// if `assoc_name` is None, then the query should've been redirected to an
// external provider
assert!(assoc_name.is_some());
tcx.super_predicates_of(trait_def_id)
}
} }
/// Returns the predicates defined on `item_def_id` of the form /// Returns the predicates defined on `item_def_id` of the form
@ -624,7 +622,7 @@ pub(super) fn super_predicates_that_define_assoc_type(
#[instrument(level = "trace", skip(tcx))] #[instrument(level = "trace", skip(tcx))]
pub(super) fn type_param_predicates( pub(super) fn type_param_predicates(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
(item_def_id, def_id, assoc_name): (DefId, LocalDefId, Ident), (item_def_id, def_id, assoc_name): (LocalDefId, LocalDefId, Ident),
) -> ty::GenericPredicates<'_> { ) -> ty::GenericPredicates<'_> {
use rustc_hir::*; use rustc_hir::*;
@ -639,21 +637,21 @@ pub(super) fn type_param_predicates(
let ty = tcx.mk_ty_param(index, tcx.hir().ty_param_name(def_id)); let ty = tcx.mk_ty_param(index, tcx.hir().ty_param_name(def_id));
// Don't look for bounds where the type parameter isn't in scope. // Don't look for bounds where the type parameter isn't in scope.
let parent = if item_def_id == param_owner.to_def_id() { let parent = if item_def_id == param_owner {
None None
} else { } else {
tcx.generics_of(item_def_id).parent tcx.generics_of(item_def_id).parent.map(|def_id| def_id.expect_local())
}; };
let mut result = parent let mut result = parent
.map(|parent| { .map(|parent| {
let icx = ItemCtxt::new(tcx, parent); let icx = ItemCtxt::new(tcx, parent);
icx.get_type_parameter_bounds(DUMMY_SP, def_id.to_def_id(), assoc_name) icx.get_type_parameter_bounds(DUMMY_SP, def_id, assoc_name)
}) })
.unwrap_or_default(); .unwrap_or_default();
let mut extend = None; let mut extend = None;
let item_hir_id = tcx.hir().local_def_id_to_hir_id(item_def_id.expect_local()); let item_hir_id = tcx.hir().local_def_id_to_hir_id(item_def_id);
let ast_generics = match tcx.hir().get(item_hir_id) { let ast_generics = match tcx.hir().get(item_hir_id) {
Node::TraitItem(item) => &item.generics, Node::TraitItem(item) => &item.generics,
@ -675,7 +673,8 @@ pub(super) fn type_param_predicates(
ItemKind::Trait(_, _, generics, ..) => { ItemKind::Trait(_, _, generics, ..) => {
// Implied `Self: Trait` and supertrait bounds. // Implied `Self: Trait` and supertrait bounds.
if param_id == item_hir_id { if param_id == item_hir_id {
let identity_trait_ref = ty::TraitRef::identity(tcx, item_def_id); let identity_trait_ref =
ty::TraitRef::identity(tcx, item_def_id.to_def_id());
extend = extend =
Some((identity_trait_ref.without_const().to_predicate(tcx), item.span)); Some((identity_trait_ref.without_const().to_predicate(tcx), item.span));
} }

View file

@ -63,7 +63,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
.find(|(_, node)| matches!(node, OwnerNode::Item(_))) .find(|(_, node)| matches!(node, OwnerNode::Item(_)))
.unwrap() .unwrap()
.0 .0
.to_def_id(); .def_id;
let item_ctxt = &ItemCtxt::new(tcx, item_def_id) as &dyn crate::astconv::AstConv<'_>; let item_ctxt = &ItemCtxt::new(tcx, item_def_id) as &dyn crate::astconv::AstConv<'_>;
let ty = item_ctxt.ast_ty_to_ty(hir_ty); let ty = item_ctxt.ast_ty_to_ty(hir_ty);
@ -269,7 +269,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let icx = ItemCtxt::new(tcx, def_id.to_def_id()); let icx = ItemCtxt::new(tcx, def_id);
let output = match tcx.hir().get(hir_id) { let output = match tcx.hir().get(hir_id) {
Node::TraitItem(item) => match item.kind { Node::TraitItem(item) => match item.kind {

View file

@ -31,7 +31,7 @@ fn diagnostic_hir_wf_check<'tcx>(
tcx.sess tcx.sess
.delay_span_bug(tcx.def_span(def_id), "Performed HIR wfcheck without an existing error!"); .delay_span_bug(tcx.def_span(def_id), "Performed HIR wfcheck without an existing error!");
let icx = ItemCtxt::new(tcx, def_id.to_def_id()); let icx = ItemCtxt::new(tcx, def_id);
// To perform HIR-based WF checking, we iterate over all HIR types // To perform HIR-based WF checking, we iterate over all HIR types
// that occur 'inside' the item we're checking. For example, // that occur 'inside' the item we're checking. For example,

View file

@ -513,7 +513,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
// def-ID that will be used to determine the traits/predicates in // def-ID that will be used to determine the traits/predicates in
// scope. This is derived from the enclosing item-like thing. // scope. This is derived from the enclosing item-like thing.
let env_def_id = tcx.hir().get_parent_item(hir_ty.hir_id); let env_def_id = tcx.hir().get_parent_item(hir_ty.hir_id);
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.to_def_id()); let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.def_id);
item_cx.astconv().ast_ty_to_ty(hir_ty) item_cx.astconv().ast_ty_to_ty(hir_ty)
} }
@ -526,7 +526,7 @@ pub fn hir_trait_to_predicates<'tcx>(
// def-ID that will be used to determine the traits/predicates in // def-ID that will be used to determine the traits/predicates in
// scope. This is derived from the enclosing item-like thing. // scope. This is derived from the enclosing item-like thing.
let env_def_id = tcx.hir().get_parent_item(hir_trait.hir_ref_id); let env_def_id = tcx.hir().get_parent_item(hir_trait.hir_ref_id);
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.to_def_id()); let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.def_id);
let mut bounds = Bounds::default(); let mut bounds = Bounds::default();
let _ = &item_cx.astconv().instantiate_poly_trait_ref( let _ = &item_cx.astconv().instantiate_poly_trait_ref(
hir_trait, hir_trait,

View file

@ -211,13 +211,13 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
fn get_type_parameter_bounds( fn get_type_parameter_bounds(
&self, &self,
_: Span, _: Span,
def_id: DefId, def_id: LocalDefId,
_: Ident, _: Ident,
) -> ty::GenericPredicates<'tcx> { ) -> ty::GenericPredicates<'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
let item_def_id = tcx.hir().ty_param_owner(def_id.expect_local()); let item_def_id = tcx.hir().ty_param_owner(def_id);
let generics = tcx.generics_of(item_def_id); let generics = tcx.generics_of(item_def_id);
let index = generics.param_def_id_to_index[&def_id]; let index = generics.param_def_id_to_index[&def_id.to_def_id()];
ty::GenericPredicates { ty::GenericPredicates {
parent: None, parent: None,
predicates: tcx.arena.alloc_from_iter( predicates: tcx.arena.alloc_from_iter(

View file

@ -316,12 +316,12 @@ impl Key for (DefId, Option<Ident>) {
} }
} }
impl Key for (DefId, LocalDefId, Ident) { impl Key for (LocalDefId, LocalDefId, Ident) {
type CacheSelector = DefaultCacheSelector<Self>; type CacheSelector = DefaultCacheSelector<Self>;
type LocalKey = (LocalDefId, LocalDefId, Ident); type LocalKey = Self;
fn as_local_key(&self) -> Option<Self::LocalKey> { fn as_local_key(&self) -> Option<Self::LocalKey> {
Some((self.0.as_local()?, self.1, self.2)) Some(*self)
} }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span { fn default_span(&self, tcx: TyCtxt<'_>) -> Span {

View file

@ -639,7 +639,7 @@ rustc_queries! {
/// To avoid cycles within the predicates of a single item we compute /// To avoid cycles within the predicates of a single item we compute
/// per-type-parameter predicates for resolving `T::AssocTy`. /// per-type-parameter predicates for resolving `T::AssocTy`.
query type_param_predicates(key: (DefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> { query type_param_predicates(key: (LocalDefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir().ty_param_name(key.1) } desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir().ty_param_name(key.1) }
} }