Skip to content

Commit 1d1dc48

Browse files
committed
codegen_llvm_back: whitespace & formatting fixes
1 parent 06118ea commit 1d1dc48

File tree

7 files changed

+53
-62
lines changed

7 files changed

+53
-62
lines changed

src/librustc_codegen_llvm/back/archive.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl<'a> ArchiveBuilder<'a> {
8383
if self.src_archive().is_none() {
8484
return Vec::new()
8585
}
86+
8687
let archive = self.src_archive.as_ref().unwrap().as_ref().unwrap();
8788
let ret = archive.iter()
8889
.filter_map(|child| child.ok())

src/librustc_codegen_llvm/back/link.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ use std::str;
4747
use syntax::attr;
4848

4949
pub use rustc_codegen_utils::link::{find_crate_name, filename_for_input, default_output_for_target,
50-
invalid_output_for_target, out_filename, check_file_is_writeable,
51-
filename_for_metadata};
50+
invalid_output_for_target, filename_for_metadata,
51+
out_filename, check_file_is_writeable};
5252

5353
// The third parameter is for env vars, used on windows to set up the
5454
// path for MSVC to find its DLLs, and gcc to find its bundled
@@ -147,9 +147,7 @@ pub(crate) fn link_binary(sess: &Session,
147147

148148
// Remove the temporary object file and metadata if we aren't saving temps
149149
if !sess.opts.cg.save_temps {
150-
if sess.opts.output_types.should_codegen() &&
151-
!preserve_objects_for_their_debuginfo(sess)
152-
{
150+
if sess.opts.output_types.should_codegen() && !preserve_objects_for_their_debuginfo(sess) {
153151
for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) {
154152
remove(sess, obj);
155153
}
@@ -814,8 +812,8 @@ fn link_natively(sess: &Session,
814812
.unwrap_or_else(|_| {
815813
let mut x = "Non-UTF-8 output: ".to_string();
816814
x.extend(s.iter()
817-
.flat_map(|&b| ascii::escape_default(b))
818-
.map(|b| char::from_u32(b as u32).unwrap()));
815+
.flat_map(|&b| ascii::escape_default(b))
816+
.map(|b| char::from_u32(b as u32).unwrap()));
819817
x
820818
})
821819
}
@@ -1012,8 +1010,7 @@ fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: &
10121010
// ensure the line is interpreted as one whole argument.
10131011
for c in self.arg.chars() {
10141012
match c {
1015-
'\\' |
1016-
' ' => write!(f, "\\{}", c)?,
1013+
'\\' | ' ' => write!(f, "\\{}", c)?,
10171014
c => write!(f, "{}", c)?,
10181015
}
10191016
}

src/librustc_codegen_llvm/back/lto.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ pub(crate) fn run(cgcx: &CodegenContext,
205205
Lto::Fat => {
206206
assert!(cached_modules.is_empty());
207207
let opt_jobs = fat_lto(cgcx,
208-
&diag_handler,
209-
modules,
210-
upstream_modules,
211-
&symbol_white_list,
212-
timeline);
208+
&diag_handler,
209+
modules,
210+
upstream_modules,
211+
&symbol_white_list,
212+
timeline);
213213
opt_jobs.map(|opt_jobs| (opt_jobs, vec![]))
214214
}
215215
Lto::Thin |
@@ -310,8 +310,8 @@ fn fat_lto(cgcx: &CodegenContext,
310310
unsafe {
311311
let ptr = symbol_white_list.as_ptr();
312312
llvm::LLVMRustRunRestrictionPass(llmod,
313-
ptr as *const *const libc::c_char,
314-
symbol_white_list.len() as libc::size_t);
313+
ptr as *const *const libc::c_char,
314+
symbol_white_list.len() as libc::size_t);
315315
cgcx.save_temp_bitcode(&module, "lto.after-restriction");
316316
}
317317

@@ -617,8 +617,7 @@ fn run_pass_manager(cgcx: &CodegenContext,
617617
llvm::LLVMRustAddPass(pm, pass.unwrap());
618618
}
619619

620-
time_ext(cgcx.time_passes, None, "LTO passes", ||
621-
llvm::LLVMRunPassManager(pm, llmod));
620+
time_ext(cgcx.time_passes, None, "LTO passes", || llvm::LLVMRunPassManager(pm, llmod));
622621

623622
llvm::LLVMDisposePassManager(pm);
624623
}

src/librustc_codegen_llvm/back/rpath.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ fn get_rpath_relative_to_output(config: &mut RPathConfig, lib: &Path) -> String
117117
let relative = path_relative_from(&lib, &output).unwrap_or_else(||
118118
panic!("couldn't create relative path from {:?} to {:?}", output, lib));
119119
// FIXME (#9639): This needs to handle non-utf8 paths
120-
format!("{}/{}", prefix,
121-
relative.to_str().expect("non-utf8 component in path"))
120+
format!("{}/{}", prefix, relative.to_str().expect("non-utf8 component in path"))
122121
}
123122

