mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
Move WritableDst
method onto Style
directly
This commit is contained in:
parent
00074698a7
commit
1e2167f5b5
@ -2590,7 +2590,8 @@ fn emit_to_destination(
|
|||||||
let _buffer_lock = lock::acquire_global_lock("rustc_errors");
|
let _buffer_lock = lock::acquire_global_lock("rustc_errors");
|
||||||
for (pos, line) in rendered_buffer.iter().enumerate() {
|
for (pos, line) in rendered_buffer.iter().enumerate() {
|
||||||
for part in line {
|
for part in line {
|
||||||
dst.apply_style(*lvl, part.style)?;
|
let style = part.style.color_spec(*lvl);
|
||||||
|
dst.set_color(&style)?;
|
||||||
write!(dst, "{}", part.text)?;
|
write!(dst, "{}", part.text)?;
|
||||||
dst.reset()?;
|
dst.reset()?;
|
||||||
}
|
}
|
||||||
@ -2675,10 +2676,10 @@ impl Destination {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WritableDst<'a> {
|
impl Style {
|
||||||
fn apply_style(&mut self, lvl: Level, style: Style) -> io::Result<()> {
|
fn color_spec(&self, lvl: Level) -> ColorSpec {
|
||||||
let mut spec = ColorSpec::new();
|
let mut spec = ColorSpec::new();
|
||||||
match style {
|
match self {
|
||||||
Style::Addition => {
|
Style::Addition => {
|
||||||
spec.set_fg(Some(Color::Green)).set_intense(true);
|
spec.set_fg(Some(Color::Green)).set_intense(true);
|
||||||
}
|
}
|
||||||
@ -2723,9 +2724,11 @@ impl<'a> WritableDst<'a> {
|
|||||||
spec.set_bold(true);
|
spec.set_bold(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.set_color(&spec)
|
spec
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> WritableDst<'a> {
|
||||||
fn set_color(&mut self, color: &ColorSpec) -> io::Result<()> {
|
fn set_color(&mut self, color: &ColorSpec) -> io::Result<()> {
|
||||||
match *self {
|
match *self {
|
||||||
WritableDst::Raw(ref mut t) => t.set_color(color),
|
WritableDst::Raw(ref mut t) => t.set_color(color),
|
||||||
|
Loading…
Reference in New Issue
Block a user