Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/bin/rustfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#![cfg(not(test))]

#[macro_use]

extern crate log;
extern crate rustfmt;
extern crate toml;
Expand All @@ -28,14 +28,6 @@ use std::str::FromStr;

use getopts::{Matches, Options};

macro_rules! msg {
($($arg:tt)*) => (
match writeln!(&mut ::std::io::stderr(), $($arg)* ) {
Ok(_) => {},
Err(x) => panic!("Unable to write to stderr: {}", x),
}
)
}

/// Rustfmt operations.
enum Operation {
Expand Down
5 changes: 3 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
extern crate toml;

use lists::{SeparatorTactic, ListTactic};
use std::io::Write;

macro_rules! configuration_option_enum{
($e:ident: $( $x:ident ),+ $(,)*) => {
Expand Down Expand Up @@ -222,9 +223,9 @@ macro_rules! create_config {
let parsed_config:ParsedConfig = match toml::decode(parsed) {
Some(decoded) => decoded,
None => {
println!("Decoding config file failed. Config:\n{}", toml);
msg!("Decoding config file failed. Config:\n{}", toml);
let parsed: toml::Value = toml.parse().expect("Could not parse TOML");
println!("\n\nParsed:\n{:?}", parsed);
msg!("\n\nParsed:\n{:?}", parsed);
panic!();
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use syntax::errors::Handler;
use syntax::errors::emitter::{ColorConfig, EmitterWriter};
use syntax::parse::{self, ParseSess};

use std::io::stdout;
use std::io::{stdout, Write};
use std::ops::{Add, Sub};
use std::path::{Path, PathBuf};
use std::rc::Rc;
Expand Down Expand Up @@ -456,7 +456,7 @@ pub fn run(input: Input, config: &Config) {

if let Err(msg) = write_result {
if !ignore_errors {
println!("Error writing files: {}", msg);
msg!("Error writing files: {}", msg);
}
}
}
10 changes: 10 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ macro_rules! try_opt {
})
}

macro_rules! msg {
($($arg:tt)*) => (
match writeln!(&mut ::std::io::stderr(), $($arg)* ) {
Ok(_) => {},
Err(x) => panic!("Unable to write to stderr: {}", x),
}
)
}


// Wraps string-like values in an Option. Returns Some when the string adheres
// to the Rewrite constraints defined for the Rewrite trait and else otherwise.
pub fn wrap_str<S: AsRef<str>>(s: S, max_width: usize, width: usize, offset: Indent) -> Option<S> {
Expand Down