Skip to content

Commit b03a82c

Browse files
committed
rustc/driver: whitespace & formatting fixes
1 parent d838a7f commit b03a82c

File tree

5 files changed

+87
-86
lines changed

5 files changed

+87
-86
lines changed

src/librustc_driver/driver.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@ where
10211021
.cloned()
10221022
.collect();
10231023
missing_fragment_specifiers.sort();
1024+
10241025
for span in missing_fragment_specifiers {
10251026
let lint = lint::builtin::MISSING_FRAGMENT_SPECIFIER;
10261027
let msg = "missing fragment specifier";
@@ -1517,6 +1518,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
15171518
Symbol::intern("proc-macro"),
15181519
Symbol::intern("bin")
15191520
];
1521+
15201522
if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().node {
15211523
let span = spanned.span;
15221524
let lev_candidate = find_best_match_for_name(
@@ -1587,12 +1589,12 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
15871589
base.retain(|crate_type| {
15881590
let res = !::rustc_codegen_utils::link::invalid_output_for_target(session, *crate_type);
15891591

1590-
if !res {
1591-
session.warn(&format!(
1592-
"dropping unsupported crate type `{}` for target `{}`",
1593-
*crate_type, session.opts.target_triple
1594-
));
1595-
}
1592+
if !res {
1593+
session.warn(&format!(
1594+
"dropping unsupported crate type `{}` for target `{}`",
1595+
*crate_type, session.opts.target_triple
1596+
));
1597+
}
15961598

15971599
res
15981600
});

src/librustc_driver/lib.rs

+20-24
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,16 @@ pub fn run<F>(run_compiler: F) -> isize
188188
}
189189
None => {
190190
let emitter =
191-
errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
192-
None,
193-
true,
194-
false);
191+
errors::emitter::EmitterWriter::stderr(
192+
errors::ColorConfig::Auto,
193+
None,
194+
true,
195+
false
196+
);
195197
let handler = errors::Handler::with_emitter(true, false, Box::new(emitter));
196198
handler.emit(&MultiSpan::new(),
197-
"aborting due to previous error(s)",
198-
errors::Level::Fatal);
199+
"aborting due to previous error(s)",
200+
errors::Level::Fatal);
199201
panic::resume_unwind(Box::new(errors::FatalErrorMarker));
200202
}
201203
}
@@ -316,9 +318,8 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
316318
let sysroot = sysroot_candidates.iter()
317319
.map(|sysroot| {
318320
let libdir = filesearch::relative_target_lib_path(&sysroot, &target);
319-
sysroot.join(libdir)
320-
.with_file_name(option_env!("CFG_CODEGEN_BACKENDS_DIR")
321-
.unwrap_or("codegen-backends"))
321+
sysroot.join(libdir).with_file_name(
322+
option_env!("CFG_CODEGEN_BACKENDS_DIR").unwrap_or("codegen-backends"))
322323
})
323324
.filter(|f| {
324325
info!("codegen backend candidate: {}", f.display());
@@ -360,8 +361,8 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
360361
}
361362
if let Some(ref prev) = file {
362363
let err = format!("duplicate codegen backends found\n\
363-
first: {}\n\
364-
second: {}\n\
364+
first: {}\n\
365+
second: {}\n\
365366
", prev.display(), path.display());
366367
early_error(ErrorOutputType::default(), &err);
367368
}
@@ -373,7 +374,7 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
373374
None => {
374375
let err = format!("failed to load default codegen backend for `{}`, \
375376
no appropriate codegen dylib found in `{}`",
376-
backend_name, sysroot.display());
377+
backend_name, sysroot.display());
377378
early_error(ErrorOutputType::default(), &err);
378379
}
379380
}
@@ -1010,7 +1011,7 @@ impl RustcDefaultCalls {
10101011
use rustc::session::config::PrintRequest::*;
10111012
// PrintRequest::NativeStaticLibs is special - printed during linking
10121013
// (empty iterator returns true)
1013-
if sess.opts.prints.iter().all(|&p| p==PrintRequest::NativeStaticLibs) {
1014+
if sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs) {
10141015
return Compilation::Continue;
10151016
}
10161017

@@ -1054,10 +1055,7 @@ impl RustcDefaultCalls {
10541055
&id,
10551056
&t_outputs
10561057
);
1057-
println!("{}",
1058-
fname.file_name()
1059-
.unwrap()
1060-
.to_string_lossy());
1058+
println!("{}", fname.file_name().unwrap().to_string_lossy());
10611059
}
10621060
}
10631061
Cfg => {
@@ -1129,9 +1127,8 @@ fn commit_date_str() -> Option<&'static str> {
11291127
pub fn version(binary: &str, matches: &getopts::Matches) {
11301128
let verbose = matches.opt_present("verbose");
11311129

1132-
println!("{} {}",
1133-
binary,
1134-
option_env!("CFG_VERSION").unwrap_or("unknown version"));
1130+
println!("{} {}", binary, option_env!("CFG_VERSION").unwrap_or("unknown version"));
1131+
11351132
if verbose {
11361133
fn unw(x: Option<&str>) -> &str {
11371134
x.unwrap_or("unknown")
@@ -1252,8 +1249,6 @@ Available lint options:
12521249

12531250
print_lints(builtin);
12541251

1255-
1256-
12571252
let max_name_len = max("warnings".len(),
12581253
plugin_groups.iter()
12591254
.chain(&builtin_groups)
@@ -1429,6 +1424,7 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
14291424
}
14301425

14311426
let cg_flags = matches.opt_strs("C");
1427+
14321428
if cg_flags.iter().any(|x| *x == "help") {
14331429
describe_codegen_flags();
14341430
return None;
@@ -1477,7 +1473,7 @@ pub fn in_named_rustc_thread<F, R>(name: String, f: F) -> Result<R, Box<dyn Any
14771473
// Temporarily have stack size set to 16MB to deal with nom-using crates failing
14781474
const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB
14791475

1480-
#[cfg(all(unix,not(target_os = "haiku")))]
1476+
#[cfg(all(unix, not(target_os = "haiku")))]
14811477
let spawn_thread = unsafe {
14821478
// Fetch the current resource limits
14831479
let mut rlim = libc::rlimit {
@@ -1531,7 +1527,7 @@ pub fn in_named_rustc_thread<F, R>(name: String, f: F) -> Result<R, Box<dyn Any
15311527
}
15321528
};
15331529

1534-
#[cfg(not(any(windows,unix)))]
1530+
#[cfg(not(any(windows, unix)))]
15351531
let spawn_thread = true;
15361532

15371533
// The or condition is added from backward compatibility.

src/librustc_driver/pretty.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ pub fn parse_pretty(sess: &Session,
167167
impl PpSourceMode {
168168
/// Constructs a `PrinterSupport` object and passes it to `f`.
169169
fn call_with_pp_support<'tcx, A, F>(&self,
170-
sess: &'tcx Session,
171-
hir_map: Option<&hir_map::Map<'tcx>>,
172-
f: F)
173-
-> A
170+
sess: &'tcx Session,
171+
hir_map: Option<&hir_map::Map<'tcx>>,
172+
f: F)
173+
-> A
174174
where F: FnOnce(&dyn PrinterSupport) -> A
175175
{
176176
match *self {
@@ -198,17 +198,18 @@ impl PpSourceMode {
198198
_ => panic!("Should use call_with_pp_support_hir"),
199199
}
200200
}
201-
fn call_with_pp_support_hir<'tcx, A, F>(&self,
202-
sess: &'tcx Session,
203-
cstore: &'tcx CStore,
204-
hir_map: &hir_map::Map<'tcx>,
205-
analysis: &ty::CrateAnalysis,
206-
resolutions: &Resolutions,
207-
arenas: &'tcx AllArenas<'tcx>,
208-
output_filenames: &OutputFilenames,
209-
id: &str,
210-
f: F)
211-
-> A
201+
fn call_with_pp_support_hir<'tcx, A, F>(
202+
&self,
203+
sess: &'tcx Session,
204+
cstore: &'tcx CStore,
205+
hir_map: &hir_map::Map<'tcx>,
206+
analysis: &ty::CrateAnalysis,
207+
resolutions: &Resolutions,
208+
arenas: &'tcx AllArenas<'tcx>,
209+
output_filenames: &OutputFilenames,
210+
id: &str,
211+
f: F
212+
) -> A
212213
where F: FnOnce(&dyn HirPrinterSupport, &hir::Crate) -> A
213214
{
214215
match *self {
@@ -952,18 +953,17 @@ pub fn print_after_parsing(sess: &Session,
952953
// Silently ignores an identified node.
953954
let out: &mut dyn Write = &mut out;
954955
s.call_with_pp_support(sess, None, move |annotation| {
955-
debug!("pretty printing source code {:?}", s);
956-
let sess = annotation.sess();
957-
pprust::print_crate(sess.source_map(),
958-
&sess.parse_sess,
959-
krate,
960-
src_name,
961-
&mut rdr,
962-
box out,
963-
annotation.pp_ann(),
964-
false)
965-
})
966-
.unwrap()
956+
debug!("pretty printing source code {:?}", s);
957+
let sess = annotation.sess();
958+
pprust::print_crate(sess.source_map(),
959+
&sess.parse_sess,
960+
krate,
961+
src_name,
962+
&mut rdr,
963+
box out,
964+
annotation.pp_ann(),
965+
false)
966+
}).unwrap()
967967
} else {
968968
unreachable!();
969969
};

src/librustc_driver/profile/mod.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn begin(sess: &Session) {
2323
use std::sync::mpsc::{channel};
2424
let (tx, rx) = channel();
2525
if profq_set_chan(sess, tx) {
26-
thread::spawn(move||profile_queries_thread(rx));
26+
thread::spawn(move || profile_queries_thread(rx));
2727
}
2828
}
2929

@@ -34,11 +34,12 @@ pub fn begin(sess: &Session) {
3434
pub fn dump(sess: &Session, path: String) {
3535
use std::sync::mpsc::{channel};
3636
let (tx, rx) = channel();
37-
let params = ProfQDumpParams{
38-
path, ack:tx,
37+
let params = ProfQDumpParams {
38+
path,
39+
ack: tx,
3940
// FIXME: Add another compiler flag to toggle whether this log
4041
// is written; false for now
41-
dump_profq_msg_log:true,
42+
dump_profq_msg_log: true,
4243
};
4344
profq_msg(sess, ProfileQueriesMsg::Dump(params));
4445
let _ = rx.recv().unwrap();
@@ -63,20 +64,20 @@ struct StackFrame {
6364
}
6465

6566
fn total_duration(traces: &[trace::Rec]) -> Duration {
66-
let mut sum : Duration = Duration::new(0,0);
67+
let mut sum : Duration = Duration::new(0, 0);
6768
for t in traces.iter() { sum += t.dur_total; }
6869
return sum
6970
}
7071

7172
// profiling thread; retains state (in local variables) and dump traces, upon request.
72-
fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
73+
fn profile_queries_thread(r: Receiver<ProfileQueriesMsg>) {
7374
use self::trace::*;
7475
use std::fs::File;
7576
use std::time::{Instant};
7677

77-
let mut profq_msgs : Vec<ProfileQueriesMsg> = vec![];
78-
let mut frame : StackFrame = StackFrame{ parse_st:ParseState::Clear, traces:vec![] };
79-
let mut stack : Vec<StackFrame> = vec![];
78+
let mut profq_msgs: Vec<ProfileQueriesMsg> = vec![];
79+
let mut frame: StackFrame = StackFrame { parse_st: ParseState::Clear, traces: vec![] };
80+
let mut stack: Vec<StackFrame> = vec![];
8081
loop {
8182
let msg = r.recv();
8283
if let Err(_recv_err) = msg {
@@ -138,7 +139,7 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
138139

139140
// Parse State: Clear
140141
(ParseState::Clear,
141-
ProfileQueriesMsg::QueryBegin(span,querymsg)) => {
142+
ProfileQueriesMsg::QueryBegin(span, querymsg)) => {
142143
let start = Instant::now();
143144
frame.parse_st = ParseState::HaveQuery
144145
(Query { span, msg: querymsg }, start)
@@ -284,8 +285,6 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
284285
frame = StackFrame{parse_st:ParseState::Clear, traces:vec![]};
285286
},
286287

287-
//
288-
//
289288
// Parse errors:
290289

291290
(ParseState::HaveQuery(q,_),
@@ -307,7 +306,6 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
307306
unreachable!()
308307
},
309308
}
310-
311309
}
312310
}
313311
}

0 commit comments

Comments
 (0)