Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 39753c8

Browse files
committed
rustc/driver: improve macro calls
1 parent 5bfe08f commit 39753c8

File tree

5 files changed

+25
-30
lines changed

5 files changed

+25
-30
lines changed

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[Pa
14721472
.collect();
14731473
let mut file = fs::File::create(&deps_filename)?;
14741474
for path in out_filenames {
1475-
write!(file, "{}: {}\n\n", path.display(), files.join(" "))?;
1475+
writeln!(file, "{}: {}\n", path.display(), files.join(" "))?;
14761476
}
14771477

14781478
// Emit a fake target for each input file to the compilation. This

src/librustc_driver/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ pub fn set_sigpipe_handler() {
579579
unsafe {
580580
// Set the SIGPIPE signal handler, so that an EPIPE
581581
// will cause rustc to terminate, as expected.
582-
assert!(libc::signal(libc::SIGPIPE, libc::SIG_DFL) != libc::SIG_ERR);
582+
assert_ne!(libc::signal(libc::SIGPIPE, libc::SIG_DFL), libc::SIG_ERR);
583583
}
584584
}
585585

src/librustc_driver/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
855855
break n.body();
856856
}
857857
let parent = tcx.hir.get_parent_node(node_id);
858-
assert!(node_id != parent);
858+
assert_ne!(node_id, parent);
859859
node_id = parent;
860860
}
861861
}

src/librustc_driver/profile/mod.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,14 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
109109
let counts_path = format!("{}.counts.txt", params.path);
110110
let mut counts_file = File::create(&counts_path).unwrap();
111111

112-
write!(html_file, "<html>\n").unwrap();
113-
write!(html_file,
114-
"<head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">\n",
115-
"profile_queries.css").unwrap();
116-
write!(html_file, "<style>\n").unwrap();
112+
writeln!(html_file,
113+
"<html>\n<head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">",
114+
"profile_queries.css").unwrap();
115+
writeln!(html_file, "<style>").unwrap();
117116
trace::write_style(&mut html_file);
118-
write!(html_file, "</style>\n").unwrap();
119-
write!(html_file, "</head>\n").unwrap();
120-
write!(html_file, "<body>\n").unwrap();
117+
writeln!(html_file, "</style>\n</head>\n<body>").unwrap();
121118
trace::write_traces(&mut html_file, &mut counts_file, &frame.traces);
122-
write!(html_file, "</body>\n</html>\n").unwrap();
119+
writeln!(html_file, "</body>\n</html>").unwrap();
123120

124121
let ack_path = format!("{}.ack", params.path);
125122
let ack_file = File::create(&ack_path).unwrap();

src/librustc_driver/profile/trace.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,20 @@ fn write_traces_rec(file: &mut File, traces: &[Rec], total: Duration, depth: usi
130130
let fraction = duration_div(t.dur_total, total);
131131
let percent = fraction * 100.0;
132132
let (frc_text, frc_css_classes) = html_of_fraction(fraction);
133-
write!(file, "<div class=\"trace depth-{} extent-{}{} {} {} {}\">\n",
134-
depth,
135-
t.extent.len(),
136-
/* Heuristic for 'important' CSS class: */
137-
if t.extent.len() > 5 || percent >= 1.0 {
138-
" important" }
139-
else { "" },
140-
eff_css_classes,
141-
dur_css_classes,
142-
frc_css_classes,
133+
writeln!(file, "<div class=\"trace depth-{} extent-{}{} {} {} {}\">",
134+
depth,
135+
t.extent.len(),
136+
/* Heuristic for 'important' CSS class: */
137+
if t.extent.len() > 5 || percent >= 1.0 { " important" } else { "" },
138+
eff_css_classes,
139+
dur_css_classes,
140+
frc_css_classes,
143141
).unwrap();
144-
write!(file, "<div class=\"eff\">{}</div>\n", eff_text).unwrap();
145-
write!(file, "<div class=\"dur\">{}</div>\n", dur_text).unwrap();
146-
write!(file, "<div class=\"frc\">{}</div>\n", frc_text).unwrap();
142+
writeln!(file, "<div class=\"eff\">{}</div>", eff_text).unwrap();
143+
writeln!(file, "<div class=\"dur\">{}</div>", dur_text).unwrap();
144+
writeln!(file, "<div class=\"frc\">{}</div>", frc_text).unwrap();
147145
write_traces_rec(file, &t.extent, total, depth + 1);
148-
write!(file, "</div>\n").unwrap();
146+
writeln!(file, "</div>").unwrap();
149147
}
150148
}
151149

@@ -209,10 +207,10 @@ pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap<String,QueryMe
209207
).collect::<Vec<_>>();
210208
data.sort_by_key(|k| Reverse(k.3));
211209
for (cons, count, dur_total, dur_self) in data {
212-
write!(count_file, "{}, {}, {}, {}\n",
213-
cons, count,
214-
duration_to_secs_str(dur_total),
215-
duration_to_secs_str(dur_self)
210+
writeln!(count_file, "{}, {}, {}, {}",
211+
cons, count,
212+
duration_to_secs_str(dur_total),
213+
duration_to_secs_str(dur_self)
216214
).unwrap();
217215
}
218216
}

0 commit comments

Comments
 (0)