Skip to content

Commit 1e2167f

Browse files
committed
Move WritableDst method onto Style directly
1 parent 0007469 commit 1e2167f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: compiler/rustc_errors/src/emitter.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,8 @@ fn emit_to_destination(
25902590
let _buffer_lock = lock::acquire_global_lock("rustc_errors");
25912591
for (pos, line) in rendered_buffer.iter().enumerate() {
25922592
for part in line {
2593-
dst.apply_style(*lvl, part.style)?;
2593+
let style = part.style.color_spec(*lvl);
2594+
dst.set_color(&style)?;
25942595
write!(dst, "{}", part.text)?;
25952596
dst.reset()?;
25962597
}
@@ -2675,10 +2676,10 @@ impl Destination {
26752676
}
26762677
}
26772678

2678-
impl<'a> WritableDst<'a> {
2679-
fn apply_style(&mut self, lvl: Level, style: Style) -> io::Result<()> {
2679+
impl Style {
2680+
fn color_spec(&self, lvl: Level) -> ColorSpec {
26802681
let mut spec = ColorSpec::new();
2681-
match style {
2682+
match self {
26822683
Style::Addition => {
26832684
spec.set_fg(Some(Color::Green)).set_intense(true);
26842685
}
@@ -2723,9 +2724,11 @@ impl<'a> WritableDst<'a> {
27232724
spec.set_bold(true);
27242725
}
27252726
}
2726-
self.set_color(&spec)
2727+
spec
27272728
}
2729+
}
27282730

2731+
impl<'a> WritableDst<'a> {
27292732
fn set_color(&mut self, color: &ColorSpec) -> io::Result<()> {
27302733
match *self {
27312734
WritableDst::Raw(ref mut t) => t.set_color(color),

0 commit comments

Comments
 (0)