Remove dead code stemming from the old effects desugaring
This commit is contained in:
parent
759e07f063
commit
a6bbdf0fd4
@ -821,8 +821,7 @@ pub(super) fn check_specialization_validity<'tcx>(
|
|||||||
let result = opt_result.unwrap_or(Ok(()));
|
let result = opt_result.unwrap_or(Ok(()));
|
||||||
|
|
||||||
if let Err(parent_impl) = result {
|
if let Err(parent_impl) = result {
|
||||||
// FIXME(effects) the associated type from effects could be specialized
|
if !tcx.is_impl_trait_in_trait(impl_item) {
|
||||||
if !tcx.is_impl_trait_in_trait(impl_item) && !tcx.is_effects_desugared_assoc_ty(impl_item) {
|
|
||||||
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
||||||
} else {
|
} else {
|
||||||
tcx.dcx().delayed_bug(format!("parent item: {parent_impl:?} not marked as default"));
|
tcx.dcx().delayed_bug(format!("parent item: {parent_impl:?} not marked as default"));
|
||||||
|
@ -2042,7 +2042,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||||||
// A synthetic impl Trait for RPITIT desugaring or assoc type for effects desugaring has no HIR,
|
// A synthetic impl Trait for RPITIT desugaring or assoc type for effects desugaring has no HIR,
|
||||||
// which we currently use to get the span for an impl's associated type. Instead, for these,
|
// which we currently use to get the span for an impl's associated type. Instead, for these,
|
||||||
// use the def_span for the synthesized associated type.
|
// use the def_span for the synthesized associated type.
|
||||||
let impl_ty_span = if impl_ty.is_impl_trait_in_trait() || impl_ty.is_effects_desugaring {
|
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_node_by_def_id(impl_ty_def_id) {
|
match tcx.hir_node_by_def_id(impl_ty_def_id) {
|
||||||
|
@ -379,9 +379,6 @@ pub(super) fn explicit_item_bounds_with_filter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let bounds = match tcx.hir_node_by_def_id(def_id) {
|
let bounds = match tcx.hir_node_by_def_id(def_id) {
|
||||||
_ if tcx.is_effects_desugared_assoc_ty(def_id.to_def_id()) => {
|
|
||||||
associated_type_bounds(tcx, def_id, &[], tcx.def_span(def_id), filter)
|
|
||||||
}
|
|
||||||
hir::Node::TraitItem(hir::TraitItem {
|
hir::Node::TraitItem(hir::TraitItem {
|
||||||
kind: hir::TraitItemKind::Type(bounds, _),
|
kind: hir::TraitItemKind::Type(bounds, _),
|
||||||
span,
|
span,
|
||||||
|
@ -140,9 +140,7 @@ pub(super) fn lower_trait_object_ty(
|
|||||||
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| {
|
.filter(|item| !item.is_impl_trait_in_trait())
|
||||||
!item.is_impl_trait_in_trait() && !item.is_effects_desugaring
|
|
||||||
})
|
|
||||||
.map(|item| item.def_id),
|
.map(|item| item.def_id),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1365,7 +1365,6 @@ pub(crate) fn differs_from(&self, other: &Self) -> bool {
|
|||||||
trait_item_def_id: _,
|
trait_item_def_id: _,
|
||||||
fn_has_self_parameter: _,
|
fn_has_self_parameter: _,
|
||||||
opt_rpitit_info: _,
|
opt_rpitit_info: _,
|
||||||
is_effects_desugaring: _,
|
|
||||||
},
|
},
|
||||||
kind: _,
|
kind: _,
|
||||||
import_ids: _,
|
import_ids: _,
|
||||||
|
@ -1317,9 +1317,7 @@ fn get_associated_item_or_field_def_ids(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_associated_item(self, id: DefIndex, sess: &'a Session) -> ty::AssocItem {
|
fn get_associated_item(self, id: DefIndex, sess: &'a Session) -> ty::AssocItem {
|
||||||
let name = if self.root.tables.opt_rpitit_info.get(self, id).is_some()
|
let name = if self.root.tables.opt_rpitit_info.get(self, id).is_some() {
|
||||||
|| self.root.tables.is_effects_desugaring.get(self, id)
|
|
||||||
{
|
|
||||||
kw::Empty
|
kw::Empty
|
||||||
} else {
|
} else {
|
||||||
self.item_name(id)
|
self.item_name(id)
|
||||||
@ -1342,7 +1340,6 @@ fn get_associated_item(self, id: DefIndex, sess: &'a Session) -> ty::AssocItem {
|
|||||||
container,
|
container,
|
||||||
fn_has_self_parameter: has_self,
|
fn_has_self_parameter: has_self,
|
||||||
opt_rpitit_info,
|
opt_rpitit_info,
|
||||||
is_effects_desugaring: self.root.tables.is_effects_desugaring.get(self, id),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1677,9 +1677,6 @@ fn encode_info_for_assoc_item(&mut self, def_id: DefId) {
|
|||||||
self.encode_precise_capturing_args(def_id);
|
self.encode_precise_capturing_args(def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if item.is_effects_desugaring {
|
|
||||||
self.tables.is_effects_desugaring.set(def_id.index, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_precise_capturing_args(&mut self, def_id: DefId) {
|
fn encode_precise_capturing_args(&mut self, def_id: DefId) {
|
||||||
|
@ -396,7 +396,6 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables {
|
|||||||
inherent_impls: Table<DefIndex, LazyArray<DefIndex>>,
|
inherent_impls: Table<DefIndex, LazyArray<DefIndex>>,
|
||||||
associated_types_for_impl_traits_in_associated_fn: Table<DefIndex, LazyArray<DefId>>,
|
associated_types_for_impl_traits_in_associated_fn: Table<DefIndex, LazyArray<DefId>>,
|
||||||
opt_rpitit_info: Table<DefIndex, Option<LazyValue<ty::ImplTraitInTraitData>>>,
|
opt_rpitit_info: Table<DefIndex, Option<LazyValue<ty::ImplTraitInTraitData>>>,
|
||||||
is_effects_desugaring: Table<DefIndex, bool>,
|
|
||||||
unused_generic_params: Table<DefIndex, UnusedGenericParams>,
|
unused_generic_params: Table<DefIndex, UnusedGenericParams>,
|
||||||
// Reexported names are not associated with individual `DefId`s,
|
// Reexported names are not associated with individual `DefId`s,
|
||||||
// e.g. a glob import can introduce a lot of names, all with the same `DefId`.
|
// e.g. a glob import can introduce a lot of names, all with the same `DefId`.
|
||||||
|
@ -34,8 +34,6 @@ pub struct AssocItem {
|
|||||||
/// return-position `impl Trait` in trait desugaring. The `ImplTraitInTraitData`
|
/// return-position `impl Trait` in trait desugaring. The `ImplTraitInTraitData`
|
||||||
/// provides additional information about its source.
|
/// provides additional information about its source.
|
||||||
pub opt_rpitit_info: Option<ty::ImplTraitInTraitData>,
|
pub opt_rpitit_info: Option<ty::ImplTraitInTraitData>,
|
||||||
|
|
||||||
pub is_effects_desugaring: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AssocItem {
|
impl AssocItem {
|
||||||
|
@ -1625,16 +1625,6 @@ pub fn opt_rpitit_info(self, def_id: DefId) -> Option<ImplTraitInTraitData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the `def_id` is an associated type that was desugared from a
|
|
||||||
/// `#[const_trait]` or `impl_const`.
|
|
||||||
pub fn is_effects_desugared_assoc_ty(self, def_id: DefId) -> bool {
|
|
||||||
if let DefKind::AssocTy = self.def_kind(def_id) {
|
|
||||||
self.associated_item(def_id).is_effects_desugaring
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn find_field_index(self, ident: Ident, variant: &VariantDef) -> Option<FieldIdx> {
|
pub fn find_field_index(self, ident: Ident, variant: &VariantDef) -> Option<FieldIdx> {
|
||||||
variant.fields.iter_enumerated().find_map(|(i, field)| {
|
variant.fields.iter_enumerated().find_map(|(i, field)| {
|
||||||
self.hygienic_eq(ident, field.ident(self), variant.def_id).then_some(i)
|
self.hygienic_eq(ident, field.ident(self), variant.def_id).then_some(i)
|
||||||
|
@ -5226,12 +5226,6 @@ fn point_at_assoc_type_restriction<G: EmissionGuarantee>(
|
|||||||
let ty::ClauseKind::Projection(proj) = clause else {
|
let ty::ClauseKind::Projection(proj) = clause else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
// avoid ICEing since effects desugared associated types don't have names.
|
|
||||||
// this path should only be hit for `~const` on invalid places, so they
|
|
||||||
// will have an informative error already.
|
|
||||||
if tcx.is_effects_desugared_assoc_ty(proj.projection_term.def_id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let name = tcx.item_name(proj.projection_term.def_id);
|
let name = tcx.item_name(proj.projection_term.def_id);
|
||||||
let mut predicates = generics.predicates.iter().peekable();
|
let mut predicates = generics.predicates.iter().peekable();
|
||||||
let mut prev: Option<&hir::WhereBoundPredicate<'_>> = None;
|
let mut prev: Option<&hir::WhereBoundPredicate<'_>> = None;
|
||||||
|
@ -143,7 +143,6 @@ fn associated_item_from_trait_item_ref(trait_item_ref: &hir::TraitItemRef) -> ty
|
|||||||
container: ty::TraitContainer,
|
container: ty::TraitContainer,
|
||||||
fn_has_self_parameter: has_self,
|
fn_has_self_parameter: has_self,
|
||||||
opt_rpitit_info: None,
|
opt_rpitit_info: None,
|
||||||
is_effects_desugaring: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +162,6 @@ fn associated_item_from_impl_item_ref(impl_item_ref: &hir::ImplItemRef) -> ty::A
|
|||||||
container: ty::ImplContainer,
|
container: ty::ImplContainer,
|
||||||
fn_has_self_parameter: has_self,
|
fn_has_self_parameter: has_self,
|
||||||
opt_rpitit_info: None,
|
opt_rpitit_info: None,
|
||||||
is_effects_desugaring: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +273,6 @@ fn associated_type_for_impl_trait_in_trait(
|
|||||||
fn_def_id: fn_def_id.to_def_id(),
|
fn_def_id: fn_def_id.to_def_id(),
|
||||||
opaque_def_id: opaque_ty_def_id.to_def_id(),
|
opaque_def_id: opaque_ty_def_id.to_def_id(),
|
||||||
}),
|
}),
|
||||||
is_effects_desugaring: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Copy visility of the containing function.
|
// Copy visility of the containing function.
|
||||||
@ -327,7 +324,6 @@ fn associated_type_for_impl_trait_in_impl(
|
|||||||
container: ty::ImplContainer,
|
container: ty::ImplContainer,
|
||||||
fn_has_self_parameter: false,
|
fn_has_self_parameter: false,
|
||||||
opt_rpitit_info: Some(ImplTraitInTraitData::Impl { fn_def_id: impl_fn_def_id.to_def_id() }),
|
opt_rpitit_info: Some(ImplTraitInTraitData::Impl { fn_def_id: impl_fn_def_id.to_def_id() }),
|
||||||
is_effects_desugaring: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Copy visility of the containing function.
|
// Copy visility of the containing function.
|
||||||
|
Loading…
Reference in New Issue
Block a user