Skip to content

Commit 0baf440

Browse files
authored
Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorino
Make it clearer that we're just checking for an RPITIT Tiny nit to use `is_impl_trait_in_trait` more, to make it clearer that we're just checking whether a def-id is an RPITIT, rather than doing something meaningful with the `opt_rpitit_info`. r? `@spastorino`
2 parents 9a6eac3 + 14672eb commit 0baf440

File tree

9 files changed

+14
-10
lines changed

9 files changed

+14
-10
lines changed

compiler/rustc_hir_analysis/src/astconv/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
123123
let all_candidate_names: Vec<_> = all_candidates()
124124
.flat_map(|r| self.tcx().associated_items(r.def_id()).in_definition_order())
125125
.filter_map(|item| {
126-
if item.opt_rpitit_info.is_none() && item.kind == ty::AssocKind::Type {
126+
if !item.is_impl_trait_in_trait() && item.kind == ty::AssocKind::Type {
127127
Some(item.name)
128128
} else {
129129
None
@@ -164,7 +164,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
164164
self.tcx().associated_items(*trait_def_id).in_definition_order()
165165
})
166166
.filter_map(|item| {
167-
if item.opt_rpitit_info.is_none() && item.kind == ty::AssocKind::Type {
167+
if !item.is_impl_trait_in_trait() && item.kind == ty::AssocKind::Type {
168168
Some(item.name)
169169
} else {
170170
None

compiler/rustc_hir_analysis/src/astconv/object_safety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
173173
tcx.associated_items(pred.def_id())
174174
.in_definition_order()
175175
.filter(|item| item.kind == ty::AssocKind::Type)
176-
.filter(|item| item.opt_rpitit_info.is_none())
176+
.filter(|item| !item.is_impl_trait_in_trait())
177177
.map(|item| item.def_id),
178178
);
179179
}

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ fn compare_number_of_generics<'tcx>(
13221322
// has mismatched type or const generic arguments, then the method that it's
13231323
// inheriting the generics from will also have mismatched arguments, and
13241324
// we'll report an error for that instead. Delay a bug for safety, though.
1325-
if trait_.opt_rpitit_info.is_some() {
1325+
if trait_.is_impl_trait_in_trait() {
13261326
return Err(tcx.sess.delay_span_bug(
13271327
rustc_span::DUMMY_SP,
13281328
"errors comparing numbers of generics of trait/impl functions were not emitted",
@@ -2116,7 +2116,7 @@ pub(super) fn check_type_bounds<'tcx>(
21162116
// A synthetic impl Trait for RPITIT desugaring has no HIR, which we currently use to get the
21172117
// span for an impl's associated type. Instead, for these, use the def_span for the synthesized
21182118
// associated type.
2119-
let impl_ty_span = if impl_ty.opt_rpitit_info.is_some() {
2119+
let impl_ty_span = if impl_ty.is_impl_trait_in_trait() {
21202120
tcx.def_span(impl_ty_def_id)
21212121
} else {
21222122
match tcx.hir().get_by_def_id(impl_ty_def_id) {

compiler/rustc_hir_analysis/src/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn missing_items_err(
188188
full_impl_span: Span,
189189
) {
190190
let missing_items =
191-
missing_items.iter().filter(|trait_item| trait_item.opt_rpitit_info.is_none());
191+
missing_items.iter().filter(|trait_item| !trait_item.is_impl_trait_in_trait());
192192

193193
let missing_items_msg = missing_items
194194
.clone()

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
11361136
// the default projection predicates in default trait methods
11371137
// with RPITITs.
11381138
ty::AssocItemContainer::TraitContainer => {
1139-
assoc_item.defaultness(tcx).has_value() || assoc_item.opt_rpitit_info.is_some()
1139+
assoc_item.defaultness(tcx).has_value() || assoc_item.is_impl_trait_in_trait()
11401140
}
11411141
}
11421142
}

compiler/rustc_middle/src/ty/assoc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ impl AssocItem {
9696
}
9797
}
9898
}
99+
100+
pub fn is_impl_trait_in_trait(&self) -> bool {
101+
self.opt_rpitit_info.is_some()
102+
}
99103
}
100104

101105
#[derive(Copy, Clone, PartialEq, Debug, HashStable, Eq, Hash, Encodable, Decodable)]

compiler/rustc_passes/src/dead.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
276276
}
277277

278278
// Avoid accessing the HIR for the synthesized associated type generated for RPITITs.
279-
if self.tcx.opt_rpitit_info(id.to_def_id()).is_some() {
279+
if self.tcx.is_impl_trait_in_trait(id.to_def_id()) {
280280
self.live_symbols.insert(id);
281281
continue;
282282
}

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ fn suggest_restriction<'tcx>(
435435
) {
436436
if hir_generics.where_clause_span.from_expansion()
437437
|| hir_generics.where_clause_span.desugaring_kind().is_some()
438-
|| projection.is_some_and(|projection| tcx.opt_rpitit_info(projection.def_id).is_some())
438+
|| projection.is_some_and(|projection| tcx.is_impl_trait_in_trait(projection.def_id))
439439
{
440440
return;
441441
}

compiler/rustc_trait_selection/src/traits/object_safety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ fn object_safety_violation_for_assoc_item(
393393
ty::AssocKind::Type => {
394394
if !tcx.features().generic_associated_types_extended
395395
&& !tcx.generics_of(item.def_id).params.is_empty()
396-
&& item.opt_rpitit_info.is_none()
396+
&& !item.is_impl_trait_in_trait()
397397
{
398398
Some(ObjectSafetyViolation::GAT(item.name, item.ident(tcx).span))
399399
} else {

0 commit comments

Comments
 (0)