about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Regueiro <alex@noldorin.com>2019-02-19 02:56:42 +0000
committerSeiichi Uchida <seuchida@gmail.com>2019-02-19 11:56:42 +0900
commit7a3b7c9275f057aa1d71ea7516ef33a44bdffb7f (patch)
tree009cfe505aeb4da3150d487f1d676020549be362 /src
parent74755e86ab96ca8eaf9e3cd75a22e83edbfe8d43 (diff)
Various cosmetic improvements (#3403)
Diffstat (limited to 'src')
-rw-r--r--src/attr.rs10
-rw-r--r--src/bin/main.rs12
-rw-r--r--src/cargo-fmt/main.rs18
-rw-r--r--src/chains.rs18
-rw-r--r--src/checkstyle.rs10
-rw-r--r--src/closures.rs12
-rw-r--r--src/comment.rs67
-rw-r--r--src/config/config_type.rs24
-rw-r--r--src/config/file_lines.rs24
-rw-r--r--src/config/license.rs2
-rw-r--r--src/config/lists.rs10
-rw-r--r--src/config/mod.rs16
-rw-r--r--src/config/options.rs12
-rw-r--r--src/expr.rs16
-rw-r--r--src/format-diff/main.rs10
-rw-r--r--src/formatting.rs8
-rw-r--r--src/git-rustfmt/main.rs15
-rw-r--r--src/imports.rs18
-rw-r--r--src/issues.rs10
-rw-r--r--src/items.rs44
-rw-r--r--src/lib.rs18
-rw-r--r--src/lists.rs14
-rw-r--r--src/macros.rs28
-rw-r--r--src/matches.rs14
-rw-r--r--src/missed_spans.rs15
-rw-r--r--src/modules.rs14
-rw-r--r--src/overflow.rs12
-rw-r--r--src/pairs.rs10
-rw-r--r--src/patterns.rs15
-rw-r--r--src/reorder.rs12
-rw-r--r--src/rewrite.rs12
-rw-r--r--src/rustfmt_diff.rs14
-rw-r--r--src/shape.rs10
-rw-r--r--src/source_file.rs10
-rw-r--r--src/source_map.rs10
-rw-r--r--src/spanned.rs10
-rw-r--r--src/string.rs14
-rw-r--r--src/test/mod.rs100
-rw-r--r--src/types.rs10
-rw-r--r--src/utils.rs14
-rw-r--r--src/vertical.rs10
-rw-r--r--src/visitor.rs10
42 files changed, 167 insertions, 565 deletions
diff --git a/src/attr.rs b/src/attr.rs
index 89b0367c484..3379bf2369b 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -1,13 +1,3 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 //! Format attributes and meta items.
 
 use syntax::ast;
diff --git a/src/bin/main.rs b/src/bin/main.rs
index b357eed34cf..dc1e64a27bb 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use env_logger;
 #[macro_use]
 extern crate failure;
@@ -45,7 +35,7 @@ fn main() {
 
     // Exit with given exit code.
     //
-    // NOTE: This immediately terminates the process without doing any cleanup,
+    // NOTE: this immediately terminates the process without doing any cleanup,
     // so make sure to finish all necessary cleanup before this is called.
     std::process::exit(exit_code);
 }
diff --git a/src/cargo-fmt/main.rs b/src/cargo-fmt/main.rs
index 3873671781c..e887b940fce 100644
--- a/src/cargo-fmt/main.rs
+++ b/src/cargo-fmt/main.rs
@@ -1,14 +1,4 @@
-// Copyright 2015-2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
-// Inspired by Paul Woolcock's cargo-fmt (https://github.com/pwoolcoc/cargo-fmt/)
+// Inspired by Paul Woolcock's cargo-fmt (https://github.com/pwoolcoc/cargo-fmt/).
 
 #![cfg(not(test))]
 #![deny(warnings)]
@@ -146,12 +136,12 @@ fn format_crate(verbosity: Verbosity, strategy: &CargoFmtStrategy) -> Result<i32
         get_targets(strategy)?
     };
 
-    // Currently only bin and lib files get formatted
+    // Currently only bin and lib files get formatted.
     run_rustfmt(&targets, &rustfmt_args, verbosity)
 }
 
 fn get_fmt_args() -> Vec<String> {
-    // All arguments after -- are passed to rustfmt
+    // All arguments after -- are passed to rustfmt.
     env::args().skip_while(|a| a != "--").skip(1).collect()
 }
 