124123
// This routine is adapted from the *old* Path's `path_relative_from`

src/librustc_codegen_llvm/back/write.rs

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ pub fn write_output_file(
106106
file_type: llvm::FileType) -> Result<(), FatalError> {
107107
unsafe {
108108
let output_c = path2cstr(output);
109-
let result = llvm::LLVMRustWriteOutputFile(
110-
target, pm, m, output_c.as_ptr(), file_type);
109+
let result = llvm::LLVMRustWriteOutputFile(target, pm, m, output_c.as_ptr(), file_type);
111110
if result.into_result().is_err() {
112111
let msg = format!("could not write output to {}", output.display());
113112
Err(llvm_err(handler, msg))
@@ -590,8 +589,7 @@ unsafe fn optimize(cgcx: &CodegenContext,
590589

591590
for pass in &config.passes {
592591
if !addpass(pass) {
593-
diag_handler.warn(&format!("unknown pass `{}`, ignoring",
594-
pass));
592+
diag_handler.warn(&format!("unknown pass `{}`, ignoring", pass));
595593
}
596594
if pass == "name-anon-globals" {
597595
have_name_anon_globals_pass = true;
@@ -601,8 +599,8 @@ unsafe fn optimize(cgcx: &CodegenContext,
601599
for pass in &cgcx.plugin_passes {
602600
if !addpass(pass) {
603601
diag_handler.err(&format!("a plugin asked for LLVM pass \
604-
`{}` but LLVM does not \
605-
recognize it", pass));
602+
`{}` but LLVM does not \
603+
recognize it", pass));
606604
}
607605
if pass == "name-anon-globals" {
608606
have_name_anon_globals_pass = true;
@@ -613,12 +611,12 @@ unsafe fn optimize(cgcx: &CodegenContext,
613611
// As described above, this will probably cause an error in LLVM
614612
if config.no_prepopulate_passes {
615613
diag_handler.err("The current compilation is going to use thin LTO buffers \
616-
without running LLVM's NameAnonGlobals pass. \
617-
This will likely cause errors in LLVM. Consider adding \
618-
-C passes=name-anon-globals to the compiler command line.");
614+
without running LLVM's NameAnonGlobals pass. \
615+
This will likely cause errors in LLVM. Consider adding \
616+
-C passes=name-anon-globals to the compiler command line.");
619617
} else {
620618
bug!("We are using thin LTO buffers without running the NameAnonGlobals pass. \
621-
This will likely cause errors in LLVM and should never happen.");
619+
This will likely cause errors in LLVM and should never happen.");
622620
}
623621
}
624622
}
@@ -704,9 +702,9 @@ unsafe fn codegen(cgcx: &CodegenContext,
704702
// escape the closure itself, and the manager should only be
705703
// used once.
706704
unsafe fn with_codegen<'ll, F, R>(tm: &'ll llvm::TargetMachine,
707-
llmod: &'ll llvm::Module,
708-
no_builtins: bool,
709-
f: F) -> R
705+
llmod: &'ll llvm::Module,
706+
no_builtins: bool,
707+
f: F) -> R
710708
where F: FnOnce(&'ll mut PassManager<'ll>) -> R,
711709
{
712710
let cpm = llvm::LLVMCreatePassManager();
@@ -818,15 +816,15 @@ unsafe fn codegen(cgcx: &CodegenContext,
818816
};
819817
with_codegen(tm, llmod, config.no_builtins, |cpm| {
820818
write_output_file(diag_handler, tm, cpm, llmod, &path,
821-
llvm::FileType::AssemblyFile)
819+
llvm::FileType::AssemblyFile)
822820
})?;
823821
timeline.record("asm");
824822
}
825823

826824
if write_obj {
827825
with_codegen(tm, llmod, config.no_builtins, |cpm| {
828826
write_output_file(diag_handler, tm, cpm, llmod, &obj_out,
829-
llvm::FileType::ObjectFile)
827+
llvm::FileType::ObjectFile)
830828
})?;
831829
timeline.record("obj");
832830
} else if asm_to_obj {
@@ -947,11 +945,11 @@ fn need_pre_thin_lto_bitcode_for_incr_comp(sess: &Session) -> bool {
947945
}
948946

949947
pub fn start_async_codegen(tcx: TyCtxt,
950-
time_graph: Option<TimeGraph>,
951-
metadata: EncodedMetadata,
952-
coordinator_receive: Receiver<Box<dyn Any + Send>>,
953-
total_cgus: usize)
954-
-> OngoingCodegen {
948+
time_graph: Option<TimeGraph>,
949+
metadata: EncodedMetadata,
950+
coordinator_receive: Receiver<Box<dyn Any + Send>>,
951+
total_cgus: usize)
952+
-> OngoingCodegen {
955953
let sess = tcx.sess;
956954
let crate_name = tcx.crate_name(LOCAL_CRATE);
957955
let crate_hash = tcx.crate_hash(LOCAL_CRATE);
@@ -1116,7 +1114,8 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
11161114
}
11171115

11181116
if let Some((id, product)) =
1119-
copy_cgu_workproducts_to_incr_comp_cache_dir(sess, &module.name, &files) {
1117+
copy_cgu_workproducts_to_incr_comp_cache_dir(sess, &module.name, &files)
1118+
{
11201119
work_products.insert(id, product);
11211120
}
11221121
}
@@ -1584,10 +1583,8 @@ fn start_executing_work(tcx: TyCtxt,
15841583

15851584
let (name, mut cmd) = get_linker(sess, &linker, flavor);
15861585
cmd.args(&sess.target.target.options.asm_args);
1587-
Some(Arc::new(AssemblerCommand {
1588-
name,
1589-
cmd,
1590-
}))
1586+
1587+
Some(Arc::new(AssemblerCommand { name, cmd }))
15911588
} else {
15921589
None
15931590
};
@@ -2186,9 +2183,9 @@ pub fn run_assembler(cgcx: &CodegenContext, handler: &Handler, assembly: &Path,
21862183
handler.struct_err(&format!("linking with `{}` failed: {}",
21872184
pname.display(),
21882185
prog.status))
2189-
.note(&format!("{:?}", &cmd))
2190-
.note(str::from_utf8(&note[..]).unwrap())
2191-
.emit();
2186+
.note(&format!("{:?}", &cmd))
2187+
.note(str::from_utf8(&note[..]).unwrap())
2188+
.emit();
21922189
handler.abort_if_errors();
21932190
}
21942191
},
@@ -2450,8 +2447,8 @@ impl OngoingCodegen {
24502447
}
24512448

24522449
pub(crate) fn submit_pre_codegened_module_to_llvm(&self,
2453-
tcx: TyCtxt,
2454-
module: ModuleCodegen) {
2450+
tcx: TyCtxt,
2451+
module: ModuleCodegen) {
24552452
self.wait_for_signal_to_codegen_item();
24562453
self.check_for_errors(tcx.sess);
24572454

src/librustc_codegen_utils/linker.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ impl<'a> GccLinker<'a> {
224224
}
225225

226226
impl<'a> Linker for GccLinker<'a> {
227-
fn link_dylib(&mut self, lib: &str) { self.hint_dynamic(); self.cmd.arg(format!("-l{}",lib)); }
227+
fn link_dylib(&mut self, lib: &str) { self.hint_dynamic(); self.cmd.arg(format!("-l{}", lib)); }
228228
fn link_staticlib(&mut self, lib: &str) {
229-
self.hint_static(); self.cmd.arg(format!("-l{}",lib));
229+
self.hint_static(); self.cmd.arg(format!("-l{}", lib));
230230
}
231231
fn link_rlib(&mut self, lib: &Path) { self.hint_static(); self.cmd.arg(lib); }
232232
fn include_path(&mut self, path: &Path) { self.cmd.arg("-L").arg(path); }
@@ -243,7 +243,7 @@ impl<'a> Linker for GccLinker<'a> {
243243

244244
fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
245245
self.hint_dynamic();
246-
self.cmd.arg(format!("-l{}",lib));
246+
self.cmd.arg(format!("-l{}", lib));
247247
}
248248

249249
fn link_framework(&mut self, framework: &str) {
@@ -261,7 +261,7 @@ impl<'a> Linker for GccLinker<'a> {
261261
self.hint_static();
262262
let target = &self.sess.target.target;
263263
if !target.options.is_like_osx {
264-
self.linker_arg("--whole-archive").cmd.arg(format!("-l{}",lib));
264+
self.linker_arg("--whole-archive").cmd.arg(format!("-l{}", lib));
265265
self.linker_arg("--no-whole-archive");
266266
} else {
267267
// -force_load is the macOS equivalent of --whole-archive, but it
@@ -373,8 +373,7 @@ impl<'a> Linker for GccLinker<'a> {
373373
// purely to support rustbuild right now, we should get a more
374374
// principled solution at some point to force the compiler to pass
375375
// the right `-Wl,-install_name` with an `@rpath` in it.
376-
if self.sess.opts.cg.rpath ||
377-
self.sess.opts.debugging_opts.osx_rpath_install_name {
376+
if self.sess.opts.cg.rpath || self.sess.opts.debugging_opts.osx_rpath_install_name {
378377
self.linker_arg("-install_name");
379378
let mut v = OsString::from("@rpath/");
380379
v.push(out_filename.file_name().unwrap());

src/librustc_codegen_utils/symbol_export.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ fn crate_export_threshold(crate_type: config::CrateType) -> SymbolExportLevel {
4747
}
4848
}
4949

50-
pub fn crates_export_threshold(crate_types: &[config::CrateType])
51-
-> SymbolExportLevel {
52-
if crate_types.iter().any(|&crate_type| {
53-
crate_export_threshold(crate_type) == SymbolExportLevel::Rust
54-
}) {
50+
pub fn crates_export_threshold(crate_types: &[config::CrateType]) -> SymbolExportLevel {
51+
if crate_types.iter().any(|&crate_type|
52+
crate_export_threshold(crate_type) == SymbolExportLevel::Rust)
53+
{
5554
SymbolExportLevel::Rust
5655
} else {
5756
SymbolExportLevel::C
@@ -359,7 +358,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt, def_id: DefId) -> bool
359358
!tcx.reachable_set(LOCAL_CRATE).0.contains(&node_id)
360359
} else {
361360
bug!("is_unreachable_local_definition called with non-local DefId: {:?}",
362-
def_id)
361+
def_id)
363362
}
364363
}
365364

0 commit comments

Comments
 (0)