Skip to content

Commit df945fa

Browse files
committed
Move opt_rpitit_info field to hir::AssocKind::Fn.
From `hir::AssocItem`.
1 parent ce2aa97 commit df945fa

File tree

28 files changed

+103
-91
lines changed

28 files changed

+103
-91
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ fn best_definition_site_of_opaque<'tcx>(
449449
return Some(span);
450450
}
451451
}
452-
ty::AssocKind::Type => {}
452+
ty::AssocKind::Type { .. } => {}
453453
}
454454
}
455455

@@ -740,7 +740,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
740740

741741
for &assoc_item in assoc_items.in_definition_order() {
742742
match assoc_item.kind {
743-
ty::AssocKind::Type if assoc_item.defaultness(tcx).has_value() => {
743+
ty::AssocKind::Type { .. } if assoc_item.defaultness(tcx).has_value() => {
744744
let trait_args = GenericArgs::identity_for_item(tcx, def_id);
745745
let _: Result<_, rustc_errors::ErrorGuaranteed> = check_type_bounds(
746746
tcx,
@@ -953,7 +953,7 @@ fn check_impl_items_against_trait<'tcx>(
953953
);
954954
}
955955
ty::AssocKind::Const => {}
956-
ty::AssocKind::Type => {}
956+
ty::AssocKind::Type { .. } => {}
957957
}
958958
}
959959

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub(super) fn compare_impl_item(
4444

4545
match impl_item.kind {
4646
ty::AssocKind::Fn { .. } => compare_impl_method(tcx, impl_item, trait_item, impl_trait_ref),
47-
ty::AssocKind::Type => compare_impl_ty(tcx, impl_item, trait_item, impl_trait_ref),
47+
ty::AssocKind::Type { .. } => compare_impl_ty(tcx, impl_item, trait_item, impl_trait_ref),
4848
ty::AssocKind::Const => compare_impl_const(tcx, impl_item, trait_item, impl_trait_ref),
4949
}
5050
}
@@ -1703,7 +1703,7 @@ fn compare_generic_param_kinds<'tcx>(
17031703
trait_item: ty::AssocItem,
17041704
delay: bool,
17051705
) -> Result<(), ErrorGuaranteed> {
1706-
assert_eq!(impl_item.kind, trait_item.kind);
1706+
assert_eq!(impl_item.as_tag(), trait_item.as_tag());
17071707

17081708
let ty_const_params_of = |def_id| {
17091709
tcx.generics_of(def_id).own_params.iter().filter(|param| {
@@ -2235,16 +2235,19 @@ fn param_env_with_gat_bounds<'tcx>(
22352235
// of the RPITITs associated with the same body. This is because checking
22362236
// the item bounds of RPITITs often involves nested RPITITs having to prove
22372237
// bounds about themselves.
2238-
let impl_tys_to_install = match impl_ty.opt_rpitit_info {
2239-
None => vec![impl_ty],
2240-
Some(
2241-
ty::ImplTraitInTraitData::Impl { fn_def_id }
2242-
| ty::ImplTraitInTraitData::Trait { fn_def_id, .. },
2243-
) => tcx
2238+
let impl_tys_to_install = match impl_ty.kind {
2239+
ty::AssocKind::Type {
2240+
opt_rpitit_info:
2241+
Some(
2242+
ty::ImplTraitInTraitData::Impl { fn_def_id }
2243+
| ty::ImplTraitInTraitData::Trait { fn_def_id, .. },
2244+
),
2245+
} => tcx
22442246
.associated_types_for_impl_traits_in_associated_fn(fn_def_id)
22452247
.iter()
22462248
.map(|def_id| tcx.associated_item(*def_id))
22472249
.collect(),
2250+
_ => vec![impl_ty],
22482251
};
22492252

22502253
for impl_ty in impl_tys_to_install {

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ fn suggestion_signature<'tcx>(
499499
tcx.predicates_of(assoc.def_id).instantiate_own(tcx, args),
500500
assoc,
501501
),
502-
ty::AssocKind::Type => {
502+
ty::AssocKind::Type { .. } => {
503503
let (generics, where_clauses) = bounds_from_generic_predicates(
504504
tcx,
505505
tcx.predicates_of(assoc.def_id).instantiate_own(tcx, args),

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
408408
let gat_def_id = gat_item.def_id.expect_local();
409409
let gat_item = tcx.associated_item(gat_def_id);
410410
// If this item is not an assoc ty, or has no args, then it's not a GAT
411-
if gat_item.kind != ty::AssocKind::Type {
411+
if !gat_item.is_type() {
412412
continue;
413413
}
414414
let gat_generics = tcx.generics_of(gat_def_id);
@@ -453,7 +453,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
453453
)
454454
}
455455
// In our example, this corresponds to the `Iter` and `Item` associated types
456-
ty::AssocKind::Type => {
456+
ty::AssocKind::Type { .. } => {
457457
// If our associated item is a GAT with missing bounds, add them to
458458
// the param-env here. This allows this GAT to propagate missing bounds
459459
// to other GATs.
@@ -1101,7 +1101,7 @@ fn check_associated_item(
11011101
);
11021102
check_method_receiver(wfcx, hir_sig, item, self_ty)
11031103
}
1104-
ty::AssocKind::Type => {
1104+
ty::AssocKind::Type { .. } => {
11051105
if let ty::AssocItemContainer::Trait = item.container {
11061106
check_associated_type_bounds(wfcx, item, span)
11071107
}

compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(super) fn find_opaque_ty_constraints_for_impl_trait_in_assoc_type(
3636
locator.check(assoc_id.expect_local())
3737
}
3838
// Associated types don't have bodies, so they can't constrain hidden types
39-
ty::AssocKind::Type => {}
39+
ty::AssocKind::Type { .. } => {}
4040
}
4141
}
4242

compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use GenericArgsInfo::*;
44
use rustc_errors::codes::*;
55
use rustc_errors::{Applicability, Diag, Diagnostic, EmissionGuarantee, MultiSpan, pluralize};
66
use rustc_hir as hir;
7-
use rustc_middle::ty::{self as ty, AssocItems, AssocKind, TyCtxt};
7+
use rustc_middle::ty::{self as ty, AssocItems, TyCtxt};
88
use rustc_span::def_id::DefId;
99
use tracing::debug;
1010

@@ -486,7 +486,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
486486
let items: &AssocItems = self.tcx.associated_items(self.def_id);
487487
items
488488
.in_definition_order()
489-
.filter(|item| item.kind == AssocKind::Type)
489+
.filter(|item| item.is_type())
490490
.filter(|item| {
491491
!self
492492
.gen_args

compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
201201
tcx.associated_items(pred.trait_ref.def_id)
202202
.in_definition_order()
203203
// We only care about associated types.
204-
.filter(|item| item.kind == ty::AssocKind::Type)
204+
.filter(|item| item.is_type())
205205
// No RPITITs -- they're not dyn-compatible for now.
206206
.filter(|item| !item.is_impl_trait_in_trait())
207207
// If the associated type has a `where Self: Sized` bound,

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
17331733
.any(|i| {
17341734
i.kind.namespace() == Namespace::TypeNS
17351735
&& i.ident(tcx).normalize_to_macros_2_0() == assoc_ident
1736-
&& matches!(i.kind, ty::AssocKind::Type)
1736+
&& i.is_type()
17371737
})
17381738
// Consider only accessible traits
17391739
&& tcx.visibility(*trait_def_id)

compiler/rustc_hir_analysis/src/impl_wf_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained(
112112
.flat_map(|def_id| {
113113
let item = tcx.associated_item(def_id);
114114
match item.kind {
115-
ty::AssocKind::Type => {
115+
ty::AssocKind::Type { .. } => {
116116
if item.defaultness(tcx).has_value() {
117117
cgp::parameters_for(tcx, tcx.type_of(def_id).instantiate_identity(), true)
118118
} else {

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,15 +1671,7 @@ impl<'tcx> Pick<'tcx> {
16711671
/// Do not use for type checking.
16721672
pub(crate) fn differs_from(&self, other: &Self) -> bool {
16731673
let Self {
1674-
item:
1675-
AssocItem {
1676-
def_id,
1677-
name: _,
1678-
kind: _,
1679-
container: _,
1680-
trait_item_def_id: _,
1681-
opt_rpitit_info: _,
1682-
},
1674+
item: AssocItem { def_id, name: _, kind: _, container: _, trait_item_def_id: _ },
16831675
kind: _,
16841676
import_ids: _,
16851677
autoderefs: _,
@@ -2253,7 +2245,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
22532245
match self.mode {
22542246
Mode::MethodCall => item.is_method(),
22552247
Mode::Path => match item.kind {
2256-
ty::AssocKind::Type => false,
2248+
ty::AssocKind::Type { .. } => false,
22572249
ty::AssocKind::Fn { .. } | ty::AssocKind::Const => true,
22582250
},
22592251
}

0 commit comments

Comments
 (0)