From 5a9b70462a885ea8a4522c07f3fb22412dbe1878 Mon Sep 17 00:00:00 2001
From: Nicholas Nethercote <nnethercote@mozilla.com>
Date: Wed, 13 Nov 2019 08:35:52 +1100
Subject: [PATCH 01/26] Improve comments about NodeStates.

This commit clarifies some comments, fixes some minor errors in
comments, and adds a state transition diagram.
---
 .../obligation_forest/mod.rs                  | 73 +++++++++++++------
 1 file changed, 52 insertions(+), 21 deletions(-)

diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs
index 958ab617cb315..75ffa076b0848 100644
--- a/src/librustc_data_structures/obligation_forest/mod.rs
+++ b/src/librustc_data_structures/obligation_forest/mod.rs
@@ -130,12 +130,11 @@ type ObligationTreeIdGenerator =
 pub struct ObligationForest<O: ForestObligation> {
     /// The list of obligations. In between calls to
     /// `process_obligations`, this list only contains nodes in the
-    /// `Pending` or `Success` state (with a non-zero number of
+    /// `Pending` or `Waiting` state (with a non-zero number of
     /// incomplete children). During processing, some of those nodes
     /// may be changed to the error state, or we may find that they
-    /// are completed (That is, `num_incomplete_children` drops to 0).
-    /// At the end of processing, those nodes will be removed by a
-    /// call to `compress`.
+    /// are completed. At the end of processing, those nodes will be
+    /// removed by a call to `compress`.
     ///
     /// `usize` indices are used here and throughout this module, rather than
     /// `rustc_index::newtype_index!` indices, because this code is hot enough that the
@@ -211,28 +210,56 @@ impl<O> Node<O> {
 /// represents the current state of processing for the obligation (of
 /// type `O`) associated with this node.
 ///
-/// Outside of ObligationForest methods, nodes should be either Pending
-/// or Waiting.
+/// The non-`Error` state transitions are as follows.
+/// ```
+/// (Pre-creation)
+///  |
+///  |     register_obligation_at() (called by process_obligations() and
+///  v                               from outside the crate)
+/// Pending
+///  |
+///  |     process_obligations()
+///  v
+/// Success
+///  |  ^
+///  |  |  mark_as_waiting()
+///  |  v
+///  | Waiting
+///  |
+///  |     process_cycles()
+///  v
+/// Done
+///  |
+///  |     compress()
+///  v
+/// (Removed)
+/// ```
+/// The `Error` state can be introduced in several places, via `error_at()`.
+///
+/// Outside of `ObligationForest` methods, nodes should be either `Pending` or
+/// `Waiting`.
 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
 enum NodeState {
-    /// Obligations for which selection had not yet returned a
-    /// non-ambiguous result.
+    /// This obligation has not yet been selected successfully. Cannot have
+    /// subobligations.
     Pending,
 
-    /// This obligation was selected successfully, but may or
-    /// may not have subobligations.
+    /// This obligation was selected successfully, but the state of any
+    /// subobligations are current unknown. It will be converted to `Waiting`
+    /// or `Done` once the states of the subobligations become known.
     Success,
 
-    /// This obligation was selected successfully, but it has
-    /// a pending subobligation.
+    /// This obligation was selected successfully, but it has one or more
+    /// pending subobligations.
     Waiting,
 
-    /// This obligation, along with its subobligations, are complete,
-    /// and will be removed in the next collection.
+    /// This obligation was selected successfully, as were all of its
+    /// subobligations (of which there may be none). It will be removed by the
+    /// next compression step.
     Done,
 
-    /// This obligation was resolved to an error. Error nodes are
-    /// removed from the vector by the compression step.
+    /// This obligation was resolved to an error. It will be removed by the
+    /// next compression step.
     Error,
 }
 
@@ -466,10 +493,9 @@ impl<O: ForestObligation> ObligationForest<O> {
         }
     }
 
-    /// Mark all `NodeState::Success` nodes as `NodeState::Done` and
-    /// report all cycles between them. This should be called
-    /// after `mark_as_waiting` marks all nodes with pending
-    /// subobligations as NodeState::Waiting.
+    /// Mark all `Success` nodes as `Done` and report all cycles between them.
+    /// This should be called after `mark_as_waiting` updates the status of all
+    /// `Waiting` and `Success` nodes.
     fn process_cycles<P>(&self, processor: &mut P)
         where P: ObligationProcessor<Obligation=O>
     {
@@ -575,14 +601,19 @@ impl<O: ForestObligation> ObligationForest<O> {
         self.inlined_mark_neighbors_as_waiting_from(node)
     }
 
-    /// Marks all nodes that depend on a pending node as `NodeState::Waiting`.
+    /// Updates the states of all `Waiting` and `Success` nodes. Upon
+    /// completion, all such nodes that depend on a pending node will be marked
+    /// as `Waiting`, and all others will be marked as `Success`.
     fn mark_as_waiting(&self) {
+        // Optimistically mark all `Waiting` nodes as `Success`.
         for node in &self.nodes {
             if node.state.get() == NodeState::Waiting {
                 node.state.set(NodeState::Success);
             }
         }
 
+        // Convert all `Success` nodes that still depend on a pending node to
+        // `Waiting`. This may undo some of the changes done in the loop above.
         for node in &self.nodes {
             if node.state.get() == NodeState::Pending {
                 // This call site is hot.

From c45fc6b104549fbcfc8819a6218be367d312cb4b Mon Sep 17 00:00:00 2001
From: Nicholas Nethercote <nnethercote@mozilla.com>
Date: Thu, 14 Nov 2019 17:08:22 +1100
Subject: [PATCH 02/26] Give two functions clearer names.

---
 .../obligation_forest/mod.rs                  | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs
index 75ffa076b0848..1ffa279b3aa8f 100644
--- a/src/librustc_data_structures/obligation_forest/mod.rs
+++ b/src/librustc_data_structures/obligation_forest/mod.rs
@@ -222,7 +222,7 @@ impl<O> Node<O> {
 ///  v
 /// Success
 ///  |  ^
-///  |  |  mark_as_waiting()
+///  |  |  update_waiting_and_success_states()
 ///  |  v
 ///  | Waiting
 ///  |
@@ -480,7 +480,7 @@ impl<O: ForestObligation> ObligationForest<O> {
             };
         }
 
-        self.mark_as_waiting();
+        self.update_waiting_and_success_states();
         self.process_cycles(processor);
         let completed = self.compress(do_completed);
 
@@ -494,8 +494,8 @@ impl<O: ForestObligation> ObligationForest<O> {
     }
 
     /// Mark all `Success` nodes as `Done` and report all cycles between them.
-    /// This should be called after `mark_as_waiting` updates the status of all
-    /// `Waiting` and `Success` nodes.
+    /// This should be called after `update_waiting_and_success_states` updates
+    /// the status of all `Waiting` and `Success` nodes.
     fn process_cycles<P>(&self, processor: &mut P)
         where P: ObligationProcessor<Obligation=O>
     {
@@ -577,7 +577,7 @@ impl<O: ForestObligation> ObligationForest<O> {
 
     // This always-inlined function is for the hot call site.
     #[inline(always)]
-    fn inlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
+    fn inlined_mark_dependents_as_waiting(&self, node: &Node<O>) {
         for &index in node.dependents.iter() {
             let node = &self.nodes[index];
             match node.state.get() {
@@ -585,11 +585,11 @@ impl<O: ForestObligation> ObligationForest<O> {
                 NodeState::Success => {
                     node.state.set(NodeState::Waiting);
                     // This call site is cold.
-                    self.uninlined_mark_neighbors_as_waiting_from(node);
+                    self.uninlined_mark_dependents_as_waiting(node);
                 }
                 NodeState::Pending | NodeState::Done => {
                     // This call site is cold.
-                    self.uninlined_mark_neighbors_as_waiting_from(node);
+                    self.uninlined_mark_dependents_as_waiting(node);
                 }
             }
         }
@@ -597,14 +597,14 @@ impl<O: ForestObligation> ObligationForest<O> {
 
     // This never-inlined function is for the cold call site.
     #[inline(never)]
-    fn uninlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
-        self.inlined_mark_neighbors_as_waiting_from(node)
+    fn uninlined_mark_dependents_as_waiting(&self, node: &Node<O>) {
+        self.inlined_mark_dependents_as_waiting(node)
     }
 
     /// Updates the states of all `Waiting` and `Success` nodes. Upon
     /// completion, all such nodes that depend on a pending node will be marked
     /// as `Waiting`, and all others will be marked as `Success`.
-    fn mark_as_waiting(&self) {
+    fn update_waiting_and_success_states(&self) {
         // Optimistically mark all `Waiting` nodes as `Success`.
         for node in &self.nodes {
             if node.state.get() == NodeState::Waiting {
@@ -617,7 +617,7 @@ impl<O: ForestObligation> ObligationForest<O> {
         for node in &self.nodes {
             if node.state.get() == NodeState::Pending {
                 // This call site is hot.
-                self.inlined_mark_neighbors_as_waiting_from(node);
+                self.inlined_mark_dependents_as_waiting(node);
             }
         }
     }

From c874789613302d87b7b2667dead94c6e9540a877 Mon Sep 17 00:00:00 2001
From: Stefan Lankes <slankes@eonerc.rwth-aachen.de>
Date: Mon, 25 Nov 2019 08:59:23 +0100
Subject: [PATCH 03/26] remove dependency from libhermit

The build process of the unikernel HermitCore is redesigned and
doesn't longer depend on libhermit.
---
 src/libstd/build.rs | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/libstd/build.rs b/src/libstd/build.rs
index 1f839f165320f..8db7bc12cd308 100644
--- a/src/libstd/build.rs
+++ b/src/libstd/build.rs
@@ -54,7 +54,5 @@ fn main() {
         }
         println!("cargo:rustc-link-lib=c");
         println!("cargo:rustc-link-lib=compiler_rt");
-    } else if target.contains("hermit") {
-        println!("cargo:rustc-link-lib=hermit");
     }
 }

From 481b18acd09b480cc1ca50ea726cf91847f928f1 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Sat, 30 Nov 2019 13:28:53 +0100
Subject: [PATCH 04/26] Small error codes explanation cleanup (E0092, E0093 and
 E0094)

---
 src/librustc_error_codes/error_codes/E0092.md | 7 ++++---
 src/librustc_error_codes/error_codes/E0093.md | 8 +++++---
 src/librustc_error_codes/error_codes/E0094.md | 3 ++-
 src/librustc_error_codes/error_codes/E0106.md | 4 ++--
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/librustc_error_codes/error_codes/E0092.md b/src/librustc_error_codes/error_codes/E0092.md
index 2750a7d45b48e..e289534bf7abd 100644
--- a/src/librustc_error_codes/error_codes/E0092.md
+++ b/src/librustc_error_codes/error_codes/E0092.md
@@ -1,4 +1,5 @@
-You tried to declare an undefined atomic operation function.
+An undefined atomic operation function was declared.
+
 Erroneous code example:
 
 ```compile_fail,E0092
@@ -11,8 +12,8 @@ extern "rust-intrinsic" {
 ```
 
 Please check you didn't make a mistake in the function's name. All intrinsic
-functions are defined in librustc_codegen_llvm/intrinsic.rs and in
-libcore/intrinsics.rs in the Rust source code. Example:
+functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in
+`libcore/intrinsics.rs` in the Rust source code. Example:
 
 ```
 #![feature(intrinsics)]
diff --git a/src/librustc_error_codes/error_codes/E0093.md b/src/librustc_error_codes/error_codes/E0093.md
index 9633f794d8bb7..8e7de1a9d37b3 100644
--- a/src/librustc_error_codes/error_codes/E0093.md
+++ b/src/librustc_error_codes/error_codes/E0093.md
@@ -1,4 +1,6 @@
-You declared an unknown intrinsic function. Erroneous code example:
+An unknown intrinsic function was declared.
+
+Erroneous code example:
 
 ```compile_fail,E0093
 #![feature(intrinsics)]
@@ -15,8 +17,8 @@ fn main() {
 ```
 
 Please check you didn't make a mistake in the function's name. All intrinsic
-functions are defined in librustc_codegen_llvm/intrinsic.rs and in
-libcore/intrinsics.rs in the Rust source code. Example:
+functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in
+`libcore/intrinsics.rs` in the Rust source code. Example:
 
 ```
 #![feature(intrinsics)]
diff --git a/src/librustc_error_codes/error_codes/E0094.md b/src/librustc_error_codes/error_codes/E0094.md
index 4d27f616d2d84..42baa65bf9faf 100644
--- a/src/librustc_error_codes/error_codes/E0094.md
+++ b/src/librustc_error_codes/error_codes/E0094.md
@@ -1,4 +1,5 @@
-You gave an invalid number of type parameters to an intrinsic function.
+An invalid number of type parameters was given to an intrinsic function.
+
 Erroneous code example:
 
 ```compile_fail,E0094
diff --git a/src/librustc_error_codes/error_codes/E0106.md b/src/librustc_error_codes/error_codes/E0106.md
index 8a49c1f79e475..60ca1ddc2830c 100644
--- a/src/librustc_error_codes/error_codes/E0106.md
+++ b/src/librustc_error_codes/error_codes/E0106.md
@@ -2,7 +2,7 @@ This error indicates that a lifetime is missing from a type. If it is an error
 inside a function signature, the problem may be with failing to adhere to the
 lifetime elision rules (see below).
 
-Here are some simple examples of where you'll run into this error:
+Erroneous code examples:
 
 ```compile_fail,E0106
 struct Foo1 { x: &bool }
@@ -27,7 +27,7 @@ function signatures which allows you to leave out lifetimes in certain cases.
 For more background on lifetime elision see [the book][book-le].
 
 The lifetime elision rules require that any function signature with an elided
-output lifetime must either have
+output lifetime must either have:
 
  - exactly one input lifetime
  - or, multiple input lifetimes, but the function must also be a method with a

From e4b2cb8cba6eace2046c191861d1c8c0cfd4cad1 Mon Sep 17 00:00:00 2001
From: msizanoen1 <qtmlabs@protonmail.com>
Date: Sat, 23 Nov 2019 14:22:05 +0700
Subject: [PATCH 05/26] Add support for RISC-V 64-bit GNU/Linux

---
 src/libpanic_unwind/gcc.rs     | 3 +++
 src/libstd/env.rs              | 5 +++++
 src/libstd/os/linux/raw.rs     | 7 ++++++-
 src/libstd/os/raw/mod.rs       | 6 ++++--
 src/libstd/sys/unix/fs.rs      | 2 ++
 src/libstd/sys_common/alloc.rs | 3 ++-
 src/libunwind/libunwind.rs     | 3 +++
 7 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs
index 4f572fe21b30b..5eaacc0c90be8 100644
--- a/src/libpanic_unwind/gcc.rs
+++ b/src/libpanic_unwind/gcc.rs
@@ -129,6 +129,9 @@ const UNWIND_DATA_REG: (i32, i32) = (24, 25); // I0, I1
 #[cfg(target_arch = "hexagon")]
 const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1
 
+#[cfg(target_arch = "riscv64")]
+const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11
+
 // The following code is based on GCC's C and C++ personality routines.  For reference, see:
 // https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc
 // https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c
diff --git a/src/libstd/env.rs b/src/libstd/env.rs
index cf71b61b917a7..b5867e400026e 100644
--- a/src/libstd/env.rs
+++ b/src/libstd/env.rs
@@ -1033,6 +1033,11 @@ mod arch {
     pub const ARCH: &'static str = "hexagon";
 }
 
+#[cfg(target_arch = "riscv64")]
+mod arch {
+    pub const ARCH: &'static str = "riscv64";
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
diff --git a/src/libstd/os/linux/raw.rs b/src/libstd/os/linux/raw.rs
index d9b2236047bdf..0caec97bb7b90 100644
--- a/src/libstd/os/linux/raw.rs
+++ b/src/libstd/os/linux/raw.rs
@@ -230,7 +230,12 @@ mod arch {
     }
 }
 
-#[cfg(any(target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))]
+#[cfg(any(
+    target_arch = "mips64",
+    target_arch = "s390x",
+    target_arch = "sparc64",
+    target_arch = "riscv64"
+))]
 mod arch {
     pub use libc::{blkcnt_t, blksize_t, ino_t, nlink_t, off_t, stat, time_t};
 }
diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs
index e09012007f2d4..47daf0cce1b37 100644
--- a/src/libstd/os/raw/mod.rs
+++ b/src/libstd/os/raw/mod.rs
@@ -18,7 +18,8 @@
             target_arch = "hexagon",
             target_arch = "powerpc",
             target_arch = "powerpc64",
-            target_arch = "s390x"
+            target_arch = "s390x",
+            target_arch = "riscv64"
         )
     ),
     all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")),
@@ -60,7 +61,8 @@ pub type c_char = u8;
             target_arch = "hexagon",
             target_arch = "powerpc",
             target_arch = "powerpc64",
-            target_arch = "s390x"
+            target_arch = "s390x",
+            target_arch = "riscv64"
         )
     ),
     all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")),
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index 8669c48e3bb50..08fb088c86103 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -57,6 +57,7 @@ macro_rules! cfg_has_statx {
                 // target_arch = "mips64",
                 // target_arch = "s390x",
                 target_arch = "sparc64",
+                target_arch = "riscv64",
             )))] {
                 $($then_tt)*
             } else {
@@ -76,6 +77,7 @@ macro_rules! cfg_has_statx {
             // target_arch = "mips64",
             // target_arch = "s390x",
             target_arch = "sparc64",
+            target_arch = "riscv64",
         )))]
         {
             $($block_inner)*
diff --git a/src/libstd/sys_common/alloc.rs b/src/libstd/sys_common/alloc.rs
index 713b9949f6461..c669410078592 100644
--- a/src/libstd/sys_common/alloc.rs
+++ b/src/libstd/sys_common/alloc.rs
@@ -22,7 +22,8 @@ pub const MIN_ALIGN: usize = 8;
     target_arch = "aarch64",
     target_arch = "mips64",
     target_arch = "s390x",
-    target_arch = "sparc64"
+    target_arch = "sparc64",
+    target_arch = "riscv64"
 )))]
 pub const MIN_ALIGN: usize = 16;
 
diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs
index 0b39503c0d034..4867a0f7f92b7 100644
--- a/src/libunwind/libunwind.rs
+++ b/src/libunwind/libunwind.rs
@@ -53,6 +53,9 @@ pub const unwinder_private_data_size: usize = 2;
 #[cfg(target_arch = "sparc64")]
 pub const unwinder_private_data_size: usize = 2;
 
+#[cfg(target_arch = "riscv64")]
+pub const unwinder_private_data_size: usize = 2;
+
 #[cfg(target_os = "emscripten")]
 pub const unwinder_private_data_size: usize = 20;
 

From 930a0a2d0b9966b276de49e7a865186152c2f075 Mon Sep 17 00:00:00 2001
From: msizanoen1 <qtmlabs@protonmail.com>
Date: Sat, 30 Nov 2019 19:16:06 +0700
Subject: [PATCH 06/26] Update libc

---
 Cargo.lock | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index d27eec893b0af..037c6400d32b0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1821,9 +1821,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
 
 [[package]]
 name = "libc"
-version = "0.2.64"
+version = "0.2.66"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c"
+checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
 dependencies = [
  "rustc-std-workspace-core",
 ]

From 5748b4ce95a2aaba6fede25408f59d044a8e0804 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Thu, 28 Nov 2019 00:02:37 +0100
Subject: [PATCH 07/26] Add missing check

---
 src/librustdoc/html/static/main.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index cc0f470b34920..49a9cb093da2a 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -1221,7 +1221,7 @@ function getSearchElement() {
                     // then an exact path match
                     path.indexOf(keys[i]) > -1 ||
                     // next if there is a parent, check for exact parent match
-                    (parent !== undefined &&
+                    (parent !== undefined && parent.name !== undefined &&
                         parent.name.toLowerCase().indexOf(keys[i]) > -1) ||
                     // lastly check to see if the name was a levenshtein match
                     levenshtein(name, keys[i]) <= MAX_LEV_DISTANCE)) {

From 35ba58f5a9a91f03b37360d9459f944978438373 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Thu, 28 Nov 2019 00:02:51 +0100
Subject: [PATCH 08/26] Remove minification on search-index.js file

---
 src/librustdoc/html/render.rs | 94 ++++-------------------------------
 1 file changed, 9 insertions(+), 85 deletions(-)

diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index ba94cb82c00d2..2d7fef56731a2 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -715,19 +715,13 @@ themePicker.onblur = handleThemeButtonsBlur;
         path: &Path,
         krate: &str,
         key: &str,
-        for_search_index: bool,
-    ) -> io::Result<(Vec<String>, Vec<String>, Vec<String>)> {
+    ) -> io::Result<(Vec<String>, Vec<String>)> {
         let mut ret = Vec::new();
         let mut krates = Vec::new();
-        let mut variables = Vec::new();
 
         if path.exists() {
             for line in BufReader::new(File::open(path)?).lines() {
                 let line = line?;
-                if for_search_index && line.starts_with("var R") {
-                    variables.push(line.clone());
-                    continue;
-                }
                 if !line.starts_with(key) {
                     continue;
                 }
@@ -741,7 +735,7 @@ themePicker.onblur = handleThemeButtonsBlur;
                                                  .unwrap_or_else(|| String::new()));
             }
         }
-        Ok((ret, krates, variables))
+        Ok((ret, krates))
     }
 
     fn show_item(item: &IndexItem, krate: &str) -> String {
@@ -756,7 +750,7 @@ themePicker.onblur = handleThemeButtonsBlur;
 
     let dst = cx.dst.join(&format!("aliases{}.js", cx.shared.resource_suffix));
     {
-        let (mut all_aliases, _, _) = try_err!(collect(&dst, &krate.name, "ALIASES", false), &dst);
+        let (mut all_aliases, _) = try_err!(collect(&dst, &krate.name, "ALIASES"), &dst);
         let mut output = String::with_capacity(100);
         for (alias, items) in &cx.cache.aliases {
             if items.is_empty() {
@@ -853,9 +847,7 @@ themePicker.onblur = handleThemeButtonsBlur;
         }
 
         let dst = cx.dst.join(&format!("source-files{}.js", cx.shared.resource_suffix));
-        let (mut all_sources, _krates, _) = try_err!(collect(&dst, &krate.name, "sourcesIndex",
-                                                             false),
-                                                     &dst);
+        let (mut all_sources, _krates) = try_err!(collect(&dst, &krate.name, "sourcesIndex"), &dst);
         all_sources.push(format!("sourcesIndex[\"{}\"] = {};",
                                  &krate.name,
                                  hierarchy.to_json_string()));
@@ -867,20 +859,15 @@ themePicker.onblur = handleThemeButtonsBlur;
 
     // Update the search index
     let dst = cx.dst.join(&format!("search-index{}.js", cx.shared.resource_suffix));
-    let (mut all_indexes, mut krates, variables) = try_err!(collect(&dst,
-                                                                    &krate.name,
-                                                                    "searchIndex",
-                                                                    true), &dst);
+    let (mut all_indexes, mut krates) = try_err!(collect(&dst, &krate.name, "searchIndex"), &dst);
     all_indexes.push(search_index);
 
     // Sort the indexes by crate so the file will be generated identically even
     // with rustdoc running in parallel.
     all_indexes.sort();
     {
-        let mut v = String::from("var N=null,E=\"\",T=\"t\",U=\"u\",searchIndex={};\n");
-        v.push_str(&minify_replacer(
-            &format!("{}\n{}", variables.join(""), all_indexes.join("\n")),
-            options.enable_minification));
+        let mut v = String::from("var searchIndex={};\n");
+        v.push_str(&all_indexes.join("\n"));
         // "addSearchOptions" has to be called first so the crate filtering can be set before the
         // search might start (if it's set into the URL for example).
         v.push_str("addSearchOptions(searchIndex);initSearch(searchIndex);");
@@ -981,9 +968,8 @@ themePicker.onblur = handleThemeButtonsBlur;
                             remote_item_type,
                             remote_path[remote_path.len() - 1]));
 
-        let (mut all_implementors, _, _) = try_err!(collect(&mydst, &krate.name, "implementors",
-                                                            false),
-                                                    &mydst);
+        let (mut all_implementors, _) = try_err!(collect(&mydst, &krate.name, "implementors"),
+                                                 &mydst);
         all_implementors.push(implementors);
         // Sort the implementors by crate so the file will be generated
         // identically even with rustdoc running in parallel.
@@ -1020,68 +1006,6 @@ fn write_minify(fs:&DocFS, dst: PathBuf, contents: &str, enable_minification: bo
     }
 }
 
-fn minify_replacer(
-    contents: &str,
-    enable_minification: bool,
-) -> String {
-    use minifier::js::{simple_minify, Keyword, ReservedChar, Token, Tokens};
-
-    if enable_minification {
-        let tokens: Tokens<'_> = simple_minify(contents)
-            .into_iter()
-            .filter(|(f, next)| {
-                // We keep backlines.
-                minifier::js::clean_token_except(f, next, &|c: &Token<'_>| {
-                    c.get_char() != Some(ReservedChar::Backline)
-                })
-            })
-            .map(|(f, _)| {
-                minifier::js::replace_token_with(f, &|t: &Token<'_>| {
-                    match *t {
-                        Token::Keyword(Keyword::Null) => Some(Token::Other("N")),
-                        Token::String(s) => {
-                            let s = &s[1..s.len() -1]; // The quotes are included
-                            if s.is_empty() {
-                                Some(Token::Other("E"))
-                            } else if s == "t" {
-                                Some(Token::Other("T"))
-                            } else if s == "u" {
-                                Some(Token::Other("U"))
-                            } else {
-                                None
-                            }
-                        }
-                        _ => None,
-                    }
-                })
-            })
-            .collect::<Vec<_>>()
-            .into();
-        let o = tokens.apply(|f| {
-            // We add a backline after the newly created variables.
-            minifier::js::aggregate_strings_into_array_with_separation_filter(
-                f,
-                "R",
-                Token::Char(ReservedChar::Backline),
-                // This closure prevents crates' names from being aggregated.
-                //
-                // The point here is to check if the string is preceded by '[' and
-                // "searchIndex". If so, it means this is a crate name and that it
-                // shouldn't be aggregated.
-                |tokens, pos| {
-                    pos < 2 ||
-                    !tokens[pos - 1].eq_char(ReservedChar::OpenBracket) ||
-                    tokens[pos - 2].get_other() != Some("searchIndex")
-                }
-            )
-        })
-        .to_string();
-        format!("{}\n", o)
-    } else {
-        format!("{}\n", contents)
-    }
-}
-
 #[derive(Debug, Eq, PartialEq, Hash)]
 struct ItemEntry {
     url: String,

From 852079fbf23e478b065895c0db49db10f9e47929 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Thu, 28 Nov 2019 00:26:59 +0100
Subject: [PATCH 09/26] minify theme.js as well

---
 src/librustdoc/html/render.rs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 2d7fef56731a2..49471a8e938a9 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -644,10 +644,9 @@ themePicker.onblur = handleThemeButtonsBlur;
     themes.appendChild(but);
 }});"#,
                  as_json(&themes));
