about summary refs log tree commit diff
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-10-12 14:36:10 +0200
committerljedrz <ljedrz@gmail.com>2018-10-13 10:15:46 +0200
commitb03a82cfca27c11fabc19e4146d6583b3cd320ae (patch)
tree2126ce372ccd9e4b86f72d9833520ace5982feb9
parentd838a7fcca93034dcb50914ca242a6973a7c3ac2 (diff)
downloadrust-b03a82cfca27c11fabc19e4146d6583b3cd320ae.tar.gz
rust-b03a82cfca27c11fabc19e4146d6583b3cd320ae.zip
rustc/driver: whitespace & formatting fixes
-rw-r--r--src/librustc_driver/driver.rs14
-rw-r--r--src/librustc_driver/lib.rs44
-rw-r--r--src/librustc_driver/pretty.rs54
-rw-r--r--src/librustc_driver/profile/mod.rs24
-rw-r--r--src/librustc_driver/profile/trace.rs37
5 files changed, 87 insertions, 86 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 976a50e9d69..b4f95b915eb 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -1021,6 +1021,7 @@ where
             .cloned()
             .collect();
         missing_fragment_specifiers.sort();
+
         for span in missing_fragment_specifiers {
             let lint = lint::builtin::MISSING_FRAGMENT_SPECIFIER;
             let msg = "missing fragment specifier";
@@ -1517,6 +1518,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
                             Symbol::intern("proc-macro"),
                             Symbol::intern("bin")
                         ];
+
                         if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().node {
                             let span = spanned.span;
                             let lev_candidate = find_best_match_for_name(
@@ -1587,12 +1589,12 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
     base.retain(|crate_type| {
         let res = !::rustc_codegen_utils::link::invalid_output_for_target(session, *crate_type);
 
-            if !res {
-                session.warn(&format!(
-                    "dropping unsupported crate type `{}` for target `{}`",
-                    *crate_type, session.opts.target_triple
-                ));
-            }
+        if !res {
+            session.warn(&format!(
+                "dropping unsupported crate type `{}` for target `{}`",
+                *crate_type, session.opts.target_triple
+            ));
+        }
 
         res
     });
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index 8ec88c9d8f6..8c945ccbe95 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -188,14 +188,16 @@ pub fn run<F>(run_compiler: F) -> isize
                     }
                     None => {
                         let emitter =
-                            errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
-                                                                None,
-                                                                true,
-                                                                false);
+                            errors::emitter::EmitterWriter::stderr(
+                                errors::ColorConfig::Auto,
+                                None,
+                                true,
+                                false
+                            );
                         let handler = errors::Handler::with_emitter(true, false, Box::new(emitter));
                         handler.emit(&MultiSpan::new(),
-                                    "aborting due to previous error(s)",
-                                    errors::Level::Fatal);
+                                     "aborting due to previous error(s)",
+                                     errors::Level::Fatal);
                         panic::resume_unwind(Box::new(errors::FatalErrorMarker));
                     }
                 }
@@ -316,9 +318,8 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
     let sysroot = sysroot_candidates.iter()
         .map(|sysroot| {
             let libdir = filesearch::relative_target_lib_path(&sysroot, &target);
-            sysroot.join(libdir)
-                .with_file_name(option_env!("CFG_CODEGEN_BACKENDS_DIR")
-                                .unwrap_or("codegen-backends"))
+            sysroot.join(libdir).with_file_name(
+                option_env!("CFG_CODEGEN_BACKENDS_DIR").unwrap_or("codegen-backends"))
         })
         .filter(|f| {
             info!("codegen backend candidate: {}", f.display());
@@ -360,8 +361,8 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
         }
         if let Some(ref prev) = file {
             let err = format!("duplicate codegen backends found\n\
-                first:  {}\n\
-                second: {}\n\
+                               first:  {}\n\
+                               second: {}\n\
             ", prev.display(), path.display());
             early_error(ErrorOutputType::default(), &err);
         }
@@ -373,7 +374,7 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
         None => {
             let err = format!("failed to load default codegen backend for `{}`, \
                                no appropriate codegen dylib found in `{}`",
-                               backend_name, sysroot.display());
+                              backend_name, sysroot.display());
             early_error(ErrorOutputType::default(), &err);
         }
     }
