Skip to content

Commit 483307f

Browse files
committed
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.
1 parent 2931760 commit 483307f

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

compiler/rustc_hir_analysis/src/collect.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ mod type_of;
5757

5858
///////////////////////////////////////////////////////////////////////////
5959

60-
pub fn provide(providers: &mut Providers) {
60+
pub(crate) fn provide(providers: &mut Providers) {
6161
resolve_bound_vars::provide(providers);
6262
*providers = Providers {
6363
type_of: type_of::type_of,
@@ -122,7 +122,7 @@ pub fn provide(providers: &mut Providers) {
122122
/// `ItemCtxt` is parameterized by a `DefId` that it uses to satisfy
123123
/// `probe_ty_param_bounds` requests, drawing the information from
124124
/// the HIR (`hir::Generics`), recursively.
125-
pub struct ItemCtxt<'tcx> {
125+
pub(crate) struct ItemCtxt<'tcx> {
126126
tcx: TyCtxt<'tcx>,
127127
item_def_id: LocalDefId,
128128
tainted_by_errors: Cell<Option<ErrorGuaranteed>>,
@@ -148,7 +148,7 @@ impl<'v> Visitor<'v> for HirPlaceholderCollector {
148148
}
149149
}
150150

151-
pub struct CollectItemTypesVisitor<'tcx> {
151+
pub(crate) struct CollectItemTypesVisitor<'tcx> {
152152
pub tcx: TyCtxt<'tcx>,
153153
}
154154

@@ -364,19 +364,19 @@ fn bad_placeholder<'cx, 'tcx>(
364364
}
365365

366366
impl<'tcx> ItemCtxt<'tcx> {
367-
pub fn new(tcx: TyCtxt<'tcx>, item_def_id: LocalDefId) -> ItemCtxt<'tcx> {
367+
pub(crate) fn new(tcx: TyCtxt<'tcx>, item_def_id: LocalDefId) -> ItemCtxt<'tcx> {
368368
ItemCtxt { tcx, item_def_id, tainted_by_errors: Cell::new(None) }
369369
}
370370

371-
pub fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
371+
pub(crate) fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
372372
self.lowerer().lower_ty(hir_ty)
373373
}
374374

375-
pub fn hir_id(&self) -> hir::HirId {
375+
pub(crate) fn hir_id(&self) -> hir::HirId {
376376
self.tcx.local_def_id_to_hir_id(self.item_def_id)
377377
}
378378

379-
pub fn node(&self) -> hir::Node<'tcx> {
379+
pub(crate) fn node(&self) -> hir::Node<'tcx> {
380380
self.tcx.hir_node(self.hir_id())
381381
}
382382

compiler/rustc_hir_analysis/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ pub mod autoderef;
8383
mod bounds;
8484
mod check_unused;
8585
mod coherence;
86-
mod delegation;
87-
pub mod hir_ty_lowering;
88-
// FIXME: This module shouldn't be public.
89-
pub mod collect;
86+
mod collect;
9087
mod constrained_generic_params;
88+
mod delegation;
9189
mod errors;
90+
pub mod hir_ty_lowering;
9291
pub mod hir_wf_check;
9392
mod impl_wf_check;
9493
mod outlives;
@@ -104,7 +103,8 @@ use rustc_middle::ty::{self, Const, Ty, TyCtxt};
104103
use rustc_span::Span;
105104
use rustc_trait_selection::traits;
106105

107-
use self::hir_ty_lowering::{FeedConstTy, HirTyLowerer};
106+
pub use crate::collect::suggest_impl_trait;
107+
use crate::hir_ty_lowering::{FeedConstTy, HirTyLowerer};
108108

109109
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
110110

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ use crate::{CoroutineTypes, Diverges, EnclosingBreakables, TypeckRootCtxt};
3131
/// functions, closures, and `const`s, including performing type inference
3232
/// with [`InferCtxt`].
3333
///
34-
/// This is in contrast to [`ItemCtxt`], which is used to type-check item *signatures*
35-
/// and thus does not perform type inference.
34+
/// This is in contrast to `rustc_hir_analysis::collect::ItemCtxt`, which is
35+
/// used to type-check item *signatures* and thus does not perform type
36+
/// inference.
3637
///
37-
/// See [`ItemCtxt`]'s docs for more.
38+
/// See `ItemCtxt`'s docs for more.
3839
///
39-
/// [`ItemCtxt`]: rustc_hir_analysis::collect::ItemCtxt
4040
/// [`InferCtxt`]: infer::InferCtxt
4141
pub(crate) struct FnCtxt<'a, 'tcx> {
4242
pub(super) body_id: LocalDefId,

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use rustc_hir::{
1212
GenericBound, HirId, Node, PatExpr, PatExprKind, Path, QPath, Stmt, StmtKind, TyKind,
1313
WherePredicateKind, expr_needs_parens,
1414
};
15-
use rustc_hir_analysis::collect::suggest_impl_trait;
1615
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
16+
use rustc_hir_analysis::suggest_impl_trait;
1717
use rustc_middle::lint::in_external_macro;
1818
use rustc_middle::middle::stability::EvalResult;
1919
use rustc_middle::span_bug;

0 commit comments

Comments
 (0)