-    write(cx.dst.join(&format!("theme{}.js", cx.shared.resource_suffix)),
-          theme_js.as_bytes()
-    )?;
-
+    write_minify(&cx.shared.fs, cx.path("theme.js"),
+                 &theme_js,
+                 options.enable_minification)?;
     write_minify(&cx.shared.fs, cx.path("main.js"),
                  static_files::MAIN_JS,
                  options.enable_minification)?;

From 85df207ecc3a7b8b7150e2b65c67eec3a23b7c81 Mon Sep 17 00:00:00 2001
From: Victor Ding <victording@google.com>
Date: Mon, 2 Dec 2019 20:53:01 +1100
Subject: [PATCH 10/26] Use Module::print() instead of a PrintModulePass

llvm::Module has a print() method. It is unnecessary to create a
pass just for the purpose of printing LLVM IR.
---
 src/librustc_codegen_llvm/back/write.rs | 13 +++-----
 src/librustc_codegen_llvm/llvm/ffi.rs   |  3 +-
 src/rustllvm/PassWrapper.cpp            | 43 ++-----------------------
 3 files changed, 9 insertions(+), 50 deletions(-)

diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs
index 07ac76cec990b..187063b866ac6 100644
--- a/src/librustc_codegen_llvm/back/write.rs
+++ b/src/librustc_codegen_llvm/back/write.rs
@@ -587,14 +587,11 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<LlvmCodegenBackend>,
                     cursor.position() as size_t
                 }
 
