diff --git a/Cargo.lock b/Cargo.lock index ebbcf35f6d682..76425710d55c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4270,7 +4270,6 @@ dependencies = [ "rustc_errors", "rustc_fluent_macro", "rustc_hir", - "rustc_index", "rustc_macros", "rustc_middle", "rustc_session", diff --git a/compiler/rustc_monomorphize/Cargo.toml b/compiler/rustc_monomorphize/Cargo.toml index 6d3a3bf906ebf..fe097424e8ad4 100644 --- a/compiler/rustc_monomorphize/Cargo.toml +++ b/compiler/rustc_monomorphize/Cargo.toml @@ -13,7 +13,6 @@ rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_hir = { path = "../rustc_hir" } rustc_fluent_macro = { path = "../rustc_fluent_macro" } -rustc_index = { path = "../rustc_index" } rustc_macros = { path = "../rustc_macros" } rustc_middle = { path = "../rustc_middle" } rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_monomorphize/messages.ftl b/compiler/rustc_monomorphize/messages.ftl index cf23d79afaf16..e27875853df08 100644 --- a/compiler/rustc_monomorphize/messages.ftl +++ b/compiler/rustc_monomorphize/messages.ftl @@ -27,8 +27,6 @@ monomorphize_type_length_limit = reached the type-length limit while instantiati monomorphize_unknown_cgu_collection_mode = unknown codegen-item collection mode '{$mode}', falling back to 'lazy' mode -monomorphize_unknown_partition_strategy = unknown partitioning strategy - monomorphize_unused_generic_params = item has unused generic parameters monomorphize_written_to_path = the full type name has been written to '{$path}' diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 6ea177bb6ea9a..eb1c7db026e19 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -173,7 +173,7 @@ use rustc_hir::lang_items::LangItem; use rustc_middle::mir::interpret::{AllocId, ErrorHandled, GlobalAlloc, Scalar}; use rustc_middle::mir::mono::{InstantiationMode, MonoItem}; use rustc_middle::mir::visit::Visitor as MirVisitor; -use rustc_middle::mir::{self, Local, Location}; +use rustc_middle::mir::{self, Location}; use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion}; use rustc_middle::ty::print::with_no_trimmed_paths; @@ -874,14 +874,6 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { self.super_operand(operand, location); self.check_operand_move_size(operand, location); } - - fn visit_local( - &mut self, - _place_local: Local, - _context: mir::visit::PlaceContext, - _location: Location, - ) { - } } fn visit_drop_use<'tcx>( @@ -1220,7 +1212,7 @@ impl<'v> RootCollector<'_, 'v> { } fn is_root(&self, def_id: LocalDefId) -> bool { - !item_requires_monomorphization(self.tcx, def_id) + !self.tcx.generics_of(def_id).requires_monomorphization(self.tcx) && match self.mode { MonoItemCollectionMode::Eager => true, MonoItemCollectionMode::Lazy => { @@ -1283,11 +1275,6 @@ impl<'v> RootCollector<'_, 'v> { } } -fn item_requires_monomorphization(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { - let generics = tcx.generics_of(def_id); - generics.requires_monomorphization(tcx) -} - #[instrument(level = "debug", skip(tcx, output))] fn create_mono_items_for_default_impls<'tcx>( tcx: TyCtxt<'tcx>, @@ -1394,17 +1381,6 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt } } -fn add_assoc_fn<'tcx>( - tcx: TyCtxt<'tcx>, - def_id: Option, - fn_ident: Ident, - skip_move_check_fns: &mut Vec, -) { - if let Some(def_id) = def_id.and_then(|def_id| assoc_fn_of_type(tcx, def_id, fn_ident)) { - skip_move_check_fns.push(def_id); - } -} - fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) -> Option { for impl_def_id in tcx.inherent_impls(def_id) { if let Some(new) = tcx.associated_items(impl_def_id).find_by_name_and_kind( @@ -1420,26 +1396,16 @@ fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) -> } fn build_skip_move_check_fns(tcx: TyCtxt<'_>) -> Vec { - let mut skip_move_check_fns = vec![]; - add_assoc_fn( - tcx, - tcx.lang_items().owned_box(), - Ident::from_str("new"), - &mut skip_move_check_fns, - ); - add_assoc_fn( - tcx, - tcx.get_diagnostic_item(sym::Arc), - Ident::from_str("new"), - &mut skip_move_check_fns, - ); - add_assoc_fn( - tcx, - tcx.get_diagnostic_item(sym::Rc), - Ident::from_str("new"), - &mut skip_move_check_fns, - ); - skip_move_check_fns + let fns = [ + (tcx.lang_items().owned_box(), "new"), + (tcx.get_diagnostic_item(sym::Rc), "new"), + (tcx.get_diagnostic_item(sym::Arc), "new"), + ]; + fns.into_iter() + .filter_map(|(def_id, fn_name)| { + def_id.and_then(|def_id| assoc_fn_of_type(tcx, def_id, Ident::from_str(fn_name))) + }) + .collect::>() } /// Scans the MIR in order to find function calls, closures, and drop-glue. diff --git a/compiler/rustc_monomorphize/src/errors.rs b/compiler/rustc_monomorphize/src/errors.rs index fdcc95f137f76..d242a7baec1bc 100644 --- a/compiler/rustc_monomorphize/src/errors.rs +++ b/compiler/rustc_monomorphize/src/errors.rs @@ -75,10 +75,6 @@ pub struct LargeAssignmentsLint { pub limit: u64, } -#[derive(Diagnostic)] -#[diag(monomorphize_unknown_partition_strategy)] -pub struct UnknownPartitionStrategy; - #[derive(Diagnostic)] #[diag(monomorphize_symbol_already_defined)] pub struct SymbolAlreadyDefined {