Skip to content

Commit 5acf4e7

Browse files
committed
Add warn(unreachable_pub) to rustc_hir_analysis.
1 parent bffa224 commit 5acf4e7

27 files changed

+155
-145
lines changed

compiler/rustc_hir_analysis/src/bounds.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ use rustc_span::Span;
2626
/// Our representation is a bit mixed here -- in some cases, we
2727
/// include the self type (e.g., `trait_bounds`) but in others we do not
2828
#[derive(Default, PartialEq, Eq, Clone, Debug)]
29-
pub struct Bounds<'tcx> {
29+
pub(crate) struct Bounds<'tcx> {
3030
clauses: Vec<(ty::Clause<'tcx>, Span)>,
3131
effects_min_tys: FxIndexMap<Ty<'tcx>, Span>,
3232
}
3333

3434
impl<'tcx> Bounds<'tcx> {
35-
pub fn push_region_bound(
35+
pub(crate) fn push_region_bound(
3636
&mut self,
3737
tcx: TyCtxt<'tcx>,
3838
region: ty::PolyTypeOutlivesPredicate<'tcx>,
@@ -42,7 +42,7 @@ impl<'tcx> Bounds<'tcx> {
4242
.push((region.map_bound(|p| ty::ClauseKind::TypeOutlives(p)).upcast(tcx), span));
4343
}
4444

45-
pub fn push_trait_bound(
45+
pub(crate) fn push_trait_bound(
4646
&mut self,
4747
tcx: TyCtxt<'tcx>,
4848
defining_def_id: DefId,
@@ -154,7 +154,7 @@ impl<'tcx> Bounds<'tcx> {
154154
self.clauses.push((bound_trait_ref.rebind(new_trait_ref).upcast(tcx), span));
155155
}
156156

157-
pub fn push_projection_bound(
157+
pub(crate) fn push_projection_bound(
158158
&mut self,
159159
tcx: TyCtxt<'tcx>,
160160
projection: ty::PolyProjectionPredicate<'tcx>,
@@ -166,22 +166,22 @@ impl<'tcx> Bounds<'tcx> {
166166
));
167167
}
168168

169-
pub fn push_sized(&mut self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) {
169+
pub(crate) fn push_sized(&mut self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) {
170170
let sized_def_id = tcx.require_lang_item(LangItem::Sized, Some(span));
171171
let trait_ref = ty::TraitRef::new(tcx, sized_def_id, [ty]);
172172
// Preferable to put this obligation first, since we report better errors for sized ambiguity.
173173
self.clauses.insert(0, (trait_ref.upcast(tcx), span));
174174
}
175175

176-
pub fn clauses(
176+
pub(crate) fn clauses(
177177
&self,
178178
// FIXME(effects): remove tcx
179179
_tcx: TyCtxt<'tcx>,
180180
) -> impl Iterator<Item = (ty::Clause<'tcx>, Span)> + '_ {
181181
self.clauses.iter().cloned()
182182
}
183183

184-
pub fn effects_min_tys(&self) -> impl Iterator<Item = Ty<'tcx>> + '_ {
184+
pub(crate) fn effects_min_tys(&self) -> impl Iterator<Item = Ty<'tcx>> + '_ {
185185
self.effects_min_tys.keys().copied()
186186
}
187187
}

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ fn check_impl_items_against_trait<'tcx>(
10531053
}
10541054
}
10551055

1056-
pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
1056+
fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
10571057
let t = tcx.type_of(def_id).instantiate_identity();
10581058
if let ty::Adt(def, args) = t.kind()
10591059
&& def.is_struct()

compiler/rustc_hir_analysis/src/check/errs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_span::Span;
66
use crate::errors;
77

88
/// Check for shared or mutable references of `static mut` inside expression
9-
pub fn maybe_expr_static_mut(tcx: TyCtxt<'_>, expr: hir::Expr<'_>) {
9+
pub(crate) fn maybe_expr_static_mut(tcx: TyCtxt<'_>, expr: hir::Expr<'_>) {
1010
let span = expr.span;
1111
let hir_id = expr.hir_id;
1212
if let hir::ExprKind::AddrOf(borrow_kind, m, expr) = expr.kind
@@ -26,7 +26,7 @@ pub fn maybe_expr_static_mut(tcx: TyCtxt<'_>, expr: hir::Expr<'_>) {
2626
}
2727

2828
/// Check for shared or mutable references of `static mut` inside statement
29-
pub fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
29+
pub(crate) fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
3030
if let hir::StmtKind::Let(loc) = stmt.kind
3131
&& let hir::PatKind::Binding(ba, _, _, _) = loc.pat.kind
3232
&& let hir::ByRef::Yes(rmutbl) = ba.0

compiler/rustc_hir_analysis/src/check/region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_span::source_map;
2222
use super::errs::{maybe_expr_static_mut, maybe_stmt_static_mut};
2323

2424
#[derive(Debug, Copy, Clone)]
25-
pub struct Context {
25+
struct Context {
2626
/// The scope that contains any new variables declared, plus its depth in
2727
/// the scope tree.
2828
var_parent: Option<(Scope, ScopeDepth)>,
@@ -893,7 +893,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
893893
/// re-use in incremental scenarios. We may sometimes need to rerun the
894894
/// type checker even when the HIR hasn't changed, and in those cases
895895
/// we can avoid reconstructing the region scope tree.
896-
pub fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
896+
pub(crate) fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
897897
let typeck_root_def_id = tcx.typeck_root_def_id(def_id);
898898
if typeck_root_def_id != def_id {
899899
return tcx.region_scope_tree(typeck_root_def_id);

compiler/rustc_hir_analysis/src/check_unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_middle::query::Providers;
55
use rustc_middle::ty::TyCtxt;
66
use rustc_session::lint;
77

8-
pub fn provide(providers: &mut Providers) {
8+
pub(crate) fn provide(providers: &mut Providers) {
99
*providers = Providers { check_unused_traits, ..*providers };
1010
}
1111

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
332332
}
333333
}
334334

335-
pub fn coerce_unsized_info<'tcx>(
335+
pub(crate) fn coerce_unsized_info<'tcx>(
336336
tcx: TyCtxt<'tcx>,
337337
impl_did: LocalDefId,
338338
) -> Result<CoerceUnsizedInfo, ErrorGuaranteed> {

compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_span::ErrorGuaranteed;
1919
use crate::errors;
2020

2121
/// On-demand query: yields a map containing all types mapped to their inherent impls.
22-
pub fn crate_inherent_impls(
22+
pub(crate) fn crate_inherent_impls(
2323
tcx: TyCtxt<'_>,
2424
(): (),
2525
) -> Result<&'_ CrateInherentImpls, ErrorGuaranteed> {
@@ -32,7 +32,7 @@ pub fn crate_inherent_impls(
3232
Ok(tcx.arena.alloc(collect.impls_map))
3333
}
3434

35-
pub fn crate_incoherent_impls(
35+
pub(crate) fn crate_incoherent_impls(
3636
tcx: TyCtxt<'_>,
3737
simp: SimplifiedType,
3838
) -> Result<&[DefId], ErrorGuaranteed> {
@@ -43,7 +43,10 @@ pub fn crate_incoherent_impls(
4343
}
4444

4545
/// On-demand query: yields a vector of the inherent impls for a specific type.
46-
pub fn inherent_impls(tcx: TyCtxt<'_>, ty_def_id: LocalDefId) -> Result<&[DefId], ErrorGuaranteed> {
46+
pub(crate) fn inherent_impls(
47+
tcx: TyCtxt<'_>,
48+
ty_def_id: LocalDefId,
49+
) -> Result<&[DefId], ErrorGuaranteed> {
4750
let crate_map = tcx.crate_inherent_impls(())?;
4851
Ok(match crate_map.inherent_impls.get(&ty_def_id) {
4952
Some(v) => &v[..],

compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ use rustc_span::{ErrorGuaranteed, Symbol};
1111
use rustc_trait_selection::traits::{self, SkipLeakCheck};
1212
use smallvec::SmallVec;
1313

14-
pub fn crate_inherent_impls_overlap_check(tcx: TyCtxt<'_>, (): ()) -> Result<(), ErrorGuaranteed> {
14+
pub(crate) fn crate_inherent_impls_overlap_check(
15+
tcx: TyCtxt<'_>,
16+
(): (),
17+
) -> Result<(), ErrorGuaranteed> {
1518
let mut inherent_overlap_checker = InherentOverlapChecker { tcx };
1619
let mut res = Ok(());
1720
for id in tcx.hir().items() {

compiler/rustc_hir_analysis/src/coherence/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn enforce_empty_impls_for_marker_traits(
123123
.emit())
124124
}
125125

126-
pub fn provide(providers: &mut Providers) {
126+
pub(crate) fn provide(providers: &mut Providers) {
127127
use self::builtin::coerce_unsized_info;
128128
use self::inherent_impls::{crate_incoherent_impls, crate_inherent_impls, inherent_impls};
129129
use self::inherent_impls_overlap::crate_inherent_impls_overlap_check;

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ fn is_late_bound_map(
20712071
}
20722072
}
20732073

2074-
pub fn deny_non_region_late_bound(
2074+
fn deny_non_region_late_bound(
20752075
tcx: TyCtxt<'_>,
20762076
bound_vars: &mut FxIndexMap<LocalDefId, ResolvedArg>,
20772077
where_: &str,

compiler/rustc_hir_analysis/src/collect/type_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ fn check_feature_inherent_assoc_ty(tcx: TyCtxt<'_>, span: Span) {
725725
}
726726
}
727727

728-
pub fn type_alias_is_lazy<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool {
728+
pub(crate) fn type_alias_is_lazy<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool {
729729
use hir::intravisit::Visitor;
730730
if tcx.features().lazy_type_alias {
731731
return true;

compiler/rustc_hir_analysis/src/constrained_generic_params.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_span::Span;
66
use rustc_type_ir::fold::TypeFoldable;
77

88
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
9-
pub struct Parameter(pub u32);
9+
pub(crate) struct Parameter(pub u32);
1010

1111
impl From<ty::ParamTy> for Parameter {
1212
fn from(param: ty::ParamTy) -> Self {
@@ -27,7 +27,7 @@ impl From<ty::ParamConst> for Parameter {
2727
}
2828

2929
/// Returns the set of parameters constrained by the impl header.
30-
pub fn parameters_for_impl<'tcx>(
30+
pub(crate) fn parameters_for_impl<'tcx>(
3131
tcx: TyCtxt<'tcx>,
3232
impl_self_ty: Ty<'tcx>,
3333
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
@@ -44,7 +44,7 @@ pub fn parameters_for_impl<'tcx>(
4444
/// uniquely determined by `value` (see RFC 447). If it is true, return the list
4545
/// of parameters whose values are needed in order to constrain `value` - these
4646
/// differ, with the latter being a superset, in the presence of projections.
47-
pub fn parameters_for<'tcx>(
47+
pub(crate) fn parameters_for<'tcx>(
4848
tcx: TyCtxt<'tcx>,
4949
value: impl TypeFoldable<TyCtxt<'tcx>>,
5050
include_nonconstraining: bool,
@@ -102,7 +102,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ParameterCollector {
102102
}
103103
}
104104

105-
pub fn identify_constrained_generic_params<'tcx>(
105+
pub(crate) fn identify_constrained_generic_params<'tcx>(
106106
tcx: TyCtxt<'tcx>,
107107
predicates: ty::GenericPredicates<'tcx>,
108108
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
@@ -156,7 +156,7 @@ pub fn identify_constrained_generic_params<'tcx>(
156156
/// which is determined by 1, which requires `U`, that is determined
157157
/// by 0. I should probably pick a less tangled example, but I can't
158158
/// think of any.
159-
pub fn setup_constraining_predicates<'tcx>(
159+
pub(crate) fn setup_constraining_predicates<'tcx>(
160160
tcx: TyCtxt<'tcx>,
161161
predicates: &mut [(ty::Clause<'tcx>, Span)],
162162
impl_trait_ref: Option<ty::TraitRef<'tcx>>,

0 commit comments

Comments
 (0)