-                with_codegen(tm, llmod, config.no_builtins, |cpm| {
-                    let result =
-                        llvm::LLVMRustPrintModule(cpm, llmod, out_c.as_ptr(), demangle_callback);
-                    llvm::LLVMDisposePassManager(cpm);
-                    result.into_result().map_err(|()| {
-                        let msg = format!("failed to write LLVM IR to {}", out.display());
-                        llvm_err(diag_handler, &msg)
-                    })
+                let result =
+                    llvm::LLVMRustPrintModule(llmod, out_c.as_ptr(), demangle_callback);
+                result.into_result().map_err(|()| {
+                    let msg = format!("failed to write LLVM IR to {}", out.display());
+                    llvm_err(diag_handler, &msg)
                 })?;
             }
 
diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs
index a49e863fa2185..762c821de4d51 100644
--- a/src/librustc_codegen_llvm/llvm/ffi.rs
+++ b/src/librustc_codegen_llvm/llvm/ffi.rs
@@ -1726,8 +1726,7 @@ extern "C" {
                                    Output: *const c_char,
                                    FileType: FileType)
                                    -> LLVMRustResult;
-    pub fn LLVMRustPrintModule(PM: &PassManager<'a>,
-                               M: &'a Module,
+    pub fn LLVMRustPrintModule(M: &'a Module,
                                Output: *const c_char,
                                Demangle: extern fn(*const c_char,
                                                    size_t,
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index a116ed282acd1..40823422c2710 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -660,46 +660,11 @@ class RustAssemblyAnnotationWriter : public AssemblyAnnotationWriter {
   }
 };
 
-class RustPrintModulePass : public ModulePass {
-  raw_ostream* OS;
-  DemangleFn Demangle;
-public:
-  static char ID;
-  RustPrintModulePass() : ModulePass(ID), OS(nullptr), Demangle(nullptr) {}
-  RustPrintModulePass(raw_ostream &OS, DemangleFn Demangle)
-      : ModulePass(ID), OS(&OS), Demangle(Demangle) {}
-
-  bool runOnModule(Module &M) override {
-    RustAssemblyAnnotationWriter AW(Demangle);
-
-    M.print(*OS, &AW, false);
-
-    return false;
-  }
-
-  void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.setPreservesAll();
-  }
-
-  static StringRef name() { return "RustPrintModulePass"; }
-};
-
 } // namespace
 
-namespace llvm {
-  void initializeRustPrintModulePassPass(PassRegistry&);
-}
-
-char RustPrintModulePass::ID = 0;
-INITIALIZE_PASS(RustPrintModulePass, "print-rust-module",
-                "Print rust module to stderr", false, false)
-
 extern "C" LLVMRustResult
-LLVMRustPrintModule(LLVMPassManagerRef PMR, LLVMModuleRef M,
-                    const char *Path, DemangleFn Demangle) {
-  llvm::legacy::PassManager *PM = unwrap<llvm::legacy::PassManager>(PMR);
+LLVMRustPrintModule(LLVMModuleRef M, const char *Path, DemangleFn Demangle) {
   std::string ErrorInfo;
-
   std::error_code EC;
   raw_fd_ostream OS(Path, EC, sys::fs::F_None);
   if (EC)
@@ -709,11 +674,9 @@ LLVMRustPrintModule(LLVMPassManagerRef PMR, LLVMModuleRef M,
     return LLVMRustResult::Failure;
   }
 
+  RustAssemblyAnnotationWriter AAW(Demangle);
   formatted_raw_ostream FOS(OS);
-
-  PM->add(new RustPrintModulePass(FOS, Demangle));
-
-  PM->run(*unwrap(M));
+  unwrap(M)->print(FOS, &AAW);
 
   return LLVMRustResult::Success;
 }

From 2d0f0ca25b473c16bfa8f071d2d8462a36f43ce0 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Mon, 2 Dec 2019 11:25:27 +0100
Subject: [PATCH 11/26] Add missing backline

---
 src/librustdoc/html/render.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 49471a8e938a9..0f26703598971 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -869,7 +869,7 @@ themePicker.onblur = handleThemeButtonsBlur;
         v.push_str(&all_indexes.join("\n"));
         // "addSearchOptions" has to be called first so the crate filtering can be set before the
         // search might start (if it's set into the URL for example).
-        v.push_str("addSearchOptions(searchIndex);initSearch(searchIndex);");
+        v.push_str("\naddSearchOptions(searchIndex);initSearch(searchIndex);");
         cx.shared.fs.write(&dst, &v)?;
     }
     if options.enable_index_page {

From 7693bb9e1d122bea1b0645dcc201c6ed79c910e2 Mon Sep 17 00:00:00 2001
From: Reese Williams <rtwill722@gmail.com>
Date: Mon, 2 Dec 2019 21:52:04 -0500
Subject: [PATCH 12/26] Add long error for E0631 and update ui tests.

---
 src/librustc_error_codes/error_codes.rs       |  2 +-
 src/librustc_error_codes/error_codes/E0631.md | 29 +++++++++++++++++++
 .../anonymous-higher-ranked-lifetime.stderr   |  1 +
 .../expect-fn-supply-fn.stderr                |  3 +-
 .../expect-infer-var-appearing-twice.stderr   |  1 +
 src/test/ui/closures/issue-41366.stderr       |  3 +-
 src/test/ui/issues/issue-43623.stderr         |  3 +-
 src/test/ui/issues/issue-60283.stderr         |  3 +-
 src/test/ui/mismatched_types/E0631.stderr     |  1 +
 .../closure-arg-type-mismatch.stderr          |  3 +-
 .../mismatched_types/closure-mismatch.stderr  |  3 +-
 .../ui/mismatched_types/fn-variance-1.stderr  |  1 +
 .../ui/mismatched_types/issue-36053-2.stderr  |  3 +-
 .../unboxed-closures-vtable-mismatch.stderr   |  1 +
 14 files changed, 49 insertions(+), 8 deletions(-)
 create mode 100644 src/librustc_error_codes/error_codes/E0631.md

diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs
index 7f111b42403b5..9e4b704170b9b 100644
--- a/src/librustc_error_codes/error_codes.rs
+++ b/src/librustc_error_codes/error_codes.rs
@@ -347,6 +347,7 @@ E0622: include_str!("./error_codes/E0622.md"),
 E0623: include_str!("./error_codes/E0623.md"),
 E0624: include_str!("./error_codes/E0624.md"),
 E0626: include_str!("./error_codes/E0626.md"),
+E0631: include_str!("./error_codes/E0631.md"),
 E0633: include_str!("./error_codes/E0633.md"),
 E0635: include_str!("./error_codes/E0635.md"),
 E0636: include_str!("./error_codes/E0636.md"),
@@ -580,7 +581,6 @@ E0745: include_str!("./error_codes/E0745.md"),
     // rustc_const_unstable attribute must be paired with stable/unstable
     // attribute
     E0630,
-    E0631, // type mismatch in closure arguments
     E0632, // cannot provide explicit generic arguments when `impl Trait` is
            // used in argument position
     E0634, // type has conflicting packed representaton hints
diff --git a/src/librustc_error_codes/error_codes/E0631.md b/src/librustc_error_codes/error_codes/E0631.md
new file mode 100644
index 0000000000000..ad419f82250cc
--- /dev/null
+++ b/src/librustc_error_codes/error_codes/E0631.md
@@ -0,0 +1,29 @@
+This error indicates a type mismatch in closure arguments.
+
+Erroneous code example:
+
+```compile_fail,E0631
+fn test_strings(string_vec: Vec<String>) -> Vec<bool> {
+  string_vec
+    .iter()
+    .map(|arg: &i32| arg.eq("Test String"))
+    .collect()
+}
+```
+
+The closure passed to `map` expects a `&String` argument, since `some_vec`
+has the type `Vec<String>`.
+However, the closure argument is annotated as an `&i32`, which does not match
+the type of the iterable.
+
+This can be resolved by changing the type annotation or removing it entirely
+if it can be inferred.
+
+```
+fn test_strings(string_vec: Vec<String>) -> Vec<bool> {
+  string_vec
+    .iter()
+    .map(|arg| arg.eq("Test String"))
+    .collect()
+}
+```
diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr
index 9be44c7f44807..c6d9a61bdd95a 100644
--- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr
+++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr
@@ -121,3 +121,4 @@ LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(),
 
 error: aborting due to 11 previous errors
 
+For more information about this error, try `rustc --explain E0631`.
diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr
index a15444207f5cd..0033395846815 100644
--- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr
+++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr
@@ -77,4 +77,5 @@ LL |     with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
 
 error: aborting due to 5 previous errors
 
-For more information about this error, try `rustc --explain E0308`.
+Some errors have detailed explanations: E0308, E0631.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr b/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr
index 9fbe95a9c3945..1c6564ee426e5 100644
--- a/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr
+++ b/src/test/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr
@@ -13,3 +13,4 @@ LL |     with_closure(|x: u32, y: i32| {
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0631`.
diff --git a/src/test/ui/closures/issue-41366.stderr b/src/test/ui/closures/issue-41366.stderr
index 91d26efbc4f35..2f2871e9f0e90 100644
--- a/src/test/ui/closures/issue-41366.stderr
+++ b/src/test/ui/closures/issue-41366.stderr
@@ -19,4 +19,5 @@ LL |     (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
diff --git a/src/test/ui/issues/issue-43623.stderr b/src/test/ui/issues/issue-43623.stderr
index 2c57b8585d924..d90eb53f9006f 100644
--- a/src/test/ui/issues/issue-43623.stderr
+++ b/src/test/ui/issues/issue-43623.stderr
@@ -25,4 +25,5 @@ LL |     break_me::<Type, fn(_)>;
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
diff --git a/src/test/ui/issues/issue-60283.stderr b/src/test/ui/issues/issue-60283.stderr
index 69c1d85e4e12d..d13dcd54a479a 100644
--- a/src/test/ui/issues/issue-60283.stderr
+++ b/src/test/ui/issues/issue-60283.stderr
@@ -27,4 +27,5 @@ LL |     foo((), drop)
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
diff --git a/src/test/ui/mismatched_types/E0631.stderr b/src/test/ui/mismatched_types/E0631.stderr
index 88c1efdbb90f4..06f5c058f81f5 100644
--- a/src/test/ui/mismatched_types/E0631.stderr
+++ b/src/test/ui/mismatched_types/E0631.stderr
@@ -46,3 +46,4 @@ LL |     bar(f);
 
 error: aborting due to 4 previous errors
 
+For more information about this error, try `rustc --explain E0631`.
diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr
index 85cad61210ebf..ed5028247124f 100644
--- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr
+++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr
@@ -45,4 +45,5 @@ LL |     baz(f);
 
 error: aborting due to 5 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr
index fd2b9f3c66b04..f3874c0907be0 100644
--- a/src/test/ui/mismatched_types/closure-mismatch.stderr
+++ b/src/test/ui/mismatched_types/closure-mismatch.stderr
@@ -24,4 +24,5 @@ LL |     baz(|_| ());
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0271`.
+Some errors have detailed explanations: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr
index 1a82dd53edc70..88c92661994cb 100644
--- a/src/test/ui/mismatched_types/fn-variance-1.stderr
+++ b/src/test/ui/mismatched_types/fn-variance-1.stderr
@@ -24,3 +24,4 @@ LL |     apply(&mut 3, takes_imm);
 
 error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0631`.
diff --git a/src/test/ui/mismatched_types/issue-36053-2.stderr b/src/test/ui/mismatched_types/issue-36053-2.stderr
index 72f3220cc1aba..da018aa89482c 100644
--- a/src/test/ui/mismatched_types/issue-36053-2.stderr
+++ b/src/test/ui/mismatched_types/issue-36053-2.stderr
@@ -18,4 +18,5 @@ LL |     once::<&str>("str").fuse().filter(|a: &str| true).count();
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0599`.
+Some errors have detailed explanations: E0599, E0631.
+For more information about an error, try `rustc --explain E0599`.
diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr
index 2daf4781c7e6f..3c999f200d9c7 100644
--- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr
+++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr
@@ -12,3 +12,4 @@ LL |     let z = call_it(3, f);
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0631`.

From 26a1ba85b890cdf7bbb7066c3a18aab84aef171f Mon Sep 17 00:00:00 2001
From: Reese Williams <rtwill722@gmail.com>
Date: Tue, 3 Dec 2019 07:51:11 -0500
Subject: [PATCH 13/26] Use simpler code example for E0631 long error.

---
 src/librustc_error_codes/error_codes/E0631.md | 26 +++++++++----------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/librustc_error_codes/error_codes/E0631.md b/src/librustc_error_codes/error_codes/E0631.md
index ad419f82250cc..6188d5f61a7f9 100644
--- a/src/librustc_error_codes/error_codes/E0631.md
+++ b/src/librustc_error_codes/error_codes/E0631.md
@@ -3,27 +3,25 @@ This error indicates a type mismatch in closure arguments.
 Erroneous code example:
 
 ```compile_fail,E0631
-fn test_strings(string_vec: Vec<String>) -> Vec<bool> {
-  string_vec
-    .iter()
-    .map(|arg: &i32| arg.eq("Test String"))
-    .collect()
+fn foo<F: Fn(i32)>(f: F) {
+}
+
+fn main() {
+    foo(|x: &str| {});
 }
 ```
 
-The closure passed to `map` expects a `&String` argument, since `some_vec`
-has the type `Vec<String>`.
-However, the closure argument is annotated as an `&i32`, which does not match
-the type of the iterable.
+The error occurs because `foo` accepts a closure that takes an `i32` argument,
+but in `main`, it is passed a closure with a `&str` argument.
 
 This can be resolved by changing the type annotation or removing it entirely
 if it can be inferred.
 
 ```
-fn test_strings(string_vec: Vec<String>) -> Vec<bool> {
-  string_vec
-    .iter()
-    .map(|arg| arg.eq("Test String"))
-    .collect()
+fn foo<F: Fn(i32)>(f: F) {
+}
+
+fn main() {
+    foo(|x: i32| {});
 }
 ```

From 3091b823d1080cfd2851f13b2eed5deed20d5f67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Mon, 25 Nov 2019 18:31:27 -0800
Subject: [PATCH 14/26] Tweak wording of `collect()` on bad target type

---
 src/libcore/iter/traits/collect.rs                     | 4 ++--
 src/test/ui/type/type-check-defaults.rs                | 4 ++--
 src/test/ui/type/type-check-defaults.stderr            | 8 ++++----
 src/test/ui/type/type-dependent-def-issue-49241.rs     | 2 +-
 src/test/ui/type/type-dependent-def-issue-49241.stderr | 4 ++--
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/libcore/iter/traits/collect.rs b/src/libcore/iter/traits/collect.rs
index bbdb169cac0fc..d6ae5cfe9e00e 100644
--- a/src/libcore/iter/traits/collect.rs
+++ b/src/libcore/iter/traits/collect.rs
@@ -91,9 +91,9 @@
 /// ```
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_on_unimplemented(
-    message="a collection of type `{Self}` cannot be built from an iterator \
+    message="a value of type `{Self}` cannot be built from an iterator \
              over elements of type `{A}`",
-    label="a collection of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
+    label="value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
 )]
 pub trait FromIterator<A>: Sized {
     /// Creates a value from an iterator.
diff --git a/src/test/ui/type/type-check-defaults.rs b/src/test/ui/type/type-check-defaults.rs
index 5748c9bcff8cb..5380fae5417e4 100644
--- a/src/test/ui/type/type-check-defaults.rs
+++ b/src/test/ui/type/type-check-defaults.rs
@@ -4,9 +4,9 @@ use std::ops::Add;
 
 struct Foo<T, U: FromIterator<T>>(T, U);
 struct WellFormed<Z = Foo<i32, i32>>(Z);
-//~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32`
+//~^ ERROR a value of type `i32` cannot be built from an iterator over elements of type `i32`
 struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z);
-//~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32`
+//~^ ERROR a value of type `i32` cannot be built from an iterator over elements of type `i32`
 
 struct Bounds<T:Copy=String>(T);
 //~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277]
diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr
index 6802bc38b89c9..6f84b37d61249 100644
--- a/src/test/ui/type/type-check-defaults.stderr
+++ b/src/test/ui/type/type-check-defaults.stderr
@@ -1,21 +1,21 @@
-error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `i32`
+error[E0277]: a value of type `i32` cannot be built from an iterator over elements of type `i32`
   --> $DIR/type-check-defaults.rs:6:19
    |
 LL | struct Foo<T, U: FromIterator<T>>(T, U);
    | ---------------------------------------- required by `Foo`
 LL | struct WellFormed<Z = Foo<i32, i32>>(Z);
-   |                   ^ a collection of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
+   |                   ^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
    |
    = help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32`
 
-error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `i32`
+error[E0277]: a value of type `i32` cannot be built from an iterator over elements of type `i32`
   --> $DIR/type-check-defaults.rs:8:27
    |
 LL | struct Foo<T, U: FromIterator<T>>(T, U);
    | ---------------------------------------- required by `Foo`
 ...
 LL | struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z);
-   |                           ^ a collection of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
+   |                           ^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
    |
    = help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32`
 
diff --git a/src/test/ui/type/type-dependent-def-issue-49241.rs b/src/test/ui/type/type-dependent-def-issue-49241.rs
index 5ad50ffcbc389..a25e3ba5fa89f 100644
--- a/src/test/ui/type/type-dependent-def-issue-49241.rs
+++ b/src/test/ui/type/type-dependent-def-issue-49241.rs
@@ -3,5 +3,5 @@ fn main() {
     const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant
     let s: [u32; l] = v.into_iter().collect();
     //~^ ERROR evaluation of constant value failed
-    //~^^ ERROR a collection of type
+    //~^^ ERROR a value of type
 }
diff --git a/src/test/ui/type/type-dependent-def-issue-49241.stderr b/src/test/ui/type/type-dependent-def-issue-49241.stderr
index 851004d105897..18a69c50ebd6d 100644
--- a/src/test/ui/type/type-dependent-def-issue-49241.stderr
+++ b/src/test/ui/type/type-dependent-def-issue-49241.stderr
@@ -10,11 +10,11 @@ error[E0080]: evaluation of constant value failed
 LL |     let s: [u32; l] = v.into_iter().collect();
    |                  ^ referenced constant has errors
 
-error[E0277]: a collection of type `[u32; _]` cannot be built from an iterator over elements of type `{integer}`
+error[E0277]: a value of type `[u32; _]` cannot be built from an iterator over elements of type `{integer}`
   --> $DIR/type-dependent-def-issue-49241.rs:4:37
    |
 LL |     let s: [u32; l] = v.into_iter().collect();
-   |                                     ^^^^^^^ a collection of type `[u32; _]` cannot be built from `std::iter::Iterator<Item={integer}>`
+   |                                     ^^^^^^^ value of type `[u32; _]` cannot be built from `std::iter::Iterator<Item={integer}>`
    |
    = help: the trait `std::iter::FromIterator<{integer}>` is not implemented for `[u32; _]`
 

From 911b7d6d4dc19da085883d19b7a772b5ca35ffc9 Mon Sep 17 00:00:00 2001
From: Reese Williams <rtwill722@gmail.com>
Date: Tue, 3 Dec 2019 14:58:41 -0500
Subject: [PATCH 15/26] Update missed test.

---
 src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr
index a6b52b258f005..7141c047d7f53 100644
--- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr
+++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr
@@ -39,3 +39,4 @@ LL |     with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
 
 error: aborting due to 3 previous errors
 
+For more information about this error, try `rustc --explain E0631`.

From c911bb1a2e5efc35a8e76bfe6e2581f4a9dfc20b Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Sat, 30 Nov 2019 13:42:50 +0100
Subject: [PATCH 16/26] clean up E0107 error explanation

---
 src/librustc_error_codes/error_codes/E0107.md | 23 ++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/librustc_error_codes/error_codes/E0107.md b/src/librustc_error_codes/error_codes/E0107.md
index bfe0d21f3129b..4d22b17fe1016 100644
--- a/src/librustc_error_codes/error_codes/E0107.md
+++ b/src/librustc_error_codes/error_codes/E0107.md
@@ -1,4 +1,6 @@
-This error means that an incorrect number of generic arguments were provided:
+An incorrect number of generic arguments were provided.
+
+Erroneous code example:
 
 ```compile_fail,E0107
 struct Foo<T> { x: T }
@@ -9,6 +11,7 @@ struct Baz<S, T> { x: Foo<S, T> } // error: wrong number of type arguments:
                                   //        expected 1, found 2
 
 fn foo<T, U>(x: T, y: U) {}
+fn f() {}
 
 fn main() {
     let x: bool = true;
@@ -16,12 +19,26 @@ fn main() {
                                     //        expected 2, found 1
     foo::<bool, i32, i32>(x, 2, 4); // error: wrong number of type arguments:
                                     //        expected 2, found 3
+    f::<'static>();                 // error: wrong number of lifetime arguments
+                                    //        expected 0, found 1
 }
+```
+
+When using/declaring an item with generic arguments, you must provide the exact
+same number:
+
+```
+struct Foo<T> { x: T }
+
+struct Bar<T> { x: Foo<T> }               // ok!
+struct Baz<S, T> { x: Foo<S>, y: Foo<T> } // ok!
 
+fn foo<T, U>(x: T, y: U) {}
 fn f() {}
 
 fn main() {
-    f::<'static>(); // error: wrong number of lifetime arguments:
-                    //        expected 0, found 1
+    let x: bool = true;
+    foo::<bool, u32>(x, 12);              // ok!
+    f();                                  // ok!
 }
 ```

From 1fa948f4ccf73aa0a0d903878693c685710cd764 Mon Sep 17 00:00:00 2001
From: Andrew Banchich <andrewbanchich@gmail.com>
Date: Tue, 3 Dec 2019 19:11:53 -0500
Subject: [PATCH 17/26] capitalize Rust

---
 src/libcore/sync/atomic.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs
index c9ccef972c2b5..69c4aa7f30f45 100644
--- a/src/libcore/sync/atomic.rs
+++ b/src/libcore/sync/atomic.rs
@@ -27,7 +27,7 @@
 //!
 //! Atomic variables are safe to share between threads (they implement [`Sync`])
 //! but they do not themselves provide the mechanism for sharing and follow the
-//! [threading model](../../../std/thread/index.html#the-threading-model) of rust.
+//! [threading model](../../../std/thread/index.html#the-threading-model) of Rust.
 //! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an
 //! atomically-reference-counted shared pointer).
 //!

From f6b435d923e5979cd3579427901d2140a932dfc0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Tue, 3 Dec 2019 19:01:42 -0800
Subject: [PATCH 18/26] Accurately portray raw identifiers in error messages

When refering to or suggesting raw identifiers, refer to them with `r#`.

Fix #65634.
---
 src/librustc/ty/print/pretty.rs               |  3 +++
 src/libsyntax_pos/symbol.rs                   |  6 +++++
 .../ui/parser/raw/raw-literal-keywords.rs     |  4 ++--
 .../ui/parser/raw/raw-literal-keywords.stderr |  4 ++--
 src/test/ui/raw-ident-suggestion.rs           | 22 +++++++++++++++++++
 src/test/ui/raw-ident-suggestion.stderr       | 22 +++++++++++++++++++
 .../ui/suggestions/raw-name-use-suggestion.rs |  2 +-
 .../raw-name-use-suggestion.stderr            |  2 +-
 8 files changed, 59 insertions(+), 6 deletions(-)
 create mode 100644 src/test/ui/raw-ident-suggestion.rs
 create mode 100644 src/test/ui/raw-ident-suggestion.stderr

diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs
index fff2f06e87b8e..745f7d0276d80 100644
--- a/src/librustc/ty/print/pretty.rs
+++ b/src/librustc/ty/print/pretty.rs
@@ -1282,6 +1282,9 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
             if !self.empty_path {
                 write!(self, "::")?;
             }
+            if ast::Ident::from_str(&name).is_raw_guess() {
+                write!(self, "r#")?;
+            }
             write!(self, "{}", name)?;
 
             // FIXME(eddyb) this will print e.g. `{{closure}}#3`, but it
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index 88a325112ac6c..73df24a836dc3 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -840,12 +840,18 @@ impl Hash for Ident {
 
 impl fmt::Debug for Ident {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        if self.is_raw_guess() {
+            write!(f, "r#")?;
+        }
         write!(f, "{}{:?}", self.name, self.span.ctxt())
     }
 }
 
 impl fmt::Display for Ident {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        if self.is_raw_guess() {
+            write!(f, "r#")?;
+        }
         fmt::Display::fmt(&self.name, f)
     }
 }
diff --git a/src/test/ui/parser/raw/raw-literal-keywords.rs b/src/test/ui/parser/raw/raw-literal-keywords.rs
index bf9cbcdab2e89..a986980fab97b 100644
--- a/src/test/ui/parser/raw/raw-literal-keywords.rs
+++ b/src/test/ui/parser/raw/raw-literal-keywords.rs
@@ -11,11 +11,11 @@ fn test_union() {
 }
 
 fn test_if_2() {
-    let _ = r#if; //~ ERROR cannot find value `if` in this scope
+    let _ = r#if; //~ ERROR cannot find value `r#if` in this scope
 }
 
 fn test_struct_2() {
-    let _ = r#struct; //~ ERROR cannot find value `struct` in this scope
+    let _ = r#struct; //~ ERROR cannot find value `r#struct` in this scope
 }
 
 fn test_union_2() {
diff --git a/src/test/ui/parser/raw/raw-literal-keywords.stderr b/src/test/ui/parser/raw/raw-literal-keywords.stderr
index fd8eda3770d27..f7b6c894a90fe 100644
--- a/src/test/ui/parser/raw/raw-literal-keywords.stderr
+++ b/src/test/ui/parser/raw/raw-literal-keywords.stderr
@@ -16,13 +16,13 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
 LL |     r#union Test;
    |             ^^^^ expected one of 8 possible tokens
 
-error[E0425]: cannot find value `if` in this scope
+error[E0425]: cannot find value `r#if` in this scope
   --> $DIR/raw-literal-keywords.rs:14:13
    |
 LL |     let _ = r#if;
    |             ^^^^ not found in this scope
 
-error[E0425]: cannot find value `struct` in this scope
+error[E0425]: cannot find value `r#struct` in this scope
   --> $DIR/raw-literal-keywords.rs:18:13
    |
 LL |     let _ = r#struct;
diff --git a/src/test/ui/raw-ident-suggestion.rs b/src/test/ui/raw-ident-suggestion.rs
new file mode 100644
index 0000000000000..b928510258b2f
--- /dev/null
+++ b/src/test/ui/raw-ident-suggestion.rs
@@ -0,0 +1,22 @@
+#![allow(non_camel_case_types)]
+
+trait r#async {
+    fn r#struct(&self) {
+        println!("async");
+    }
+}
+
+trait r#await {
+    fn r#struct(&self) {
+        println!("await");
+    }
+}
+
+struct r#fn {}
+
+impl r#async for r#fn {}
+impl r#await for r#fn {}
+
+fn main() {
+    r#fn {}.r#struct(); //~ ERROR multiple applicable items in scope
+}
diff --git a/src/test/ui/raw-ident-suggestion.stderr b/src/test/ui/raw-ident-suggestion.stderr
new file mode 100644
index 0000000000000..fddd9427ab786
--- /dev/null
+++ b/src/test/ui/raw-ident-suggestion.stderr
@@ -0,0 +1,22 @@
+error[E0034]: multiple applicable items in scope
+  --> $DIR/raw-ident-suggestion.rs:21:13
+   |
+LL |     r#fn {}.r#struct();
+   |             ^^^^^^^^ multiple `r#struct` found
+   |
+note: candidate #1 is defined in an impl of the trait `async` for the type `r#fn`
+  --> $DIR/raw-ident-suggestion.rs:4:5
+   |
+LL |     fn r#struct(&self) {
+   |     ^^^^^^^^^^^^^^^^^^
+   = help: to disambiguate the method call, write `async::r#struct(r#fn {})` instead
+note: candidate #2 is defined in an impl of the trait `await` for the type `r#fn`
+  --> $DIR/raw-ident-suggestion.rs:10:5
+   |
+LL |     fn r#struct(&self) {
+   |     ^^^^^^^^^^^^^^^^^^
+   = help: to disambiguate the method call, write `await::r#struct(r#fn {})` instead
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0034`.
diff --git a/src/test/ui/suggestions/raw-name-use-suggestion.rs b/src/test/ui/suggestions/raw-name-use-suggestion.rs
index 6c01383d9610d..0a8073c0be2ea 100644
--- a/src/test/ui/suggestions/raw-name-use-suggestion.rs
+++ b/src/test/ui/suggestions/raw-name-use-suggestion.rs
@@ -5,5 +5,5 @@ mod foo {
 
 fn main() {
     foo::let(); //~ ERROR expected identifier, found keyword `let`
-    r#break(); //~ ERROR cannot find function `break` in this scope
+    r#break(); //~ ERROR cannot find function `r#break` in this scope
 }
