From a6bbdf0fd41989c09c1f77f42be9026d29475075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 30 Oct 2024 23:52:10 +0100 Subject: [PATCH] Remove dead code stemming from the old effects desugaring --- compiler/rustc_hir_analysis/src/check/check.rs | 3 +-- .../rustc_hir_analysis/src/check/compare_impl_item.rs | 2 +- compiler/rustc_hir_analysis/src/collect/item_bounds.rs | 3 --- .../src/hir_ty_lowering/dyn_compatibility.rs | 4 +--- compiler/rustc_hir_typeck/src/method/probe.rs | 1 - compiler/rustc_metadata/src/rmeta/decoder.rs | 5 +---- compiler/rustc_metadata/src/rmeta/encoder.rs | 3 --- compiler/rustc_metadata/src/rmeta/mod.rs | 1 - compiler/rustc_middle/src/ty/assoc.rs | 2 -- compiler/rustc_middle/src/ty/mod.rs | 10 ---------- .../src/error_reporting/traits/suggestions.rs | 6 ------ compiler/rustc_ty_utils/src/assoc.rs | 4 ---- 12 files changed, 4 insertions(+), 40 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index f830108a02f..79e84e507bc 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -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")); diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index db2c44fd29d..cdd85e4ead5 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -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) { diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index 5c4cecc02f0..da779a16569 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -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, diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs index f2ee4b0ccd4..46a5cbb0af4 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs @@ -140,9 +140,7 @@ pub(super) fn lower_trait_object_ty( 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), ); } diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 569fdea11ce..eb5581f421b 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1365,7 +1365,6 @@ pub(crate) fn differs_from(&self, other: &Self) -> bool { trait_item_def_id: _, fn_has_self_parameter: _, opt_rpitit_info: _, - is_effects_desugaring: _, }, kind: _, import_ids: _, diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 4b406496337..ebfd3c09fc1 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1317,9 +1317,7 @@ fn get_associated_item_or_field_def_ids( } 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) @@ -1342,7 +1340,6 @@ fn get_associated_item(self, id: DefIndex, sess: &'a Session) -> ty::AssocItem { container, fn_has_self_parameter: has_self, opt_rpitit_info, - is_effects_desugaring: self.root.tables.is_effects_desugaring.get(self, id), } } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index b5ac302c597..b4b48570453 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1677,9 +1677,6 @@ fn encode_info_for_assoc_item(&mut self, def_id: DefId) { 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) { diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index f1844045677..927c9fa47a1 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -396,7 +396,6 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { inherent_impls: Table>, associated_types_for_impl_traits_in_associated_fn: Table>, opt_rpitit_info: Table>>, - is_effects_desugaring: Table, unused_generic_params: Table, // 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`. diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs index db56e0016a2..3137fe9bd1d 100644 --- a/compiler/rustc_middle/src/ty/assoc.rs +++ b/compiler/rustc_middle/src/ty/assoc.rs @@ -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, - - pub is_effects_desugaring: bool, } impl AssocItem { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index bd32e5837b3..dac81a6dfbb 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1625,16 +1625,6 @@ pub fn opt_rpitit_info(self, def_id: DefId) -> Option { } } - /// 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 { variant.fields.iter_enumerated().find_map(|(i, field)| { self.hygienic_eq(ident, field.ident(self), variant.def_id).then_some(i) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 8e0bdce1280..834eb94b3ad 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -5226,12 +5226,6 @@ fn point_at_assoc_type_restriction( 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; diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 16fd28201c2..7d72474f9a4 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -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, } } @@ -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, } } @@ -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. @@ -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.