Make it clearer that we're just checking for an RPITIT
This commit is contained in:
parent
bacf5bcbc7
commit
14672eba8b
9 changed files with 14 additions and 10 deletions
|
@ -123,7 +123,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let all_candidate_names: Vec<_> = all_candidates()
|
let all_candidate_names: Vec<_> = all_candidates()
|
||||||
.flat_map(|r| self.tcx().associated_items(r.def_id()).in_definition_order())
|
.flat_map(|r| self.tcx().associated_items(r.def_id()).in_definition_order())
|
||||||
.filter_map(|item| {
|
.filter_map(|item| {
|
||||||
if item.opt_rpitit_info.is_none() && item.kind == ty::AssocKind::Type {
|
if !item.is_impl_trait_in_trait() && item.kind == ty::AssocKind::Type {
|
||||||
Some(item.name)
|
Some(item.name)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -164,7 +164,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
self.tcx().associated_items(*trait_def_id).in_definition_order()
|
self.tcx().associated_items(*trait_def_id).in_definition_order()
|
||||||
})
|
})
|
||||||
.filter_map(|item| {
|
.filter_map(|item| {
|
||||||
if item.opt_rpitit_info.is_none() && item.kind == ty::AssocKind::Type {
|
if !item.is_impl_trait_in_trait() && item.kind == ty::AssocKind::Type {
|
||||||
Some(item.name)
|
Some(item.name)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -173,7 +173,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
tcx.associated_items(pred.def_id())
|
tcx.associated_items(pred.def_id())
|
||||||
.in_definition_order()
|
.in_definition_order()
|
||||||
.filter(|item| item.kind == ty::AssocKind::Type)
|
.filter(|item| item.kind == ty::AssocKind::Type)
|
||||||
.filter(|item| item.opt_rpitit_info.is_none())
|
.filter(|item| !item.is_impl_trait_in_trait())
|
||||||
.map(|item| item.def_id),
|
.map(|item| item.def_id),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1319,7 +1319,7 @@ fn compare_number_of_generics<'tcx>(
|
||||||
// has mismatched type or const generic arguments, then the method that it's
|
// has mismatched type or const generic arguments, then the method that it's
|
||||||
// inheriting the generics from will also have mismatched arguments, and
|
// inheriting the generics from will also have mismatched arguments, and
|
||||||
// we'll report an error for that instead. Delay a bug for safety, though.
|
// we'll report an error for that instead. Delay a bug for safety, though.
|
||||||
if trait_.opt_rpitit_info.is_some() {
|
if trait_.is_impl_trait_in_trait() {
|
||||||
return Err(tcx.sess.delay_span_bug(
|
return Err(tcx.sess.delay_span_bug(
|
||||||
rustc_span::DUMMY_SP,
|
rustc_span::DUMMY_SP,
|
||||||
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
||||||
|
@ -2111,7 +2111,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
||||||
// A synthetic impl Trait for RPITIT desugaring has no HIR, which we currently use to get the
|
// A synthetic impl Trait for RPITIT desugaring has no HIR, which we currently use to get the
|
||||||
// span for an impl's associated type. Instead, for these, use the def_span for the synthesized
|
// span for an impl's associated type. Instead, for these, use the def_span for the synthesized
|
||||||
// associated type.
|
// associated type.
|
||||||
let impl_ty_span = if impl_ty.opt_rpitit_info.is_some() {
|
let impl_ty_span = if impl_ty.is_impl_trait_in_trait() {
|
||||||
tcx.def_span(impl_ty_def_id)
|
tcx.def_span(impl_ty_def_id)
|
||||||
} else {
|
} else {
|
||||||
match tcx.hir().get_by_def_id(impl_ty_def_id) {
|
match tcx.hir().get_by_def_id(impl_ty_def_id) {
|
||||||
|
|
|
@ -188,7 +188,7 @@ fn missing_items_err(
|
||||||
full_impl_span: Span,
|
full_impl_span: Span,
|
||||||
) {
|
) {
|
||||||
let missing_items =
|
let missing_items =
|
||||||
missing_items.iter().filter(|trait_item| trait_item.opt_rpitit_info.is_none());
|
missing_items.iter().filter(|trait_item| !trait_item.is_impl_trait_in_trait());
|
||||||
|
|
||||||
let missing_items_msg = missing_items
|
let missing_items_msg = missing_items
|
||||||
.clone()
|
.clone()
|
||||||
|
|
|
@ -1136,7 +1136,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
|
||||||
// the default projection predicates in default trait methods
|
// the default projection predicates in default trait methods
|
||||||
// with RPITITs.
|
// with RPITITs.
|
||||||
ty::AssocItemContainer::TraitContainer => {
|
ty::AssocItemContainer::TraitContainer => {
|
||||||
assoc_item.defaultness(tcx).has_value() || assoc_item.opt_rpitit_info.is_some()
|
assoc_item.defaultness(tcx).has_value() || assoc_item.is_impl_trait_in_trait()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,10 @@ impl AssocItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_impl_trait_in_trait(&self) -> bool {
|
||||||
|
self.opt_rpitit_info.is_some()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Debug, HashStable, Eq, Hash, Encodable, Decodable)]
|
#[derive(Copy, Clone, PartialEq, Debug, HashStable, Eq, Hash, Encodable, Decodable)]
|
||||||
|
|
|
@ -276,7 +276,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid accessing the HIR for the synthesized associated type generated for RPITITs.
|
// Avoid accessing the HIR for the synthesized associated type generated for RPITITs.
|
||||||
if self.tcx.opt_rpitit_info(id.to_def_id()).is_some() {
|
if self.tcx.is_impl_trait_in_trait(id.to_def_id()) {
|
||||||
self.live_symbols.insert(id);
|
self.live_symbols.insert(id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -435,7 +435,7 @@ fn suggest_restriction<'tcx>(
|
||||||
) {
|
) {
|
||||||
if hir_generics.where_clause_span.from_expansion()
|
if hir_generics.where_clause_span.from_expansion()
|
||||||
|| hir_generics.where_clause_span.desugaring_kind().is_some()
|
|| hir_generics.where_clause_span.desugaring_kind().is_some()
|
||||||
|| projection.is_some_and(|projection| tcx.opt_rpitit_info(projection.def_id).is_some())
|
|| projection.is_some_and(|projection| tcx.is_impl_trait_in_trait(projection.def_id))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,7 +393,7 @@ fn object_safety_violation_for_assoc_item(
|
||||||
ty::AssocKind::Type => {
|
ty::AssocKind::Type => {
|
||||||
if !tcx.features().generic_associated_types_extended
|
if !tcx.features().generic_associated_types_extended
|
||||||
&& !tcx.generics_of(item.def_id).params.is_empty()
|
&& !tcx.generics_of(item.def_id).params.is_empty()
|
||||||
&& item.opt_rpitit_info.is_none()
|
&& !item.is_impl_trait_in_trait()
|
||||||
{
|
{
|
||||||
Some(ObjectSafetyViolation::GAT(item.name, item.ident(tcx).span))
|
Some(ObjectSafetyViolation::GAT(item.name, item.ident(tcx).span))
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue