1
Fork 0

Don't export rustc_hir_analysis::collect.

Instead re-export `rustc_hir_analysis::collect::suggest_impl_trait`,
which is the only thing from the module used in another crate. This
fixes a `FIXME` comment. Also adjust some visibilities to satisfy the
`unreachable_pub` lint.

This changes requires downgrading a link in a comment on `FnCtxt`
because `collect` is no longer public and rustdoc complains otherwise.
This is annoying but I can't see how to avoid it.
This commit is contained in:
Nicholas Nethercote 2025-01-29 10:52:24 +11:00
parent 29317604d1
commit 483307f127
4 changed files with 17 additions and 17 deletions

View file

@ -57,7 +57,7 @@ mod type_of;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
pub fn provide(providers: &mut Providers) { pub(crate) fn provide(providers: &mut Providers) {
resolve_bound_vars::provide(providers); resolve_bound_vars::provide(providers);
*providers = Providers { *providers = Providers {
type_of: type_of::type_of, type_of: type_of::type_of,
@ -122,7 +122,7 @@ pub fn provide(providers: &mut Providers) {
/// `ItemCtxt` is parameterized by a `DefId` that it uses to satisfy /// `ItemCtxt` is parameterized by a `DefId` that it uses to satisfy
/// `probe_ty_param_bounds` requests, drawing the information from /// `probe_ty_param_bounds` requests, drawing the information from
/// the HIR (`hir::Generics`), recursively. /// the HIR (`hir::Generics`), recursively.
pub struct ItemCtxt<'tcx> { pub(crate) struct ItemCtxt<'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
item_def_id: LocalDefId, item_def_id: LocalDefId,
tainted_by_errors: Cell<Option<ErrorGuaranteed>>, tainted_by_errors: Cell<Option<ErrorGuaranteed>>,
@ -148,7 +148,7 @@ impl<'v> Visitor<'v> for HirPlaceholderCollector {
} }
} }
pub struct CollectItemTypesVisitor<'tcx> { pub(crate) struct CollectItemTypesVisitor<'tcx> {
pub tcx: TyCtxt<'tcx>, pub tcx: TyCtxt<'tcx>,
} }
@ -364,19 +364,19 @@ fn bad_placeholder<'cx, 'tcx>(
} }
impl<'tcx> ItemCtxt<'tcx> { impl<'tcx> ItemCtxt<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, item_def_id: LocalDefId) -> ItemCtxt<'tcx> { pub(crate) fn new(tcx: TyCtxt<'tcx>, item_def_id: LocalDefId) -> ItemCtxt<'tcx> {
ItemCtxt { tcx, item_def_id, tainted_by_errors: Cell::new(None) } ItemCtxt { tcx, item_def_id, tainted_by_errors: Cell::new(None) }
} }
pub fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> { pub(crate) fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
self.lowerer().lower_ty(hir_ty) self.lowerer().lower_ty(hir_ty)
} }
pub fn hir_id(&self) -> hir::HirId { pub(crate) fn hir_id(&self) -> hir::HirId {
self.tcx.local_def_id_to_hir_id(self.item_def_id) self.tcx.local_def_id_to_hir_id(self.item_def_id)
} }
pub fn node(&self) -> hir::Node<'tcx> { pub(crate) fn node(&self) -> hir::Node<'tcx> {
self.tcx.hir_node(self.hir_id()) self.tcx.hir_node(self.hir_id())
} }

View file

@ -83,12 +83,11 @@ pub mod autoderef;
mod bounds; mod bounds;
mod check_unused; mod check_unused;
mod coherence; mod coherence;
mod delegation; mod collect;
pub mod hir_ty_lowering;
// FIXME: This module shouldn't be public.
pub mod collect;
mod constrained_generic_params; mod constrained_generic_params;
mod delegation;
mod errors; mod errors;
pub mod hir_ty_lowering;
pub mod hir_wf_check; pub mod hir_wf_check;
mod impl_wf_check; mod impl_wf_check;
mod outlives; mod outlives;
@ -104,7 +103,8 @@ use rustc_middle::ty::{self, Const, Ty, TyCtxt};
use rustc_span::Span; use rustc_span::Span;
use rustc_trait_selection::traits; use rustc_trait_selection::traits;
use self::hir_ty_lowering::{FeedConstTy, HirTyLowerer}; pub use crate::collect::suggest_impl_trait;
use crate::hir_ty_lowering::{FeedConstTy, HirTyLowerer};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" } rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -31,12 +31,12 @@ use crate::{CoroutineTypes, Diverges, EnclosingBreakables, TypeckRootCtxt};
/// functions, closures, and `const`s, including performing type inference /// functions, closures, and `const`s, including performing type inference
/// with [`InferCtxt`]. /// with [`InferCtxt`].
/// ///
/// This is in contrast to [`ItemCtxt`], which is used to type-check item *signatures* /// This is in contrast to `rustc_hir_analysis::collect::ItemCtxt`, which is
/// and thus does not perform type inference. /// used to type-check item *signatures* and thus does not perform type
/// inference.
/// ///
/// See [`ItemCtxt`]'s docs for more. /// See `ItemCtxt`'s docs for more.
/// ///
/// [`ItemCtxt`]: rustc_hir_analysis::collect::ItemCtxt
/// [`InferCtxt`]: infer::InferCtxt /// [`InferCtxt`]: infer::InferCtxt
pub(crate) struct FnCtxt<'a, 'tcx> { pub(crate) struct FnCtxt<'a, 'tcx> {
pub(super) body_id: LocalDefId, pub(super) body_id: LocalDefId,

View file

@ -12,8 +12,8 @@ use rustc_hir::{
GenericBound, HirId, Node, PatExpr, PatExprKind, Path, QPath, Stmt, StmtKind, TyKind, GenericBound, HirId, Node, PatExpr, PatExprKind, Path, QPath, Stmt, StmtKind, TyKind,
WherePredicateKind, expr_needs_parens, WherePredicateKind, expr_needs_parens,
}; };
use rustc_hir_analysis::collect::suggest_impl_trait;
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer; use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
use rustc_hir_analysis::suggest_impl_trait;
use rustc_middle::lint::in_external_macro; use rustc_middle::lint::in_external_macro;
use rustc_middle::middle::stability::EvalResult; use rustc_middle::middle::stability::EvalResult;
use rustc_middle::span_bug; use rustc_middle::span_bug;