summaryrefslogtreecommitdiff
path: root/compiler/rustc_ty_utils
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2023-03-23 00:00:34 +0530
committerGitHub <noreply@github.com>2023-03-23 00:00:34 +0530
commitb9151b2d7014149be2acdea29ae9fa272dd11583 (patch)
treeb86785363525b10cad32a5251a7efa1edcd6e8ec /compiler/rustc_ty_utils
parent8ce52b7b65927c83189175e2488a3047201a5e8c (diff)
parentc3e6f689312872ac9859b18230c6323ab27fbd7f (diff)
downloadrust-b9151b2d7014149be2acdea29ae9fa272dd11583.tar.gz
Rollup merge of #109405 - compiler-errors:rpitit-as-opaques, r=spastorino
RPITITs are `DefKind::Opaque` with new lowering strategy r? `@spastorino` Kinda cherry-picked #109400
Diffstat (limited to 'compiler/rustc_ty_utils')
-rw-r--r--compiler/rustc_ty_utils/src/assoc.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs
index 6d9ad96fa74..562f5bffba3 100644
--- a/compiler/rustc_ty_utils/src/assoc.rs
+++ b/compiler/rustc_ty_utils/src/assoc.rs
@@ -254,13 +254,16 @@ fn associated_type_for_impl_trait_in_trait(
tcx: TyCtxt<'_>,
opaque_ty_def_id: LocalDefId,
) -> LocalDefId {
- let fn_def_id = tcx.impl_trait_in_trait_parent_fn(opaque_ty_def_id.to_def_id());
- let trait_def_id = tcx.parent(fn_def_id);
+ let (hir::OpaqueTyOrigin::FnReturn(fn_def_id) | hir::OpaqueTyOrigin::AsyncFn(fn_def_id)) =
+ tcx.hir().expect_item(opaque_ty_def_id).expect_opaque_ty().origin
+ else {
+ bug!("expected opaque for {opaque_ty_def_id:?}");
+ };
+ let trait_def_id = tcx.local_parent(fn_def_id);
assert_eq!(tcx.def_kind(trait_def_id), DefKind::Trait);
let span = tcx.def_span(opaque_ty_def_id);
- let trait_assoc_ty =
- tcx.at(span).create_def(trait_def_id.expect_local(), DefPathData::ImplTraitAssocTy);
+ let trait_assoc_ty = tcx.at(span).create_def(trait_def_id, DefPathData::ImplTraitAssocTy);
let local_def_id = trait_assoc_ty.def_id();
let def_id = local_def_id.to_def_id();
@@ -282,7 +285,7 @@ fn associated_type_for_impl_trait_in_trait(
container: ty::TraitContainer,
fn_has_self_parameter: false,
opt_rpitit_info: Some(ImplTraitInTraitData::Trait {
- fn_def_id,
+ fn_def_id: fn_def_id.to_def_id(),
opaque_def_id: opaque_ty_def_id.to_def_id(),
}),
});
@@ -324,7 +327,7 @@ fn associated_type_for_impl_trait_in_trait(
params.iter().map(|param| (param.def_id, param.index)).collect();
ty::Generics {
- parent: Some(trait_def_id),
+ parent: Some(trait_def_id.to_def_id()),
parent_count,
params,
param_def_id_to_index,
@@ -335,7 +338,7 @@ fn associated_type_for_impl_trait_in_trait(
// There are no predicates for the synthesized associated type.
trait_assoc_ty.explicit_predicates_of(ty::GenericPredicates {
- parent: Some(trait_def_id),
+ parent: Some(trait_def_id.to_def_id()),
predicates: &[],
});
@@ -356,7 +359,6 @@ fn associated_type_for_impl_trait_in_impl(
impl_fn_def_id: LocalDefId,
) -> LocalDefId {
let impl_local_def_id = tcx.local_parent(impl_fn_def_id);
- let impl_def_id = impl_local_def_id.to_def_id();
// FIXME fix the span, we probably want the def_id of the return type of the function
let span = tcx.def_span(impl_fn_def_id);
@@ -402,7 +404,7 @@ fn associated_type_for_impl_trait_in_impl(
let trait_assoc_parent_count = trait_assoc_generics.parent_count;
let mut params = trait_assoc_generics.params.clone();
- let parent_generics = tcx.generics_of(impl_def_id);
+ let parent_generics = tcx.generics_of(impl_local_def_id.to_def_id());
let parent_count = parent_generics.parent_count + parent_generics.params.len();
for param in &mut params {
@@ -413,7 +415,7 @@ fn associated_type_for_impl_trait_in_impl(
params.iter().map(|param| (param.def_id, param.index)).collect();
ty::Generics {
- parent: Some(impl_def_id),
+ parent: Some(impl_local_def_id.to_def_id()),
parent_count,
params,
param_def_id_to_index,
@@ -424,7 +426,7 @@ fn associated_type_for_impl_trait_in_impl(
// There are no predicates for the synthesized associated type.
impl_assoc_ty.explicit_predicates_of(ty::GenericPredicates {
- parent: Some(impl_def_id),
+ parent: Some(impl_local_def_id.to_def_id()),
predicates: &[],
});