Skip to content

Commit

Permalink
Remove dead code stemming from the old effects desugaring
Browse files Browse the repository at this point in the history
  • Loading branch information
fmease committed Oct 30, 2024
1 parent 759e07f commit a6bbdf0
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 40 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,7 @@ pub(super) fn check_specialization_validity<'tcx>(
let result = opt_result.unwrap_or(Ok(()));

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) && !tcx.is_effects_desugared_assoc_ty(impl_item) {
if !tcx.is_impl_trait_in_trait(impl_item) {
report_forbidden_specialization(tcx, impl_item, parent_impl);
} else {
tcx.dcx().delayed_bug(format!("parent item: {parent_impl:?} not marked as default"));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
// 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.
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)
} else {
match tcx.hir_node_by_def_id(impl_ty_def_id) {
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_hir_analysis/src/collect/item_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,6 @@ pub(super) fn explicit_item_bounds_with_filter(
}

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 {
kind: hir::TraitItemKind::Type(bounds, _),
span,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
tcx.associated_items(pred.def_id())
.in_definition_order()
.filter(|item| item.kind == ty::AssocKind::Type)
.filter(|item| {
!item.is_impl_trait_in_trait() && !item.is_effects_desugaring
})
.filter(|item| !item.is_impl_trait_in_trait())
.map(|item| item.def_id),
);
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,6 @@ impl<'tcx> Pick<'tcx> {
trait_item_def_id: _,
fn_has_self_parameter: _,
opt_rpitit_info: _,
is_effects_desugaring: _,
},
kind: _,
import_ids: _,
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,7 @@ impl<'a> CrateMetadataRef<'a> {
}

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()
|| self.root.tables.is_effects_desugaring.get(self, id)
{
let name = if self.root.tables.opt_rpitit_info.get(self, id).is_some() {
kw::Empty
} else {
self.item_name(id)
Expand All @@ -1342,7 +1340,6 @@ impl<'a> CrateMetadataRef<'a> {
container,
fn_has_self_parameter: has_self,
opt_rpitit_info,
is_effects_desugaring: self.root.tables.is_effects_desugaring.get(self, id),
}
}

Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1677,9 +1677,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
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) {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_metadata/src/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ define_tables! {
inherent_impls: Table<DefIndex, LazyArray<DefIndex>>,
associated_types_for_impl_traits_in_associated_fn: Table<DefIndex, LazyArray<DefId>>,
opt_rpitit_info: Table<DefIndex, Option<LazyValue<ty::ImplTraitInTraitData>>>,
is_effects_desugaring: Table<DefIndex, bool>,
unused_generic_params: Table<DefIndex, UnusedGenericParams>,
// 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`.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/ty/assoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ pub struct AssocItem {
/// return-position `impl Trait` in trait desugaring. The `ImplTraitInTraitData`
/// provides additional information about its source.
pub opt_rpitit_info: Option<ty::ImplTraitInTraitData>,

pub is_effects_desugaring: bool,
}

impl AssocItem {
Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,16 +1625,6 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

/// 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> {
variant.fields.iter_enumerated().find_map(|(i, field)| {
self.hygienic_eq(ident, field.ident(self), variant.def_id).then_some(i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5226,12 +5226,6 @@ fn point_at_assoc_type_restriction<G: EmissionGuarantee>(
let ty::ClauseKind::Projection(proj) = clause else {
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 mut predicates = generics.predicates.iter().peekable();
let mut prev: Option<&hir::WhereBoundPredicate<'_>> = None;
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_ty_utils/src/assoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ fn associated_item_from_trait_item_ref(trait_item_ref: &hir::TraitItemRef) -> ty
container: ty::TraitContainer,
fn_has_self_parameter: has_self,
opt_rpitit_info: None,
is_effects_desugaring: false,
}
}

Expand All @@ -163,7 +162,6 @@ fn associated_item_from_impl_item_ref(impl_item_ref: &hir::ImplItemRef) -> ty::A
container: ty::ImplContainer,
fn_has_self_parameter: has_self,
opt_rpitit_info: None,
is_effects_desugaring: false,
}
}

Expand Down Expand Up @@ -275,7 +273,6 @@ fn associated_type_for_impl_trait_in_trait(
fn_def_id: fn_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.
Expand Down Expand Up @@ -327,7 +324,6 @@ fn associated_type_for_impl_trait_in_impl(
container: ty::ImplContainer,
fn_has_self_parameter: false,
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.
Expand Down

0 comments on commit a6bbdf0

Please sign in to comment.