@@ -1010,7 +1011,7 @@ impl RustcDefaultCalls {
         use rustc::session::config::PrintRequest::*;
         // PrintRequest::NativeStaticLibs is special - printed during linking
         // (empty iterator returns true)
-        if sess.opts.prints.iter().all(|&p| p==PrintRequest::NativeStaticLibs) {
+        if sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs) {
             return Compilation::Continue;
         }
 
@@ -1054,10 +1055,7 @@ impl RustcDefaultCalls {
                             &id,
                             &t_outputs
                         );
-                        println!("{}",
-                                 fname.file_name()
-                                      .unwrap()
-                                      .to_string_lossy());
+                        println!("{}", fname.file_name().unwrap().to_string_lossy());
                     }
                 }
                 Cfg => {
@@ -1129,9 +1127,8 @@ fn commit_date_str() -> Option<&'static str> {
 pub fn version(binary: &str, matches: &getopts::Matches) {
     let verbose = matches.opt_present("verbose");
 
-    println!("{} {}",
-             binary,
-             option_env!("CFG_VERSION").unwrap_or("unknown version"));
+    println!("{} {}", binary, option_env!("CFG_VERSION").unwrap_or("unknown version"));
+
     if verbose {
         fn unw(x: Option<&str>) -> &str {
             x.unwrap_or("unknown")
@@ -1252,8 +1249,6 @@ Available lint options:
 
     print_lints(builtin);
 
-
-
     let max_name_len = max("warnings".len(),
                            plugin_groups.iter()
                                         .chain(&builtin_groups)
@@ -1429,6 +1424,7 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
     }
 
     let cg_flags = matches.opt_strs("C");
+
     if cg_flags.iter().any(|x| *x == "help") {
         describe_codegen_flags();
         return None;
@@ -1477,7 +1473,7 @@ pub fn in_named_rustc_thread<F, R>(name: String, f: F) -> Result<R, Box<dyn Any
     // Temporarily have stack size set to 16MB to deal with nom-using crates failing
     const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB
 
-    #[cfg(all(unix,not(target_os = "haiku")))]
+    #[cfg(all(unix, not(target_os = "haiku")))]
     let spawn_thread = unsafe {
         // Fetch the current resource limits
         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
         }
     };
 
-    #[cfg(not(any(windows,unix)))]
+    #[cfg(not(any(windows, unix)))]
     let spawn_thread = true;
 
     // The or condition is added from backward compatibility.
diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs
index 1a53d61a3c1..b4f6d10b1f8 100644
--- a/src/librustc_driver/pretty.rs
+++ b/src/librustc_driver/pretty.rs
@@ -167,10 +167,10 @@ pub fn parse_pretty(sess: &Session,
 impl PpSourceMode {
     /// Constructs a `PrinterSupport` object and passes it to `f`.
     fn call_with_pp_support<'tcx, A, F>(&self,
-                                           sess: &'tcx Session,
-                                           hir_map: Option<&hir_map::Map<'tcx>>,
-                                           f: F)
-                                           -> A
+                                        sess: &'tcx Session,
+                                        hir_map: Option<&hir_map::Map<'tcx>>,
+                                        f: F)
+                                        -> A
         where F: FnOnce(&dyn PrinterSupport) -> A
     {
         match *self {
@@ -198,17 +198,18 @@ impl PpSourceMode {
             _ => panic!("Should use call_with_pp_support_hir"),
         }
     }
-    fn call_with_pp_support_hir<'tcx, A, F>(&self,
-                                               sess: &'tcx Session,
-                                               cstore: &'tcx CStore,
-                                               hir_map: &hir_map::Map<'tcx>,
-                                               analysis: &ty::CrateAnalysis,
-                                               resolutions: &Resolutions,
-                                               arenas: &'tcx AllArenas<'tcx>,
-                                               output_filenames: &OutputFilenames,
-                                               id: &str,
-                                               f: F)
-                                               -> A
+    fn call_with_pp_support_hir<'tcx, A, F>(
+        &self,
+        sess: &'tcx Session,
+        cstore: &'tcx CStore,
+        hir_map: &hir_map::Map<'tcx>,
+        analysis: &ty::CrateAnalysis,
+        resolutions: &Resolutions,
+        arenas: &'tcx AllArenas<'tcx>,
+        output_filenames: &OutputFilenames,
+        id: &str,
+        f: F
+    ) -> A
         where F: FnOnce(&dyn HirPrinterSupport, &hir::Crate) -> A
     {
         match *self {
@@ -952,18 +953,17 @@ pub fn print_after_parsing(sess: &Session,
         // Silently ignores an identified node.
         let out: &mut dyn Write = &mut out;
         s.call_with_pp_support(sess, None, move |annotation| {
-                debug!("pretty printing source code {:?}", s);
-                let sess = annotation.sess();
-                pprust::print_crate(sess.source_map(),
-                                    &sess.parse_sess,
-                                    krate,
-                                    src_name,
-                                    &mut rdr,
-                                    box out,
-                                    annotation.pp_ann(),
-                                    false)
-            })
-            .unwrap()
+            debug!("pretty printing source code {:?}", s);
+            let sess = annotation.sess();
+            pprust::print_crate(sess.source_map(),
+                                &sess.parse_sess,
+                                krate,
+                                src_name,
+                                &mut rdr,
+                                box out,
+                                annotation.pp_ann(),
+                                false)
+        }).unwrap()
     } else {
         unreachable!();
     };
diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs
index 9016e0d0fe7..d334a9476ce 100644
--- a/src/librustc_driver/profile/mod.rs
+++ b/src/librustc_driver/profile/mod.rs
@@ -23,7 +23,7 @@ pub fn begin(sess: &Session) {
     use std::sync::mpsc::{channel};
     let (tx, rx) = channel();
     if profq_set_chan(sess, tx) {
-        thread::spawn(move||profile_queries_thread(rx));
+        thread::spawn(move || profile_queries_thread(rx));
     }
 }
 
@@ -34,11 +34,12 @@ pub fn begin(sess: &Session) {
 pub fn dump(sess: &Session, path: String) {
     use std::sync::mpsc::{channel};
     let (tx, rx) = channel();
-    let params = ProfQDumpParams{
-        path, ack:tx,
+    let params = ProfQDumpParams {
+        path,
+        ack: tx,
         // FIXME: Add another compiler flag to toggle whether this log
         // is written; false for now
-        dump_profq_msg_log:true,
+        dump_profq_msg_log: true,
     };
     profq_msg(sess, ProfileQueriesMsg::Dump(params));
     let _ = rx.recv().unwrap();
@@ -63,20 +64,20 @@ struct StackFrame {
 }
 
 fn total_duration(traces: &[trace::Rec]) -> Duration {
-    let mut sum : Duration = Duration::new(0,0);
+    let mut sum : Duration = Duration::new(0, 0);
     for t in traces.iter() { sum += t.dur_total; }
     return sum
 }
 
 // profiling thread; retains state (in local variables) and dump traces, upon request.
-fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
+fn profile_queries_thread(r: Receiver<ProfileQueriesMsg>) {
     use self::trace::*;
     use std::fs::File;
     use std::time::{Instant};
 
-    let mut profq_msgs : Vec<ProfileQueriesMsg> = vec![];
-    let mut frame : StackFrame = StackFrame{ parse_st:ParseState::Clear, traces:vec![] };
-    let mut stack : Vec<StackFrame> = vec![];
+    let mut profq_msgs: Vec<ProfileQueriesMsg> = vec![];
+    let mut frame: StackFrame = StackFrame { parse_st: ParseState::Clear, traces: vec![] };
+    let mut stack: Vec<StackFrame> = vec![];
     loop {
         let msg = r.recv();
         if let Err(_recv_err) = msg {
@@ -138,7 +139,7 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
 
                     // Parse State: Clear
                     (ParseState::Clear,
-                     ProfileQueriesMsg::QueryBegin(span,querymsg)) => {
+                     ProfileQueriesMsg::QueryBegin(span, querymsg)) => {
                         let start = Instant::now();
                         frame.parse_st = ParseState::HaveQuery
                             (Query { span, msg: querymsg }, start)
@@ -284,8 +285,6 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
                         frame = StackFrame{parse_st:ParseState::Clear, traces:vec![]};
                     },
 
-                    //
-                    //
                     // Parse errors:
 
                     (ParseState::HaveQuery(q,_),
@@ -307,7 +306,6 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
                         unreachable!()
                     },
                 }
-
             }
         }
     }
diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs
index 121be04bbb1..9589ae2a8db 100644
--- a/src/librustc_driver/profile/trace.rs
+++ b/src/librustc_driver/profile/trace.rs
@@ -84,9 +84,7 @@ pub fn html_of_effect(eff: &Effect) -> (String, String) {
 // First return value is text; second return value is a CSS class
 fn html_of_duration(_start: &Instant, dur: &Duration) -> (String, String) {
     use rustc::util::common::duration_to_secs_str;
-    (duration_to_secs_str(dur.clone()),
-     String::new()
-    )
+    (duration_to_secs_str(dur.clone()), String::new())
 }
 
 fn html_of_fraction(frac: f64) -> (String, &'static str) {
@@ -103,8 +101,12 @@ fn html_of_fraction(frac: f64) -> (String, &'static str) {
         else                  { "frac-0" }
     };
     let percent = frac * 100.0;
-    if percent > 0.1 { (format!("{:.1}%", percent), css) }
-    else { ("< 0.1%".to_string(), css) }
+
+    if percent > 0.1 {
+        (format!("{:.1}%", percent), css)
+    } else {
+        ("< 0.1%".to_string(), css)
+    }
 }
 
 fn total_duration(traces: &[Rec]) -> Duration {
@@ -149,40 +151,42 @@ fn compute_counts_rec(counts: &mut FxHashMap<String,QueryMetric>, traces: &[Rec]
         match t.effect {
             Effect::TimeBegin(ref msg) => {
                 let qm = match counts.get(msg) {
-                    Some(_qm) => { panic!("TimeBegin with non-unique, repeat message") }
-                    None => QueryMetric{
+                    Some(_qm) => panic!("TimeBegin with non-unique, repeat message"),
+                    None => QueryMetric {
                         count: 1,
                         dur_self: t.dur_self,
                         dur_total: t.dur_total,
-                    }};
+                    }
+                };
                 counts.insert(msg.clone(), qm);
             },
             Effect::TaskBegin(ref key) => {
                 let cons = cons_of_key(key);
                 let qm = match counts.get(&cons) {
                     Some(qm) =>
-                        QueryMetric{
+                        QueryMetric {
                             count: qm.count + 1,
                             dur_self: qm.dur_self + t.dur_self,
                             dur_total: qm.dur_total + t.dur_total,
                         },
-                    None => QueryMetric{
+                    None => QueryMetric {
                         count: 1,
                         dur_self: t.dur_self,
                         dur_total: t.dur_total,
-                    }};
+                    }
+                };
                 counts.insert(cons, qm);
             },
             Effect::QueryBegin(ref qmsg, ref _cc) => {
                 let qcons = cons_of_query_msg(qmsg);
                 let qm = match counts.get(&qcons) {
                     Some(qm) =>
-                        QueryMetric{
+                        QueryMetric {
                             count: qm.count + 1,
                             dur_total: qm.dur_total + t.dur_total,
                             dur_self: qm.dur_self + t.dur_self
                         },
-                    None => QueryMetric{
+                    None => QueryMetric {
                         count: 1,
                         dur_total: t.dur_total,
                         dur_self: t.dur_self,
@@ -195,13 +199,14 @@ fn compute_counts_rec(counts: &mut FxHashMap<String,QueryMetric>, traces: &[Rec]
     }
 }
 
-pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap<String,QueryMetric>) {
+pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap<String, QueryMetric>) {
     use rustc::util::common::duration_to_secs_str;
     use std::cmp::Reverse;
 
     let mut data = counts.iter().map(|(ref cons, ref qm)|
         (cons.clone(), qm.count.clone(), qm.dur_total.clone(), qm.dur_self.clone())
     ).collect::<Vec<_>>();
+
     data.sort_by_key(|k| Reverse(k.3));
     for (cons, count, dur_total, dur_self) in data {
         writeln!(count_file, "{}, {}, {}, {}",
@@ -218,12 +223,12 @@ pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &[Rec]
     compute_counts_rec(&mut counts, traces);
     write_counts(counts_file, &mut counts);
 
-    let total : Duration = total_duration(traces);
+    let total: Duration = total_duration(traces);
     write_traces_rec(html_file, traces, total, 0)
 }
 
 pub fn write_style(html_file: &mut File) {
-    write!(html_file,"{}", "
+    write!(html_file, "{}", "
 body {
     font-family: sans-serif;
     background: black;