Drop skip_move_check_fns query.

This commit is contained in:
Camille Gillot
2026-05-24 09:20:52 +00:00
parent e1ff77d898
commit 20d113eff1
3 changed files with 18 additions and 39 deletions
-6
View File
@@ -2710,12 +2710,6 @@
desc { "monomorphization-time checking" }
}
/// Builds the set of functions that should be skipped for the move-size check.
query skip_move_check_fns(_: ()) -> &'tcx FxIndexSet<DefId> {
arena_cache
desc { "functions to skip for move-size check" }
}
query items_of_instance(key: (ty::Instance<'tcx>, CollectionMode)) -> Result<(&'tcx [Spanned<MonoItem<'tcx>>], &'tcx [Spanned<MonoItem<'tcx>>]), NormalizationErrorInMono> {
desc { "collecting items used by `{}`", key.0 }
cache_on_disk
@@ -15,9 +15,5 @@ fn check_mono_item<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
}
pub(super) fn provide(providers: &mut Providers) {
*providers = Providers {
check_mono_item,
skip_move_check_fns: move_check::skip_move_check_fns,
..*providers
}
*providers = Providers { check_mono_item, ..*providers }
}
@@ -1,12 +1,12 @@
use rustc_abi::Size;
use rustc_data_structures::fx::FxIndexSet;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_hir::limit::Limit;
use rustc_middle::mir::visit::Visitor as MirVisitor;
use rustc_middle::mir::{self, Location, traversal};
use rustc_middle::ty::{self, AssocTag, Instance, Ty, TyCtxt, TypeFoldable};
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};
use rustc_session::lint::builtin::LARGE_ASSIGNMENTS;
use rustc_span::{Ident, Span, Spanned, sym};
use rustc_span::{Span, Spanned, sym};
use tracing::{debug, trace};
use crate::errors::LargeAssignmentsLint;
@@ -98,7 +98,7 @@ pub(super) fn check_fn_args_move_size(
let ty::FnDef(def_id, _) = *callee_ty.kind() else {
return;
};
if self.tcx.skip_move_check_fns(()).contains(&def_id) {
if should_skip_fn(self.tcx, def_id) {
return;
}
@@ -188,29 +188,18 @@ fn lint_large_assignment(
}
}
fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) -> Option<DefId> {
for &impl_def_id in tcx.inherent_impls(def_id) {
if let Some(new) = tcx.associated_items(impl_def_id).find_by_ident_and_kind(
tcx,
fn_ident,
AssocTag::Fn,
def_id,
) {
return Some(new.def_id);
}
/// Return `true` if `def_id` is `Box::new`, `Rc::new` or `Arc::new`.
fn should_skip_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
if let DefKind::AssocFn = tcx.def_kind(def_id)
&& tcx.item_name(def_id) == sym::new
&& let parent = tcx.parent(def_id)
&& let DefKind::Impl { of_trait: false } = tcx.def_kind(parent)
&& let ty::Adt(adt_def, ..) =
tcx.type_of(parent).instantiate_identity().skip_normalization().kind()
{
return Some(adt_def.did()) == tcx.lang_items().owned_box()
|| Some(adt_def.did()) == tcx.get_diagnostic_item(sym::Rc)
|| Some(adt_def.did()) == tcx.get_diagnostic_item(sym::Arc);
}
None
}
pub(crate) fn skip_move_check_fns(tcx: TyCtxt<'_>, _: ()) -> FxIndexSet<DefId> {
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()
false
}