Skip to content

Commit bdacdfe

Browse files
committed
Minimize visibilities.
This makes it much clearer which things are used outside the crate.
1 parent 04a3187 commit bdacdfe

24 files changed

Lines changed: 188 additions & 179 deletions

‎compiler/rustc_codegen_ssa/src/back/archive.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub trait ArchiveBuilderBuilder {
157157
}
158158
}
159159

160-
pubfncreate_mingw_dll_import_lib(
160+
fncreate_mingw_dll_import_lib(
161161
sess:&Session,
162162
lib_name:&str,
163163
import_name_and_ordinal_vector:Vec<(String,Option<u16>)>,

‎compiler/rustc_codegen_ssa/src/back/command.rs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{fmt, io, mem};
88
use rustc_target::spec::LldFlavor;
99

1010
#[derive(Clone)]
11-
pubstructCommand{
11+
pub(crate)structCommand{
1212
program:Program,
1313
args:Vec<OsString>,
1414
env:Vec<(OsString,OsString)>,
@@ -23,28 +23,28 @@ enum Program {
2323
}
2424

2525
implCommand{
26-
pubfnnew<P:AsRef<OsStr>>(program:P) -> Command{
26+
pub(crate)fnnew<P:AsRef<OsStr>>(program:P) -> Command{
2727
Command::_new(Program::Normal(program.as_ref().to_owned()))
2828
}
2929

30-
pubfnbat_script<P:AsRef<OsStr>>(program:P) -> Command{
30+
pub(crate)fnbat_script<P:AsRef<OsStr>>(program:P) -> Command{
3131
Command::_new(Program::CmdBatScript(program.as_ref().to_owned()))
3232
}
3333

34-
pubfnlld<P:AsRef<OsStr>>(program:P,flavor:LldFlavor) -> Command{
34+
pub(crate)fnlld<P:AsRef<OsStr>>(program:P,flavor:LldFlavor) -> Command{
3535
Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
3636
}
3737

3838
fn_new(program:Program) -> Command{
3939
Command{ program,args:Vec::new(),env:Vec::new(),env_remove:Vec::new()}
4040
}
4141

42-
pubfnarg<P:AsRef<OsStr>>(&mutself,arg:P) -> &mutCommand{
42+
pub(crate)fnarg<P:AsRef<OsStr>>(&mutself,arg:P) -> &mutCommand{
4343
self._arg(arg.as_ref());
4444
self
4545
}
4646

47-
pubfnargs<I>(&mutself,args:I) -> &mutCommand
47+
pub(crate)fnargs<I>(&mutself,args:I) -> &mutCommand
4848
where
4949
I:IntoIterator<Item:AsRef<OsStr>>,
5050
{
@@ -58,7 +58,7 @@ impl Command {
5858
self.args.push(arg.to_owned());
5959
}
6060

61-
pubfnenv<K,V>(&mutself,key:K,value:V) -> &mutCommand
61+
pub(crate)fnenv<K,V>(&mutself,key:K,value:V) -> &mutCommand
6262
where
6363
K:AsRef<OsStr>,
6464
V:AsRef<OsStr>,
@@ -71,7 +71,7 @@ impl Command {
7171
self.env.push((key.to_owned(), value.to_owned()));
7272
}
7373

74-
pubfnenv_remove<K>(&mutself,key:K) -> &mutCommand
74+
pub(crate)fnenv_remove<K>(&mutself,key:K) -> &mutCommand
7575
where
7676
K:AsRef<OsStr>,
7777
{
@@ -83,11 +83,11 @@ impl Command {
8383
self.env_remove.push(key.to_owned());
8484
}
8585

86-
pubfnoutput(&mutself) -> io::Result<Output>{
86+
pub(crate)fnoutput(&mutself) -> io::Result<Output>{
8787
self.command().output()
8888
}
8989

90-
pubfncommand(&self) -> process::Command{
90+
pub(crate)fncommand(&self) -> process::Command{
9191
letmut ret = matchself.program{
9292
Program::Normal(ref p) => process::Command::new(p),
9393
Program::CmdBatScript(ref p) => {
@@ -111,17 +111,17 @@ impl Command {
111111

112112
// extensions
113113

114-
pubfnget_args(&self) -> &[OsString]{
114+
pub(crate)fnget_args(&self) -> &[OsString]{
115115
&self.args
116116
}
117117

118-
pubfntake_args(&mutself) -> Vec<OsString>{
118+
pub(crate)fntake_args(&mutself) -> Vec<OsString>{
119119
mem::take(&mutself.args)
120120
}
121121

122122
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
123123
/// or `false` if we should attempt to spawn and see what the OS says.
124-
pubfnvery_likely_to_exceed_some_spawn_limit(&self) -> bool{
124+
pub(crate)fnvery_likely_to_exceed_some_spawn_limit(&self) -> bool{
125125
// We mostly only care about Windows in this method, on Unix the limits
126126
// can be gargantuan anyway so we're pretty unlikely to hit them
127127
ifcfg!(unix){

‎compiler/rustc_codegen_ssa/src/back/linker.rs‎

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::errors;
2828
/// and prevent inspection of linker output in case of errors, which we occasionally do.
2929
/// This should be acceptable because other messages from rustc are in English anyway,
3030
/// and may also be desirable to improve searchability of the linker diagnostics.
31-
pubfndisable_localization(linker:&mutCommand){
31+
pub(crate)fndisable_localization(linker:&mutCommand){
3232
// No harm in setting both env vars simultaneously.
3333
// Unix-style linkers.
3434
linker.env("LC_ALL","C");
@@ -39,7 +39,7 @@ pub fn disable_localization(linker: &mut Command) {
3939
/// The third parameter is for env vars, used on windows to set up the
4040
/// path for MSVC to find its DLLs, and gcc to find its bundled
4141
/// toolchain
42-
pubfnget_linker<'a>(
42+
pub(crate)fnget_linker<'a>(
4343
sess:&'aSession,
4444
linker:&Path,
4545
flavor:LinkerFlavor,
@@ -213,28 +213,36 @@ fn link_or_cc_args<L: Linker + ?Sized>(
213213
macro_rules! generate_arg_methods {
214214
($($ty:ty)*) => { $(
215215
impl $ty {
216-
pubfn verbatim_args(&mutself, args:implIntoIterator<Item:AsRef<OsStr>>) -> &mutSelf{
216+
#[allow(unused)]
217+
pub(crate)fn verbatim_args(&mutself, args:implIntoIterator<Item:AsRef<OsStr>>) -> &mutSelf{
217218
verbatim_args(self, args)
218219
}
219-
pubfn verbatim_arg(&mutself, arg:implAsRef<OsStr>) -> &mutSelf{
220+
#[allow(unused)]
221+
pub(crate)fn verbatim_arg(&mutself, arg:implAsRef<OsStr>) -> &mutSelf{
220222
verbatim_args(self, iter::once(arg))
221223
}
222-
pubfn link_args(&mutself, args:implIntoIterator<Item:AsRef<OsStr>,IntoIter:ExactSizeIterator>) -> &mutSelf{
224+
#[allow(unused)]
225+
pub(crate)fn link_args(&mutself, args:implIntoIterator<Item:AsRef<OsStr>,IntoIter:ExactSizeIterator>) -> &mutSelf{
223226
link_args(self, args)
224227
}
225-
pubfn link_arg(&mutself, arg:implAsRef<OsStr>) -> &mutSelf{
228+
#[allow(unused)]
229+
pub(crate)fn link_arg(&mutself, arg:implAsRef<OsStr>) -> &mutSelf{
226230
link_args(self, iter::once(arg))
227231
}
228-
pubfn cc_args(&mutself, args:implIntoIterator<Item:AsRef<OsStr>>) -> &mutSelf{
232+
#[allow(unused)]
233+
pub(crate)fn cc_args(&mutself, args:implIntoIterator<Item:AsRef<OsStr>>) -> &mutSelf{
229234
cc_args(self, args)
230235
}
231-
pubfn cc_arg(&mutself, arg:implAsRef<OsStr>) -> &mutSelf{
236+
#[allow(unused)]
237+
pub(crate)fn cc_arg(&mutself, arg:implAsRef<OsStr>) -> &mutSelf{
232238
cc_args(self, iter::once(arg))
233239
}
234-
pubfn link_or_cc_args(&mutself, args:implIntoIterator<Item:AsRef<OsStr>>) -> &mutSelf{
240+
#[allow(unused)]
241+
pub(crate)fn link_or_cc_args(&mutself, args:implIntoIterator<Item:AsRef<OsStr>>) -> &mutSelf{
235242
link_or_cc_args(self, args)
236243
}
237-
pubfn link_or_cc_arg(&mutself, arg:implAsRef<OsStr>) -> &mutSelf{
244+
#[allow(unused)]
245+
pub(crate)fn link_or_cc_arg(&mutself, arg:implAsRef<OsStr>) -> &mutSelf{
238246
link_or_cc_args(self, iter::once(arg))
239247
}
240248
}
@@ -261,7 +269,7 @@ generate_arg_methods! {
261269
/// represents the meaning of each option being passed down. This trait is then
262270
/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
263271
/// MSVC linker (e.g., `link.exe`) is being used.
264-
pubtraitLinker{
272+
pub(crate)traitLinker{
265273
fncmd(&mutself) -> &mutCommand;
266274
fnis_cc(&self) -> bool{
267275
false
@@ -312,12 +320,12 @@ pub trait Linker {
312320
}
313321

314322
impldynLinker + '_{
315-
pubfntake_cmd(&mutself) -> Command{
323+
pub(crate)fntake_cmd(&mutself) -> Command{
316324
mem::replace(self.cmd(),Command::new(""))
317325
}
318326
}
319327

320-
pubstructGccLinker<'a>{
328+
structGccLinker<'a>{
321329
cmd:Command,
322330
sess:&'aSession,
323331
target_cpu:&'astr,
@@ -847,7 +855,7 @@ impl<'a> Linker for GccLinker<'a> {
847855
}
848856
}
849857

850-
pubstructMsvcLinker<'a>{
858+
structMsvcLinker<'a>{
851859
cmd:Command,
852860
sess:&'aSession,
853861
}
@@ -1095,7 +1103,7 @@ impl<'a> Linker for MsvcLinker<'a> {
10951103
}
10961104
}
10971105

1098-
pubstructEmLinker<'a>{
1106+
structEmLinker<'a>{
10991107
cmd:Command,
11001108
sess:&'aSession,
11011109
}
@@ -1212,7 +1220,7 @@ impl<'a> Linker for EmLinker<'a> {
12121220
}
12131221
}
12141222

1215-
pubstructWasmLd<'a>{
1223+
structWasmLd<'a>{
12161224
cmd:Command,
12171225
sess:&'aSession,
12181226
}
@@ -1396,7 +1404,7 @@ impl<'a> WasmLd<'a> {
13961404
}
13971405

13981406
/// Linker shepherd script for L4Re (Fiasco)
1399-
pubstructL4Bender<'a>{
1407+
structL4Bender<'a>{
14001408
cmd:Command,
14011409
sess:&'aSession,
14021410
hinted_static:bool,
@@ -1502,7 +1510,7 @@ impl<'a> Linker for L4Bender<'a> {
15021510
}
15031511

15041512
impl<'a>L4Bender<'a>{
1505-
pubfnnew(cmd:Command,sess:&'aSession) -> L4Bender<'a>{
1513+
fnnew(cmd:Command,sess:&'aSession) -> L4Bender<'a>{
15061514
L4Bender{ cmd, sess,hinted_static:false}
15071515
}
15081516

@@ -1515,14 +1523,14 @@ impl<'a> L4Bender<'a> {
15151523
}
15161524

15171525
/// Linker for AIX.
1518-
pubstructAixLinker<'a>{
1526+
structAixLinker<'a>{
15191527
cmd:Command,
15201528
sess:&'aSession,
15211529
hinted_static:Option<bool>,
15221530
}
15231531

15241532
impl<'a>AixLinker<'a>{
1525-
pubfnnew(cmd:Command,sess:&'aSession) -> AixLinker<'a>{
1533+
fnnew(cmd:Command,sess:&'aSession) -> AixLinker<'a>{
15261534
AixLinker{ cmd, sess,hinted_static:None}
15271535
}
15281536

@@ -1750,7 +1758,7 @@ pub(crate) fn linked_symbols(
17501758

17511759
/// Much simplified and explicit CLI for the NVPTX linker. The linker operates
17521760
/// with bitcode and uses LLVM backend to generate a PTX assembly.
1753-
pubstructPtxLinker<'a>{
1761+
structPtxLinker<'a>{
17541762
cmd:Command,
17551763
sess:&'aSession,
17561764
}
@@ -1816,7 +1824,7 @@ impl<'a> Linker for PtxLinker<'a> {
18161824
}
18171825

18181826
/// The `self-contained` LLVM bitcode linker
1819-
pubstructLlbcLinker<'a>{
1827+
structLlbcLinker<'a>{
18201828
cmd:Command,
18211829
sess:&'aSession,
18221830
}
@@ -1887,7 +1895,7 @@ impl<'a> Linker for LlbcLinker<'a> {
18871895
fnlinker_plugin_lto(&mutself){}
18881896
}
18891897

1890-
pubstructBpfLinker<'a>{
1898+
structBpfLinker<'a>{
18911899
cmd:Command,
18921900
sess:&'aSession,
18931901
}

‎compiler/rustc_codegen_ssa/src/back/metadata.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc_target::spec::{ef_avr_arch, RelocModel, Target};
3232
/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd>
3333
/// </dl>
3434
#[derive(Debug)]
35-
pubstructDefaultMetadataLoader;
35+
pub(crate)structDefaultMetadataLoader;
3636

3737
staticAIX_METADATA_SYMBOL_NAME:&'staticstr = "__aix_rust_metadata";
3838

@@ -416,7 +416,7 @@ fn macho_is_arm64e(target: &Target) -> bool {
416416
target.llvm_target.starts_with("arm64e")
417417
}
418418

419-
pubenumMetadataPosition{
419+
pub(crate)enumMetadataPosition{
420420
First,
421421
Last,
422422
}
@@ -452,7 +452,7 @@ pub enum MetadataPosition {
452452
/// * ELF - All other targets are similar to Windows in that there's a
453453
/// `SHF_EXCLUDE` flag we can set on sections in an object file to get
454454
/// automatically removed from the final output.
455-
pubfncreate_wrapper_file(
455+
pub(crate)fncreate_wrapper_file(
456456
sess:&Session,
457457
section_name:String,
458458
data:&[u8],
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pubmod archive;
2-
pubmod command;
2+
pub(crate)mod command;
33
pubmod link;
4-
pubmod linker;
4+
pub(crate)mod linker;
55
pubmod lto;
66
pubmod metadata;
7-
pubmod rpath;
7+
pub(crate)mod rpath;
88
pubmod symbol_export;
99
pubmod write;

‎compiler/rustc_codegen_ssa/src/back/rpath.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ use rustc_data_structures::fx::FxHashSet;
66
use rustc_fs_util::try_canonicalize;
77
use tracing::debug;
88

9-
pubstructRPathConfig<'a>{
9+
pub(super)structRPathConfig<'a>{
1010
publibs:&'a[&'aPath],
1111
pubout_filename:PathBuf,
1212
pubis_like_osx:bool,
1313
publinker_is_gnu:bool,
1414
}
1515

16-
pubfnget_rpath_flags(config:&RPathConfig<'_>) -> Vec<OsString>{
16+
pub(super)fnget_rpath_flags(config:&RPathConfig<'_>) -> Vec<OsString>{
1717
debug!("preparing the RPATH!");
1818

1919
let rpaths = get_rpaths(config);

‎compiler/rustc_codegen_ssa/src/back/symbol_export.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use tracing::debug;
1818

1919
usecrate::base::allocator_kind_for_codegen;
2020

21-
pubfnthreshold(tcx:TyCtxt<'_>) -> SymbolExportLevel{
21+
fnthreshold(tcx:TyCtxt<'_>) -> SymbolExportLevel{
2222
crates_export_threshold(tcx.crate_types())
2323
}
2424

@@ -484,7 +484,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId)
484484
!tcx.reachable_set(()).contains(&def_id)
485485
}
486486

487-
pubfnprovide(providers:&mutProviders){
487+
pub(crate)fnprovide(providers:&mutProviders){
488488
providers.reachable_non_generics = reachable_non_generics_provider;
489489
providers.is_reachable_non_generic = is_reachable_non_generic_provider_local;
490490
providers.exported_symbols = exported_symbols_provider_local;
@@ -525,7 +525,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
525525
}
526526

527527
/// This is the symbol name of the given instance instantiated in a specific crate.
528-
pubfnsymbol_name_for_instance_in_crate<'tcx>(
528+
pub(crate)fnsymbol_name_for_instance_in_crate<'tcx>(
529529
tcx:TyCtxt<'tcx>,
530530
symbol:ExportedSymbol<'tcx>,
531531
instantiating_crate:CrateNum,
@@ -582,7 +582,7 @@ pub fn symbol_name_for_instance_in_crate<'tcx>(
582582
/// This is the symbol name of the given instance as seen by the linker.
583583
///
584584
/// On 32-bit Windows symbols are decorated according to their calling conventions.
585-
pubfnlinking_symbol_name_for_instance_in_crate<'tcx>(
585+
pub(crate)fnlinking_symbol_name_for_instance_in_crate<'tcx>(
586586
tcx:TyCtxt<'tcx>,
587587
symbol:ExportedSymbol<'tcx>,
588588
instantiating_crate:CrateNum,
@@ -661,7 +661,7 @@ pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
661661
format!("{prefix}{undecorated}{suffix}{args_in_bytes}")
662662
}
663663

664-
pubfnexporting_symbol_name_for_instance_in_crate<'tcx>(
664+
pub(crate)fnexporting_symbol_name_for_instance_in_crate<'tcx>(
665665
tcx:TyCtxt<'tcx>,
666666
symbol:ExportedSymbol<'tcx>,
667667
cnum:CrateNum,

0 commit comments

Comments
 (0)