diff options
| author | bors <bors@rust-lang.org> | 2025-07-04 04:21:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-04 04:21:14 +0000 |
| commit | c96a69059ecc618b519da385a6ccd03155aa0237 (patch) | |
| tree | 8a658b79c06f3b54d15b22c22fa7b30edd889557 /compiler/rustc_hir_analysis/src | |
| parent | 837c5dd7de03aa97190593aef4e70d53e1bb574b (diff) | |
| parent | e4e26d2acb13f42badb6e4953c7d72a001e3aed7 (diff) | |
| download | rust-c96a69059ecc618b519da385a6ccd03155aa0237.tar.gz rust-c96a69059ecc618b519da385a6ccd03155aa0237.zip | |
Auto merge of #143407 - jhpratt:rollup-ekkoubw, r=jhpratt
Rollup of 11 pull requests
Successful merges:
- rust-lang/rust#142749 (Add methods for converting bool to `Result<(), E>`)
- rust-lang/rust#143288 (Fix `x clean` with a fifo)
- rust-lang/rust#143307 (Fast path nitpicks)
- rust-lang/rust#143346 (update coherence example)
- rust-lang/rust#143356 (use unsigned_abs instead of `abs` on signed int to silence clippy)
- rust-lang/rust#143370 (remove redundant #[must_use])
- rust-lang/rust#143378 (simplify receivers for some array method calls)
- rust-lang/rust#143380 (Replace kw_span by full span for generic const parameters.)
- rust-lang/rust#143381 (rustdoc: don't treat methods under const impls or traits as const)
- rust-lang/rust#143394 (compiler: Document and reduce `fn provide`s in hir crates)
- rust-lang/rust#143395 (Always use the pure Rust fallback instead of `llvm.{maximum,minimum}`)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/mod.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/wfcheck.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check_unused.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/coherence/mod.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/hir_wf_check.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/lib.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/outlives/mod.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/variance/mod.rs | 9 |
10 files changed, 28 insertions, 39 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 5cec3331bb1..b2cfab37c1f 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -100,8 +100,8 @@ use self::compare_impl_item::collect_return_position_impl_trait_in_trait_tys; use self::region::region_scope_tree; use crate::{errors, require_c_abi_if_c_variadic}; -pub fn provide(providers: &mut Providers) { - wfcheck::provide(providers); +/// Adds query implementations to the [Providers] vtable, see [`rustc_middle::query`] +pub(super) fn provide(providers: &mut Providers) { *providers = Providers { adt_destructor, adt_async_destructor, @@ -109,6 +109,8 @@ pub fn provide(providers: &mut Providers) { collect_return_position_impl_trait_in_trait_tys, compare_impl_item: compare_impl_item::compare_impl_item, check_coroutine_obligations: check::check_coroutine_obligations, + check_type_wf: wfcheck::check_type_wf, + check_well_formed: wfcheck::check_well_formed, ..*providers }; } diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index ed8d25e9915..4934136bc7a 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -15,7 +15,6 @@ use rustc_infer::infer::{self, InferCtxt, SubregionOrigin, TyCtxtInferExt}; use rustc_lint_defs::builtin::SUPERTRAIT_ITEM_SHADOWING_DEFINITION; use rustc_macros::LintDiagnostic; use rustc_middle::mir::interpret::ErrorHandled; -use rustc_middle::query::Providers; use rustc_middle::traits::solve::NoSolution; use rustc_middle::ty::trait_def::TraitSpecializationKind; use rustc_middle::ty::{ @@ -189,7 +188,10 @@ where } } -fn check_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGuaranteed> { +pub(super) fn check_well_formed( + tcx: TyCtxt<'_>, + def_id: LocalDefId, +) -> Result<(), ErrorGuaranteed> { let mut res = crate::check::check::check_item_type(tcx, def_id); for param in &tcx.generics_of(def_id).own_params { @@ -2249,7 +2251,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { } } -fn check_type_wf(tcx: TyCtxt<'_>, (): ()) -> Result<(), ErrorGuaranteed> { +pub(super) fn check_type_wf(tcx: TyCtxt<'_>, (): ()) -> Result<(), ErrorGuaranteed> { let items = tcx.hir_crate_items(()); let res = items .par_items(|item| tcx.ensure_ok().check_well_formed(item.owner_id.def_id)) @@ -2397,7 +2399,3 @@ struct RedundantLifetimeArgsLint<'tcx> { // The lifetime we can replace the victim with. candidate: ty::Region<'tcx>, } - -pub fn provide(providers: &mut Providers) { - *providers = Providers { check_type_wf, check_well_formed, ..*providers }; -} diff --git a/compiler/rustc_hir_analysis/src/check_unused.rs b/compiler/rustc_hir_analysis/src/check_unused.rs index 464ffa8711a..0133b1e8fcd 100644 --- a/compiler/rustc_hir_analysis/src/check_unused.rs +++ b/compiler/rustc_hir_analysis/src/check_unused.rs @@ -1,16 +1,11 @@ use rustc_data_structures::unord::{ExtendUnord, UnordSet}; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; -use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_session::lint; use tracing::debug; -pub(crate) fn provide(providers: &mut Providers) { - *providers = Providers { check_unused_traits, ..*providers }; -} - -fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) { +pub(super) fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) { let mut used_trait_imports = UnordSet::<LocalDefId>::default(); // FIXME: Use `tcx.hir_par_body_owners()` when we implement creating `DefId`s diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs index 16bac430491..ed8f78216ff 100644 --- a/compiler/rustc_hir_analysis/src/coherence/mod.rs +++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs @@ -130,6 +130,7 @@ fn enforce_empty_impls_for_marker_traits( .emit()) } +/// Adds query implementations to the [Providers] vtable, see [`rustc_middle::query`]. pub(crate) fn provide(providers: &mut Providers) { use self::builtin::coerce_unsized_info; use self::inherent_impls::{ diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index b10d5b55789..aad9b08b2a3 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -61,6 +61,7 @@ mod type_of; /////////////////////////////////////////////////////////////////////////// +/// Adds query implementations to the [Providers] vtable, see [`rustc_middle::query`] pub(crate) fn provide(providers: &mut Providers) { resolve_bound_vars::provide(providers); *providers = Providers { diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 95743f9a63e..0e775d374ab 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -222,6 +222,7 @@ enum BinderScopeType { type ScopeRef<'a> = &'a Scope<'a>; +/// Adds query implementations to the [Providers] vtable, see [`rustc_middle::query`] pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { resolve_bound_vars, diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs index fef0dbf2ece..bf539dfab42 100644 --- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs @@ -4,7 +4,6 @@ use rustc_hir::{self as hir, AmbigArg, ForeignItem, ForeignItemKind}; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::{ObligationCause, ObligationCauseCode, WellFormedLoc}; use rustc_middle::bug; -use rustc_middle::query::Providers; use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt, TypingMode, fold_regions}; use rustc_span::def_id::LocalDefId; use rustc_trait_selection::traits::{self, ObligationCtxt}; @@ -12,13 +11,9 @@ use tracing::debug; use crate::collect::ItemCtxt; -pub(crate) fn provide(providers: &mut Providers) { - *providers = Providers { diagnostic_hir_wf_check, ..*providers }; -} - // Ideally, this would be in `rustc_trait_selection`, but we // need access to `ItemCtxt` -fn diagnostic_hir_wf_check<'tcx>( +pub(super) fn diagnostic_hir_wf_check<'tcx>( tcx: TyCtxt<'tcx>, (predicate, loc): (ty::Predicate<'tcx>, WellFormedLoc), ) -> Option<ObligationCause<'tcx>> { diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 2ff7caef732..3a153ab089a 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -150,18 +150,21 @@ fn require_c_abi_if_c_variadic( .emit(); } +/// Adds query implementations to the [Providers] vtable, see [`rustc_middle::query`] pub fn provide(providers: &mut Providers) { collect::provide(providers); coherence::provide(providers); check::provide(providers); - check_unused::provide(providers); - variance::provide(providers); - outlives::provide(providers); - hir_wf_check::provide(providers); *providers = Providers { + check_unused_traits: check_unused::check_unused_traits, + diagnostic_hir_wf_check: hir_wf_check::diagnostic_hir_wf_check, + inferred_outlives_crate: outlives::inferred_outlives_crate, + inferred_outlives_of: outlives::inferred_outlives_of, inherit_sig_for_delegation_item: delegation::inherit_sig_for_delegation_item, enforce_impl_non_lifetime_params_are_constrained: impl_wf_check::enforce_impl_non_lifetime_params_are_constrained, + crate_variances: variance::crate_variances, + variances_of: variance::variances_of, ..*providers }; } diff --git a/compiler/rustc_hir_analysis/src/outlives/mod.rs b/compiler/rustc_hir_analysis/src/outlives/mod.rs index 499f5572f47..d155f4f98ad 100644 --- a/compiler/rustc_hir_analysis/src/outlives/mod.rs +++ b/compiler/rustc_hir_analysis/src/outlives/mod.rs @@ -1,6 +1,5 @@ use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; -use rustc_middle::query::Providers; use rustc_middle::ty::{self, CratePredicatesMap, GenericArgKind, TyCtxt, Upcast}; use rustc_span::Span; @@ -9,11 +8,10 @@ mod explicit; mod implicit_infer; mod utils; -pub(crate) fn provide(providers: &mut Providers) { - *providers = Providers { inferred_outlives_of, inferred_outlives_crate, ..*providers }; -} - -fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clause<'_>, Span)] { +pub(super) fn inferred_outlives_of( + tcx: TyCtxt<'_>, + item_def_id: LocalDefId, +) -> &[(ty::Clause<'_>, Span)] { match tcx.def_kind(item_def_id) { DefKind::Struct | DefKind::Enum | DefKind::Union => { let crate_map = tcx.inferred_outlives_crate(()); @@ -48,7 +46,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clau } } -fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> { +pub(super) fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> { // Compute a map from each ADT (struct/enum/union) and lazy type alias to // the **explicit** outlives predicates (`T: 'a`, `'a: 'b`) that the user wrote. // Typically there won't be many of these, except in older code where diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs index dbba45dc7bb..0666b335e09 100644 --- a/compiler/rustc_hir_analysis/src/variance/mod.rs +++ b/compiler/rustc_hir_analysis/src/variance/mod.rs @@ -8,7 +8,6 @@ use rustc_arena::DroplessArena; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_middle::query::Providers; use rustc_middle::span_bug; use rustc_middle::ty::{ self, CrateVariancesMap, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, @@ -27,18 +26,14 @@ mod solve; pub(crate) mod dump; -pub(crate) fn provide(providers: &mut Providers) { - *providers = Providers { variances_of, crate_variances, ..*providers }; -} - -fn crate_variances(tcx: TyCtxt<'_>, (): ()) -> CrateVariancesMap<'_> { +pub(super) fn crate_variances(tcx: TyCtxt<'_>, (): ()) -> CrateVariancesMap<'_> { let arena = DroplessArena::default(); let terms_cx = terms::determine_parameters_to_be_inferred(tcx, &arena); let constraints_cx = constraints::add_constraints_from_crate(terms_cx); solve::solve_constraints(constraints_cx) } -fn variances_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Variance] { +pub(super) fn variances_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Variance] { // Skip items with no generics - there's nothing to infer in them. if tcx.generics_of(item_def_id).is_empty() { return &[]; |
