From 9dd83a9c39b747e9f0d6c5adeba87a2ca3aaea75 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Mon, 3 Jul 2017 02:59:47 -0700 Subject: [PATCH] Use 'eprintln' instead of custom 'printerr'. --- codegen/build.rs | 19 +++++-------------- lib/build.rs | 19 +++++-------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/codegen/build.rs b/codegen/build.rs index 2fffad76..8d8488a5 100644 --- a/codegen/build.rs +++ b/codegen/build.rs @@ -11,22 +11,13 @@ use version_check::{supports_features, is_min_version, is_min_date}; const MIN_DATE: &'static str = "2017-06-19"; const MIN_VERSION: &'static str = "1.19.0-nightly"; -// Convenience macro for writing to stderr. -macro_rules! printerr { - ($($arg:tt)*) => ({ - use std::io::prelude::*; - write!(&mut ::std::io::stderr(), "{}\n", format_args!($($arg)*)) - .expect("Failed to write to stderr.") - }) -} - fn main() { let ok_channel = supports_features(); let ok_version = is_min_version(MIN_VERSION); let ok_date = is_min_date(MIN_DATE); let print_version_err = |version: &str, date: &str| { - printerr!("{} {}. {} {}.", + eprintln!("{} {}. {} {}.", White.paint("Installed version is:"), Yellow.paint(format!("{} ({})", version, date)), White.paint("Minimum required:"), @@ -36,11 +27,11 @@ fn main() { match (ok_channel, ok_version, ok_date) { (Some(ok_channel), Some((ok_version, version)), Some((ok_date, date))) => { if !ok_channel { - printerr!("{} {}", + eprintln!("{} {}", Red.paint("Error:").bold(), White.paint("Rocket requires a nightly or dev version of Rust.")); print_version_err(&*version, &*date); - printerr!("{}{}{}", + eprintln!("{}{}{}", Blue.paint("See the getting started guide ("), White.paint("https://rocket.rs/guide/getting-started/"), Blue.paint(") for more information.")); @@ -48,10 +39,10 @@ fn main() { } if !ok_version || !ok_date { - printerr!("{} {}", + eprintln!("{} {}", Red.paint("Error:").bold(), White.paint("Rocket codegen requires a more recent version of rustc.")); - printerr!("{}{}{}", + eprintln!("{}{}{}", Blue.paint("Use `"), White.paint("rustup update"), Blue.paint("` or your preferred method to update Rust.")); diff --git a/lib/build.rs b/lib/build.rs index b9643c5a..5d18401f 100644 --- a/lib/build.rs +++ b/lib/build.rs @@ -11,15 +11,6 @@ use version_check::{supports_features, is_min_version, is_min_date}; const MIN_DATE: &'static str = "2017-07-02"; const MIN_VERSION: &'static str = "1.20.0-nightly"; -// Convenience macro for writing to stderr. -macro_rules! printerr { - ($($arg:tt)*) => ({ - use std::io::prelude::*; - write!(&mut ::std::io::stderr(), "{}\n", format_args!($($arg)*)) - .expect("Failed to write to stderr.") - }) -} - fn main() { let ok_channel = supports_features(); let ok_version = is_min_version(MIN_VERSION); @@ -27,7 +18,7 @@ fn main() { let triple = (ok_channel, ok_version, ok_date); let print_version_err = |version: &str, date: &str| { - printerr!("{} {}. {} {}.", + eprintln!("{} {}. {} {}.", White.paint("Installed version is:"), Yellow.paint(format!("{} ({})", version, date)), White.paint("Minimum required:"), @@ -36,11 +27,11 @@ fn main() { if let (Some(ok_channel), Some((ok_version, version)), Some((ok_date, date))) = triple { if !ok_channel { - printerr!("{} {}", + eprintln!("{} {}", Red.paint("Error:").bold(), White.paint("Rocket requires a nightly or dev version of Rust.")); print_version_err(&*version, &*date); - printerr!("{}{}{}", + eprintln!("{}{}{}", Blue.paint("See the getting started guide ("), White.paint("https://rocket.rs/guide/getting-started/"), Blue.paint(") for more information.")); @@ -48,10 +39,10 @@ fn main() { } if !ok_version || !ok_date { - printerr!("{} {}", + eprintln!("{} {}", Red.paint("Error:").bold(), White.paint("Rocket requires a more recent version of rustc.")); - printerr!("{}{}{}", + eprintln!("{}{}{}", Blue.paint("Use `"), White.paint("rustup update"), Blue.paint("` or your preferred method to update Rust."));