diff --git a/src/test/ui/suggestions/raw-name-use-suggestion.stderr b/src/test/ui/suggestions/raw-name-use-suggestion.stderr
index 58eb87c00a411..62b76318e09b5 100644
--- a/src/test/ui/suggestions/raw-name-use-suggestion.stderr
+++ b/src/test/ui/suggestions/raw-name-use-suggestion.stderr
@@ -20,7 +20,7 @@ help: you can escape reserved keywords to use them as identifiers
 LL |     foo::r#let();
    |          ^^^^^
 
-error[E0425]: cannot find function `break` in this scope
+error[E0425]: cannot find function `r#break` in this scope
   --> $DIR/raw-name-use-suggestion.rs:8:5
    |
 LL |     r#break();

From 168e35d56935b265d9c3ce767430f40ed7448d05 Mon Sep 17 00:00:00 2001
From: Aaron Hill <aa1ronham@gmail.com>
Date: Tue, 3 Dec 2019 22:20:05 -0500
Subject: [PATCH 19/26] Include a span in more `expected...found` notes

In most places, we use a span when emitting `expected...found` errors.
However, there were a couple of places where we didn't use any span,
resulting in hard-to-interpret error messages.

This commit attaches the relevant span to these notes, and additionally
switches over to using `note_expected_found` instead of manually
formatting the message
---
 src/librustc/infer/error_reporting/mod.rs     | 15 ++++---
 src/librustc/infer/error_reporting/note.rs    | 20 +++++++---
 .../project-fn-ret-invariant.transmute.stderr | 20 +++++++---
 src/test/ui/c-variadic/variadic-ffi-4.stderr  | 10 +++--
 .../dyn-trait.stderr                          | 20 +++++++---
 src/test/ui/issues/issue-16683.stderr         | 10 +++--
 src/test/ui/issues/issue-17758.stderr         | 10 +++--
 .../ui/issues/issue-20831-debruijn.stderr     | 16 ++++++--
 src/test/ui/issues/issue-52213.stderr         | 10 +++--
 src/test/ui/issues/issue-55796.stderr         | 20 +++++++---
 src/test/ui/nll/issue-55394.stderr            | 10 +++--
 .../ui/nll/normalization-bounds-error.stderr  | 10 +++--
 .../ui/nll/type-alias-free-regions.stderr     | 40 +++++++++++++------
 .../constant-in-expr-inherent-1.stderr        | 10 +++--
 .../constant-in-expr-trait-item-3.stderr      | 10 +++--
 .../object-lifetime-default-elision.stderr    | 20 +++++++---
 .../region-object-lifetime-in-coercion.stderr | 20 +++++++---
 ...-type-region-bound-in-trait-not-met.stderr | 20 +++++++---
 ...-type-static-bound-in-trait-not-met.stderr | 10 +++--
 .../regions-close-object-into-object-2.stderr | 10 +++--
 .../regions-close-object-into-object-4.stderr | 10 +++--
 ...-close-over-type-parameter-multiple.stderr | 10 +++--
 .../ui/regions/regions-creating-enums4.stderr | 20 +++++++---
 .../ui/regions/regions-escape-method.stderr   | 10 +++--
 .../regions-escape-via-trait-or-not.stderr    | 10 +++--
 src/test/ui/regions/regions-nested-fns.stderr | 15 +++++--
 ...ions-normalize-in-where-clause-list.stderr | 13 ++++--
 .../ui/regions/regions-ret-borrowed-1.stderr  | 10 +++--
 .../ui/regions/regions-ret-borrowed.stderr    | 10 +++--
 .../regions-trait-object-subtyping.stderr     | 10 +++--
 .../ui/reject-specialized-drops-8142.stderr   | 10 +++--
 ...trait-has-wrong-lifetime-parameters.stderr | 10 +++--
 .../dyn-trait-underscore.stderr               | 10 +++--
 33 files changed, 325 insertions(+), 134 deletions(-)

diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs
index 5a940f2f80aa2..58c1498faa9de 100644
--- a/src/librustc/infer/error_reporting/mod.rs
+++ b/src/librustc/infer/error_reporting/mod.rs
@@ -1809,12 +1809,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                             sub_region,
                             "...",
                         );
