Skip to content

Commit

Permalink
rustc/driver: improve macro calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Oct 12, 2018
1 parent 5bfe08f commit 39753c8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Expand Up @@ -1472,7 +1472,7 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[Pa
.collect();
let mut file = fs::File::create(&deps_filename)?;
for path in out_filenames {
write!(file, "{}: {}\n\n", path.display(), files.join(" "))?;
writeln!(file, "{}: {}\n", path.display(), files.join(" "))?;
}

// Emit a fake target for each input file to the compilation. This
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/lib.rs
Expand Up @@ -579,7 +579,7 @@ pub fn set_sigpipe_handler() {
unsafe {
// Set the SIGPIPE signal handler, so that an EPIPE
// will cause rustc to terminate, as expected.
assert!(libc::signal(libc::SIGPIPE, libc::SIG_DFL) != libc::SIG_ERR);
assert_ne!(libc::signal(libc::SIGPIPE, libc::SIG_DFL), libc::SIG_ERR);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/pretty.rs
Expand Up @@ -855,7 +855,7 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
break n.body();
}
let parent = tcx.hir.get_parent_node(node_id);
assert!(node_id != parent);
assert_ne!(node_id, parent);
node_id = parent;
}
}
Expand Down
15 changes: 6 additions & 9 deletions src/librustc_driver/profile/mod.rs
Expand Up @@ -109,17 +109,14 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
let counts_path = format!("{}.counts.txt", params.path);
let mut counts_file = File::create(&counts_path).unwrap();

write!(html_file, "<html>\n").unwrap();
write!(html_file,
"<head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">\n",
"profile_queries.css").unwrap();
write!(html_file, "<style>\n").unwrap();
writeln!(html_file,
"<html>\n<head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">",
"profile_queries.css").unwrap();
writeln!(html_file, "<style>").unwrap();
trace::write_style(&mut html_file);
write!(html_file, "</style>\n").unwrap();
write!(html_file, "</head>\n").unwrap();
write!(html_file, "<body>\n").unwrap();
writeln!(html_file, "</style>\n</head>\n<body>").unwrap();
trace::write_traces(&mut html_file, &mut counts_file, &frame.traces);
write!(html_file, "</body>\n</html>\n").unwrap();
writeln!(html_file, "</body>\n</html>").unwrap();

let ack_path = format!("{}.ack", params.path);
let ack_file = File::create(&ack_path).unwrap();
Expand Down
34 changes: 16 additions & 18 deletions src/librustc_driver/profile/trace.rs
Expand Up @@ -130,22 +130,20 @@ fn write_traces_rec(file: &mut File, traces: &[Rec], total: Duration, depth: usi
let fraction = duration_div(t.dur_total, total);
let percent = fraction * 100.0;
let (frc_text, frc_css_classes) = html_of_fraction(fraction);
write!(file, "<div class=\"trace depth-{} extent-{}{} {} {} {}\">\n",
depth,
t.extent.len(),
/* Heuristic for 'important' CSS class: */
if t.extent.len() > 5 || percent >= 1.0 {
" important" }
else { "" },
eff_css_classes,
dur_css_classes,
frc_css_classes,
writeln!(file, "<div class=\"trace depth-{} extent-{}{} {} {} {}\">",
depth,
t.extent.len(),
/* Heuristic for 'important' CSS class: */
if t.extent.len() > 5 || percent >= 1.0 { " important" } else { "" },
eff_css_classes,
dur_css_classes,
frc_css_classes,
).unwrap();
write!(file, "<div class=\"eff\">{}</div>\n", eff_text).unwrap();
write!(file, "<div class=\"dur\">{}</div>\n", dur_text).unwrap();
write!(file, "<div class=\"frc\">{}</div>\n", frc_text).unwrap();
writeln!(file, "<div class=\"eff\">{}</div>", eff_text).unwrap();
writeln!(file, "<div class=\"dur\">{}</div>", dur_text).unwrap();
writeln!(file, "<div class=\"frc\">{}</div>", frc_text).unwrap();
write_traces_rec(file, &t.extent, total, depth + 1);
write!(file, "</div>\n").unwrap();
writeln!(file, "</div>").unwrap();
}
}

Expand Down Expand Up @@ -209,10 +207,10 @@ pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap<String,QueryMe
).collect::<Vec<_>>();
data.sort_by_key(|k| Reverse(k.3));
for (cons, count, dur_total, dur_self) in data {
write!(count_file, "{}, {}, {}, {}\n",
cons, count,
duration_to_secs_str(dur_total),
duration_to_secs_str(dur_self)
writeln!(count_file, "{}, {}, {}, {}",
cons, count,
duration_to_secs_str(dur_total),
duration_to_secs_str(dur_self)
).unwrap();
}
}
Expand Down

0 comments on commit 39753c8

Please sign in to comment.