@@ -160,7 +150,7 @@ fn get_fmt_args() -> Vec<String> {
 pub struct Target {
     /// A path to the main source file of the target.
     path: PathBuf,
-    /// A kind of target (e.g. lib, bin, example, ...).
+    /// A kind of target (e.g., lib, bin, example, ...).
     kind: String,
     /// Rust edition for this target.
     edition: String,
diff --git a/src/chains.rs b/src/chains.rs
index 66862116323..3d928623aac 100644
--- a/src/chains.rs
+++ b/src/chains.rs
@@ -1,15 +1,5 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
-//! Formatting of chained expressions, i.e. expressions which are chained by
-//! dots: struct and enum field access, method calls, and try shorthand (?).
+//! Formatting of chained expressions, i.e., expressions that are chained by
+//! dots: struct and enum field access, method calls, and try shorthand (`?`).
 //!
 //! Instead of walking these subexpressions one-by-one, as is our usual strategy
 //! for expression formatting, we collect maximal sequences of these expressions
@@ -534,7 +524,7 @@ impl<'a> ChainFormatterShared<'a> {
     // ```
     //
     // In particular, overflowing is effective when the last child is a method with a multi-lined
-    // block-like argument (e.g. closure):
+    // block-like argument (e.g., closure):
     // ```ignore
     // parent.child1.child2.last_child(|a, b, c| {
     //     let x = foo(a, b, c);
@@ -853,7 +843,7 @@ impl<'a> ChainFormatter for ChainFormatterVisual<'a> {
     }
 }
 
-/// Remove try operators (`?`s) that appear in the given string. If removing
+/// Removes try operators (`?`s) that appear in the given string. If removing
 /// them leaves an empty line, remove that line as well unless it is the first
 /// line (we need the first newline for detecting pre/post comment).
 fn trim_tries(s: &str) -> String {
diff --git a/src/checkstyle.rs b/src/checkstyle.rs
index efc35a0b083..169a3741be4 100644
--- a/src/checkstyle.rs
+++ b/src/checkstyle.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::io::{self, Write};
 use std::path::Path;
 
diff --git a/src/closures.rs b/src/closures.rs
index a93d718161a..381d083c82f 100644
--- a/src/closures.rs
+++ b/src/closures.rs
@@ -1,13 +1,3 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use syntax::parse::classify;
 use syntax::source_map::Span;
 use syntax::{ast, ptr};
@@ -360,7 +350,7 @@ pub fn rewrite_last_closure(
     None
 }
 
-/// Returns true if the given vector of arguments has more than one `ast::ExprKind::Closure`.
+/// Returns `true` if the given vector of arguments has more than one `ast::ExprKind::Closure`.
 pub fn args_have_many_closure(args: &[OverflowableItem<'_>]) -> bool {
     args.iter()
         .filter_map(|arg| arg.to_expr())
diff --git a/src/comment.rs b/src/comment.rs
index d9d367fa353..83ec810381e 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 // Formatting and tools for comments.
 
 use std::{self, borrow::Cow, iter};
@@ -54,7 +44,7 @@ fn custom_opener(s: &str) -> &str {
 }
 
 impl<'a> CommentStyle<'a> {
-    /// Returns true if the commenting style covers a line only.
+    /// Returns `true` if the commenting style covers a line only.
     pub fn is_line_comment(&self) -> bool {
         match *self {
             CommentStyle::DoubleSlash
@@ -65,7 +55,7 @@ impl<'a> CommentStyle<'a> {
         }
     }
 
-    /// Returns true if the commenting style can span over multiple lines.
+    /// Returns `true` if the commenting style can span over multiple lines.
     pub fn is_block_comment(&self) -> bool {
         match *self {
             CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => {
@@ -75,7 +65,7 @@ impl<'a> CommentStyle<'a> {
         }
     }
 
-    /// Returns true if the commenting style is for documentation.
+    /// Returns `true` if the commenting style is for documentation.
     pub fn is_doc_comment(&self) -> bool {
         match *self {
             CommentStyle::TripleSlash | CommentStyle::Doc => true,
@@ -439,7 +429,7 @@ struct ItemizedBlock {
 }
 
 impl ItemizedBlock {
-    /// Returns true if the line is formatted as an item
+    /// Returns `true` if the line is formatted as an item
     fn is_itemized_line(line: &str) -> bool {
         let trimmed = line.trim_start();
         trimmed.starts_with("* ") || trimmed.starts_with("- ")
@@ -458,7 +448,7 @@ impl ItemizedBlock {
         }
     }
 
-    /// Returns a `StringFormat` used for formatting the content of an item
+    /// Returns a `StringFormat` used for formatting the content of an item.
     fn create_string_format<'a>(&'a self, fmt: &'a StringFormat<'_>) -> StringFormat<'a> {
         StringFormat {
             opener: "",
@@ -471,8 +461,8 @@ impl ItemizedBlock {
         }
     }
 
-    /// Returns true if the line is part of the current itemized block.
-    /// If it is, then it is added to the internal lines vec.
+    /// Returns `true` if the line is part of the current itemized block.
+    /// If it is, then it is added to the internal lines list.
     fn add_line(&mut self, line: &str) -> bool {
         if !ItemizedBlock::is_itemized_line(line)
             && self.indent <= line.chars().take_while(|c| c.is_whitespace()).count()
@@ -491,7 +481,7 @@ impl ItemizedBlock {
             .collect::<String>()
     }
 
-    /// Returns the block as a string under its original form
+    /// Returns the block as a string under its original form.
     fn original_block_as_string(&self) -> String {
         self.lines.join("\n")
     }
@@ -842,7 +832,7 @@ fn trim_custom_comment_prefix(s: &str) -> String {
         .join("\n")
 }
 
-/// Returns true if the given string MAY include URLs or alike.
+/// Returns `true` if the given string MAY include URLs or alike.
 fn has_url(s: &str) -> bool {
     // This function may return false positive, but should get its job done in most cases.
     s.contains("https://") || s.contains("http://") || s.contains("ftp://") || s.contains("file://")
@@ -1000,8 +990,8 @@ impl FindUncommented for str {
 
 // Returns the first byte position after the first comment. The given string
 // is expected to be prefixed by a comment, including delimiters.
-// Good: "/* /* inner */ outer */ code();"
-// Bad:  "code(); // hello\n world!"
+// Good: `/* /* inner */ outer */ code();`
+// Bad:  `code(); // hello\n world!`
 pub fn find_comment_end(s: &str) -> Option<usize> {
     let mut iter = CharClasses::new(s.char_indices());
     for (kind, (i, _c)) in &mut iter {
@@ -1010,7 +1000,7 @@ pub fn find_comment_end(s: &str) -> Option<usize> {
         }
     }
 
-    // Handle case where the comment ends at the end of s.
+    // Handle case where the comment ends at the end of `s`.
     if iter.status == CharClassesStatus::Normal {
         Some(s.len())
     } else {
@@ -1018,7 +1008,7 @@ pub fn find_comment_end(s: &str) -> Option<usize> {
     }
 }
 
-/// Returns true if text contains any comment.
+/// Returns `true` if text contains any comment.
 pub fn contains_comment(text: &str) -> bool {
     CharClasses::new(text.chars()).any(|(kind, _)| kind.is_comment())
 }
@@ -1540,7 +1530,7 @@ impl<'a> Iterator for CommentCodeSlices<'a> {
 }
 
 /// Checks is `new` didn't miss any comment from `span`, if it removed any, return previous text
-/// (if it fits in the width/offset, else return None), else return `new`
+/// (if it fits in the width/offset, else return `None`), else return `new`
 pub fn recover_comment_removed(
     new: String,
     span: Span,
@@ -1583,14 +1573,14 @@ pub fn filter_normal_code(code: &str) -> String {
     buffer
 }
 
-/// Return true if the two strings of code have the same payload of comments.
+/// Returns `true` if the two strings of code have the same payload of comments.
 /// The payload of comments is everything in the string except:
-///     - actual code (not comments)
-///     - comment start/end marks
-///     - whitespace
-///     - '*' at the beginning of lines in block comments
+/// - actual code (not comments),
+/// - comment start/end marks,
+/// - whitespace,
+/// - '*' at the beginning of lines in block comments.
 fn changed_comment_content(orig: &str, new: &str) -> bool {
-    // Cannot write this as a fn since we cannot return types containing closures
+    // Cannot write this as a fn since we cannot return types containing closures.
     let code_comment_content = |code| {
         let slices = UngroupedCommentCodeSlices::new(code);
         slices
@@ -1625,7 +1615,8 @@ impl<'a> CommentReducer<'a> {
         let comment = remove_comment_header(comment);
         CommentReducer {
             is_block,
-            at_start_line: false, // There are no supplementary '*' on the first line
+            // There are no supplementary '*' on the first line.
+            at_start_line: false,
             iter: comment.chars(),
         }
     }
@@ -1641,7 +1632,7 @@ impl<'a> Iterator for CommentReducer<'a> {
                 while c.is_whitespace() {
                     c = self.iter.next()?;
                 }
-                // Ignore leading '*'
+                // Ignore leading '*'.
                 if c == '*' {
                     c = self.iter.next()?;
                 }
@@ -1777,7 +1768,7 @@ mod test {
                                       &wrap_normalize_config).unwrap();
         assert_eq!("/* trimmed */", comment);
 
-        // check that different comment style are properly recognised
+        // Check that different comment style are properly recognised.
         let comment = rewrite_comment(r#"/// test1
                                          /// test2
                                          /*
@@ -1788,7 +1779,7 @@ mod test {
                                       &wrap_normalize_config).unwrap();
         assert_eq!("/// test1\n/// test2\n// test3", comment);
 
-        // check that the blank line marks the end of a commented paragraph
+        // Check that the blank line marks the end of a commented paragraph.
         let comment = rewrite_comment(r#"// test1
 
                                          // test2"#,
@@ -1797,7 +1788,7 @@ mod test {
                                       &wrap_normalize_config).unwrap();
         assert_eq!("// test1\n\n// test2", comment);
 
-        // check that the blank line marks the end of a custom-commented paragraph
+        // Check that the blank line marks the end of a custom-commented paragraph.
         let comment = rewrite_comment(r#"//@ test1
 
                                          //@ test2"#,
@@ -1806,7 +1797,7 @@ mod test {
                                       &wrap_normalize_config).unwrap();
         assert_eq!("//@ test1\n\n//@ test2", comment);
 
-        // check that bare lines are just indented but left unchanged otherwise
+        // Check that bare lines are just indented but otherwise left unchanged.
         let comment = rewrite_comment(r#"// test1
                                          /*
                                            a bare line!
@@ -1819,8 +1810,8 @@ mod test {
         assert_eq!("// test1\n/*\n a bare line!\n\n      another bare line!\n*/", comment);
     }
 
-    // This is probably intended to be a non-test fn, but it is not used. I'm
-    // keeping it around unless it helps us test stuff.
+    // This is probably intended to be a non-test fn, but it is not used.
+    // We should keep this around unless it helps us test stuff to remove it.
     fn uncommented(text: &str) -> String {
         CharClasses::new(text.chars())
             .filter_map(|(s, c)| match s {
diff --git a/src/config/config_type.rs b/src/config/config_type.rs
index 08d086c668e..4d09eea7c47 100644
--- a/src/config/config_type.rs
+++ b/src/config/config_type.rs
@@ -1,13 +1,3 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use crate::config::file_lines::FileLines;
 use crate::config::options::{IgnoreList, WidthHeuristics};
 
@@ -60,14 +50,14 @@ impl ConfigType for IgnoreList {
     }
 }
 
-/// Check if we're in a nightly build.
+/// Checks if we're in a nightly build.
 ///
 /// The environment variable `CFG_RELEASE_CHANNEL` is set during the rustc bootstrap
 /// to "stable", "beta", or "nightly" depending on what toolchain is being built.
 /// If we are being built as part of the stable or beta toolchains, we want
 /// to disable unstable configuration options.
 ///
-/// If we're being built by cargo (e.g. `cargo +nightly install rustfmt-nightly`),
+/// If we're being built by cargo (e.g., `cargo +nightly install rustfmt-nightly`),
 /// `CFG_RELEASE_CHANNEL` is not set. As we only support being built against the
 /// nightly compiler when installed from crates.io, default to nightly mode.
 macro_rules! is_nightly_channel {
@@ -297,13 +287,13 @@ macro_rules! create_config {
                 }
             }
 
-            /// Construct a `Config` from the toml file specified at `file_path`.
+            /// Constructs a `Config` from the toml file specified at `file_path`.
             ///
             /// This method only looks at the provided path, for a method that
             /// searches parents for a `rustfmt.toml` see `from_resolved_toml_path`.
             ///
-            /// Return a `Config` if the config could be read and parsed from
-            /// the file, Error otherwise.
+            /// Returns a `Config` if the config could be read and parsed from
+            /// the file, otherwise errors.
             pub(super) fn from_toml_path(file_path: &Path) -> Result<Config, Error> {
                 let mut file = File::open(&file_path)?;
                 let mut toml = String::new();
@@ -312,7 +302,7 @@ macro_rules! create_config {
                     .map_err(|err| Error::new(ErrorKind::InvalidData, err))
             }
 
-            /// Resolve the config for input in `dir`.
+            /// Resolves the config for input in `dir`.
             ///
             /// Searches for `rustfmt.toml` beginning with `dir`, and
             /// recursively checking parents of `dir` if no config file is found.
@@ -441,7 +431,7 @@ macro_rules! create_config {
                 self.ignore.2.add_prefix(dir);
             }
 
-            /// Returns true if the config key was explicitly set and is the default value.
+            /// Returns `true` if the config key was explicitly set and is the default value.
             pub fn is_default(&self, key: &str) -> bool {
                 $(
                     if let stringify!($i) = key {
diff --git a/src/config/file_lines.rs b/src/config/file_lines.rs
index a7371a3da90..c085a0b5deb 100644
--- a/src/config/file_lines.rs
+++ b/src/config/file_lines.rs
@@ -1,13 +1,3 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 //! This module contains types and functions to support formatting specific line ranges.
 
 use std::collections::HashMap;
@@ -191,7 +181,7 @@ impl FileLines {
         FileLines(None)
     }
 
-    /// Returns true if this `FileLines` contains all lines in all files.
+    /// Returns `true` if this `FileLines` contains all lines in all files.
     pub(crate) fn is_all(&self) -> bool {
         self.0.is_none()
     }
@@ -221,8 +211,8 @@ impl FileLines {
         }
     }
 
-    /// Returns true if `self` includes all lines in all files. Otherwise runs `f` on all ranges in
-    /// the designated file (if any) and returns true if `f` ever does.
+    /// Returns `true` if `self` includes all lines in all files. Otherwise runs `f` on all ranges
+    /// in the designated file (if any) and returns true if `f` ever does.
     fn file_range_matches<F>(&self, file_name: &FileName, f: F) -> bool
     where
         F: FnMut(&Range) -> bool,
@@ -239,23 +229,23 @@ impl FileLines {
         }
     }
 
-    /// Returns true if `range` is fully contained in `self`.
+    /// Returns `true` if `range` is fully contained in `self`.
     #[allow(dead_code)]
     pub(crate) fn contains(&self, range: &LineRange) -> bool {
         self.file_range_matches(&range.file_name(), |r| r.contains(Range::from(range)))
     }
 
-    /// Returns true if any lines in `range` are in `self`.
+    /// Returns `true` if any lines in `range` are in `self`.
     pub(crate) fn intersects(&self, range: &LineRange) -> bool {
         self.file_range_matches(&range.file_name(), |r| r.intersects(Range::from(range)))
     }
 
-    /// Returns true if `line` from `file_name` is in `self`.
+    /// Returns `true` if `line` from `file_name` is in `self`.
     pub(crate) fn contains_line(&self, file_name: &FileName, line: usize) -> bool {
         self.file_range_matches(file_name, |r| r.lo <= line && r.hi >= line)
     }
 
-    /// Returns true if all the lines between `lo` and `hi` from `file_name` are in `self`.
+    /// Returns `true` if all the lines between `lo` and `hi` from `file_name` are in `self`.
     pub(crate) fn contains_range(&self, file_name: &FileName, lo: usize, hi: usize) -> bool {
         self.file_range_matches(file_name, |r| r.contains(Range::new(lo, hi)))
     }
diff --git a/src/config/license.rs b/src/config/license.rs
index 38e37508450..7adaecf9d5c 100644
--- a/src/config/license.rs
+++ b/src/config/license.rs
@@ -67,7 +67,7 @@ impl TemplateParser {
         }
     }
 
-    /// Convert a license template into a string which can be turned into a regex.
+    /// Converts a license template into a string which can be turned into a regex.
     ///
     /// The license template could use regex syntax directly, but that would require a lot of manual
     /// escaping, which is inconvenient. It is therefore literal by default, with optional regex
diff --git a/src/config/lists.rs b/src/config/lists.rs
index 74f8e186180..79fd3db5b6e 100644
--- a/src/config/lists.rs
+++ b/src/config/lists.rs
@@ -1,13 +1,3 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 //! Configuration options related to rewriting a list.
 
 use crate::config::config_type::ConfigType;
diff --git a/src/config/mod.rs b/src/config/mod.rs
index e51279018e2..6c09e4b0b1a 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::cell::Cell;
 use std::default::Default;
 use std::fs::File;
@@ -65,7 +55,7 @@ create_config! {
     struct_lit_single_line: bool, true, false,
         "Put small struct literals on a single line";
     fn_single_line: bool, false, false, "Put single-expression functions on a single line";
-    where_single_line: bool, false, false, "Force where clauses to be on a single line";
+    where_single_line: bool, false, false, "Force where-clauses to be on a single line";
 
     // Imports
     imports_indent: IndentStyle, IndentStyle::Block, false, "Indent of imports";
@@ -157,7 +147,7 @@ create_config! {
     make_backup: bool, false, false, "Backup changed files";
 }
 
-/// Load a config by checking the client-supplied options and if appropriate, the
+/// Loads a config by checking the client-supplied options and if appropriate, the
 /// file system (including searching the file system for overrides).
 pub fn load_config<O: CliOptions>(
     file_path: Option<&Path>,
@@ -333,7 +323,7 @@ mod test {
         assert_eq!(s.contains("(unstable)"), true);
     }
 
-    // FIXME(#2183) these tests cannot be run in parallel because they use env vars
+    // FIXME(#2183): these tests cannot be run in parallel because they use env vars.
     // #[test]
     // fn test_as_not_nightly_channel() {
     //     let mut config = Config::default();
diff --git a/src/config/options.rs b/src/config/options.rs
index f167c34aedf..be32c142916 100644
--- a/src/config/options.rs
+++ b/src/config/options.rs
@@ -1,13 +1,3 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::collections::HashSet;
 use std::path::{Path, PathBuf};
 
@@ -199,7 +189,7 @@ impl NewlineStyle {
 configuration_option_enum! { BraceStyle:
     AlwaysNextLine,
     PreferSameLine,
-    // Prefer same line except where there is a where clause, in which case force
+    // Prefer same line except where there is a where-clause, in which case force
     // the brace to the next line.
     SameLineWhere,
 }
diff --git a/src/expr.rs b/src/expr.rs
index 5b59a5114b5..d4461293d60 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::borrow::Cow;
 use std::cmp::min;
 
@@ -626,7 +616,7 @@ struct ControlFlow<'a> {
     matcher: &'a str,
     connector: &'a str,
     allow_single_line: bool,
-    // True if this is an `if` expression in an `else if` :-( hacky
+    // HACK: `true` if this is an `if` expression in an `else if`.
     nested_if: bool,
     span: Span,
 }
@@ -812,7 +802,7 @@ impl<'a> ControlFlow<'a> {
     }
 }
 
-/// Returns true if the last line of pat_str has leading whitespace and it is wider than the
+/// Returns `true` if the last line of pat_str has leading whitespace and it is wider than the
 /// shape's indent.
 fn last_line_offsetted(start_column: usize, pat_str: &str) -> bool {
     let mut leading_whitespaces = 0;
@@ -1402,7 +1392,7 @@ pub fn is_nested_call(expr: &ast::Expr) -> bool {
     }
 }
 
-/// Return true if a function call or a method call represented by the given span ends with a
+/// Returns `true` if a function call or a method call represented by the given span ends with a
 /// trailing comma. This function is used when rewriting macro, as adding or removing a trailing
 /// comma from macro can potentially break the code.
 pub fn span_ends_with_comma(context: &RewriteContext<'_>, span: Span) -> bool {
diff --git a/src/format-diff/main.rs b/src/format-diff/main.rs
index 5ffff79811c..a10a04386aa 100644
--- a/src/format-diff/main.rs
+++ b/src/format-diff/main.rs
@@ -1,13 +1,3 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 // Inspired by Clang's clang-format-diff:
 //
 // https://github.com/llvm-mirror/clang/blob/master/tools/clang-format/clang-format-diff.py
diff --git a/src/formatting.rs b/src/formatting.rs
index 91930bad00a..38440802ef2 100644
--- a/src/formatting.rs
+++ b/src/formatting.rs
@@ -301,7 +301,7 @@ pub(crate) type FormatErrorMap = HashMap<FileName, Vec<FormattingError>>;
 
 #[derive(Default, Debug)]
 pub(crate) struct ReportedErrors {
-    // Encountered e.g. an IO error.
+    // Encountered e.g., an IO error.
     pub(crate) has_operational_errors: bool,
 
     // Failed to reformat code because of parsing errors.
@@ -415,7 +415,7 @@ impl Timer {
 }
 
 // Formatting done on a char by char or line by line basis.
-// FIXME(#20) other stuff for parity with make tidy
+// FIXME(#20): other stuff for parity with make tidy.
 fn format_lines(
     text: &mut String,
     name: &FileName,
@@ -446,7 +446,7 @@ struct FormatLines<'a> {
     errors: Vec<FormattingError>,
     issue_seeker: BadIssueSeeker,
     line_buffer: String,
-    // true if the current line contains a string literal.
+    // `true` if the current line contains a string literal.
     is_string: bool,
     format_line: bool,
     allow_issue_seek: bool,
@@ -593,7 +593,7 @@ impl<'a> FormatLines<'a> {
         }
     }
 
-    /// Returns true if the line with the given line number was skipped by `#[rustfmt::skip]`.
+    /// Returns `true` if the line with the given line number was skipped by `#[rustfmt::skip]`.
     fn is_skipped_line(&self) -> bool {
         self.skipped_range
             .iter()
diff --git a/src/git-rustfmt/main.rs b/src/git-rustfmt/main.rs
index aae81ba3270..67b641a384d 100644
--- a/src/git-rustfmt/main.rs
+++ b/src/git-rustfmt/main.rs
@@ -1,18 +1,5 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
-use env_logger;
-
 #[macro_use]
 extern crate log;
-use rustfmt_nightly as rustfmt;
 
 use std::env;
 use std::io::stdout;
@@ -20,7 +7,9 @@ use std::path::{Path, PathBuf};
 use std::process::Command;
 use std::str::FromStr;
 
+use env_logger;
 use getopts::{Matches, Options};
+use rustfmt_nightly as rustfmt;
 
 use crate::rustfmt::{load_config, CliOptions, Input, Session};
 
diff --git a/src/imports.rs b/src/imports.rs
index 6ca29cfeaed..43835c30e4b 100644
--- a/src/imports.rs
+++ b/src/imports.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::borrow::Cow;
 use std::cmp::Ordering;
 use std::fmt;
@@ -28,8 +18,8 @@ use crate::spanned::Spanned;
 use crate::utils::{is_same_visibility, mk_sp, rewrite_ident};
 use crate::visitor::FmtVisitor;
 
-/// Returns a name imported by a `use` declaration. e.g. returns `Ordering`
-/// for `std::cmp::Ordering` and `self` for `std::cmp::self`.
+/// Returns a name imported by a `use` declaration.
+/// E.g., returns `Ordering` for `std::cmp::Ordering` and `self` for `std::cmp::self`.
 pub fn path_to_imported_ident(path: &ast::Path) -> ast::Ident {
     path.segments.last().unwrap().ident
 }
@@ -87,7 +77,7 @@ impl<'a> FmtVisitor<'a> {
 // when ordering unless the imports are identical except for the alias (rare in
 // practice).
 
-// FIXME(#2531) - we should unify the comparison code here with the formatting
+// FIXME(#2531): we should unify the comparison code here with the formatting
 // code elsewhere since we are essentially string-ifying twice. Furthermore, by
 // parsing to our own format on comparison, we repeat a lot of work when
 // sorting.
@@ -267,7 +257,7 @@ impl UseTree {
 
     // FIXME: Use correct span?
     // The given span is essentially incorrect, since we are reconstructing
-    // use statements. This should not be a problem, though, since we have
+    // use-statements. This should not be a problem, though, since we have
     // already tried to extract comment and observed that there are no comment
     // around the given use item, and the span will not be used afterward.
     fn from_path(path: Vec<UseSegment>, span: Span) -> UseTree {
diff --git a/src/issues.rs b/src/issues.rs
index 3716110465e..c89469bff79 100644
--- a/src/issues.rs
+++ b/src/issues.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 // Objects for seeking through a char stream for occurrences of TODO and FIXME.
 // Depending on the loaded configuration, may also check that these have an
 // associated issue number.
diff --git a/src/items.rs b/src/items.rs
index 818cf5d6c91..c2568735ad8 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 // Formatting top-level items - functions, structs, enums, traits, impls.
 
 use std::borrow::Cow;
@@ -715,7 +705,7 @@ pub fn format_impl(
             false,
         )?;
 
-        // If there is no where clause, we may have missing comments between the trait name and
+        // If there is no where-clause, we may have missing comments between the trait name and
         // the opening brace.
         if generics.where_clause.predicates.is_empty() {
             if let Some(hi) = where_span_end {
@@ -737,7 +727,7 @@ pub fn format_impl(
             result.push_str(&where_clause_str);
             if where_clause_str.contains('\n') || last_line_contains_single_line_comment(&result) {
                 // if the where_clause contains extra comments AND
-                // there is only one where clause predicate
+                // there is only one where-clause predicate
                 // recover the suppressed comma in single line where_clause formatting
                 if generics.where_clause.predicates.len() == 1 {
                     result.push_str(",");
@@ -868,7 +858,7 @@ fn format_impl_ref_and_type(
         // ` for`
         let trait_ref_overhead = if trait_ref.is_some() { 4 } else { 0 };
         let curly_brace_overhead = if generics.where_clause.predicates.is_empty() {
-            // If there is no where clause adapt budget for type formatting to take space and curly
+            // If there is no where-clause adapt budget for type formatting to take space and curly
             // brace into account.
             match context.config.brace_style() {
                 BraceStyle::AlwaysNextLine => 0,
@@ -1047,7 +1037,7 @@ pub fn format_trait(
             )?;
         }
 
-        // Rewrite where clause.
+        // Rewrite where-clause.
         if !generics.where_clause.predicates.is_empty() {
             let where_density = if context.config.indent_style() == IndentStyle::Block {
                 Density::Compressed
@@ -1074,8 +1064,8 @@ pub fn format_trait(
                 option,
                 false,
             )?;
-            // If the where clause cannot fit on the same line,
-            // put the where clause on a new line
+            // If the where-clause cannot fit on the same line,
+            // put the where-clause on a new line
             if !where_clause_str.contains('\n')
                 && last_line_width(&result) + where_clause_str.len() + offset.width()
                     > context.config.comment_width()
@@ -1426,8 +1416,8 @@ fn format_tuple_struct(
             || offset.block_indent + result.len() + where_clause_str.len() + 1
                 > context.config.max_width())
     {
-        // We need to put the where clause on a new line, but we didn't
-        // know that earlier, so the where clause will not be indented properly.
+        // We need to put the where-clause on a new line, but we didn't
+        // know that earlier, so the where-clause will not be indented properly.
         result.push('\n');
         result.push_str(
             &(offset.block_only() + (context.config.tab_spaces() - 1)).to_string(context.config),
@@ -2122,7 +2112,7 @@ fn rewrite_fn_base(
                 // the closing parenthesis of the argument and the arrow '->' is considered.
                 let mut sig_length = result.len() + indent.width() + ret_str_len + 1;
 
-                // If there is no where clause, take into account the space after the return type
+                // If there is no where-clause, take into account the space after the return type
                 // and the brace.
                 if where_clause.predicates.is_empty() {
                     sig_length += 2;
@@ -2139,7 +2129,7 @@ fn rewrite_fn_base(
             } else {
                 // FIXME: we might want to check that using the arg indent
                 // doesn't blow our budget, and if it does, then fallback to
-                // the where clause indent.
+                // the where-clause indent.
                 arg_indent
             };
 
@@ -2215,7 +2205,7 @@ fn rewrite_fn_base(
         option,
         is_args_multi_lined,
     )?;
-    // If there are neither where clause nor return type, we may be missing comments between
+    // If there are neither where-clause nor return type, we may be missing comments between
     // args and `{`.
     if where_clause_str.is_empty() {
         if let ast::FunctionRetTy::Default(ret_span) = fd.output {
@@ -2245,7 +2235,7 @@ fn rewrite_fn_base(
 struct WhereClauseOption {
     suppress_comma: bool, // Force no trailing comma
     snuggle: bool,        // Do not insert newline before `where`
-    compress_where: bool, // Try single line where clause instead of vertical layout
+    compress_where: bool, // Try single line where-clause instead of vertical layout
 }
 
 impl WhereClauseOption {
@@ -2515,8 +2505,8 @@ fn rewrite_generics(
     generics: &ast::Generics,
     shape: Shape,
 ) -> Option<String> {
-    // FIXME: convert bounds to where clauses where they get too big or if
-    // there is a where clause at all.
+    // FIXME: convert bounds to where-clauses where they get too big or if
+    // there is a where-clause at all.
 
     if generics.params.is_empty() {
         return Some(ident.to_owned());
@@ -2593,7 +2583,7 @@ fn rewrite_where_clause_rfc_style(
     };
 
     // shape should be vertical only and only if we have `where_single_line` option enabled
-    // and the number of items of the where clause is equal to 1
+    // and the number of items of the where-clause is equal to 1
     let shape_tactic = if where_single_line {
         DefinitiveListTactic::Horizontal
     } else {
@@ -2703,7 +2693,7 @@ fn rewrite_where_clause(
     let tactic = definitive_tactic(&item_vec, ListTactic::Vertical, Separator::Comma, budget);
 
     let mut comma_tactic = context.config.trailing_comma();
-    // Kind of a hack because we don't usually have trailing commas in where clauses.
+    // Kind of a hack because we don't usually have trailing commas in where-clauses.
     if comma_tactic == SeparatorTactic::Vertical || where_clause_option.suppress_comma {
         comma_tactic = SeparatorTactic::Never;
     }
@@ -2945,7 +2935,7 @@ pub fn rewrite_extern_crate(context: &RewriteContext<'_>, item: &ast::Item) -> O
     })
 }
 
-/// Returns true for `mod foo;`, false for `mod foo { .. }`.
+/// Returns `true` for `mod foo;`, false for `mod foo { .. }`.
 pub fn is_mod_decl(item: &ast::Item) -> bool {
     match item.node {
         ast::ItemKind::Mod(ref m) => m.inner.hi() != item.span.hi(),
diff --git a/src/lib.rs b/src/lib.rs
index 49ddbdb0a6c..520a6e66fcd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,13 +1,3 @@
-// Copyright 2015-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 #![deny(rust_2018_idioms)]
 
 #[macro_use]
@@ -155,7 +145,7 @@ impl FormattedSnippet {
             });
     }
 
-    /// Returns true if the line n did not get formatted.
+    /// Returns `true` if the line n did not get formatted.
     fn is_line_non_formatted(&self, n: usize) -> bool {
         self.non_formatted_ranges
             .iter()
@@ -408,9 +398,9 @@ fn format_snippet(snippet: &str, config: &Config) -> Option<FormattedSnippet> {
 }
 
 /// Format the given code block. Mainly targeted for code block in comment.
-/// The code block may be incomplete (i.e. parser may be unable to parse it).
+/// The code block may be incomplete (i.e., parser may be unable to parse it).
 /// To avoid panic in parser, we wrap the code block with a dummy function.
-/// The returned code block does *not* end with newline.
+/// The returned code block does **not** end with newline.
 fn format_code_block(code_snippet: &str, config: &Config) -> Option<FormattedSnippet> {
     const FN_MAIN_PREFIX: &str = "fn main() {\n";
 
@@ -437,7 +427,7 @@ fn format_code_block(code_snippet: &str, config: &Config) -> Option<FormattedSni
     let mut is_first = true;
 
     // While formatting the code, ignore the config's newline style setting and always use "\n"
-    // instead of "\r\n" for the newline characters. This is okay because the output here is
+    // instead of "\r\n" for the newline characters. This is ok because the output here is
     // not directly outputted by rustfmt command, but used by the comment formatter's input.
     // We have output-file-wide "\n" ==> "\r\n" conversion process after here if it's necessary.
     let mut config_with_unix_newline = config.clone();
diff --git a/src/lists.rs b/src/lists.rs
index 0fb1eec68d0..cbf5d35c49c 100644
--- a/src/lists.rs
+++ b/src/lists.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 //! Format list-like expressions and items.
 
 use std::cmp;
@@ -29,7 +19,7 @@ pub struct ListFormatting<'a> {
     trailing_separator: SeparatorTactic,
     separator_place: SeparatorPlace,
     shape: Shape,
-    // Non-expressions, e.g. items, will have a new line at the end of the list.
+    // Non-expressions, e.g., items, will have a new line at the end of the list.
     // Important for comment styles.
     ends_with_newline: bool,
     // Remove newlines between list elements for expressions.
@@ -198,7 +188,7 @@ impl ListItem {
         }
     }
 
-    // true if the item causes something to be written.
+    // Returns `true` if the item causes something to be written.
     fn is_substantial(&self) -> bool {
         fn empty(s: &Option<String>) -> bool {
             match *s {
diff --git a/src/macros.rs b/src/macros.rs
index d79ae82980d..6bc181fc6f9 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 // Format list-like macro invocations. These are invocations whose token trees
 // can be interpreted as expressions and separated by commas.
 // Note that these token trees do not actually have to be interpreted as
@@ -601,9 +591,9 @@ fn replace_names(input: &str) -> Option<(String, HashMap<String, String>)> {
 
 #[derive(Debug, Clone)]
 enum MacroArgKind {
-    /// e.g. `$x: expr`.
+    /// e.g., `$x: expr`.
     MetaVariable(ast::Ident, String),
-    /// e.g. `$($foo: expr),*`
+    /// e.g., `$($foo: expr),*`
     Repeat(
         /// `()`, `[]` or `{}`.
         DelimToken,
@@ -614,12 +604,12 @@ enum MacroArgKind {
         /// The repeat token. This could be one of `*`, `+` or `?`.
         Token,
     ),
-    /// e.g. `[derive(Debug)]`
+    /// e.g., `[derive(Debug)]`
     Delimited(DelimToken, Vec<ParsedMacroArg>),
-    /// A possible separator. e.g. `,` or `;`.
+    /// A possible separator. e.g., `,` or `;`.
     Separator(String, String),
     /// Other random stuff that does not fit to other kinds.
-    /// e.g. `== foo` in `($x: expr == foo)`.
+    /// e.g., `== foo` in `($x: expr == foo)`.
     Other(String, String),
 }
 
@@ -752,13 +742,13 @@ impl ParsedMacroArg {
 
 /// Parses macro arguments on macro def.
 struct MacroArgParser {
-    /// Holds either a name of the next metavariable, a separator or a junk.
+    /// Either a name of the next metavariable, a separator, or junk.
     buf: String,
     /// The start position on the current buffer.
     lo: BytePos,
     /// The first token of the current buffer.
     start_tok: Token,
-    /// Set to true if we are parsing a metavariable or a repeat.
+    /// `true` if we are parsing a metavariable or a repeat.
     is_meta_var: bool,
     /// The position of the last token.
     hi: BytePos,
@@ -1139,8 +1129,8 @@ fn next_space(tok: &Token) -> SpaceState {
     }
 }
 
-/// Tries to convert a macro use into a short hand try expression. Returns None
-/// when the macro is not an instance of try! (or parsing the inner expression
+/// Tries to convert a macro use into a short hand try expression. Returns `None`
+/// when the macro is not an instance of `try!` (or parsing the inner expression
 /// failed).
 pub fn convert_try_mac(mac: &ast::Mac, context: &RewriteContext<'_>) -> Option<ast::Expr> {
     if &mac.node.path.to_string() == "try" {
diff --git a/src/matches.rs b/src/matches.rs
index 15ff7dbb8fe..c3102f12123 100644
--- a/src/matches.rs
+++ b/src/matches.rs
@@ -1,13 +1,3 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 //! Format match expression.
 
 use std::iter::repeat;
@@ -35,8 +25,8 @@ use crate::utils::{
 /// A simple wrapper type against `ast::Arm`. Used inside `write_list()`.
 struct ArmWrapper<'a> {
     pub arm: &'a ast::Arm,
-    /// True if the arm is the last one in match expression. Used to decide on whether we should add
-    /// trailing comma to the match arm when `config.trailing_comma() == Never`.
+    /// `true` if the arm is the last one in match expression. Used to decide on whether we should
+    /// add trailing comma to the match arm when `config.trailing_comma() == Never`.
     pub is_last: bool,
     /// Holds a byte position of `|` at the beginning of the arm pattern, if available.
     pub beginning_vert: Option<BytePos>,
diff --git a/src/missed_spans.rs b/src/missed_spans.rs
index 740378fbc2a..008efd2bef1 100644
--- a/src/missed_spans.rs
+++ b/src/missed_spans.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::borrow::Cow;
 
 use syntax::source_map::{BytePos, Pos, Span};
@@ -44,9 +34,8 @@ impl<'a> FmtVisitor<'a> {
     }
 
     pub fn format_missing(&mut self, end: BytePos) {
-        // HACK(topecongiro)
-        // We use `format_missing()` to extract a missing comment between a macro
-        // (or alike) and a trailing semicolon. Here we just try to avoid calling
+        // HACK(topecongiro): we use `format_missing()` to extract a missing comment between
+        // a macro (or similar) and a trailing semicolon. Here we just try to avoid calling
         // `format_missing_inner` in the common case where there is no such comment.
         // This is a hack, ideally we should fix a possible bug in `format_missing_inner`
         // or refactor `visit_mac` and `rewrite_macro`, but this should suffice to fix the
diff --git a/src/modules.rs b/src/modules.rs
index 1a89be66e8f..7bb50356ed8 100644
--- a/src/modules.rs
+++ b/src/modules.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::collections::BTreeMap;
 use std::io;
 use std::path::{Path, PathBuf};
@@ -47,7 +37,7 @@ fn path_value(attr: &ast::Attribute) -> Option<Symbol> {
     }
 }
 
-// N.B. Even when there are multiple `#[path = ...]` attributes, we just need to
+// N.B., even when there are multiple `#[path = ...]` attributes, we just need to
 // examine the first one, since rustc ignores the second and the subsequent ones
 // as unused attributes.
 fn find_path_value(attrs: &[ast::Attribute]) -> Option<Symbol> {
@@ -88,7 +78,7 @@ fn list_submodules<'a>(
     Ok(())
 }
 
-/// Find the file corresponding to an external mod
+/// Finds the file corresponding to an external mod
 fn module_file(
     id: ast::Ident,
     attrs: &[ast::Attribute],
diff --git a/src/overflow.rs b/src/overflow.rs
index 27923ddfc7c..ac425b591aa 100644
--- a/src/overflow.rs
+++ b/src/overflow.rs
@@ -1,13 +1,3 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 //! Rewrite a list some items with overflow.
 
 use std::cmp::min;
@@ -513,7 +503,7 @@ impl<'a> Context<'a> {
                 // When we are rewriting a nested function call, we restrict the
                 // budget for the inner function to avoid them being deeply nested.
                 // However, when the inner function has a prefix or a suffix
-                // (e.g. `foo() as u32`), this budget reduction may produce poorly
+                // (e.g., `foo() as u32`), this budget reduction may produce poorly
                 // formatted code, where a prefix or a suffix being left on its own
                 // line. Here we explicitlly check those cases.
                 if count_newlines(overflowed) == 1 {
diff --git a/src/pairs.rs b/src/pairs.rs
index 8429d33114f..421167ad6d7 100644
--- a/src/pairs.rs
+++ b/src/pairs.rs
@@ -1,13 +1,3 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use syntax::ast;
 
 use crate::config::lists::*;
diff --git a/src/patterns.rs b/src/patterns.rs
index 956ce56bdf1..2140b8d870f 100644
--- a/src/patterns.rs
+++ b/src/patterns.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax};
 use syntax::ptr;
 use syntax::source_map::{self, BytePos, Span};
@@ -29,7 +19,8 @@ use crate::spanned::Spanned;
 use crate::types::{rewrite_path, PathContext};
 use crate::utils::{format_mutability, mk_sp, rewrite_ident};
 
-/// Returns true if the given pattern is short. A short pattern is defined by the following grammar:
+/// Returns `true` if the given pattern is "short".
+/// A short pattern is defined by the following grammar:
 ///
 /// [small, ntp]:
 ///     - single token
@@ -152,7 +143,7 @@ impl Rewrite for Pat {
                 let pats: Option<Vec<String>> =
                     prefix.chain(slice_pat.into_iter()).chain(suffix).collect();
 
-                // Check that all the rewrites succeeded, and if not return None.
+                // Check that all the rewrites succeeded, and if not return `None`.
                 let pats = pats?;
 
                 // Unwrap all the sub-strings and join them with commas.
diff --git a/src/reorder.rs b/src/reorder.rs
index e078cc3279b..40f6f07c8dc 100644
--- a/src/reorder.rs
+++ b/src/reorder.rs
@@ -1,13 +1,3 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 //! Reorder items.
 //!
 //! `mod`, `extern crate` and `use` declarations are reordered in alphabetical
@@ -263,7 +253,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
         item_length
     }
 
-    /// Visit and format the given items. Items are reordered If they are
+    /// Visits and format the given items. Items are reordered If they are
     /// consecutive and reorderable.
     pub fn visit_items_with_reordering(&mut self, mut items: &[&ast::Item]) {
         while !items.is_empty() {
diff --git a/src/rewrite.rs b/src/rewrite.rs
index 5c5ed438f5e..df147e0c427 100644
--- a/src/rewrite.rs
+++ b/src/rewrite.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 // A generic trait to abstract the rewriting of an element (of the AST).
 
 use std::cell::RefCell;
@@ -56,7 +46,7 @@ impl<'a> RewriteContext<'a> {
         self.snippet_provider.span_to_snippet(span).unwrap()
     }
 
-    /// Return true if we should use block indent style for rewriting function call.
+    /// Returns `true` if we should use block indent style for rewriting function call.
     pub fn use_block_indent(&self) -> bool {
         self.config.indent_style() == IndentStyle::Block || *self.use_block.borrow()
     }
diff --git a/src/rustfmt_diff.rs b/src/rustfmt_diff.rs
index 81778c33ecf..c6262dcab15 100644
--- a/src/rustfmt_diff.rs
+++ b/src/rustfmt_diff.rs
@@ -1,13 +1,3 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::collections::VecDeque;
 use std::io;
 use std::io::Write;
@@ -184,11 +174,11 @@ where
     }
 }
 
-/// Convert a Mismatch into a serialised form which just includes
+/// Converts a `Mismatch` into a serialized form, which just includes
 /// enough information to modify the original file.
 /// Each section starts with a line with three integers, space separated:
 ///     lineno num_removed num_added
-/// followed by (num_added) lines of added text.  The line numbers are
+/// followed by (`num_added`) lines of added text. The line numbers are
 /// relative to the original file.
 pub fn output_modified<W>(mut out: W, diff: Vec<Mismatch>)
 where
diff --git a/src/shape.rs b/src/shape.rs
index 1b1217346fa..d793d99a318 100644
--- a/src/shape.rs
+++ b/src/shape.rs
@@ -1,13 +1,3 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::borrow::Cow;
 use std::cmp::min;
 use std::ops::{Add, Sub};
diff --git a/src/source_file.rs b/src/source_file.rs
index b26cd0521fa..07c1e37fbed 100644
--- a/src/source_file.rs
+++ b/src/source_file.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::fs;
 use std::io::{self, Write};
 
diff --git a/src/source_map.rs b/src/source_map.rs
index 8caff51ee40..d0c4adbe61d 100644
--- a/src/source_map.rs
+++ b/src/source_map.rs
@@ -1,13 +1,3 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 //! This module contains utilities that work with the `SourceMap` from `libsyntax`/`syntex_syntax`.
 //! This includes extension traits and methods for looking up spans and line ranges for AST nodes.
 
diff --git a/src/spanned.rs b/src/spanned.rs
index 22079a45bea..068a3b8b4f4 100644
--- a/src/spanned.rs
+++ b/src/spanned.rs
@@ -1,13 +1,3 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::cmp::max;
 
 use syntax::{
diff --git a/src/string.rs b/src/string.rs
index cb174841738..8b910c0b4ce 100644
--- a/src/string.rs
+++ b/src/string.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 // Format string literals.
 
 use regex::Regex;
@@ -163,8 +153,8 @@ pub fn rewrite_string<'a>(
     wrap_str(result, fmt.config.max_width(), fmt.shape)
 }
 
-/// Returns the index to the end of the url if the given string includes an
-/// URL or alike. Otherwise, returns None;
+/// Returns the index to the end of the URL if the given string includes an
+/// URL or alike. Otherwise, returns `None`;
 fn detect_url(s: &[&str], index: usize) -> Option<usize> {
     let start = match s[..=index].iter().rposition(|g| is_whitespace(g)) {
         Some(pos) => pos + 1,
diff --git a/src/test/mod.rs b/src/test/mod.rs
index ac2a1a3ba22..2d1a62ceda5 100644
--- a/src/test/mod.rs
+++ b/src/test/mod.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::collections::{HashMap, HashSet};
 use std::env;
 use std::fs;
@@ -27,17 +17,17 @@ use crate::{FormatReport, Input, Session};
 const DIFF_CONTEXT_SIZE: usize = 3;
 const CONFIGURATIONS_FILE_NAME: &str = "Configurations.md";
 
-// Returns a `Vec` containing `PathBuf`s of files with a rs extension in the
+// Returns a `Vec` containing `PathBuf`s of files with an  `rs` extension in the
 // given path. The `recursive` argument controls if files from subdirectories
 // are also returned.
 fn get_test_files(path: &Path, recursive: bool) -> Vec<PathBuf> {
     let mut files = vec![];
     if path.is_dir() {
         for entry in fs::read_dir(path).expect(&format!(
-            "Couldn't read directory {}",
+            "couldn't read directory {}",
             path.to_str().unwrap()
         )) {
-            let entry = entry.expect("Couldn't get DirEntry");
+            let entry = entry.expect("couldn't get `DirEntry`");
             let path = entry.path();
             if path.is_dir() && recursive {
                 files.append(&mut get_test_files(&path, recursive));
@@ -51,15 +41,15 @@ fn get_test_files(path: &Path, recursive: bool) -> Vec<PathBuf> {
 
 fn verify_config_used(path: &Path, config_name: &str) {
     for entry in fs::read_dir(path).expect(&format!(
-        "Couldn't read {} directory",
+        "couldn't read {} directory",
         path.to_str().unwrap()
     )) {
-        let entry = entry.expect("Couldn't get directory entry");
+        let entry = entry.expect("couldn't get directory entry");
         let path = entry.path();
         if path.extension().map_or(false, |f| f == "rs") {
             // check if "// rustfmt-<config_name>:" appears in the file.
             let filebuf = BufReader::new(
-                fs::File::open(&path).expect(&format!("Couldn't read file {}", path.display())),
+                fs::File::open(&path).expect(&format!("couldn't read file {}", path.display())),
             );
             assert!(
                 filebuf
@@ -82,8 +72,8 @@ fn verify_config_test_names() {
         Path::new("tests/source/configs"),
         Path::new("tests/target/configs"),
     ] {
-        for entry in fs::read_dir(path).expect("Couldn't read configs directory") {
-            let entry = entry.expect("Couldn't get directory entry");
+        for entry in fs::read_dir(path).expect("couldn't read configs directory") {
+            let entry = entry.expect("couldn't get directory entry");
             let path = entry.path();
             if path.is_dir() {
                 let config_name = path.file_name().unwrap().to_str().unwrap();
@@ -95,8 +85,8 @@ fn verify_config_test_names() {
     }
 }
 
-// This writes to the terminal using the same approach (via term::stdout or
-// println!) that is used by `rustfmt::rustfmt_diff::print_diff`. Writing
+// This writes to the terminal using the same approach (via `term::stdout` or
+// `println!`) that is used by `rustfmt::rustfmt_diff::print_diff`. Writing
 // using only one or the other will cause the output order to differ when
 // `print_diff` selects the approach not used.
 fn write_message(msg: &str) {
@@ -104,8 +94,8 @@ fn write_message(msg: &str) {
     writer.writeln(msg, None);
 }
 
-// Integration tests. The files in the tests/source are formatted and compared
-// to their equivalent in tests/target. The target file and config can be
+// Integration tests. The files in `tests/source` are formatted and compared
+// to their equivalent in `tests/target`. The target file and config can be
 // overridden by annotations in the source file. The input and output must match
 // exactly.
 #[test]
@@ -119,8 +109,8 @@ fn system_tests() {
     assert_eq!(fails, 0, "{} system tests failed", fails);
 }
 
-// Do the same for tests/coverage-source directory
-// the only difference is the coverage mode
+// Do the same for tests/coverage-source directory.
+// The only difference is the coverage mode.
 #[test]
 fn coverage_tests() {
     let files = get_test_files(Path::new("tests/coverage/source"), true);
@@ -205,7 +195,7 @@ fn assert_output(source: &Path, expected_filename: &Path) {
     let _ = source_file::write_all_files(&source_file, &mut out, &config);
     let output = String::from_utf8(out).unwrap();
 
-    let mut expected_file = fs::File::open(&expected_filename).expect("Couldn't open target");
+    let mut expected_file = fs::File::open(&expected_filename).expect("couldn't open target");
     let mut expected_text = String::new();
     expected_file
         .read_to_string(&mut expected_text)
@@ -290,7 +280,7 @@ fn stdin_formatting_smoke_test() {
 
 #[test]
 fn stdin_parser_panic_caught() {
-    // https://github.com/rust-lang/rustfmt/issues/3239
+    // See issue #3239.
     for text in ["{", "}"].iter().cloned().map(String::from) {
         let mut buf = vec![];
         let mut session = Session::new(Default::default(), Some(&mut buf));
@@ -304,7 +294,8 @@ fn stdin_parser_panic_caught() {
 fn stdin_disable_all_formatting_test() {
     match option_env!("CFG_RELEASE_CHANNEL") {
         None | Some("nightly") => {}
-        _ => return, // these tests require nightly
+        // These tests require nightly.
+        _ => return,
     }
     let input = String::from("fn main() { println!(\"This should not be formatted.\"); }");
     let mut child = Command::new(rustfmt().to_str().unwrap())
@@ -407,7 +398,7 @@ fn print_mismatches<T: Fn(u32) -> String>(
 
 fn read_config(filename: &Path) -> Config {
     let sig_comments = read_significant_comments(filename);
-    // Look for a config file... If there is a 'config' property in the significant comments, use
+    // Look for a config file. If there is a 'config' property in the significant comments, use
     // that. Otherwise, if there are no significant comments at all, look for a config file with
     // the same name as the test file.
     let mut config = if !sig_comments.is_empty() {
@@ -453,7 +444,7 @@ fn idempotent_check(
 ) -> Result<FormatReport, IdempotentCheckError> {
     let sig_comments = read_significant_comments(filename);
     let config = if let Some(ref config_file_path) = opt_config {
-        Config::from_toml_path(config_file_path).expect("rustfmt.toml not found")
+        Config::from_toml_path(config_file_path).expect("`rustfmt.toml` not found")
     } else {
         read_config(filename)
     };
@@ -490,43 +481,42 @@ fn get_config(config_file: Option<&Path>) -> Config {
         }
     };
 
-    let mut def_config_file = fs::File::open(config_file_name).expect("Couldn't open config");
+    let mut def_config_file = fs::File::open(config_file_name).expect("couldn't open config");
     let mut def_config = String::new();
     def_config_file
         .read_to_string(&mut def_config)
         .expect("Couldn't read config");
 
-    Config::from_toml(&def_config, Path::new("tests/config/")).expect("Invalid toml")
+    Config::from_toml(&def_config, Path::new("tests/config/")).expect("invalid TOML")
 }
 
-// Reads significant comments of the form: // rustfmt-key: value
-// into a hash map.
+// Reads significant comments of the form: `// rustfmt-key: value` into a hash map.
 fn read_significant_comments(file_name: &Path) -> HashMap<String, String> {
     let file =
-        fs::File::open(file_name).expect(&format!("Couldn't read file {}", file_name.display()));
+        fs::File::open(file_name).expect(&format!("couldn't read file {}", file_name.display()));
     let reader = BufReader::new(file);
     let pattern = r"^\s*//\s*rustfmt-([^:]+):\s*(\S+)";
-    let regex = regex::Regex::new(pattern).expect("Failed creating pattern 1");
+    let regex = regex::Regex::new(pattern).expect("failed creating pattern 1");
 
     // Matches lines containing significant comments or whitespace.
     let line_regex = regex::Regex::new(r"(^\s*$)|(^\s*//\s*rustfmt-[^:]+:\s*\S+)")
-        .expect("Failed creating pattern 2");
+        .expect("failed creating pattern 2");
 
     reader
         .lines()
-        .map(|line| line.expect("Failed getting line"))
+        .map(|line| line.expect("failed getting line"))
         .take_while(|line| line_regex.is_match(line))
         .filter_map(|line| {
             regex.captures_iter(&line).next().map(|capture| {
                 (
                     capture
                         .get(1)
-                        .expect("Couldn't unwrap capture")
+                        .expect("couldn't unwrap capture")
                         .as_str()
                         .to_owned(),
                     capture
                         .get(2)
-                        .expect("Couldn't unwrap capture")
+                        .expect("couldn't unwrap capture")
                         .as_str()
                         .to_owned(),
                 )
@@ -535,7 +525,7 @@ fn read_significant_comments(file_name: &Path) -> HashMap<String, String> {
         .collect()
 }
 
-// Compare output to input.
+// Compares output to input.
 // TODO: needs a better name, more explanation.
 fn handle_result(
     result: HashMap<PathBuf, String>,
@@ -546,11 +536,11 @@ fn handle_result(
     for (file_name, fmt_text) in result {
         // If file is in tests/source, compare to file with same name in tests/target.
         let target = get_target(&file_name, target);
-        let open_error = format!("Couldn't open target {:?}", &target);
+        let open_error = format!("couldn't open target {:?}", &target);
         let mut f = fs::File::open(&target).expect(&open_error);
 
         let mut text = String::new();
-        let read_error = format!("Failed reading target {:?}", &target);
+        let read_error = format!("failed reading target {:?}", &target);
         f.read_to_string(&mut text).expect(&read_error);
 
         // Ignore LF and CRLF difference for Windows.
@@ -571,7 +561,7 @@ fn handle_result(
     }
 }
 
-// Map source file paths to their target paths.
+// Maps source file paths to their target paths.
 fn get_target(file_name: &Path, target: Option<&str>) -> PathBuf {
     if let Some(n) = file_name
         .components()
@@ -591,7 +581,7 @@ fn get_target(file_name: &Path, target: Option<&str>) -> PathBuf {
             target_file_name
         }
     } else {
-        // This is either and idempotence check or a self check
+        // This is either and idempotence check or a self check.
         file_name.to_owned()
     }
 }
@@ -674,10 +664,10 @@ impl ConfigurationSection {
     ) -> Option<ConfigurationSection> {
         lazy_static! {
             static ref CONFIG_NAME_REGEX: regex::Regex =
-                regex::Regex::new(r"^## `([^`]+)`").expect("Failed creating configuration pattern");
+                regex::Regex::new(r"^## `([^`]+)`").expect("failed creating configuration pattern");
             static ref CONFIG_VALUE_REGEX: regex::Regex =
                 regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#)
-                    .expect("Failed creating configuration value pattern");
+                    .expect("failed creating configuration value pattern");
         }
 
         loop {
@@ -899,7 +889,7 @@ fn configuration_snippet_tests() {
     fn get_code_blocks() -> Vec<ConfigCodeBlock> {
         let mut file_iter = BufReader::new(
             fs::File::open(Path::new(CONFIGURATIONS_FILE_NAME))
-                .expect(&format!("Couldn't read file {}", CONFIGURATIONS_FILE_NAME)),
+                .expect(&format!("couldn't read file {}", CONFIGURATIONS_FILE_NAME)),
         )
         .lines()
         .map(|l| l.unwrap())
@@ -945,28 +935,30 @@ fn make_temp_file(file_name: &'static str) -> TempFile {
     let target_dir = var("RUSTFMT_TEST_DIR").unwrap_or_else(|_| ".".to_owned());
     let path = Path::new(&target_dir).join(file_name);
 
-    let mut file = File::create(&path).expect("Couldn't create temp file");
+    let mut file = File::create(&path).expect("couldn't create temp file");
     let content = "fn main() {}\n";
     file.write_all(content.as_bytes())
-        .expect("Couldn't write temp file");
+        .expect("couldn't write temp file");
     TempFile { path }
 }
 
 impl Drop for TempFile {
     fn drop(&mut self) {
         use std::fs::remove_file;
-        remove_file(&self.path).expect("Couldn't delete temp file");
+        remove_file(&self.path).expect("couldn't delete temp file");
     }
 }
 
 fn rustfmt() -> PathBuf {
     let mut me = env::current_exe().expect("failed to get current executable");
-    me.pop(); // chop of the test name
-    me.pop(); // chop off `deps`
+    // Chop of the test name.
+    me.pop();
+    // Chop off `deps`.
+    me.pop();
 
-    // if we run `cargo test --release` we might only have a release build
+    // If we run `cargo test --release`, we might only have a release build.
     if cfg!(release) {
-        // ../release/
+        // `../release/`
         me.pop();
         me.push("release");
     }
diff --git a/src/types.rs b/src/types.rs
index 10b46959136..e2ddc49bf86 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::iter::ExactSizeIterator;
 use std::ops::Deref;
 
diff --git a/src/utils.rs b/src/utils.rs
index b7f08a556e8..e42b5c8c7d1 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::borrow::Cow;
 
 use bytecount;
@@ -320,7 +310,7 @@ pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
     Span::new(lo, hi, NO_EXPANSION)
 }
 
-// Return true if the given span does not intersect with file lines.
+// Returns `true` if the given span does not intersect with file lines.
 macro_rules! out_of_file_lines_range {
     ($self:ident, $span:expr) => {
         !$self.config.file_lines().is_all()
@@ -454,7 +444,7 @@ pub fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr: &str)
     }
 }
 
-/// Remove trailing spaces from the specified snippet. We do not remove spaces
+/// Removes trailing spaces from the specified snippet. We do not remove spaces
 /// inside strings or comments.
 pub fn remove_trailing_white_spaces(text: &str) -> String {
     let mut buffer = String::with_capacity(text.len());
diff --git a/src/vertical.rs b/src/vertical.rs
index fe476c0bd40..9dca1d600f3 100644
--- a/src/vertical.rs
+++ b/src/vertical.rs
@@ -1,13 +1,3 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 // Format with vertical alignment.
 
 use std::cmp;
diff --git a/src/visitor.rs b/src/visitor.rs
index 8ca53401126..0d350e66c1a 100644
--- a/src/visitor.rs
+++ b/src/visitor.rs
@@ -1,13 +1,3 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// 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.
-
 use std::cell::RefCell;
 
 use syntax::parse::ParseSess;