]> git.lizzy.rs Git - rust.git/blobdiff - clippy_dummy/build.rs
better ObligationCause for normalization errors in can_type_implement_copy
[rust.git] / clippy_dummy / build.rs
index b4ea0772ee5c03730ea6c18375a9017ea6ec1fb1..21af4f8244f44f93d5d2b73c5cde5af59162c8aa 100644 (file)
@@ -1,52 +1,42 @@
-// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-extern crate term;
+use term::color::{GREEN, RED, WHITE};
+use term::{Attr, Error, Result};
 
 fn main() {
-    if let Err(_) = foo() {
-        eprintln!("error: Clippy is no longer available via crates.io\n");
-        eprintln!("help: please run `rustup component add clippy-preview` instead");
+    if foo().is_err() {
+        eprintln!(
+            "error: Clippy is no longer available via crates.io\n\n\
+             help: please run `rustup component add clippy` instead"
+        );
     }
     std::process::exit(1);
 }
 
-fn foo() -> Result<(), ()> {
-    let mut t = term::stderr().ok_or(())?;
-
-    t.attr(term::Attr::Bold).map_err(|_| ())?;
-    t.fg(term::color::RED).map_err(|_| ())?;
-    write!(t, "\nerror: ").map_err(|_| ())?;
+fn foo() -> Result<()> {
+    let mut t = term::stderr().ok_or(Error::NotSupported)?;
 
+    t.attr(Attr::Bold)?;
+    t.fg(RED)?;
+    write!(t, "\nerror: ")?;
 
-    t.reset().map_err(|_| ())?;
-    t.fg(term::color::WHITE).map_err(|_| ())?;
-    writeln!(t, "Clippy is no longer available via crates.io\n").map_err(|_| ())?;
+    t.reset()?;
+    t.fg(WHITE)?;
+    writeln!(t, "Clippy is no longer available via crates.io\n")?;
 
+    t.attr(Attr::Bold)?;
+    t.fg(GREEN)?;
+    write!(t, "help: ")?;
 
-    t.attr(term::Attr::Bold).map_err(|_| ())?;
-    t.fg(term::color::GREEN).map_err(|_| ())?;
-    write!(t, "help: ").map_err(|_| ())?;
+    t.reset()?;
+    t.fg(WHITE)?;
+    write!(t, "please run `")?;
 
+    t.attr(Attr::Bold)?;
+    write!(t, "rustup component add clippy")?;
 
-    t.reset().map_err(|_| ())?;
-    t.fg(term::color::WHITE).map_err(|_| ())?;
-    write!(t, "please run `").map_err(|_| ())?;
+    t.reset()?;
+    t.fg(WHITE)?;
+    writeln!(t, "` instead")?;
 
-    t.attr(term::Attr::Bold).map_err(|_| ())?;
-    write!(t, "rustup component add clippy-preview").map_err(|_| ())?;
-
-    t.reset().map_err(|_| ())?;
-    t.fg(term::color::WHITE).map_err(|_| ())?;
-    writeln!(t, "` instead").map_err(|_| ())?;
-
-    t.reset().map_err(|_| ())?;
+    t.reset()?;
     Ok(())
-}
\ No newline at end of file
+}