Skip to content

Commit e306214

Browse files
committed
Add warn(unreachable_pub) to rustc_monomorphize.
1 parent 8a8dd3f commit e306214

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ use tracing::{debug, instrument, trace};
242242
use crate::errors::{self, EncounteredErrorWhileInstantiating, NoOptimizedMir, RecursionLimit};
243243

244244
#[derive(PartialEq)]
245-
pub enum MonoItemCollectionStrategy {
245+
pub(crate) enum MonoItemCollectionStrategy {
246246
Eager,
247247
Lazy,
248248
}
249249

250-
pub struct UsageMap<'tcx> {
250+
pub(crate) struct UsageMap<'tcx> {
251251
// Maps every mono item to the mono items used by it.
252252
used_map: UnordMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>>,
253253

@@ -306,13 +306,17 @@ impl<'tcx> UsageMap<'tcx> {
306306
assert!(self.used_map.insert(user_item, used_items).is_none());
307307
}
308308

309-
pub fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] {
309+
pub(crate) fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] {
310310
self.user_map.get(&item).map(|items| items.as_slice()).unwrap_or(&[])
311311
}
312312

313313
/// Internally iterate over all inlined items used by `item`.
314-
pub fn for_each_inlined_used_item<F>(&self, tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>, mut f: F)
315-
where
314+
pub(crate) fn for_each_inlined_used_item<F>(
315+
&self,
316+
tcx: TyCtxt<'tcx>,
317+
item: MonoItem<'tcx>,
318+
mut f: F,
319+
) where
316320
F: FnMut(MonoItem<'tcx>),
317321
{
318322
let used_items = self.used_map.get(&item).unwrap();
@@ -1615,6 +1619,6 @@ pub(crate) fn collect_crate_mono_items<'tcx>(
16151619
(mono_items, state.usage_map.into_inner())
16161620
}
16171621

1618-
pub fn provide(providers: &mut Providers) {
1622+
pub(crate) fn provide(providers: &mut Providers) {
16191623
providers.hooks.should_codegen_locally = should_codegen_locally;
16201624
}

compiler/rustc_monomorphize/src/errors.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::fluent_generated as fluent;
88

99
#[derive(Diagnostic)]
1010
#[diag(monomorphize_recursion_limit)]
11-
pub struct RecursionLimit {
11+
pub(crate) struct RecursionLimit {
1212
#[primary_span]
1313
pub span: Span,
1414
pub shrunk: String,
@@ -22,13 +22,13 @@ pub struct RecursionLimit {
2222

2323
#[derive(Diagnostic)]
2424
#[diag(monomorphize_no_optimized_mir)]
25-
pub struct NoOptimizedMir {
25+
pub(crate) struct NoOptimizedMir {
2626
#[note]
2727
pub span: Span,
2828
pub crate_name: Symbol,
2929
}
3030

31-
pub struct UnusedGenericParamsHint {
31+
pub(crate) struct UnusedGenericParamsHint {
3232
pub span: Span,
3333
pub param_spans: Vec<Span>,
3434
pub param_names: Vec<String>,
@@ -53,7 +53,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for UnusedGenericParamsHint {
5353
#[derive(LintDiagnostic)]
5454
#[diag(monomorphize_large_assignments)]
5555
#[note]
56-
pub struct LargeAssignmentsLint {
56+
pub(crate) struct LargeAssignmentsLint {
5757
#[label]
5858
pub span: Span,
5959
pub size: u64,
@@ -62,21 +62,21 @@ pub struct LargeAssignmentsLint {
6262

6363
#[derive(Diagnostic)]
6464
#[diag(monomorphize_symbol_already_defined)]
65-
pub struct SymbolAlreadyDefined {
65+
pub(crate) struct SymbolAlreadyDefined {
6666
#[primary_span]
6767
pub span: Option<Span>,
6868
pub symbol: String,
6969
}
7070

7171
#[derive(Diagnostic)]
7272
#[diag(monomorphize_couldnt_dump_mono_stats)]
73-
pub struct CouldntDumpMonoStats {
73+
pub(crate) struct CouldntDumpMonoStats {
7474
pub error: String,
7575
}
7676

7777
#[derive(Diagnostic)]
7878
#[diag(monomorphize_encountered_error_while_instantiating)]
79-
pub struct EncounteredErrorWhileInstantiating {
79+
pub(crate) struct EncounteredErrorWhileInstantiating {
8080
#[primary_span]
8181
pub span: Span,
8282
pub formatted_item: String,
@@ -85,10 +85,10 @@ pub struct EncounteredErrorWhileInstantiating {
8585
#[derive(Diagnostic)]
8686
#[diag(monomorphize_start_not_found)]
8787
#[help]
88-
pub struct StartNotFound;
88+
pub(crate) struct StartNotFound;
8989

9090
#[derive(Diagnostic)]
9191
#[diag(monomorphize_unknown_cgu_collection_mode)]
92-
pub struct UnknownCguCollectionMode<'a> {
92+
pub(crate) struct UnknownCguCollectionMode<'a> {
9393
pub mode: &'a str,
9494
}

compiler/rustc_monomorphize/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// tidy-alphabetical-start
22
#![feature(array_windows)]
3+
#![warn(unreachable_pub)]
34
// tidy-alphabetical-end
45

56
use rustc_hir::lang_items::LangItem;

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ fn dump_mono_items_stats<'tcx>(
13001300
Ok(())
13011301
}
13021302

1303-
pub fn provide(providers: &mut Providers) {
1303+
pub(crate) fn provide(providers: &mut Providers) {
13041304
providers.collect_and_partition_mono_items = collect_and_partition_mono_items;
13051305

13061306
providers.is_codegened_item = |tcx, def_id| {

compiler/rustc_monomorphize/src/polymorphize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use tracing::{debug, instrument};
1919
use crate::errors::UnusedGenericParamsHint;
2020

2121
/// Provide implementations of queries relating to polymorphization analysis.
22-
pub fn provide(providers: &mut Providers) {
22+
pub(crate) fn provide(providers: &mut Providers) {
2323
providers.unused_generic_params = unused_generic_params;
2424
}
2525

0 commit comments

Comments
 (0)