From 1937bf26268d88fabd52873a2bb0ef60e078422f Mon Sep 17 00:00:00 2001
From: Alexey Shmalko <rasen.dubi@gmail.com>
Date: Fri, 3 May 2019 22:19:24 +0300
Subject: [PATCH 1/2] Migrate tidy to rust 2018 edition

---
 src/tools/tidy/Cargo.toml      | 1 +
 src/tools/tidy/src/deps.rs     | 1 +
 src/tools/tidy/src/features.rs | 2 +-
 src/tools/tidy/src/lib.rs      | 7 -------
 src/tools/tidy/src/main.rs     | 2 --
 5 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/tools/tidy/Cargo.toml b/src/tools/tidy/Cargo.toml
index f5db2487618d6..433e9264dd1dc 100644
--- a/src/tools/tidy/Cargo.toml
+++ b/src/tools/tidy/Cargo.toml
@@ -2,6 +2,7 @@
 name = "tidy"
 version = "0.1.0"
 authors = ["Alex Crichton <alex@alexcrichton.com>"]
+edition = "2018"
 
 [dependencies]
 regex = "1"
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index 411961d70bf88..e90737febd5bf 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -5,6 +5,7 @@ use std::fs;
 use std::path::Path;
 use std::process::Command;
 
+use serde_derive::Deserialize;
 use serde_json;
 
 const LICENSES: &[&str] = &[
diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs
index 3144df6dd4cdf..f9f3623679e17 100644
--- a/src/tools/tidy/src/features.rs
+++ b/src/tools/tidy/src/features.rs
@@ -18,7 +18,7 @@ use std::path::Path;
 use regex::{Regex, escape};
 
 mod version;
-use self::version::Version;
+use version::Version;
 
 const FEATURE_GROUP_START_PREFIX: &str = "// feature-group-start";
 const FEATURE_GROUP_END_PREFIX: &str = "// feature-group-end";
diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs
index 30080452edc01..d06c99725bc6a 100644
--- a/src/tools/tidy/src/lib.rs
+++ b/src/tools/tidy/src/lib.rs
@@ -3,13 +3,6 @@
 //! This library contains the tidy lints and exposes it
 //! to be used by tools.
 
-#![deny(rust_2018_idioms)]
-
-extern crate regex;
-extern crate serde_json;
-#[macro_use]
-extern crate serde_derive;
-
 use std::fs;
 
 use std::path::Path;
diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs
index 6622403826665..eef3719043825 100644
--- a/src/tools/tidy/src/main.rs
+++ b/src/tools/tidy/src/main.rs
@@ -4,10 +4,8 @@
 //! etc. This is run by default on `make check` and as part of the auto
 //! builders.
 
-#![deny(rust_2018_idioms)]
 #![deny(warnings)]
 
-extern crate tidy;
 use tidy::*;
 
 use std::process;

From bacf792f6f8b3ae2e94930eb11faeaa49f081549 Mon Sep 17 00:00:00 2001
From: Alexey Shmalko <rasen.dubi@gmail.com>
Date: Fri, 3 May 2019 22:45:59 +0300
Subject: [PATCH 2/2] tidy: Extract `let mut part` out of `parts` block in
 `version.rs`

---
 src/tools/tidy/src/features/version.rs | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/tools/tidy/src/features/version.rs b/src/tools/tidy/src/features/version.rs
index 6027e7d35e28c..1ce9fe127dd93 100644
--- a/src/tools/tidy/src/features/version.rs
+++ b/src/tools/tidy/src/features/version.rs
@@ -31,15 +31,13 @@ impl FromStr for Version {
     fn from_str(s: &str) -> Result<Self, Self::Err> {
         let mut iter = s.split('.').map(|part| Ok(part.parse()?));
 
-        let parts = {
-            let mut part = || {
-                iter.next()
-                    .unwrap_or(Err(ParseVersionError::WrongNumberOfParts))
-            };
-
-            [part()?, part()?, part()?]
+        let mut part = || {
+            iter.next()
+                .unwrap_or(Err(ParseVersionError::WrongNumberOfParts))
         };
 
+        let parts = [part()?, part()?, part()?];
+
         if let Some(_) = iter.next() {
             // Ensure we don't have more than 3 parts.
             return Err(ParseVersionError::WrongNumberOfParts);