-                        err.note(&format!(
-                            "...so that the {}:\nexpected {}\n   found {}",
-                            sup_trace.cause.as_requirement_str(),
-                            sup_expected.content(),
-                            sup_found.content()
+                        err.span_note(sup_trace.cause.span, &format!(
+                            "...so that the {}",
+                            sup_trace.cause.as_requirement_str()
                         ));
+
+                        err.note_expected_found(
+                            &"",
+                            sup_expected,
+                            &"",
+                            sup_found
+                        );
                         err.emit();
                         return;
                     }
diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs
index c1f840ad67815..4b933735fc75f 100644
--- a/src/librustc/infer/error_reporting/note.rs
+++ b/src/librustc/infer/error_reporting/note.rs
@@ -13,12 +13,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
         match *origin {
             infer::Subtype(ref trace) => {
                 if let Some((expected, found)) = self.values_str(&trace.values) {
-                    let expected = expected.content();
-                    let found = found.content();
-                    err.note(&format!("...so that the {}:\nexpected {}\n   found {}",
-                                      trace.cause.as_requirement_str(),
-                                      expected,
-                                      found));
+                    err.span_note(
+                        trace.cause.span,
+                        &format!(
+                            "...so that the {}",
+                            trace.cause.as_requirement_str()
+                        )
+                    );
+
+                    err.note_expected_found(
+                        &"",
+                        expected,
+                        &"",
+                        found
+                    );
                 } else {
                     // FIXME: this really should be handled at some earlier stage. Our
                     // handling of region checking when type errors are present is
diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr
index 627609c4a9c00..3e39c8a792446 100644
--- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr
+++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr
@@ -9,13 +9,21 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
    |
 LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
    |        ^^
-   = note: ...so that the expression is assignable:
-           expected Type<'_>
-              found Type<'a>
+note: ...so that the expression is assignable
+  --> $DIR/project-fn-ret-invariant.rs:48:13
+   |
+LL |    bar(foo, x)
+   |             ^
+   = note: expected  `Type<'_>`
+              found  `Type<'a>`
    = note: but, the lifetime must be valid for the static lifetime...
-   = note: ...so that the expression is assignable:
-           expected Type<'static>
-              found Type<'_>
+note: ...so that the expression is assignable
+  --> $DIR/project-fn-ret-invariant.rs:48:4
+   |
+LL |    bar(foo, x)
+   |    ^^^^^^^^^^^
+   = note: expected  `Type<'static>`
+              found  `Type<'_>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/c-variadic/variadic-ffi-4.stderr b/src/test/ui/c-variadic/variadic-ffi-4.stderr
index c80ed5ebf5cef..cd4cd8b198de8 100644
--- a/src/test/ui/c-variadic/variadic-ffi-4.stderr
+++ b/src/test/ui/c-variadic/variadic-ffi-4.stderr
@@ -49,9 +49,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
    |
 LL |     let _ = ap.with_copy(|ap| { ap });
    |                          ^^^^^^^^^^^
-   = note: ...so that the expression is assignable:
-           expected core::ffi::VaList<'_, '_>
-              found core::ffi::VaList<'_, '_>
+note: ...so that the expression is assignable
+  --> $DIR/variadic-ffi-4.rs:16:33
+   |
+LL |     let _ = ap.with_copy(|ap| { ap });
+   |                                 ^^
+   = note: expected  `core::ffi::VaList<'_, '_>`
+              found  `core::ffi::VaList<'_, '_>`
 note: but, the lifetime must be valid for the method call at 16:13...
   --> $DIR/variadic-ffi-4.rs:16:13
    |
diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr b/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr
index 5e80c673258b8..3300293bb36ca 100644
--- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr
+++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr
@@ -9,13 +9,21 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
    |
 LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
    |                          ^^
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<dyn std::fmt::Debug>
-              found std::boxed::Box<(dyn std::fmt::Debug + 'a)>
+note: ...so that the expression is assignable
+  --> $DIR/dyn-trait.rs:20:16
+   |
+LL |     static_val(x);
+   |                ^
+   = note: expected  `std::boxed::Box<dyn std::fmt::Debug>`
+              found  `std::boxed::Box<(dyn std::fmt::Debug + 'a)>`
    = note: but, the lifetime must be valid for the static lifetime...
-   = note: ...so that the types are compatible:
-           expected StaticTrait
-              found StaticTrait
+note: ...so that the types are compatible
+  --> $DIR/dyn-trait.rs:20:5
+   |
+LL |     static_val(x);
+   |     ^^^^^^^^^^
+   = note: expected  `StaticTrait`
+              found  `StaticTrait`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-16683.stderr b/src/test/ui/issues/issue-16683.stderr
index b663e213ed05e..99700f2084e4a 100644
--- a/src/test/ui/issues/issue-16683.stderr
+++ b/src/test/ui/issues/issue-16683.stderr
@@ -21,9 +21,13 @@ note: but, the lifetime must be valid for the lifetime `'a` as defined on the tr
    |
 LL | trait T<'a> {
    |         ^^
-   = note: ...so that the types are compatible:
-           expected &'a Self
-              found &Self
+note: ...so that the types are compatible
+  --> $DIR/issue-16683.rs:4:14
+   |
+LL |         self.a();
+   |              ^
+   = note: expected  `&'a Self`
+              found  `&Self`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-17758.stderr b/src/test/ui/issues/issue-17758.stderr
index adcbb62e3d5bd..adfc3f5085826 100644
--- a/src/test/ui/issues/issue-17758.stderr
+++ b/src/test/ui/issues/issue-17758.stderr
@@ -22,9 +22,13 @@ note: but, the lifetime must be valid for the lifetime `'a` as defined on the tr
    |
 LL | trait Foo<'a> {
    |           ^^
-   = note: ...so that the types are compatible:
-           expected &'a Self
-              found &Self
+note: ...so that the types are compatible
+  --> $DIR/issue-17758.rs:7:14
+   |
+LL |         self.foo();
+   |              ^^^
+   = note: expected  `&'a Self`
+              found  `&Self`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-20831-debruijn.stderr b/src/test/ui/issues/issue-20831-debruijn.stderr
index 13c9c09461eae..c7fd134a129de 100644
--- a/src/test/ui/issues/issue-20831-debruijn.stderr
+++ b/src/test/ui/issues/issue-20831-debruijn.stderr
@@ -88,9 +88,19 @@ note: ...but the lifetime must also be valid for the lifetime `'a` as defined on
    |
 LL | impl<'a> Publisher<'a> for MyStruct<'a> {
    |      ^^
-   = note: ...so that the types are compatible:
-           expected Publisher<'_>
-              found Publisher<'_>
+note: ...so that the types are compatible
+  --> $DIR/issue-20831-debruijn.rs:28:5
+   |
+LL | /     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
+LL | |         // Not obvious, but there is an implicit lifetime here -------^
+LL | |
+LL | |
+...  |
+LL | |         self.sub = t;
+LL | |     }
+   | |_____^
+   = note: expected  `Publisher<'_>`
+              found  `Publisher<'_>`
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/issues/issue-52213.stderr b/src/test/ui/issues/issue-52213.stderr
index b79a5ddf3e1bf..a8960f7756367 100644
--- a/src/test/ui/issues/issue-52213.stderr
+++ b/src/test/ui/issues/issue-52213.stderr
@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
    |
 LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T {
    |                       ^^
-   = note: ...so that the types are compatible:
-           expected (&&(T,),)
-              found (&&'a (T,),)
+note: ...so that the types are compatible
+  --> $DIR/issue-52213.rs:2:11
+   |
+LL |     match (&t,) {
+   |           ^^^^^
+   = note: expected  `(&&(T,),)`
+              found  `(&&'a (T,),)`
 note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 1:27...
   --> $DIR/issue-52213.rs:1:27
    |
diff --git a/src/test/ui/issues/issue-55796.stderr b/src/test/ui/issues/issue-55796.stderr
index 7b910f5e3e5a6..b8cafdc5c14b5 100644
--- a/src/test/ui/issues/issue-55796.stderr
+++ b/src/test/ui/issues/issue-55796.stderr
@@ -15,9 +15,13 @@ note: ...so that the type `std::iter::Map<<Self as Graph<'a>>::EdgesIter, [closu
 LL |         Box::new(self.out_edges(u).map(|e| e.target()))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: but, the lifetime must be valid for the static lifetime...
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>
-              found std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>
+note: ...so that the expression is assignable
+  --> $DIR/issue-55796.rs:16:9
+   |
+LL |         Box::new(self.out_edges(u).map(|e| e.target()))
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: expected  `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
+              found  `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
 
 error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
   --> $DIR/issue-55796.rs:21:9
@@ -36,9 +40,13 @@ note: ...so that the type `std::iter::Map<<Self as Graph<'a>>::EdgesIter, [closu
 LL |         Box::new(self.in_edges(u).map(|e| e.target()))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: but, the lifetime must be valid for the static lifetime...
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>
-              found std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>
+note: ...so that the expression is assignable
+  --> $DIR/issue-55796.rs:21:9
+   |
+LL |         Box::new(self.in_edges(u).map(|e| e.target()))
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: expected  `std::boxed::Box<(dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node> + 'static)>`
+              found  `std::boxed::Box<dyn std::iter::Iterator<Item = <Self as Graph<'a>>::Node>>`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/nll/issue-55394.stderr b/src/test/ui/nll/issue-55394.stderr
index 714a63b670c66..69a6ab004fd91 100644
--- a/src/test/ui/nll/issue-55394.stderr
+++ b/src/test/ui/nll/issue-55394.stderr
@@ -21,9 +21,13 @@ note: but, the lifetime must be valid for the lifetime `'_` as defined on the im
    |
 LL | impl Foo<'_> {
    |          ^^
-   = note: ...so that the expression is assignable:
-           expected Foo<'_>
-              found Foo<'_>
+note: ...so that the expression is assignable
+  --> $DIR/issue-55394.rs:9:9
+   |
+LL |         Foo { bar }
+   |         ^^^^^^^^^^^
+   = note: expected  `Foo<'_>`
+              found  `Foo<'_>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/nll/normalization-bounds-error.stderr b/src/test/ui/nll/normalization-bounds-error.stderr
index 3a152fbc6fce8..58f206742f4f5 100644
--- a/src/test/ui/nll/normalization-bounds-error.stderr
+++ b/src/test/ui/nll/normalization-bounds-error.stderr
@@ -14,9 +14,13 @@ note: ...but the lifetime must also be valid for the lifetime `'a` as defined on
    |
 LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
    |                  ^^
-   = note: ...so that the types are compatible:
-           expected Visitor<'d>
-              found Visitor<'_>
+note: ...so that the types are compatible
+  --> $DIR/normalization-bounds-error.rs:12:1
+   |
+LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: expected  `Visitor<'d>`
+              found  `Visitor<'_>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/nll/type-alias-free-regions.stderr b/src/test/ui/nll/type-alias-free-regions.stderr
index 6986389af8814..5191deca281cc 100644
--- a/src/test/ui/nll/type-alias-free-regions.stderr
+++ b/src/test/ui/nll/type-alias-free-regions.stderr
@@ -11,17 +11,25 @@ LL | /     fn from_box(b: Box<B>) -> Self {
 LL | |         C { f: b }
 LL | |     }
    | |_____^
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<std::boxed::Box<&isize>>
-              found std::boxed::Box<std::boxed::Box<&isize>>
+note: ...so that the expression is assignable
+  --> $DIR/type-alias-free-regions.rs:17:16
+   |
+LL |         C { f: b }
+   |                ^
+   = note: expected  `std::boxed::Box<std::boxed::Box<&isize>>`
+              found  `std::boxed::Box<std::boxed::Box<&isize>>`
 note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 15:6...
   --> $DIR/type-alias-free-regions.rs:15:6
    |
 LL | impl<'a> FromBox<'a> for C<'a> {
    |      ^^
-   = note: ...so that the expression is assignable:
-           expected C<'a>
-              found C<'_>
+note: ...so that the expression is assignable
+  --> $DIR/type-alias-free-regions.rs:17:9
+   |
+LL |         C { f: b }
+   |         ^^^^^^^^^^
+   = note: expected  `C<'a>`
+              found  `C<'_>`
 
 error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
   --> $DIR/type-alias-free-regions.rs:27:16
@@ -36,17 +44,25 @@ LL | /     fn from_tuple(b: (B,)) -> Self {
 LL | |         C { f: Box::new(b.0) }
 LL | |     }
    | |_____^
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<&isize>
-              found std::boxed::Box<&isize>
+note: ...so that the expression is assignable
+  --> $DIR/type-alias-free-regions.rs:27:25
+   |
+LL |         C { f: Box::new(b.0) }
+   |                         ^^^
+   = note: expected  `std::boxed::Box<&isize>`
+              found  `std::boxed::Box<&isize>`
 note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 25:6...
   --> $DIR/type-alias-free-regions.rs:25:6
    |
 LL | impl<'a> FromTuple<'a> for C<'a> {
    |      ^^
-   = note: ...so that the expression is assignable:
-           expected C<'a>
-              found C<'_>
+note: ...so that the expression is assignable
+  --> $DIR/type-alias-free-regions.rs:27:9
+   |
+LL |         C { f: Box::new(b.0) }
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+   = note: expected  `C<'a>`
+              found  `C<'_>`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr
index 4ebd991078864..37be450fd0a79 100644
--- a/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr
+++ b/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr
@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
    |
 LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
    |        ^^
-   = note: ...so that the types are compatible:
-           expected Foo<'_>
-              found Foo<'a>
+note: ...so that the types are compatible
+  --> $DIR/constant-in-expr-inherent-1.rs:8:5
+   |
+LL |     <Foo<'a>>::C
+   |     ^^^^^^^^^^^^
+   = note: expected  `Foo<'_>`
+              found  `Foo<'a>`
    = note: but, the lifetime must be valid for the static lifetime...
 note: ...so that reference does not outlive borrowed content
   --> $DIR/constant-in-expr-inherent-1.rs:8:5
diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.stderr
index d61659e7e9afc..4ee32847c5ec8 100644
--- a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.stderr
+++ b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.stderr
@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
    |
 LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 {
    |        ^^
-   = note: ...so that the types are compatible:
-           expected Foo<'_>
-              found Foo<'a>
+note: ...so that the types are compatible
+  --> $DIR/constant-in-expr-trait-item-3.rs:10:5
+   |
+LL |     T::C
+   |     ^^^^
+   = note: expected  `Foo<'_>`
+              found  `Foo<'a>`
    = note: but, the lifetime must be valid for the static lifetime...
 note: ...so that reference does not outlive borrowed content
   --> $DIR/constant-in-expr-trait-item-3.rs:10:5
diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr
index d66322c48ec98..1952ee8269d5b 100644
--- a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr
+++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr
@@ -19,9 +19,13 @@ note: but, the lifetime must be valid for the lifetime `'b` as defined on the fu
    |
 LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait {
    |             ^^
-   = note: ...so that the expression is assignable:
-           expected &'b (dyn SomeTrait + 'b)
-              found &dyn SomeTrait
+note: ...so that the expression is assignable
+  --> $DIR/object-lifetime-default-elision.rs:71:5
+   |
+LL |     ss
+   |     ^^
+   = note: expected  `&'b (dyn SomeTrait + 'b)`
+              found  `&dyn SomeTrait`
 
 error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
   --> $DIR/object-lifetime-default-elision.rs:71:5
@@ -44,9 +48,13 @@ note: but, the lifetime must be valid for the lifetime `'b` as defined on the fu
    |
 LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait {
    |             ^^
-   = note: ...so that the expression is assignable:
-           expected &'b (dyn SomeTrait + 'b)
-              found &dyn SomeTrait
+note: ...so that the expression is assignable
+  --> $DIR/object-lifetime-default-elision.rs:71:5
+   |
+LL |     ss
+   |     ^^
+   = note: expected  `&'b (dyn SomeTrait + 'b)`
+              found  `&dyn SomeTrait`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr
index 14934d6fa4899..e889651647034 100644
--- a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr
+++ b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr
@@ -34,17 +34,25 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
    |
 LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
    |      ^^
-   = note: ...so that the expression is assignable:
-           expected &[u8]
-              found &'a [u8]
+note: ...so that the expression is assignable
+  --> $DIR/region-object-lifetime-in-coercion.rs:26:14
+   |
+LL |     Box::new(v)
+   |              ^
+   = note: expected  `&[u8]`
+              found  `&'a [u8]`
 note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 25:9...
   --> $DIR/region-object-lifetime-in-coercion.rs:25:9
    |
 LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
    |         ^^
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<(dyn Foo + 'b)>
-              found std::boxed::Box<dyn Foo>
+note: ...so that the expression is assignable
+  --> $DIR/region-object-lifetime-in-coercion.rs:26:5
+   |
+LL |     Box::new(v)
+   |     ^^^^^^^^^^^
+   = note: expected  `std::boxed::Box<(dyn Foo + 'b)>`
+              found  `std::boxed::Box<dyn Foo>`
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr
index a636c9ef22c83..865e967fba32e 100644
--- a/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr
+++ b/src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.stderr
@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the imp
    |
 LL | impl<'a> Foo<'static> for &'a i32 {
    |      ^^
-   = note: ...so that the types are compatible:
-           expected Foo<'static>
-              found Foo<'static>
+note: ...so that the types are compatible
+  --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
+   |
+LL | impl<'a> Foo<'static> for &'a i32 {
+   |          ^^^^^^^^^^^^
+   = note: expected  `Foo<'static>`
+              found  `Foo<'static>`
    = note: but, the lifetime must be valid for the static lifetime...
 note: ...so that the type `&i32` will meet its required lifetime bounds
   --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:10
@@ -30,9 +34,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the imp
    |
 LL | impl<'a,'b> Foo<'b> for &'a i64 {
    |      ^^
-   = note: ...so that the types are compatible:
-           expected Foo<'b>
-              found Foo<'_>
+note: ...so that the types are compatible
+  --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:13
+   |
+LL | impl<'a,'b> Foo<'b> for &'a i64 {
+   |             ^^^^^^^
+   = note: expected  `Foo<'b>`
+              found  `Foo<'_>`
 note: but, the lifetime must be valid for the lifetime `'b` as defined on the impl at 19:9...
   --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:9
    |
diff --git a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr
index 81256e3b46cbb..6a34871c07efd 100644
--- a/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr
+++ b/src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.stderr
@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the imp
    |
 LL | impl<'a> Foo for &'a i32 {
    |      ^^
-   = note: ...so that the types are compatible:
-           expected Foo
-              found Foo
+note: ...so that the types are compatible
+  --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10
+   |
+LL | impl<'a> Foo for &'a i32 {
+   |          ^^^
+   = note: expected  `Foo`
+              found  `Foo`
    = note: but, the lifetime must be valid for the static lifetime...
 note: ...so that the type `&i32` will meet its required lifetime bounds
   --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:10
diff --git a/src/test/ui/regions/regions-close-object-into-object-2.stderr b/src/test/ui/regions/regions-close-object-into-object-2.stderr
index 8e473dad69341..28873ab807f8d 100644
--- a/src/test/ui/regions/regions-close-object-into-object-2.stderr
+++ b/src/test/ui/regions/regions-close-object-into-object-2.stderr
@@ -15,9 +15,13 @@ note: ...so that the type `(dyn A<T> + 'a)` is not borrowed for too long
 LL |     box B(&*v) as Box<dyn X>
    |           ^^^
    = note: but, the lifetime must be valid for the static lifetime...
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<(dyn X + 'static)>
-              found std::boxed::Box<dyn X>
+note: ...so that the expression is assignable
+  --> $DIR/regions-close-object-into-object-2.rs:10:5
+   |
+LL |     box B(&*v) as Box<dyn X>
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: expected  `std::boxed::Box<(dyn X + 'static)>`
+              found  `std::boxed::Box<dyn X>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/regions/regions-close-object-into-object-4.stderr b/src/test/ui/regions/regions-close-object-into-object-4.stderr
index c80d13e15b147..449a5b5fdd4d6 100644
--- a/src/test/ui/regions/regions-close-object-into-object-4.stderr
+++ b/src/test/ui/regions/regions-close-object-into-object-4.stderr
@@ -15,9 +15,13 @@ note: ...so that the type `(dyn A<U> + 'a)` is not borrowed for too long
 LL |     box B(&*v) as Box<dyn X>
    |           ^^^
    = note: but, the lifetime must be valid for the static lifetime...
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<(dyn X + 'static)>
-              found std::boxed::Box<dyn X>
+note: ...so that the expression is assignable
+  --> $DIR/regions-close-object-into-object-4.rs:10:5
+   |
+LL |     box B(&*v) as Box<dyn X>
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: expected  `std::boxed::Box<(dyn X + 'static)>`
+              found  `std::boxed::Box<dyn X>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr
index ef21316ea83ae..b2a7afaf1b452 100644
--- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr
+++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr
@@ -19,9 +19,13 @@ note: but, the lifetime must be valid for the lifetime `'c` as defined on the fu
    |
 LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> {
    |                          ^^
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<(dyn SomeTrait + 'c)>
-              found std::boxed::Box<dyn SomeTrait>
+note: ...so that the expression is assignable
+  --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5
+   |
+LL |     box v as Box<dyn SomeTrait + 'a>
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: expected  `std::boxed::Box<(dyn SomeTrait + 'c)>`
+              found  `std::boxed::Box<dyn SomeTrait>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/regions/regions-creating-enums4.stderr b/src/test/ui/regions/regions-creating-enums4.stderr
index 12b89787d5f18..58f74e4ee142d 100644
--- a/src/test/ui/regions/regions-creating-enums4.stderr
+++ b/src/test/ui/regions/regions-creating-enums4.stderr
@@ -9,17 +9,25 @@ note: first, the lifetime cannot outlive the lifetime `'a` as defined on the fun
    |
 LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> {
    |                ^^
-   = note: ...so that the expression is assignable:
-           expected &Ast<'_>
-              found &Ast<'a>
+note: ...so that the expression is assignable
+  --> $DIR/regions-creating-enums4.rs:7:14
+   |
+LL |     Ast::Add(x, y)
+   |              ^
+   = note: expected  `&Ast<'_>`
+              found  `&Ast<'a>`
 note: but, the lifetime must be valid for the lifetime `'b` as defined on the function body at 6:19...
   --> $DIR/regions-creating-enums4.rs:6:19
    |
 LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> {
    |                   ^^
-   = note: ...so that the expression is assignable:
-           expected Ast<'b>
-              found Ast<'_>
+note: ...so that the expression is assignable
+  --> $DIR/regions-creating-enums4.rs:7:5
+   |
+LL |     Ast::Add(x, y)
+   |     ^^^^^^^^^^^^^^
+   = note: expected  `Ast<'b>`
+              found  `Ast<'_>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/regions/regions-escape-method.stderr b/src/test/ui/regions/regions-escape-method.stderr
index b93dd0d4c57c9..ffc2a259485aa 100644
--- a/src/test/ui/regions/regions-escape-method.stderr
+++ b/src/test/ui/regions/regions-escape-method.stderr
@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
    |
 LL |     s.f(|p| p)
    |         ^^^^^
-   = note: ...so that the expression is assignable:
-           expected &i32
-              found &i32
+note: ...so that the expression is assignable
+  --> $DIR/regions-escape-method.rs:15:13
+   |
+LL |     s.f(|p| p)
+   |             ^
+   = note: expected  `&i32`
+              found  `&i32`
 note: but, the lifetime must be valid for the method call at 15:5...
   --> $DIR/regions-escape-method.rs:15:5
    |
diff --git a/src/test/ui/regions/regions-escape-via-trait-or-not.stderr b/src/test/ui/regions/regions-escape-via-trait-or-not.stderr
index a6b165e2d4444..90823464c56d2 100644
--- a/src/test/ui/regions/regions-escape-via-trait-or-not.stderr
+++ b/src/test/ui/regions/regions-escape-via-trait-or-not.stderr
@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
    |
 LL |     with(|o| o)
    |          ^^^^^
-   = note: ...so that the expression is assignable:
-           expected &isize
-              found &isize
+note: ...so that the expression is assignable
+  --> $DIR/regions-escape-via-trait-or-not.rs:18:14
+   |
+LL |     with(|o| o)
+   |              ^
+   = note: expected  `&isize`
+              found  `&isize`
 note: but, the lifetime must be valid for the expression at 18:5...
   --> $DIR/regions-escape-via-trait-or-not.rs:18:5
    |
diff --git a/src/test/ui/regions/regions-nested-fns.stderr b/src/test/ui/regions/regions-nested-fns.stderr
index f4eb5c8644f03..8fce1609d7830 100644
--- a/src/test/ui/regions/regions-nested-fns.stderr
+++ b/src/test/ui/regions/regions-nested-fns.stderr
@@ -29,9 +29,18 @@ LL | |         if false { return ay; }
 LL | |         return z;
 LL | |     }));
    | |_____^
-   = note: ...so that the types are compatible:
-           expected &isize
-              found &isize
+note: ...so that the types are compatible
+  --> $DIR/regions-nested-fns.rs:13:76
+   |
+LL |       ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
+   |  ____________________________________________________________________________^
+LL | |         if false { return x; }
+LL | |         if false { return ay; }
+LL | |         return z;
+LL | |     }));
+   | |_____^
+   = note: expected  `&isize`
+              found  `&isize`
 
 error[E0312]: lifetime of reference outlives lifetime of borrowed content...
   --> $DIR/regions-nested-fns.rs:14:27
diff --git a/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr b/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr
index d29fd80943f73..8a600d2a1e695 100644
--- a/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr
+++ b/src/test/ui/regions/regions-normalize-in-where-clause-list.stderr
@@ -17,9 +17,16 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined on
    |
 LL | fn bar<'a, 'b>()
    |            ^^
-   = note: ...so that the types are compatible:
-           expected Project<'a, 'b>
-              found Project<'_, '_>
+note: ...so that the types are compatible
+  --> $DIR/regions-normalize-in-where-clause-list.rs:22:1
+   |
+LL | / fn bar<'a, 'b>()
+LL | |     where <() as Project<'a, 'b>>::Item : Eq
+LL | | {
+LL | | }
+   | |_^
+   = note: expected  `Project<'a, 'b>`
+              found  `Project<'_, '_>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/regions/regions-ret-borrowed-1.stderr b/src/test/ui/regions/regions-ret-borrowed-1.stderr
index 49076673ad398..2895a0ccdeec8 100644
--- a/src/test/ui/regions/regions-ret-borrowed-1.stderr
+++ b/src/test/ui/regions/regions-ret-borrowed-1.stderr
@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
    |
 LL |     with(|o| o)
    |          ^^^^^
-   = note: ...so that the expression is assignable:
-           expected &isize
-              found &isize
+note: ...so that the expression is assignable
+  --> $DIR/regions-ret-borrowed-1.rs:10:14
+   |
+LL |     with(|o| o)
+   |              ^
+   = note: expected  `&isize`
+              found  `&isize`
 note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 9:14...
   --> $DIR/regions-ret-borrowed-1.rs:9:14
    |
diff --git a/src/test/ui/regions/regions-ret-borrowed.stderr b/src/test/ui/regions/regions-ret-borrowed.stderr
index eb1ade27acea7..b74f10f5075eb 100644
--- a/src/test/ui/regions/regions-ret-borrowed.stderr
+++ b/src/test/ui/regions/regions-ret-borrowed.stderr
@@ -9,9 +9,13 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th
    |
 LL |     with(|o| o)
    |          ^^^^^
-   = note: ...so that the expression is assignable:
-           expected &isize
-              found &isize
+note: ...so that the expression is assignable
+  --> $DIR/regions-ret-borrowed.rs:13:14
+   |
+LL |     with(|o| o)
+   |              ^
+   = note: expected  `&isize`
+              found  `&isize`
 note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 12:14...
   --> $DIR/regions-ret-borrowed.rs:12:14
    |
diff --git a/src/test/ui/regions/regions-trait-object-subtyping.stderr b/src/test/ui/regions/regions-trait-object-subtyping.stderr
index ef69f2535dc1e..58b79d212700c 100644
--- a/src/test/ui/regions/regions-trait-object-subtyping.stderr
+++ b/src/test/ui/regions/regions-trait-object-subtyping.stderr
@@ -36,9 +36,13 @@ note: but, the lifetime must be valid for the lifetime `'b` as defined on the fu
    |
 LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy {
    |            ^^
-   = note: ...so that the expression is assignable:
-           expected &'b mut (dyn Dummy + 'b)
-              found &mut (dyn Dummy + 'b)
+note: ...so that the expression is assignable
+  --> $DIR/regions-trait-object-subtyping.rs:15:5
+   |
+LL |     x
+   |     ^
+   = note: expected  `&'b mut (dyn Dummy + 'b)`
+              found  `&mut (dyn Dummy + 'b)`
 
 error[E0308]: mismatched types
   --> $DIR/regions-trait-object-subtyping.rs:22:5
diff --git a/src/test/ui/reject-specialized-drops-8142.stderr b/src/test/ui/reject-specialized-drops-8142.stderr
index e55f0232ff94b..527babb01208f 100644
--- a/src/test/ui/reject-specialized-drops-8142.stderr
+++ b/src/test/ui/reject-specialized-drops-8142.stderr
@@ -105,9 +105,13 @@ note: ...but the lifetime must also be valid for the lifetime `'l2` as defined o
    |
 LL | struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
    |               ^^^
-   = note: ...so that the types are compatible:
-           expected W<'l1, 'l2>
-              found W<'_, '_>
+note: ...so that the types are compatible
+  --> $DIR/reject-specialized-drops-8142.rs:54:1
+   |
+LL | impl<'lw>         Drop for W<'lw,'lw>     { fn drop(&mut self) { } } // REJECT
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: expected  `W<'l1, 'l2>`
+              found  `W<'_, '_>`
 
 error: aborting due to 8 previous errors
 
diff --git a/src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr b/src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr
index 88c9c473eb0c7..9fdcd4de495c0 100644
--- a/src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr
+++ b/src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr
@@ -14,9 +14,13 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined on
    |
 LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
    |         ^^
-   = note: ...so that the types are compatible:
-           expected T1<'a>
-              found T1<'_>
+note: ...so that the types are compatible
+  --> $DIR/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
+   |
+LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
+   |             ^^^^^^^^^^
+   = note: expected  `T1<'a>`
+              found  `T1<'_>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
index d0475bf08c38d..e6029e0d4623a 100644
--- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
+++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr
@@ -18,9 +18,13 @@ note: ...so that reference does not outlive borrowed content
 LL |     Box::new(items.iter())
    |              ^^^^^
    = note: but, the lifetime must be valid for the static lifetime...
-   = note: ...so that the expression is assignable:
-           expected std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>
-              found std::boxed::Box<dyn std::iter::Iterator<Item = &T>>
+note: ...so that the expression is assignable
+  --> $DIR/dyn-trait-underscore.rs:8:5
+   |
+LL |     Box::new(items.iter())
+   |     ^^^^^^^^^^^^^^^^^^^^^^
+   = note: expected  `std::boxed::Box<(dyn std::iter::Iterator<Item = &T> + 'static)>`
+              found  `std::boxed::Box<dyn std::iter::Iterator<Item = &T>>`
 
 error: aborting due to previous error
 

From b5ad0cb03302d679e5dc7d7d1157c42ccd72b5b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Tue, 3 Dec 2019 22:25:15 -0800
Subject: [PATCH 20/26] review comments: move test

---
 .../issue-65634-raw-ident-suggestion.rs}                    | 0
 .../issue-65634-raw-ident-suggestion.stderr}                | 6 +++---
 2 files changed, 3 insertions(+), 3 deletions(-)
 rename src/test/ui/{raw-ident-suggestion.rs => issues/issue-65634-raw-ident-suggestion.rs} (100%)
 rename src/test/ui/{raw-ident-suggestion.stderr => issues/issue-65634-raw-ident-suggestion.stderr} (81%)

diff --git a/src/test/ui/raw-ident-suggestion.rs b/src/test/ui/issues/issue-65634-raw-ident-suggestion.rs
similarity index 100%
rename from src/test/ui/raw-ident-suggestion.rs
rename to src/test/ui/issues/issue-65634-raw-ident-suggestion.rs
diff --git a/src/test/ui/raw-ident-suggestion.stderr b/src/test/ui/issues/issue-65634-raw-ident-suggestion.stderr
similarity index 81%
rename from src/test/ui/raw-ident-suggestion.stderr
rename to src/test/ui/issues/issue-65634-raw-ident-suggestion.stderr
index fddd9427ab786..c7bb653dc1f14 100644
--- a/src/test/ui/raw-ident-suggestion.stderr
+++ b/src/test/ui/issues/issue-65634-raw-ident-suggestion.stderr
@@ -1,17 +1,17 @@
 error[E0034]: multiple applicable items in scope
-  --> $DIR/raw-ident-suggestion.rs:21:13
+  --> $DIR/issue-65634-raw-ident-suggestion.rs:21:13
    |
 LL |     r#fn {}.r#struct();
    |             ^^^^^^^^ multiple `r#struct` found
    |
 note: candidate #1 is defined in an impl of the trait `async` for the type `r#fn`
-  --> $DIR/raw-ident-suggestion.rs:4:5
+  --> $DIR/issue-65634-raw-ident-suggestion.rs:4:5
    |
 LL |     fn r#struct(&self) {
    |     ^^^^^^^^^^^^^^^^^^
    = help: to disambiguate the method call, write `async::r#struct(r#fn {})` instead
 note: candidate #2 is defined in an impl of the trait `await` for the type `r#fn`
-  --> $DIR/raw-ident-suggestion.rs:10:5
+  --> $DIR/issue-65634-raw-ident-suggestion.rs:10:5
    |
 LL |     fn r#struct(&self) {
    |     ^^^^^^^^^^^^^^^^^^

From 0103308ad3745109600541e139af5571838b8791 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Tue, 3 Dec 2019 22:25:44 -0800
Subject: [PATCH 21/26] Account for raw idents in module file finding

---
 src/librustc_parse/parser/module.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/librustc_parse/parser/module.rs b/src/librustc_parse/parser/module.rs
index 59d7c2b423972..807defc51c1d3 100644
--- a/src/librustc_parse/parser/module.rs
+++ b/src/librustc_parse/parser/module.rs
@@ -212,13 +212,13 @@ impl<'a> Parser<'a> {
         // `./<id>.rs` and `./<id>/mod.rs`.
         let relative_prefix_string;
         let relative_prefix = if let Some(ident) = relative {
-            relative_prefix_string = format!("{}{}", ident, path::MAIN_SEPARATOR);
+            relative_prefix_string = format!("{}{}", ident.name, path::MAIN_SEPARATOR);
             &relative_prefix_string
         } else {
             ""
         };
 
-        let mod_name = id.to_string();
+        let mod_name = id.name.to_string();
         let default_path_str = format!("{}{}.rs", relative_prefix, mod_name);
         let secondary_path_str = format!("{}{}{}mod.rs",
                                          relative_prefix, mod_name, path::MAIN_SEPARATOR);

From c2ce7dd756c36cb619c7f231ab6596d6b180afed Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Wed, 4 Dec 2019 13:27:17 +0100
Subject: [PATCH 22/26] Clean up E0116 error code long explanation

---
 src/librustc_error_codes/error_codes/E0116.md | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/librustc_error_codes/error_codes/E0116.md b/src/librustc_error_codes/error_codes/E0116.md
index 27759a423433f..ca849c2a128f4 100644
--- a/src/librustc_error_codes/error_codes/E0116.md
+++ b/src/librustc_error_codes/error_codes/E0116.md
@@ -1,11 +1,15 @@
-You can only define an inherent implementation for a type in the same crate
-where the type was defined. For example, an `impl` block as below is not allowed
-since `Vec` is defined in the standard library:
+An inherent implementation was defined for a type outside the current crate.
+
+Erroneous code example:
 
 ```compile_fail,E0116
 impl Vec<u8> { } // error
 ```
 
+You can only define an inherent implementation for a type in the same crate
+where the type was defined. For example, an `impl` block as above is not allowed
+since `Vec` is defined in the standard library.
+
 To fix this problem, you can do either of these things:
 
  - define a trait that has the desired associated functions/types/constants and

From 1e5450d4cb7bb951bbdb9bc2b09a984b132c4280 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Wed, 4 Dec 2019 13:31:40 +0100
Subject: [PATCH 23/26] Clean up E0117 error code long explanation

---
 src/librustc_error_codes/error_codes/E0117.md | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/librustc_error_codes/error_codes/E0117.md b/src/librustc_error_codes/error_codes/E0117.md
index bd36230566262..7fa211d4a27d4 100644
--- a/src/librustc_error_codes/error_codes/E0117.md
+++ b/src/librustc_error_codes/error_codes/E0117.md
@@ -1,3 +1,11 @@
+The `Drop` trait was implemented on a non-struct type.
+
+Erroneous code example:
+
+```compile_fail,E0117
+impl Drop for u32 {}
+```
+
 This error indicates a violation of one of Rust's orphan rules for trait
 implementations. The rule prohibits any implementation of a foreign trait (a
 trait defined in another crate) where
@@ -6,12 +14,6 @@ trait defined in another crate) where
  - all of the parameters being passed to the trait (if there are any) are also
    foreign.
 
-Here's one example of this error:
-
-```compile_fail,E0117
-impl Drop for u32 {}
-```
-
 To avoid this kind of error, ensure that at least one local type is referenced
 by the `impl`:
 

From 9eaea4d3ea1ae6d6858af1a83a7d44c759a31212 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Wed, 4 Dec 2019 13:35:26 +0100
Subject: [PATCH 24/26] Clean up E0118 error code long explanation

---
 src/librustc_error_codes/error_codes/E0118.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/librustc_error_codes/error_codes/E0118.md b/src/librustc_error_codes/error_codes/E0118.md
index baf35ffbb0b53..5cb5f506e0a4b 100644
--- a/src/librustc_error_codes/error_codes/E0118.md
+++ b/src/librustc_error_codes/error_codes/E0118.md
@@ -1,5 +1,7 @@
-You're trying to write an inherent implementation for something which isn't a
-struct nor an enum. Erroneous code example:
+An inherent implementation was defined for something which isn't a struct nor
+an enum.
+
+Erroneous code example:
 
 ```compile_fail,E0118
 impl (u8, u8) { // error: no base type found for inherent implementation

From ae753a55ac8b16772ad7617c8512433921271abc Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume1.gomez@gmail.com>
Date: Wed, 4 Dec 2019 13:36:50 +0100
Subject: [PATCH 25/26] some error codes long explanation

---
 src/librustc_error_codes/error_codes/E0109.md | 1 +
 src/librustc_error_codes/error_codes/E0119.md | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/librustc_error_codes/error_codes/E0109.md b/src/librustc_error_codes/error_codes/E0109.md
index 5bc229ade52f4..2eab9725a6f59 100644
--- a/src/librustc_error_codes/error_codes/E0109.md
+++ b/src/librustc_error_codes/error_codes/E0109.md
@@ -1,4 +1,5 @@
 You tried to provide a generic argument to a type which doesn't need it.
+
 Erroneous code example:
 
 ```compile_fail,E0109
diff --git a/src/librustc_error_codes/error_codes/E0119.md b/src/librustc_error_codes/error_codes/E0119.md
index 0af3bd4a0de79..e596349e5e2d1 100644
--- a/src/librustc_error_codes/error_codes/E0119.md
+++ b/src/librustc_error_codes/error_codes/E0119.md
@@ -1,5 +1,6 @@
 There are conflicting trait implementations for the same type.
-Example of erroneous code:
+
+Erroneous code example:
 
 ```compile_fail,E0119
 trait MyTrait {

From 8be7223145c486f398863ddb55d115bf91651f59 Mon Sep 17 00:00:00 2001
From: Elichai Turkel <elichai.turkel@gmail.com>
Date: Wed, 4 Dec 2019 15:13:43 +0200
Subject: [PATCH 26/26] Fix docs for formatting delegations

---
 src/libcore/fmt/mod.rs | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs
index 4c941e2dfe6de..e2f49ee25a756 100644
--- a/src/libcore/fmt/mod.rs
+++ b/src/libcore/fmt/mod.rs
@@ -662,7 +662,7 @@ pub trait Display {
 ///     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 ///         let val = self.0;
 ///
-///         write!(f, "{:o}", val) // delegate to i32's implementation
+///         fmt::Octal::fmt(&val, f) // delegate to i32's implementation
 ///     }
 /// }
 ///
@@ -712,7 +712,7 @@ pub trait Octal {
 ///     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 ///         let val = self.0;
 ///
-///         write!(f, "{:b}", val) // delegate to i32's implementation
+///         fmt::Binary::fmt(&val, f) // delegate to i32's implementation
 ///     }
 /// }
 ///
@@ -771,7 +771,7 @@ pub trait Binary {
 ///     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 ///         let val = self.0;
 ///
-///         write!(f, "{:x}", val) // delegate to i32's implementation
+///         fmt::LowerHex::fmt(&val, f) // delegate to i32's implementation
 ///     }
 /// }
 ///
@@ -824,7 +824,7 @@ pub trait LowerHex {
 ///     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 ///         let val = self.0;
 ///
-///         write!(f, "{:X}", val) // delegate to i32's implementation
+///         fmt::UpperHex::fmt(&val, f) // delegate to i32's implementation
 ///     }
 /// }
 ///
@@ -869,7 +869,8 @@ pub trait UpperHex {
 ///     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 ///         // use `as` to convert to a `*const T`, which implements Pointer, which we can use
 ///
-///         write!(f, "{:p}", self as *const Length)
+///         let ptr = self as *const Self;
+///         fmt::Pointer::fmt(&ptr, f)
 ///     }
 /// }
 ///