Rollup merge of #37257 - srinivasreddy:librustc_errors, r=eddyb
run rustfmt on librustc_errors folder
This commit is contained in:
commit
903e1f9657
@ -83,22 +83,22 @@ macro_rules! println_maybe_styled {
|
||||
}
|
||||
|
||||
impl EmitterWriter {
|
||||
pub fn stderr(color_config: ColorConfig,
|
||||
code_map: Option<Rc<CodeMapper>>)
|
||||
-> EmitterWriter {
|
||||
pub fn stderr(color_config: ColorConfig, code_map: Option<Rc<CodeMapper>>) -> EmitterWriter {
|
||||
if color_config.use_color() {
|
||||
let dst = Destination::from_stderr();
|
||||
EmitterWriter { dst: dst,
|
||||
cm: code_map}
|
||||
EmitterWriter {
|
||||
dst: dst,
|
||||
cm: code_map,
|
||||
}
|
||||
} else {
|
||||
EmitterWriter { dst: Raw(Box::new(io::stderr())),
|
||||
cm: code_map}
|
||||
EmitterWriter {
|
||||
dst: Raw(Box::new(io::stderr())),
|
||||
cm: code_map,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(dst: Box<Write + Send>,
|
||||
code_map: Option<Rc<CodeMapper>>)
|
||||
-> EmitterWriter {
|
||||
pub fn new(dst: Box<Write + Send>, code_map: Option<Rc<CodeMapper>>) -> EmitterWriter {
|
||||
EmitterWriter {
|
||||
dst: Raw(dst),
|
||||
cm: code_map,
|
||||
@ -237,9 +237,7 @@ impl EmitterWriter {
|
||||
'^',
|
||||
Style::UnderlinePrimary);
|
||||
if !annotation.is_minimized {
|
||||
buffer.set_style(line_offset,
|
||||
width_offset + p,
|
||||
Style::UnderlinePrimary);
|
||||
buffer.set_style(line_offset, width_offset + p, Style::UnderlinePrimary);
|
||||
}
|
||||
} else {
|
||||
buffer.putc(line_offset + 1,
|
||||
@ -247,9 +245,7 @@ impl EmitterWriter {
|
||||
'-',
|
||||
Style::UnderlineSecondary);
|
||||
if !annotation.is_minimized {
|
||||
buffer.set_style(line_offset,
|
||||
width_offset + p,
|
||||
Style::UnderlineSecondary);
|
||||
buffer.set_style(line_offset, width_offset + p, Style::UnderlineSecondary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -429,8 +425,7 @@ impl EmitterWriter {
|
||||
}
|
||||
// Check to make sure we're not in any <*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,
|
||||
"in this macro invocation".to_string()));
|
||||
break;
|
||||
@ -475,10 +470,10 @@ impl EmitterWriter {
|
||||
if spans_updated {
|
||||
children.push(SubDiagnostic {
|
||||
level: Level::Note,
|
||||
message:"this error originates in a macro outside of the current \
|
||||
crate".to_string(),
|
||||
message: "this error originates in a macro outside of the current crate"
|
||||
.to_string(),
|
||||
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, ": ", Style::NoStyle);
|
||||
buffer.append(0, msg, Style::NoStyle);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
buffer.append(0, &level.to_string(), Style::Level(level.clone()));
|
||||
match code {
|
||||
&Some(ref code) => {
|
||||
@ -522,13 +516,11 @@ impl EmitterWriter {
|
||||
let mut annotated_files = self.preprocess_annotations(msp);
|
||||
|
||||
// Make sure our primary file comes first
|
||||
let primary_lo =
|
||||
if let (Some(ref cm), Some(ref primary_span)) = (self.cm.as_ref(),
|
||||
msp.primary_span().as_ref()) {
|
||||
let primary_lo = if let (Some(ref cm), Some(ref primary_span)) =
|
||||
(self.cm.as_ref(), msp.primary_span().as_ref()) {
|
||||
if primary_span != &&DUMMY_SP && primary_span != &&COMMAND_LINE_SP {
|
||||
cm.lookup_char_pos(primary_span.lo)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
emit_to_destination(&buffer.render(), level, &mut self.dst)?;
|
||||
return Ok(());
|
||||
}
|
||||
@ -672,12 +664,7 @@ impl EmitterWriter {
|
||||
let max_line_num = self.get_max_line_num(span, children);
|
||||
let max_line_num_len = max_line_num.to_string().len();
|
||||
|
||||
match self.emit_message_default(span,
|
||||
message,
|
||||
code,
|
||||
level,
|
||||
max_line_num_len,
|
||||
false) {
|
||||
match self.emit_message_default(span, message, code, level, max_line_num_len, false) {
|
||||
Ok(()) => {
|
||||
if !children.is_empty() {
|
||||
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") {
|
||||
Err(e) => panic!("failed to emit error: {}", e),
|
||||
_ => match self.dst.flush() {
|
||||
_ => {
|
||||
match self.dst.flush() {
|
||||
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>>,
|
||||
lvl: &Level,
|
||||
dst: &mut Destination) -> io::Result<()> {
|
||||
dst: &mut Destination)
|
||||
-> io::Result<()> {
|
||||
use lock;
|
||||
|
||||
// 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;
|
||||
extern "system" {
|
||||
fn GetStdHandle(which: DWORD) -> HANDLE;
|
||||
fn GetConsoleMode(hConsoleHandle: HANDLE,
|
||||
lpMode: *mut DWORD) -> BOOL;
|
||||
fn GetConsoleMode(hConsoleHandle: HANDLE, lpMode: *mut DWORD) -> BOOL;
|
||||
}
|
||||
unsafe {
|
||||
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
|
||||
// this function unused on some platforms
|
||||
fn _new() -> BufferedWriter {
|
||||
BufferedWriter {
|
||||
buffer: vec![]
|
||||
}
|
||||
BufferedWriter { buffer: vec![] }
|
||||
}
|
||||
}
|
||||
|
||||
@ -866,11 +853,13 @@ impl Destination {
|
||||
#[cfg(windows)]
|
||||
/// Return a normal, unbuffered terminal when on Windows.
|
||||
fn from_stderr() -> Destination {
|
||||
let stderr: Option<Box<term::StderrTerminal>> =
|
||||
term::TerminfoTerminal::new(io::stderr())
|
||||
let stderr: Option<Box<term::StderrTerminal>> = term::TerminfoTerminal::new(io::stderr())
|
||||
.map(|t| Box::new(t) as Box<term::StderrTerminal>)
|
||||
.or_else(|| term::WinConsole::new(io::stderr()).ok()
|
||||
.map(|t| Box::new(t) as Box<term::StderrTerminal>));
|
||||
.or_else(|| {
|
||||
term::WinConsole::new(io::stderr())
|
||||
.ok()
|
||||
.map(|t| Box::new(t) as Box<term::StderrTerminal>)
|
||||
});
|
||||
|
||||
match stderr {
|
||||
Some(t) => Terminal(t),
|
||||
@ -878,10 +867,7 @@ impl Destination {
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_style(&mut self,
|
||||
lvl: Level,
|
||||
style: Style)
|
||||
-> io::Result<()> {
|
||||
fn apply_style(&mut self, lvl: Level, style: Style) -> io::Result<()> {
|
||||
match style {
|
||||
Style::FileNameStyle | Style::LineAndColumn => {}
|
||||
Style::LineNumber => {
|
||||
@ -931,8 +917,12 @@ impl Destination {
|
||||
|
||||
fn start_attr(&mut self, attr: term::Attr) -> io::Result<()> {
|
||||
match *self {
|
||||
Terminal(ref mut t) => { t.attr(attr)?; }
|
||||
BufferedTerminal(ref mut t) => { t.attr(attr)?; }
|
||||
Terminal(ref mut t) => {
|
||||
t.attr(attr)?;
|
||||
}
|
||||
BufferedTerminal(ref mut t) => {
|
||||
t.attr(attr)?;
|
||||
}
|
||||
Raw(_) => {}
|
||||
}
|
||||
Ok(())
|
||||
@ -940,8 +930,12 @@ impl Destination {
|
||||
|
||||
fn reset_attrs(&mut self) -> io::Result<()> {
|
||||
match *self {
|
||||
Terminal(ref mut t) => { t.reset()?; }
|
||||
BufferedTerminal(ref mut t) => { t.reset()?; }
|
||||
Terminal(ref mut t) => {
|
||||
t.reset()?;
|
||||
}
|
||||
BufferedTerminal(ref mut t) => {
|
||||
t.reset()?;
|
||||
}
|
||||
Raw(_) => {}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -28,8 +28,10 @@
|
||||
|
||||
extern crate serialize;
|
||||
extern crate term;
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate libc;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
extern crate libc;
|
||||
extern crate rustc_unicode;
|
||||
extern crate serialize as rustc_serialize; // used by deriving
|
||||
extern crate syntax_pos;
|
||||
@ -53,7 +55,7 @@ pub mod styled_buffer;
|
||||
mod lock;
|
||||
|
||||
use syntax_pos::{BytePos, Loc, FileLinesResult, FileName, MultiSpan, Span, NO_EXPANSION};
|
||||
use syntax_pos::{MacroBacktrace};
|
||||
use syntax_pos::MacroBacktrace;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum RenderSpan {
|
||||
@ -89,8 +91,10 @@ impl CodeSuggestion {
|
||||
pub fn splice_lines(&self, cm: &CodeMapper) -> String {
|
||||
use syntax_pos::{CharPos, Loc, Pos};
|
||||
|
||||
fn push_trailing(buf: &mut String, line_opt: Option<&str>,
|
||||
lo: &Loc, hi_opt: Option<&Loc>) {
|
||||
fn push_trailing(buf: &mut String,
|
||||
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()));
|
||||
if let Some(line) = line_opt {
|
||||
if line.len() > lo {
|
||||
@ -119,7 +123,11 @@ impl CodeSuggestion {
|
||||
// Find the bounding span.
|
||||
let lo = primary_spans.iter().map(|sp| sp.lo).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();
|
||||
assert!(!lines.lines.is_empty());
|
||||
|
||||
@ -263,8 +271,7 @@ impl<'a> DiagnosticBuilder<'a> {
|
||||
/// all, and you just supplied a `Span` to create the diagnostic,
|
||||
/// then the snippet will just include that `Span`, which is
|
||||
/// called the primary span.
|
||||
pub fn span_label(&mut self, span: Span, label: &fmt::Display)
|
||||
-> &mut DiagnosticBuilder<'a> {
|
||||
pub fn span_label(&mut self, span: Span, label: &fmt::Display) -> &mut DiagnosticBuilder<'a> {
|
||||
self.span.push_span_label(span, format!("{}", label));
|
||||
self
|
||||
}
|
||||
@ -273,8 +280,7 @@ impl<'a> DiagnosticBuilder<'a> {
|
||||
label: &fmt::Display,
|
||||
expected: &fmt::Display,
|
||||
found: &fmt::Display)
|
||||
-> &mut DiagnosticBuilder<'a>
|
||||
{
|
||||
-> &mut DiagnosticBuilder<'a> {
|
||||
self.note_expected_found_extra(label, expected, found, &"", &"")
|
||||
}
|
||||
|
||||
@ -284,8 +290,7 @@ impl<'a> DiagnosticBuilder<'a> {
|
||||
found: &fmt::Display,
|
||||
expected_extra: &fmt::Display,
|
||||
found_extra: &fmt::Display)
|
||||
-> &mut DiagnosticBuilder<'a>
|
||||
{
|
||||
-> &mut DiagnosticBuilder<'a> {
|
||||
// For now, just attach these as notes
|
||||
self.note(&format!("expected {} `{}`{}", label, expected, expected_extra));
|
||||
self.note(&format!(" found {} `{}`{}", label, found, found_extra));
|
||||
@ -333,7 +338,10 @@ impl<'a> DiagnosticBuilder<'a> {
|
||||
msg: &str,
|
||||
suggestion: String)
|
||||
-> &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(),
|
||||
substitutes: vec![suggestion],
|
||||
})));
|
||||
@ -360,9 +368,7 @@ impl<'a> DiagnosticBuilder<'a> {
|
||||
|
||||
/// Convenience function for internal use, clients should use one of the
|
||||
/// struct_* methods on Handler.
|
||||
fn new(handler: &'a Handler,
|
||||
level: Level,
|
||||
message: &str) -> DiagnosticBuilder<'a> {
|
||||
fn new(handler: &'a Handler, level: Level, message: &str) -> DiagnosticBuilder<'a> {
|
||||
DiagnosticBuilder::new_with_code(handler, level, None, message)
|
||||
}
|
||||
|
||||
@ -371,7 +377,8 @@ impl<'a> DiagnosticBuilder<'a> {
|
||||
fn new_with_code(handler: &'a Handler,
|
||||
level: Level,
|
||||
code: Option<String>,
|
||||
message: &str) -> DiagnosticBuilder<'a> {
|
||||
message: &str)
|
||||
-> DiagnosticBuilder<'a> {
|
||||
DiagnosticBuilder {
|
||||
handler: handler,
|
||||
level: level,
|
||||
@ -410,9 +417,8 @@ impl<'a> fmt::Debug for DiagnosticBuilder<'a> {
|
||||
impl<'a> Drop for DiagnosticBuilder<'a> {
|
||||
fn drop(&mut self) {
|
||||
if !panicking() && !self.cancelled() {
|
||||
let mut db = DiagnosticBuilder::new(self.handler,
|
||||
Bug,
|
||||
"Error constructed but not emitted");
|
||||
let mut db =
|
||||
DiagnosticBuilder::new(self.handler, Bug, "Error constructed but not emitted");
|
||||
db.emit();
|
||||
panic!();
|
||||
}
|
||||
@ -443,7 +449,8 @@ impl Handler {
|
||||
|
||||
pub fn with_emitter(can_emit_warnings: bool,
|
||||
treat_err_as_bug: bool,
|
||||
e: Box<Emitter>) -> Handler {
|
||||
e: Box<Emitter>)
|
||||
-> Handler {
|
||||
Handler {
|
||||
err_count: Cell::new(0),
|
||||
emitter: RefCell::new(e),
|
||||
@ -544,10 +551,10 @@ impl Handler {
|
||||
|
||||
pub fn cancel(&self, err: &mut DiagnosticBuilder) {
|
||||
if err.level == Level::Error || err.level == Level::Fatal {
|
||||
self.err_count.set(
|
||||
self.err_count.get().checked_sub(1)
|
||||
.expect("cancelled an error but err_count is 0")
|
||||
);
|
||||
self.err_count.set(self.err_count
|
||||
.get()
|
||||
.checked_sub(1)
|
||||
.expect("cancelled an error but err_count is 0"));
|
||||
}
|
||||
err.cancel();
|
||||
}
|
||||
@ -558,14 +565,16 @@ impl Handler {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str)
|
||||
-> FatalError {
|
||||
pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> FatalError {
|
||||
self.emit(&sp.into(), msg, Fatal);
|
||||
self.bump_err_count();
|
||||
self.panic_if_treat_err_as_bug();
|
||||
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 {
|
||||
self.emit_with_code(&sp.into(), msg, code, Fatal);
|
||||
self.bump_err_count();
|
||||
@ -619,9 +628,7 @@ impl Handler {
|
||||
if self.treat_err_as_bug {
|
||||
self.bug(msg);
|
||||
}
|
||||
let mut db = DiagnosticBuilder::new(self,
|
||||
Fatal,
|
||||
msg);
|
||||
let mut db = DiagnosticBuilder::new(self, Fatal, msg);
|
||||
db.emit();
|
||||
self.bump_err_count();
|
||||
FatalError
|
||||
@ -630,28 +637,20 @@ impl Handler {
|
||||
if self.treat_err_as_bug {
|
||||
self.bug(msg);
|
||||
}
|
||||
let mut db = DiagnosticBuilder::new(self,
|
||||
Error,
|
||||
msg);
|
||||
let mut db = DiagnosticBuilder::new(self, Error, msg);
|
||||
db.emit();
|
||||
self.bump_err_count();
|
||||
}
|
||||
pub fn warn(&self, msg: &str) {
|
||||
let mut db = DiagnosticBuilder::new(self,
|
||||
Warning,
|
||||
msg);
|
||||
let mut db = DiagnosticBuilder::new(self, Warning, msg);
|
||||
db.emit();
|
||||
}
|
||||
pub fn note_without_error(&self, msg: &str) {
|
||||
let mut db = DiagnosticBuilder::new(self,
|
||||
Note,
|
||||
msg);
|
||||
let mut db = DiagnosticBuilder::new(self, Note, msg);
|
||||
db.emit();
|
||||
}
|
||||
pub fn bug(&self, msg: &str) -> ! {
|
||||
let mut db = DiagnosticBuilder::new(self,
|
||||
Bug,
|
||||
msg);
|
||||
let mut db = DiagnosticBuilder::new(self, Bug, msg);
|
||||
db.emit();
|
||||
panic!(ExplicitBug);
|
||||
}
|
||||
@ -678,7 +677,7 @@ impl Handler {
|
||||
match *delayed_bug {
|
||||
Some((ref span, ref errmsg)) => {
|
||||
self.span_bug(span.clone(), errmsg);
|
||||
},
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@ -686,36 +685,33 @@ impl Handler {
|
||||
}
|
||||
1 => s = "aborting due to previous error".to_string(),
|
||||
_ => {
|
||||
s = format!("aborting due to {} previous errors",
|
||||
self.err_count.get());
|
||||
s = format!("aborting due to {} previous errors", self.err_count.get());
|
||||
}
|
||||
}
|
||||
|
||||
panic!(self.fatal(&s));
|
||||
}
|
||||
pub fn emit(&self,
|
||||
msp: &MultiSpan,
|
||||
msg: &str,
|
||||
lvl: Level) {
|
||||
if lvl == Warning && !self.can_emit_warnings { return }
|
||||
pub fn emit(&self, msp: &MultiSpan, msg: &str, lvl: Level) {
|
||||
if lvl == Warning && !self.can_emit_warnings {
|
||||
return;
|
||||
}
|
||||
let mut db = DiagnosticBuilder::new(self, lvl, msg);
|
||||
db.set_span(msp.clone());
|
||||
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,
|
||||
msg: &str,
|
||||
code: &str,
|
||||
lvl: Level) {
|
||||
if lvl == Warning && !self.can_emit_warnings { return }
|
||||
let mut db = DiagnosticBuilder::new_with_code(self,
|
||||
lvl,
|
||||
Some(code.to_owned()),
|
||||
msg);
|
||||
}
|
||||
pub fn emit_with_code(&self, msp: &MultiSpan, msg: &str, code: &str, lvl: Level) {
|
||||
if lvl == Warning && !self.can_emit_warnings {
|
||||
return;
|
||||
}
|
||||
let mut db = DiagnosticBuilder::new_with_code(self, lvl, Some(code.to_owned()), msg);
|
||||
db.set_span(msp.clone());
|
||||
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 {
|
||||
term::color::YELLOW
|
||||
}
|
||||
},
|
||||
}
|
||||
Note => term::color::BRIGHT_GREEN,
|
||||
Help => term::color::BRIGHT_CYAN,
|
||||
Cancelled => unreachable!(),
|
||||
@ -769,8 +765,8 @@ impl Level {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect<T, M>(diag: &Handler, opt: Option<T>, msg: M) -> T where
|
||||
M: FnOnce() -> String,
|
||||
pub fn expect<T, M>(diag: &Handler, opt: Option<T>, msg: M) -> T
|
||||
where M: FnOnce() -> String
|
||||
{
|
||||
match opt {
|
||||
Some(t) => t,
|
||||
|
@ -40,9 +40,9 @@ pub fn acquire_global_lock(name: &str) -> Box<Any> {
|
||||
extern "system" {
|
||||
fn CreateMutexA(lpMutexAttributes: LPSECURITY_ATTRIBUTES,
|
||||
bInitialOwner: BOOL,
|
||||
lpName: LPCSTR) -> HANDLE;
|
||||
fn WaitForSingleObject(hHandle: HANDLE,
|
||||
dwMilliseconds: DWORD) -> DWORD;
|
||||
lpName: LPCSTR)
|
||||
-> HANDLE;
|
||||
fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD;
|
||||
fn ReleaseMutex(hMutex: 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.
|
||||
let mutex = CreateMutexA(0 as *mut _, 0, cname.as_ptr() as *const u8);
|
||||
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());
|
||||
}
|
||||
let mutex = Handle(mutex);
|
||||
@ -96,8 +97,10 @@ pub fn acquire_global_lock(name: &str) -> Box<Any> {
|
||||
WAIT_OBJECT_0 | WAIT_ABANDONED => {}
|
||||
code => {
|
||||
panic!("WaitForSingleObject failed on global mutex named \
|
||||
`{}`: {} (ret={:x})", name,
|
||||
io::Error::last_os_error(), code);
|
||||
`{}`: {} (ret={:x})",
|
||||
name,
|
||||
io::Error::last_os_error(),
|
||||
code);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Registry {
|
||||
descriptions: HashMap<&'static str, &'static str>
|
||||
descriptions: HashMap<&'static str, &'static str>,
|
||||
}
|
||||
|
||||
impl Registry {
|
||||
|
@ -13,12 +13,12 @@
|
||||
use syntax_pos::{Span, FileMap};
|
||||
use CodeMapper;
|
||||
use std::rc::Rc;
|
||||
use {Level};
|
||||
use Level;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SnippetData {
|
||||
codemap: Rc<CodeMapper>,
|
||||
files: Vec<FileInfo>
|
||||
files: Vec<FileInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -30,8 +30,7 @@ impl StyledBuffer {
|
||||
if row < self.text.len() {
|
||||
for i in row + 1..self.text.len() {
|
||||
for j in 0..self.text[i].len() {
|
||||
if self.text[row].len() > j &&
|
||||
self.text[row][j] == '\t' &&
|
||||
if self.text[row].len() > j && self.text[row][j] == '\t' &&
|
||||
self.text[i][j] == ' ' {
|
||||
self.text[i][j] = '\t';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user