Rollup merge of #37257 - srinivasreddy:librustc_errors, r=eddyb

run rustfmt on librustc_errors folder
This commit is contained in:
Eduard-Mihai Burtescu 2016-10-19 08:00:04 +03:00 committed by GitHub
commit 903e1f9657
6 changed files with 172 additions and 180 deletions

View File

@ -83,22 +83,22 @@ macro_rules! println_maybe_styled {
} }
impl EmitterWriter { impl EmitterWriter {
pub fn stderr(color_config: ColorConfig, pub fn stderr(color_config: ColorConfig, code_map: Option<Rc<CodeMapper>>) -> EmitterWriter {
code_map: Option<Rc<CodeMapper>>)
-> EmitterWriter {
if color_config.use_color() { if color_config.use_color() {
let dst = Destination::from_stderr(); let dst = Destination::from_stderr();
EmitterWriter { dst: dst, EmitterWriter {
cm: code_map} dst: dst,
cm: code_map,
}
} else { } else {
EmitterWriter { dst: Raw(Box::new(io::stderr())), EmitterWriter {
cm: code_map} dst: Raw(Box::new(io::stderr())),
cm: code_map,
}
} }
} }
pub fn new(dst: Box<Write + Send>, pub fn new(dst: Box<Write + Send>, code_map: Option<Rc<CodeMapper>>) -> EmitterWriter {
code_map: Option<Rc<CodeMapper>>)
-> EmitterWriter {
EmitterWriter { EmitterWriter {
dst: Raw(dst), dst: Raw(dst),
cm: code_map, cm: code_map,
@ -237,9 +237,7 @@ impl EmitterWriter {
'^', '^',
Style::UnderlinePrimary); Style::UnderlinePrimary);
if !annotation.is_minimized { if !annotation.is_minimized {
buffer.set_style(line_offset, buffer.set_style(line_offset, width_offset + p, Style::UnderlinePrimary);
width_offset + p,
Style::UnderlinePrimary);
} }
} else { } else {
buffer.putc(line_offset + 1, buffer.putc(line_offset + 1,
@ -247,9 +245,7 @@ impl EmitterWriter {
'-', '-',
Style::UnderlineSecondary); Style::UnderlineSecondary);
if !annotation.is_minimized { if !annotation.is_minimized {
buffer.set_style(line_offset, buffer.set_style(line_offset, width_offset + p, Style::UnderlineSecondary);
width_offset + p,
Style::UnderlineSecondary);
} }
} }
} }
@ -429,8 +425,7 @@ impl EmitterWriter {
} }
// Check to make sure we're not in any <*macros> // Check to make sure we're not in any <*macros>
if !cm.span_to_filename(def_site).contains("macros>") && if !cm.span_to_filename(def_site).contains("macros>") &&
!trace.macro_decl_name.starts_with("#[") !trace.macro_decl_name.starts_with("#[") {
{
new_labels.push((trace.call_site, new_labels.push((trace.call_site,
"in this macro invocation".to_string())); "in this macro invocation".to_string()));
break; break;
@ -475,10 +470,10 @@ impl EmitterWriter {
if spans_updated { if spans_updated {
children.push(SubDiagnostic { children.push(SubDiagnostic {
level: Level::Note, level: Level::Note,
message:"this error originates in a macro outside of the current \ message: "this error originates in a macro outside of the current crate"
crate".to_string(), .to_string(),
span: MultiSpan::new(), span: MultiSpan::new(),
render_span: None render_span: None,
}); });
} }
} }
@ -502,8 +497,7 @@ impl EmitterWriter {
buffer.append(0, &level.to_string(), Style::HeaderMsg); buffer.append(0, &level.to_string(), Style::HeaderMsg);
buffer.append(0, ": ", Style::NoStyle); buffer.append(0, ": ", Style::NoStyle);
buffer.append(0, msg, Style::NoStyle); buffer.append(0, msg, Style::NoStyle);
} } else {
else {
buffer.append(0, &level.to_string(), Style::Level(level.clone())); buffer.append(0, &level.to_string(), Style::Level(level.clone()));
match code { match code {
&Some(ref code) => { &Some(ref code) => {
@ -522,13 +516,11 @@ impl EmitterWriter {
let mut annotated_files = self.preprocess_annotations(msp); let mut annotated_files = self.preprocess_annotations(msp);
// Make sure our primary file comes first // Make sure our primary file comes first
let primary_lo = let primary_lo = if let (Some(ref cm), Some(ref primary_span)) =
if let (Some(ref cm), Some(ref primary_span)) = (self.cm.as_ref(), (self.cm.as_ref(), msp.primary_span().as_ref()) {
msp.primary_span().as_ref()) {
if primary_span != &&DUMMY_SP && primary_span != &&COMMAND_LINE_SP { if primary_span != &&DUMMY_SP && primary_span != &&COMMAND_LINE_SP {
cm.lookup_char_pos(primary_span.lo) cm.lookup_char_pos(primary_span.lo)
} } else {
else {
emit_to_destination(&buffer.render(), level, &mut self.dst)?; emit_to_destination(&buffer.render(), level, &mut self.dst)?;
return Ok(()); return Ok(());
} }
@ -672,12 +664,7 @@ impl EmitterWriter {
let max_line_num = self.get_max_line_num(span, children); let max_line_num = self.get_max_line_num(span, children);
let max_line_num_len = max_line_num.to_string().len(); let max_line_num_len = max_line_num.to_string().len();
match self.emit_message_default(span, match self.emit_message_default(span, message, code, level, max_line_num_len, false) {
message,
code,
level,
max_line_num_len,
false) {
Ok(()) => { Ok(()) => {
if !children.is_empty() { if !children.is_empty() {
let mut buffer = StyledBuffer::new(); let mut buffer = StyledBuffer::new();
@ -723,13 +710,15 @@ impl EmitterWriter {
} }
} }
} }
Err(e) => panic!("failed to emit error: {}", e) Err(e) => panic!("failed to emit error: {}", e),
} }
match write!(&mut self.dst, "\n") { match write!(&mut self.dst, "\n") {
Err(e) => panic!("failed to emit error: {}", e), Err(e) => panic!("failed to emit error: {}", e),
_ => match self.dst.flush() { _ => {
match self.dst.flush() {
Err(e) => panic!("failed to emit error: {}", e), Err(e) => panic!("failed to emit error: {}", e),
_ => () _ => (),
}
} }
} }
} }
@ -754,7 +743,8 @@ fn overlaps(a1: &Annotation, a2: &Annotation) -> bool {
fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>, fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
lvl: &Level, lvl: &Level,
dst: &mut Destination) -> io::Result<()> { dst: &mut Destination)
-> io::Result<()> {
use lock; use lock;
// In order to prevent error message interleaving, where multiple error lines get intermixed // In order to prevent error message interleaving, where multiple error lines get intermixed
@ -795,8 +785,7 @@ fn stderr_isatty() -> bool {
const STD_ERROR_HANDLE: DWORD = -12i32 as DWORD; const STD_ERROR_HANDLE: DWORD = -12i32 as DWORD;
extern "system" { extern "system" {
fn GetStdHandle(which: DWORD) -> HANDLE; fn GetStdHandle(which: DWORD) -> HANDLE;
fn GetConsoleMode(hConsoleHandle: HANDLE, fn GetConsoleMode(hConsoleHandle: HANDLE, lpMode: *mut DWORD) -> BOOL;
lpMode: *mut DWORD) -> BOOL;
} }
unsafe { unsafe {
let handle = GetStdHandle(STD_ERROR_HANDLE); let handle = GetStdHandle(STD_ERROR_HANDLE);
@ -824,9 +813,7 @@ impl BufferedWriter {
// note: we use _new because the conditional compilation at its use site may make this // note: we use _new because the conditional compilation at its use site may make this
// this function unused on some platforms // this function unused on some platforms
fn _new() -> BufferedWriter { fn _new() -> BufferedWriter {
BufferedWriter { BufferedWriter { buffer: vec![] }
buffer: vec![]
}
} }
} }
@ -866,11 +853,13 @@ impl Destination {
#[cfg(windows)] #[cfg(windows)]
/// Return a normal, unbuffered terminal when on Windows. /// Return a normal, unbuffered terminal when on Windows.
fn from_stderr() -> Destination { fn from_stderr() -> Destination {
let stderr: Option<Box<term::StderrTerminal>> = let stderr: Option<Box<term::StderrTerminal>> = term::TerminfoTerminal::new(io::stderr())
term::TerminfoTerminal::new(io::stderr())
.map(|t| Box::new(t) as Box<term::StderrTerminal>) .map(|t| Box::new(t) as Box<term::StderrTerminal>)
.or_else(|| term::WinConsole::new(io::stderr()).ok() .or_else(|| {
.map(|t| Box::new(t) as Box<term::StderrTerminal>)); term::WinConsole::new(io::stderr())
.ok()
.map(|t| Box::new(t) as Box<term::StderrTerminal>)
});
match stderr { match stderr {
Some(t) => Terminal(t), Some(t) => Terminal(t),
@ -878,10 +867,7 @@ impl Destination {
} }
} }
fn apply_style(&mut self, fn apply_style(&mut self, lvl: Level, style: Style) -> io::Result<()> {
lvl: Level,
style: Style)
-> io::Result<()> {
match style { match style {
Style::FileNameStyle | Style::LineAndColumn => {} Style::FileNameStyle | Style::LineAndColumn => {}
Style::LineNumber => { Style::LineNumber => {
@ -931,8 +917,12 @@ impl Destination {
fn start_attr(&mut self, attr: term::Attr) -> io::Result<()> { fn start_attr(&mut self, attr: term::Attr) -> io::Result<()> {
match *self { match *self {
Terminal(ref mut t) => { t.attr(attr)?; } Terminal(ref mut t) => {
BufferedTerminal(ref mut t) => { t.attr(attr)?; } t.attr(attr)?;
}
BufferedTerminal(ref mut t) => {
t.attr(attr)?;
}
Raw(_) => {} Raw(_) => {}
} }
Ok(()) Ok(())
@ -940,8 +930,12 @@ impl Destination {
fn reset_attrs(&mut self) -> io::Result<()> { fn reset_attrs(&mut self) -> io::Result<()> {
match *self { match *self {
Terminal(ref mut t) => { t.reset()?; } Terminal(ref mut t) => {
BufferedTerminal(ref mut t) => { t.reset()?; } t.reset()?;
}
BufferedTerminal(ref mut t) => {
t.reset()?;
}
Raw(_) => {} Raw(_) => {}
} }
Ok(()) Ok(())

View File

@ -28,8 +28,10 @@
extern crate serialize; extern crate serialize;
extern crate term; extern crate term;
#[macro_use] extern crate log; #[macro_use]
#[macro_use] extern crate libc; extern crate log;
#[macro_use]
extern crate libc;
extern crate rustc_unicode; extern crate rustc_unicode;
extern crate serialize as rustc_serialize; // used by deriving extern crate serialize as rustc_serialize; // used by deriving
extern crate syntax_pos; extern crate syntax_pos;
@ -53,7 +55,7 @@ pub mod styled_buffer;
mod lock; mod lock;
use syntax_pos::{BytePos, Loc, FileLinesResult, FileName, MultiSpan, Span, NO_EXPANSION}; use syntax_pos::{BytePos, Loc, FileLinesResult, FileName, MultiSpan, Span, NO_EXPANSION};
use syntax_pos::{MacroBacktrace}; use syntax_pos::MacroBacktrace;
#[derive(Clone)] #[derive(Clone)]
pub enum RenderSpan { pub enum RenderSpan {
@ -89,8 +91,10 @@ impl CodeSuggestion {
pub fn splice_lines(&self, cm: &CodeMapper) -> String { pub fn splice_lines(&self, cm: &CodeMapper) -> String {
use syntax_pos::{CharPos, Loc, Pos}; use syntax_pos::{CharPos, Loc, Pos};
fn push_trailing(buf: &mut String, line_opt: Option<&str>, fn push_trailing(buf: &mut String,
lo: &Loc, hi_opt: Option<&Loc>) { line_opt: Option<&str>,
lo: &Loc,
hi_opt: Option<&Loc>) {
let (lo, hi_opt) = (lo.col.to_usize(), hi_opt.map(|hi| hi.col.to_usize())); let (lo, hi_opt) = (lo.col.to_usize(), hi_opt.map(|hi| hi.col.to_usize()));
if let Some(line) = line_opt { if let Some(line) = line_opt {
if line.len() > lo { if line.len() > lo {
@ -119,7 +123,11 @@ impl CodeSuggestion {
// Find the bounding span. // Find the bounding span.
let lo = primary_spans.iter().map(|sp| sp.lo).min().unwrap(); let lo = primary_spans.iter().map(|sp| sp.lo).min().unwrap();
let hi = primary_spans.iter().map(|sp| sp.hi).min().unwrap(); let hi = primary_spans.iter().map(|sp| sp.hi).min().unwrap();
let bounding_span = Span { lo: lo, hi: hi, expn_id: NO_EXPANSION }; let bounding_span = Span {
lo: lo,
hi: hi,
expn_id: NO_EXPANSION,
};
let lines = cm.span_to_lines(bounding_span).unwrap(); let lines = cm.span_to_lines(bounding_span).unwrap();
assert!(!lines.lines.is_empty()); assert!(!lines.lines.is_empty());
@ -263,8 +271,7 @@ impl<'a> DiagnosticBuilder<'a> {
/// all, and you just supplied a `Span` to create the diagnostic, /// all, and you just supplied a `Span` to create the diagnostic,
/// then the snippet will just include that `Span`, which is /// then the snippet will just include that `Span`, which is
/// called the primary span. /// called the primary span.
pub fn span_label(&mut self, span: Span, label: &fmt::Display) pub fn span_label(&mut self, span: Span, label: &fmt::Display) -> &mut DiagnosticBuilder<'a> {
-> &mut DiagnosticBuilder<'a> {
self.span.push_span_label(span, format!("{}", label)); self.span.push_span_label(span, format!("{}", label));
self self
} }
@ -273,8 +280,7 @@ impl<'a> DiagnosticBuilder<'a> {
label: &fmt::Display, label: &fmt::Display,
expected: &fmt::Display, expected: &fmt::Display,
found: &fmt::Display) found: &fmt::Display)
-> &mut DiagnosticBuilder<'a> -> &mut DiagnosticBuilder<'a> {
{
self.note_expected_found_extra(label, expected, found, &"", &"") self.note_expected_found_extra(label, expected, found, &"", &"")
} }
@ -284,8 +290,7 @@ impl<'a> DiagnosticBuilder<'a> {
found: &fmt::Display, found: &fmt::Display,
expected_extra: &fmt::Display, expected_extra: &fmt::Display,
found_extra: &fmt::Display) found_extra: &fmt::Display)
-> &mut DiagnosticBuilder<'a> -> &mut DiagnosticBuilder<'a> {
{
// For now, just attach these as notes // For now, just attach these as notes
self.note(&format!("expected {} `{}`{}", label, expected, expected_extra)); self.note(&format!("expected {} `{}`{}", label, expected, expected_extra));
self.note(&format!(" found {} `{}`{}", label, found, found_extra)); self.note(&format!(" found {} `{}`{}", label, found, found_extra));
@ -333,7 +338,10 @@ impl<'a> DiagnosticBuilder<'a> {
msg: &str, msg: &str,
suggestion: String) suggestion: String)
-> &mut DiagnosticBuilder<'a> { -> &mut DiagnosticBuilder<'a> {
self.sub(Level::Help, msg, MultiSpan::new(), Some(Suggestion(CodeSuggestion { self.sub(Level::Help,
msg,
MultiSpan::new(),
Some(Suggestion(CodeSuggestion {
msp: sp.into(), msp: sp.into(),
substitutes: vec![suggestion], substitutes: vec![suggestion],
}))); })));
@ -360,9 +368,7 @@ impl<'a> DiagnosticBuilder<'a> {
/// Convenience function for internal use, clients should use one of the /// Convenience function for internal use, clients should use one of the
/// struct_* methods on Handler. /// struct_* methods on Handler.
fn new(handler: &'a Handler, fn new(handler: &'a Handler, level: Level, message: &str) -> DiagnosticBuilder<'a> {
level: Level,
message: &str) -> DiagnosticBuilder<'a> {
DiagnosticBuilder::new_with_code(handler, level, None, message) DiagnosticBuilder::new_with_code(handler, level, None, message)
} }
@ -371,7 +377,8 @@ impl<'a> DiagnosticBuilder<'a> {
fn new_with_code(handler: &'a Handler, fn new_with_code(handler: &'a Handler,
level: Level, level: Level,
code: Option<String>, code: Option<String>,
message: &str) -> DiagnosticBuilder<'a> { message: &str)
-> DiagnosticBuilder<'a> {
DiagnosticBuilder { DiagnosticBuilder {
handler: handler, handler: handler,
level: level, level: level,
@ -410,9 +417,8 @@ impl<'a> fmt::Debug for DiagnosticBuilder<'a> {
impl<'a> Drop for DiagnosticBuilder<'a> { impl<'a> Drop for DiagnosticBuilder<'a> {
fn drop(&mut self) { fn drop(&mut self) {
if !panicking() && !self.cancelled() { if !panicking() && !self.cancelled() {
let mut db = DiagnosticBuilder::new(self.handler, let mut db =
Bug, DiagnosticBuilder::new(self.handler, Bug, "Error constructed but not emitted");
"Error constructed but not emitted");
db.emit(); db.emit();
panic!(); panic!();
} }
@ -443,7 +449,8 @@ impl Handler {
pub fn with_emitter(can_emit_warnings: bool, pub fn with_emitter(can_emit_warnings: bool,
treat_err_as_bug: bool, treat_err_as_bug: bool,
e: Box<Emitter>) -> Handler { e: Box<Emitter>)
-> Handler {
Handler { Handler {
err_count: Cell::new(0), err_count: Cell::new(0),
emitter: RefCell::new(e), emitter: RefCell::new(e),
@ -544,10 +551,10 @@ impl Handler {
pub fn cancel(&self, err: &mut DiagnosticBuilder) { pub fn cancel(&self, err: &mut DiagnosticBuilder) {
if err.level == Level::Error || err.level == Level::Fatal { if err.level == Level::Error || err.level == Level::Fatal {
self.err_count.set( self.err_count.set(self.err_count
self.err_count.get().checked_sub(1) .get()
.expect("cancelled an error but err_count is 0") .checked_sub(1)
); .expect("cancelled an error but err_count is 0"));
} }
err.cancel(); err.cancel();
} }
@ -558,14 +565,16 @@ impl Handler {
} }
} }
pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> FatalError {
-> FatalError {
self.emit(&sp.into(), msg, Fatal); self.emit(&sp.into(), msg, Fatal);
self.bump_err_count(); self.bump_err_count();
self.panic_if_treat_err_as_bug(); self.panic_if_treat_err_as_bug();
return FatalError; return FatalError;
} }
pub fn span_fatal_with_code<S: Into<MultiSpan>>(&self, sp: S, msg: &str, code: &str) pub fn span_fatal_with_code<S: Into<MultiSpan>>(&self,
sp: S,
msg: &str,
code: &str)
-> FatalError { -> FatalError {
self.emit_with_code(&sp.into(), msg, code, Fatal); self.emit_with_code(&sp.into(), msg, code, Fatal);
self.bump_err_count(); self.bump_err_count();
@ -619,9 +628,7 @@ impl Handler {
if self.treat_err_as_bug { if self.treat_err_as_bug {
self.bug(msg); self.bug(msg);
} }
let mut db = DiagnosticBuilder::new(self, let mut db = DiagnosticBuilder::new(self, Fatal, msg);
Fatal,
msg);
db.emit(); db.emit();
self.bump_err_count(); self.bump_err_count();
FatalError FatalError
@ -630,28 +637,20 @@ impl Handler {
if self.treat_err_as_bug { if self.treat_err_as_bug {
self.bug(msg); self.bug(msg);
} }
let mut db = DiagnosticBuilder::new(self, let mut db = DiagnosticBuilder::new(self, Error, msg);
Error,
msg);
db.emit(); db.emit();
self.bump_err_count(); self.bump_err_count();
} }
pub fn warn(&self, msg: &str) { pub fn warn(&self, msg: &str) {
let mut db = DiagnosticBuilder::new(self, let mut db = DiagnosticBuilder::new(self, Warning, msg);
Warning,
msg);
db.emit(); db.emit();
} }
pub fn note_without_error(&self, msg: &str) { pub fn note_without_error(&self, msg: &str) {
let mut db = DiagnosticBuilder::new(self, let mut db = DiagnosticBuilder::new(self, Note, msg);
Note,
msg);
db.emit(); db.emit();
} }
pub fn bug(&self, msg: &str) -> ! { pub fn bug(&self, msg: &str) -> ! {
let mut db = DiagnosticBuilder::new(self, let mut db = DiagnosticBuilder::new(self, Bug, msg);
Bug,
msg);
db.emit(); db.emit();
panic!(ExplicitBug); panic!(ExplicitBug);
} }
@ -678,7 +677,7 @@ impl Handler {
match *delayed_bug { match *delayed_bug {
Some((ref span, ref errmsg)) => { Some((ref span, ref errmsg)) => {
self.span_bug(span.clone(), errmsg); self.span_bug(span.clone(), errmsg);
}, }
_ => {} _ => {}
} }
@ -686,36 +685,33 @@ impl Handler {
} }
1 => s = "aborting due to previous error".to_string(), 1 => s = "aborting due to previous error".to_string(),
_ => { _ => {
s = format!("aborting due to {} previous errors", s = format!("aborting due to {} previous errors", self.err_count.get());
self.err_count.get());
} }
} }
panic!(self.fatal(&s)); panic!(self.fatal(&s));
} }
pub fn emit(&self, pub fn emit(&self, msp: &MultiSpan, msg: &str, lvl: Level) {
msp: &MultiSpan, if lvl == Warning && !self.can_emit_warnings {
msg: &str, return;
lvl: Level) { }
if lvl == Warning && !self.can_emit_warnings { return }
let mut db = DiagnosticBuilder::new(self, lvl, msg); let mut db = DiagnosticBuilder::new(self, lvl, msg);
db.set_span(msp.clone()); db.set_span(msp.clone());
db.emit(); db.emit();
if !self.continue_after_error.get() { self.abort_if_errors(); } if !self.continue_after_error.get() {
self.abort_if_errors();
} }
pub fn emit_with_code(&self, }
msp: &MultiSpan, pub fn emit_with_code(&self, msp: &MultiSpan, msg: &str, code: &str, lvl: Level) {
msg: &str, if lvl == Warning && !self.can_emit_warnings {
code: &str, return;
lvl: Level) { }
if lvl == Warning && !self.can_emit_warnings { return } let mut db = DiagnosticBuilder::new_with_code(self, lvl, Some(code.to_owned()), msg);
let mut db = DiagnosticBuilder::new_with_code(self,
lvl,
Some(code.to_owned()),
msg);
db.set_span(msp.clone()); db.set_span(msp.clone());
db.emit(); db.emit();
if !self.continue_after_error.get() { self.abort_if_errors(); } if !self.continue_after_error.get() {
self.abort_if_errors();
}
} }
} }
@ -750,7 +746,7 @@ impl Level {
} else { } else {
term::color::YELLOW term::color::YELLOW
} }
}, }
Note => term::color::BRIGHT_GREEN, Note => term::color::BRIGHT_GREEN,
Help => term::color::BRIGHT_CYAN, Help => term::color::BRIGHT_CYAN,
Cancelled => unreachable!(), Cancelled => unreachable!(),
@ -769,8 +765,8 @@ impl Level {
} }
} }
pub fn expect<T, M>(diag: &Handler, opt: Option<T>, msg: M) -> T where pub fn expect<T, M>(diag: &Handler, opt: Option<T>, msg: M) -> T
M: FnOnce() -> String, where M: FnOnce() -> String
{ {
match opt { match opt {
Some(t) => t, Some(t) => t,

View File

@ -40,9 +40,9 @@ pub fn acquire_global_lock(name: &str) -> Box<Any> {
extern "system" { extern "system" {
fn CreateMutexA(lpMutexAttributes: LPSECURITY_ATTRIBUTES, fn CreateMutexA(lpMutexAttributes: LPSECURITY_ATTRIBUTES,
bInitialOwner: BOOL, bInitialOwner: BOOL,
lpName: LPCSTR) -> HANDLE; lpName: LPCSTR)
fn WaitForSingleObject(hHandle: HANDLE, -> HANDLE;
dwMilliseconds: DWORD) -> DWORD; fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD;
fn ReleaseMutex(hMutex: HANDLE) -> BOOL; fn ReleaseMutex(hMutex: HANDLE) -> BOOL;
fn CloseHandle(hObject: HANDLE) -> BOOL; fn CloseHandle(hObject: HANDLE) -> BOOL;
} }
@ -76,7 +76,8 @@ pub fn acquire_global_lock(name: &str) -> Box<Any> {
// open up a handle to one if it already exists. // open up a handle to one if it already exists.
let mutex = CreateMutexA(0 as *mut _, 0, cname.as_ptr() as *const u8); let mutex = CreateMutexA(0 as *mut _, 0, cname.as_ptr() as *const u8);
if mutex.is_null() { if mutex.is_null() {
panic!("failed to create global mutex named `{}`: {}", name, panic!("failed to create global mutex named `{}`: {}",
name,
io::Error::last_os_error()); io::Error::last_os_error());
} }
let mutex = Handle(mutex); let mutex = Handle(mutex);
@ -96,8 +97,10 @@ pub fn acquire_global_lock(name: &str) -> Box<Any> {
WAIT_OBJECT_0 | WAIT_ABANDONED => {} WAIT_OBJECT_0 | WAIT_ABANDONED => {}
code => { code => {
panic!("WaitForSingleObject failed on global mutex named \ panic!("WaitForSingleObject failed on global mutex named \
`{}`: {} (ret={:x})", name, `{}`: {} (ret={:x})",
io::Error::last_os_error(), code); name,
io::Error::last_os_error(),
code);
} }
} }

View File

@ -12,7 +12,7 @@ use std::collections::HashMap;
#[derive(Clone)] #[derive(Clone)]
pub struct Registry { pub struct Registry {
descriptions: HashMap<&'static str, &'static str> descriptions: HashMap<&'static str, &'static str>,
} }
impl Registry { impl Registry {

View File

@ -13,12 +13,12 @@
use syntax_pos::{Span, FileMap}; use syntax_pos::{Span, FileMap};
use CodeMapper; use CodeMapper;
use std::rc::Rc; use std::rc::Rc;
use {Level}; use Level;
#[derive(Clone)] #[derive(Clone)]
pub struct SnippetData { pub struct SnippetData {
codemap: Rc<CodeMapper>, codemap: Rc<CodeMapper>,
files: Vec<FileInfo> files: Vec<FileInfo>,
} }
#[derive(Clone)] #[derive(Clone)]

View File

@ -30,8 +30,7 @@ impl StyledBuffer {
if row < self.text.len() { if row < self.text.len() {
for i in row + 1..self.text.len() { for i in row + 1..self.text.len() {
for j in 0..self.text[i].len() { for j in 0..self.text[i].len() {
if self.text[row].len() > j && if self.text[row].len() > j && self.text[row][j] == '\t' &&
self.text[row][j] == '\t' &&
self.text[i][j] == ' ' { self.text[i][j] == ' ' {
self.text[i][j] = '\t'; self.text[i][j] = '\t';
} }