From d5e03530f7765434d01a9561354dc0c863f1336a Mon Sep 17 00:00:00 2001
From: Eric Huss <eric@huss.org>
Date: Thu, 23 May 2019 13:27:49 -0700
Subject: [PATCH 01/29] Update cargo

---
 Cargo.lock                 | 49 ++++++++++++++++++++++++++++++++------
 src/tools/cargo            |  2 +-
 src/tools/tidy/src/deps.rs |  3 +++
 3 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index b651faac90281..a4d0180b1e406 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -253,7 +253,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "cargo"
-version = "0.37.0"
+version = "0.38.0"
 dependencies = [
  "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "bufstream 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -261,7 +261,7 @@ dependencies = [
  "bytesize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "crates-io 0.25.0",
+ "crates-io 0.26.0",
  "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "crypto-hash 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "curl 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -278,7 +278,7 @@ dependencies = [
  "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "home 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "ignore 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "im-rc 12.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "im-rc 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "jobserver 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -300,6 +300,7 @@ dependencies = [
  "serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
  "shell-escape 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strip-ansi-escapes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)",
  "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -537,7 +538,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "crates-io"
-version = "0.25.0"
+version = "0.26.0"
 dependencies = [
  "curl 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)",
  "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1163,10 +1164,11 @@ dependencies = [
 
 [[package]]
 name = "im-rc"
-version = "12.3.0"
+version = "13.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "sized-chunks 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -2239,7 +2241,7 @@ dependencies = [
 name = "rls"
 version = "1.36.0"
 dependencies = [
- "cargo 0.37.0",
+ "cargo 0.38.0",
  "cargo_metadata 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "clippy_lints 0.0.212",
  "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3262,6 +3264,14 @@ name = "siphasher"
 version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "sized-chunks"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "slab"
 version = "0.4.2"
@@ -3347,6 +3357,14 @@ name = "string_cache_shared"
 version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "strip-ansi-escapes"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "strsim"
 version = "0.7.0"
@@ -3923,6 +3941,11 @@ name = "utf8-ranges"
 version = "1.0.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "utf8parse"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
 [[package]]
 name = "vcpkg"
 version = "0.2.6"
@@ -3953,6 +3976,14 @@ name = "void"
 version = "1.0.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "vte"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "wait-timeout"
 version = "0.1.5"
@@ -4157,7 +4188,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
 "checksum if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec"
 "checksum ignore 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8dc57fa12805f367736a38541ac1a9fc6a52812a0ca959b1d4d4b640a89eb002"
-"checksum im-rc 12.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9460397452f537fd51808056ff209f4c4c4c9d20d42ae952f517708726284972"
+"checksum im-rc 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0197597d095c0d11107975d3175173f810ee572c2501ff4de64f4f3f119806"
 "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
 "checksum is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5b386aef33a1c677be65237cb9d32c3f3ef56bd035949710c4bb13083eb053"
 "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
@@ -4308,6 +4339,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
 "checksum signal-hook 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1f272d1b7586bec132ed427f532dd418d8beca1ca7f2caf7df35569b1415a4b4"
 "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537"
+"checksum sized-chunks 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2a2eb3fe454976eefb479f78f9b394d34d661b647c6326a3a6e66f68bb12c26"
 "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
 "checksum smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b73ea3738b47563803ef814925e69be00799a8c07420be8b996f8e98fb2336db"
 "checksum socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d11a52082057d87cb5caa31ad812f4504b97ab44732cd8359df2e9ff9f48e7"
@@ -4315,6 +4347,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423"
 "checksum string_cache_codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eea1eee654ef80933142157fdad9dd8bc43cf7c74e999e369263496f04ff4da"
 "checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
+"checksum strip-ansi-escapes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d63676e2abafa709460982ddc02a3bb586b6d15a49b75c212e06edd3933acee"
 "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
 "checksum strum 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c3a2071519ab6a48f465808c4c1ffdd00dfc8e93111d02b4fc5abab177676e"
 "checksum strum_macros 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8baacebd7b7c9b864d83a6ba7a246232983e277b86fa5cdec77f565715a4b136"
@@ -4367,11 +4400,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea"
 "checksum utf-8 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1262dfab4c30d5cb7c07026be00ee343a6cf5027fdc0104a9160f354e5db75c"
 "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
+"checksum utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d"
 "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d"
 "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
 "checksum vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6aba5e34f93dc7051dfad05b98a18e9156f27e7b431fe1d2398cb6061c0a1dba"
 "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
 "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
+"checksum vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f42f536e22f7fcbb407639765c8fd78707a33109301f834a594758bedd6e8cf"
 "checksum wait-timeout 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b9f3bf741a801531993db6478b95682117471f76916f5e690dd8d45395b09349"
 "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1"
 "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
diff --git a/src/tools/cargo b/src/tools/cargo
index c4fcfb725b4be..545f354259be4 160000
--- a/src/tools/cargo
+++ b/src/tools/cargo
@@ -1 +1 @@
-Subproject commit c4fcfb725b4be00c72eb9cf30c7d8b095577c280
+Subproject commit 545f354259be4e9745ea00a524c0e4c51df01aa6
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index 8626ba060bf71..b70ca6c4e7966 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -47,6 +47,9 @@ const EXCEPTIONS: &[&str] = &[
     "adler32",            // BSD-3-Clause AND Zlib, cargo dep that isn't used
     "fortanix-sgx-abi",   // MPL-2.0+, libstd but only for `sgx` target
     "constant_time_eq",   // CC0-1.0, rustfmt
+    "utf8parse",          // Apache-2.0 OR MIT, cargo via strip-ansi-escapes
+    "vte",                // Apache-2.0 OR MIT, cargo via strip-ansi-escapes
+    "sized-chunks",       // MPL-2.0+, cargo via im-rc
 ];
 
 /// Which crates to check against the whitelist?

From 46ffb6adbaed91a09d36953970078b0fae6de61f Mon Sep 17 00:00:00 2001
From: Eric Huss <eric@huss.org>
Date: Thu, 23 May 2019 13:33:08 -0700
Subject: [PATCH 02/29] tidy: don't short-circuit on license error

If there is more than one license error, tidy would only print the first
error. This changes it so that all license errors are printed.
---
 src/tools/tidy/src/deps.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index 8626ba060bf71..6f9623d18d209 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -241,7 +241,7 @@ pub fn check(path: &Path, bad: &mut bool) {
         }
 
         let toml = dir.path().join("Cargo.toml");
-        *bad = *bad || !check_license(&toml);
+        *bad = !check_license(&toml) || *bad;
     }
     assert!(saw_dir, "no vendored source");
 }

From d3c73ddec9f657b7856e6328ed07d7ec0f6e4ff5 Mon Sep 17 00:00:00 2001
From: Brent Kerby <blkerby@gmail.com>
Date: Sun, 19 May 2019 11:53:35 -0600
Subject: [PATCH 03/29] typo

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

diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index 9672cf4ffed36..8034140903768 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -11,7 +11,7 @@
 //! mutate it.
 //!
 //! Shareable mutable containers exist to permit mutability in a controlled manner, even in the
-//! presence of aliasing. Both `Cell<T>` and `RefCell<T>` allows to do this in a single threaded
+//! presence of aliasing. Both `Cell<T>` and `RefCell<T>` allow doing this in a single-threaded
 //! way. However, neither `Cell<T>` nor `RefCell<T>` are thread safe (they do not implement
 //! `Sync`). If you need to do aliasing and mutation between multiple threads it is possible to
 //! use [`Mutex`](../../std/sync/struct.Mutex.html),

From 0123fab8738db10fae52f1db1568127e602ac600 Mon Sep 17 00:00:00 2001
From: Brent Kerby <blkerby@gmail.com>
Date: Thu, 23 May 2019 19:35:27 -0600
Subject: [PATCH 04/29] Fix typo "spit_paths", add link

---
 src/libstd/env.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/libstd/env.rs b/src/libstd/env.rs
index 9058ea93d6de0..00e840a53e9c0 100644
--- a/src/libstd/env.rs
+++ b/src/libstd/env.rs
@@ -465,7 +465,7 @@ pub struct JoinPathsError {
 /// # }
 /// ```
 ///
-/// Using `env::join_paths` with `env::spit_paths` to append an item to the `PATH` environment
+/// Using `env::join_paths` with [`env::split_paths`] to append an item to the `PATH` environment
 /// variable:
 ///
 /// ```
@@ -483,6 +483,8 @@ pub struct JoinPathsError {
 ///     Ok(())
 /// }
 /// ```
+///
+/// [`env::split_paths`]: fn.split_paths.html
 #[stable(feature = "env", since = "1.0.0")]
 pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
     where I: IntoIterator<Item=T>, T: AsRef<OsStr>

From fbc6a4b9f015ebf56f4f5b883bd9b0216b33a198 Mon Sep 17 00:00:00 2001
From: Eric Huss <eric@huss.org>
Date: Thu, 23 May 2019 21:21:13 -0700
Subject: [PATCH 05/29] Revert edition-guide toolstate override

---
 src/ci/docker/x86_64-gnu-tools/checktools.sh | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/ci/docker/x86_64-gnu-tools/checktools.sh b/src/ci/docker/x86_64-gnu-tools/checktools.sh
index a0fe307cffcdb..af0198705a2fe 100755
--- a/src/ci/docker/x86_64-gnu-tools/checktools.sh
+++ b/src/ci/docker/x86_64-gnu-tools/checktools.sh
@@ -74,9 +74,7 @@ status_check() {
     check_dispatch $1 beta nomicon src/doc/nomicon
     check_dispatch $1 beta reference src/doc/reference
     check_dispatch $1 beta rust-by-example src/doc/rust-by-example
-    # Temporarily disabled until
-    # https://github.com/rust-lang/rust/issues/60459 is fixed.
-    # check_dispatch $1 beta edition-guide src/doc/edition-guide
+    check_dispatch $1 beta edition-guide src/doc/edition-guide
     check_dispatch $1 beta rls src/tools/rls
     check_dispatch $1 beta rustfmt src/tools/rustfmt
     check_dispatch $1 beta clippy-driver src/tools/clippy

From 9be8b7edc90442f4b10dfd094f65d3f8a9cdf864 Mon Sep 17 00:00:00 2001
From: Cerberuser <computers05@mail.ru>
Date: Fri, 24 May 2019 12:09:33 +0700
Subject: [PATCH 06/29] Fixed type-alias-bounds lint doc

The example code under type-alias-bounds lint produced two warnings - one from the lint itself and another from the dead_code lint, and only the second one was in the doc. This looked like an error, so I've added `#[allow(dead_code)]` and replaced the example output with the expected one.
[Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=%23%5Ballow(dead_code)%5D%0Atype%20SendVec%3CT%3A%20Send%3E%20%3D%20Vec%3CT%3E%3B)
---
 src/doc/rustc/src/lints/listing/warn-by-default.md | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/doc/rustc/src/lints/listing/warn-by-default.md b/src/doc/rustc/src/lints/listing/warn-by-default.md
index ba927b1ef3b57..f090f142c0816 100644
--- a/src/doc/rustc/src/lints/listing/warn-by-default.md
+++ b/src/doc/rustc/src/lints/listing/warn-by-default.md
@@ -529,18 +529,21 @@ This lint detects bounds in type aliases. These are not currently enforced.
 Some example code that triggers this lint:
 
 ```rust
+#[allow(dead_code)]
 type SendVec<T: Send> = Vec<T>;
 ```
 
 This will produce:
 
 ```text
-warning: type alias is never used: `SendVec`
- --> src/main.rs:1:1
+warning: bounds on generic parameters are not enforced in type aliases
+ --> src/lib.rs:2:17
   |
-1 | type SendVec<T: Send> = Vec<T>;
-  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+2 | type SendVec<T: Send> = Vec<T>;
+  |                 ^^^^
   |
+  = note: #[warn(type_alias_bounds)] on by default
+  = help: the bound will not be checked when the type alias is used, and should be removed
 ```
 
 ## tyvar-behind-raw-pointer

From a8fc09be39fd265bcd20b66043a2142c25bfc22e Mon Sep 17 00:00:00 2001
From: Simon Sapin <simon.sapin@exyr.org>
Date: Fri, 24 May 2019 07:51:48 +0200
Subject: [PATCH 07/29] Use FnOnce instead of FnBox in libtest

---
 src/libtest/lib.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 7f7db2a21251a..8bd0d74cd1710 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -22,7 +22,6 @@
 #![unstable(feature = "test", issue = "27812")]
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
 #![feature(asm)]
-#![feature(fnbox)]
 #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))]
 #![feature(nll)]
 #![feature(set_stdio)]
@@ -56,7 +55,6 @@ pub use self::TestResult::*;
 
 use std::any::Any;
 use std::borrow::Cow;
-use std::boxed::FnBox;
 use std::cmp;
 use std::collections::BTreeMap;
 use std::env;
@@ -174,7 +172,7 @@ pub trait TDynBenchFn: Send {
 pub enum TestFn {
     StaticTestFn(fn()),
     StaticBenchFn(fn(&mut Bencher)),
-    DynTestFn(Box<dyn FnBox() + Send>),
+    DynTestFn(Box<dyn FnOnce() + Send>),
     DynBenchFn(Box<dyn TDynBenchFn + 'static>),
 }
 
@@ -1447,7 +1445,7 @@ pub fn run_test(
         desc: TestDesc,
         monitor_ch: Sender<MonitorMsg>,
         nocapture: bool,
-        testfn: Box<dyn FnBox() + Send>,
+        testfn: Box<dyn FnOnce() + Send>,
         concurrency: Concurrent,
     ) {
         // Buffer for capturing standard I/O

From 67ee2862adb0df17affb0eaec18bd4dd07b7304c Mon Sep 17 00:00:00 2001
From: Scott McMurray <scottmcm@users.noreply.github.com>
Date: Thu, 23 May 2019 23:40:07 -0700
Subject: [PATCH 08/29] Remove the incorrect warning from README.md

My problem was user error; thanks to @Zoxc for fixing me!

r? @alexcrichton
---
 README.md | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 75d7823490a20..b522b161ecf93 100644
--- a/README.md
+++ b/README.md
@@ -134,9 +134,8 @@ MSVC builds of Rust additionally require an installation of Visual Studio 2017
 
 [Visual Studio Build Tools]: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019
 
-At last check (cmake 3.14.3 and msvc 16.0.3) using the 2019 tools fails to
-build the in-tree LLVM build with a CMake error, so use 2017 instead by
-including the “MSVC v141 – VS 2017 C++ x64/x86 build tools (v14.16)” component.
+(If you're installing cmake yourself, be careful that “C++ CMake tools for
+Windows” doesn't get included under “Individual components”.)
 
 With these dependencies installed, you can build the compiler in a `cmd.exe`
 shell with:
@@ -151,7 +150,7 @@ then you may need to force rustbuild to use an older version. This can be done
 by manually calling the appropriate vcvars file before running the bootstrap.
 
 ```batch
-> CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
+> CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
 > python x.py build
 ```
 

From 73fd3497d4cc65c733cc1848bea363c00cb87878 Mon Sep 17 00:00:00 2001
From: Simon Sapin <simon.sapin@exyr.org>
Date: Fri, 24 May 2019 08:55:33 +0200
Subject: [PATCH 09/29] Deprecate `FnBox`. `Box<dyn FnOnce()>` can be called
 directly, since 1.35

FCP completion: https://github.com/rust-lang/rust/issues/28796#issuecomment-439731515
---
 src/liballoc/boxed.rs                         | 42 +++++++++++++++----
 .../run-pass/unsized-locals/fnbox-compat.rs   |  1 +
 .../ui/confuse-field-and-method/issue-2392.rs | 12 ++----
 .../issue-2392.stderr                         | 28 ++++++-------
 4 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 97c2d8e7a8e79..bf8f5b8b91a1e 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -759,13 +759,14 @@ impl<A, F: Fn<A> + ?Sized> Fn<A> for Box<F> {
     }
 }
 
+/// `FnBox` is deprecated and will be removed.
+/// `Box<dyn FnOnce()>` can be called directly, since Rust 1.35.0.
+///
 /// `FnBox` is a version of the `FnOnce` intended for use with boxed
-/// closure objects. The idea is that where one would normally store a
-/// `Box<dyn FnOnce()>` in a data structure, you should use
+/// closure objects. The idea was that where one would normally store a
+/// `Box<dyn FnOnce()>` in a data structure, you whould use
 /// `Box<dyn FnBox()>`. The two traits behave essentially the same, except
-/// that a `FnBox` closure can only be called if it is boxed. (Note
-/// that `FnBox` may be deprecated in the future if `Box<dyn FnOnce()>`
-/// closures become directly usable.)
+/// that a `FnBox` closure can only be called if it is boxed.
 ///
 /// # Examples
 ///
@@ -777,6 +778,7 @@ impl<A, F: Fn<A> + ?Sized> Fn<A> for Box<F> {
 ///
 /// ```
 /// #![feature(fnbox)]
+/// #![allow(deprecated)]
 ///
 /// use std::boxed::FnBox;
 /// use std::collections::HashMap;
@@ -796,16 +798,38 @@ impl<A, F: Fn<A> + ?Sized> Fn<A> for Box<F> {
 ///     }
 /// }
 /// ```
+///
+/// In Rust 1.35.0 or later, use `FnOnce`, `FnMut`, or `Fn` instead:
+///
+/// ```
+/// use std::collections::HashMap;
+///
+/// fn make_map() -> HashMap<i32, Box<dyn FnOnce() -> i32>> {
+///     let mut map: HashMap<i32, Box<dyn FnOnce() -> i32>> = HashMap::new();
+///     map.insert(1, Box::new(|| 22));
+///     map.insert(2, Box::new(|| 44));
+///     map
+/// }
+///
+/// fn main() {
+///     let mut map = make_map();
+///     for i in &[1, 2] {
+///         let f = map.remove(&i).unwrap();
+///         assert_eq!(f(), i * 22);
+///     }
+/// }
+/// ```
 #[rustc_paren_sugar]
-#[unstable(feature = "fnbox",
-           reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
+#[unstable(feature = "fnbox", issue = "28796")]
+#[rustc_deprecated(reason = "use `FnOnce`, `FnMut`, or `Fn` instead", since = "1.37.0")]
 pub trait FnBox<A>: FnOnce<A> {
     /// Performs the call operation.
     fn call_box(self: Box<Self>, args: A) -> Self::Output;
 }
 
-#[unstable(feature = "fnbox",
-           reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
+#[unstable(feature = "fnbox", issue = "28796")]
+#[rustc_deprecated(reason = "use `FnOnce`, `FnMut`, or `Fn` instead", since = "1.37.0")]
+#[allow(deprecated, deprecated_in_future)]
 impl<A, F> FnBox<A> for F
     where F: FnOnce<A>
 {
diff --git a/src/test/run-pass/unsized-locals/fnbox-compat.rs b/src/test/run-pass/unsized-locals/fnbox-compat.rs
index 5ec54ada13bb0..74a4dd5d8515b 100644
--- a/src/test/run-pass/unsized-locals/fnbox-compat.rs
+++ b/src/test/run-pass/unsized-locals/fnbox-compat.rs
@@ -1,4 +1,5 @@
 #![feature(fnbox)]
+#![allow(deprecated, deprecated_in_future)]
 
 use std::boxed::FnBox;
 
diff --git a/src/test/ui/confuse-field-and-method/issue-2392.rs b/src/test/ui/confuse-field-and-method/issue-2392.rs
index 41287c2591497..c242b6c2c20a2 100644
--- a/src/test/ui/confuse-field-and-method/issue-2392.rs
+++ b/src/test/ui/confuse-field-and-method/issue-2392.rs
@@ -1,7 +1,3 @@
-#![feature(core, fnbox)]
-
-use std::boxed::FnBox;
-
 struct FuncContainer {
     f1: fn(data: u8),
     f2: extern "C" fn(data: u8),
@@ -18,7 +14,7 @@ struct Obj<F> where F: FnOnce() -> u32 {
 }
 
 struct BoxedObj {
-    boxed_closure: Box<FnBox() -> u32>,
+    boxed_closure: Box<FnOnce() -> u32>,
 }
 
 struct Wrapper<F> where F: FnMut() -> u32 {
@@ -29,8 +25,8 @@ fn func() -> u32 {
     0
 }
 
-fn check_expression() -> Obj<Box<FnBox() -> u32>> {
-    Obj { closure: Box::new(|| 42_u32) as Box<FnBox() -> u32>, not_closure: 42 }
+fn check_expression() -> Obj<Box<FnOnce() -> u32>> {
+    Obj { closure: Box::new(|| 42_u32) as Box<FnOnce() -> u32>, not_closure: 42 }
 }
 
 fn main() {
@@ -48,7 +44,7 @@ fn main() {
     let boxed_fn = BoxedObj { boxed_closure: Box::new(func) };
     boxed_fn.boxed_closure();//~ ERROR no method named `boxed_closure` found
 
-    let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box<FnBox() -> u32> };
+    let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box<FnOnce() -> u32> };
     boxed_closure.boxed_closure();//~ ERROR no method named `boxed_closure` found
 
     // test expression writing in the notes
diff --git a/src/test/ui/confuse-field-and-method/issue-2392.stderr b/src/test/ui/confuse-field-and-method/issue-2392.stderr
index 2107318d87b5b..351cfef1b53ea 100644
--- a/src/test/ui/confuse-field-and-method/issue-2392.stderr
+++ b/src/test/ui/confuse-field-and-method/issue-2392.stderr
@@ -1,5 +1,5 @@
-error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-2392.rs:39:36: 39:41]>` in the current scope
-  --> $DIR/issue-2392.rs:40:15
+error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-2392.rs:35:36: 35:41]>` in the current scope
+  --> $DIR/issue-2392.rs:36:15
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
    | -------------------------------------- method `closure` not found for this
@@ -11,8 +11,8 @@ help: to call the function stored in `closure`, surround the field access with p
 LL |     (o_closure.closure)();
    |     ^                 ^
 
-error[E0599]: no method named `not_closure` found for type `Obj<[closure@$DIR/issue-2392.rs:39:36: 39:41]>` in the current scope
-  --> $DIR/issue-2392.rs:42:15
+error[E0599]: no method named `not_closure` found for type `Obj<[closure@$DIR/issue-2392.rs:35:36: 35:41]>` in the current scope
+  --> $DIR/issue-2392.rs:38:15
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
    | -------------------------------------- method `not_closure` not found for this
@@ -23,7 +23,7 @@ LL |     o_closure.not_closure();
    |               field, not a method
 
 error[E0599]: no method named `closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
-  --> $DIR/issue-2392.rs:46:12
+  --> $DIR/issue-2392.rs:42:12
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
    | -------------------------------------- method `closure` not found for this
@@ -36,7 +36,7 @@ LL |     (o_func.closure)();
    |     ^              ^
 
 error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope
-  --> $DIR/issue-2392.rs:49:14
+  --> $DIR/issue-2392.rs:45:14
    |
 LL | struct BoxedObj {
    | --------------- method `boxed_closure` not found for this
@@ -49,7 +49,7 @@ LL |     (boxed_fn.boxed_closure)();
    |     ^                      ^
 
 error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope
-  --> $DIR/issue-2392.rs:52:19
+  --> $DIR/issue-2392.rs:48:19
    |
 LL | struct BoxedObj {
    | --------------- method `boxed_closure` not found for this
@@ -62,7 +62,7 @@ LL |     (boxed_closure.boxed_closure)();
    |     ^                           ^
 
 error[E0599]: no method named `closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
-  --> $DIR/issue-2392.rs:57:12
+  --> $DIR/issue-2392.rs:53:12
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
    | -------------------------------------- method `closure` not found for this
@@ -75,7 +75,7 @@ LL |     (w.wrap.closure)();
    |     ^              ^
 
 error[E0599]: no method named `not_closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
-  --> $DIR/issue-2392.rs:59:12
+  --> $DIR/issue-2392.rs:55:12
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
    | -------------------------------------- method `not_closure` not found for this
@@ -85,8 +85,8 @@ LL |     w.wrap.not_closure();
    |            |
    |            field, not a method
 
-error[E0599]: no method named `closure` found for type `Obj<std::boxed::Box<(dyn std::boxed::FnBox<(), Output = u32> + 'static)>>` in the current scope
-  --> $DIR/issue-2392.rs:62:24
+error[E0599]: no method named `closure` found for type `Obj<std::boxed::Box<(dyn std::ops::FnOnce() -> u32 + 'static)>>` in the current scope
+  --> $DIR/issue-2392.rs:58:24
    |
 LL | struct Obj<F> where F: FnOnce() -> u32 {
    | -------------------------------------- method `closure` not found for this
@@ -99,7 +99,7 @@ LL |     (check_expression().closure)();
    |     ^                          ^
 
 error[E0599]: no method named `f1` found for type `FuncContainer` in the current scope
-  --> $DIR/issue-2392.rs:68:31
+  --> $DIR/issue-2392.rs:64:31
    |
 LL | struct FuncContainer {
    | -------------------- method `f1` not found for this
@@ -112,7 +112,7 @@ LL |             ((*self.container).f1)(1);
    |             ^                    ^
 
 error[E0599]: no method named `f2` found for type `FuncContainer` in the current scope
-  --> $DIR/issue-2392.rs:69:31
+  --> $DIR/issue-2392.rs:65:31
    |
 LL | struct FuncContainer {
    | -------------------- method `f2` not found for this
@@ -125,7 +125,7 @@ LL |             ((*self.container).f2)(1);
    |             ^                    ^
 
 error[E0599]: no method named `f3` found for type `FuncContainer` in the current scope
-  --> $DIR/issue-2392.rs:70:31
+  --> $DIR/issue-2392.rs:66:31
    |
 LL | struct FuncContainer {
    | -------------------- method `f3` not found for this

From 698e50f98548cfdf36599bb975609c816567f709 Mon Sep 17 00:00:00 2001
From: "Felix S. Klock II" <pnkfelix@pnkfx.org>
Date: Fri, 24 May 2019 13:56:26 +0200
Subject: [PATCH 10/29] Delay ICE in fold_region so feature gate has chance to
 stop compilation cleanly.

---
 src/librustc/ty/subst.rs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs
index 72dfe581ba735..75ba1dd46ca2a 100644
--- a/src/librustc/ty/subst.rs
+++ b/src/librustc/ty/subst.rs
@@ -479,21 +479,22 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> {
         // the specialized routine `ty::replace_late_regions()`.
         match *r {
             ty::ReEarlyBound(data) => {
-                let r = self.substs.get(data.index as usize).map(|k| k.unpack());
-                match r {
+                let rk = self.substs.get(data.index as usize).map(|k| k.unpack());
+                match rk {
                     Some(UnpackedKind::Lifetime(lt)) => {
                         self.shift_region_through_binders(lt)
                     }
                     _ => {
                         let span = self.span.unwrap_or(DUMMY_SP);
-                        span_bug!(
-                            span,
+                        let msg = format!(
                             "Region parameter out of range \
                              when substituting in region {} (root type={:?}) \
                              (index={})",
                             data.name,
                             self.root_ty,
                             data.index);
+                        self.tcx.sess.delay_span_bug(span, &msg);
+                        r
                     }
                 }
             }

From 8e4132a55c625de8ba431a4e9fe72339c777e96a Mon Sep 17 00:00:00 2001
From: "Felix S. Klock II" <pnkfelix@pnkfx.org>
Date: Fri, 24 May 2019 14:01:07 +0200
Subject: [PATCH 11/29] Delay ICE in early_free_scope so feature gate has
 chance to stop compilation cleanly.

---
 src/librustc/middle/region.rs | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs
index fa4e8e3d4769d..3d78b9b6382b7 100644
--- a/src/librustc/middle/region.rs
+++ b/src/librustc/middle/region.rs
@@ -658,12 +658,15 @@ impl<'tcx> ScopeTree {
             // The lifetime was defined on node that doesn't own a body,
             // which in practice can only mean a trait or an impl, that
             // is the parent of a method, and that is enforced below.
-            assert_eq!(Some(param_owner_id), self.root_parent,
-                       "free_scope: {:?} not recognized by the \
-                        region scope tree for {:?} / {:?}",
-                       param_owner,
-                       self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
-                       self.root_body.map(|hir_id| DefId::local(hir_id.owner)));
+            if Some(param_owner_id) != self.root_parent {
+                tcx.sess.delay_span_bug(
+                    DUMMY_SP,
+                    &format!("free_scope: {:?} not recognized by the \
+                              region scope tree for {:?} / {:?}",
+                             param_owner,
+                             self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
+                             self.root_body.map(|hir_id| DefId::local(hir_id.owner))));
+            }
 
             // The trait/impl lifetime is in scope for the method's body.
             self.root_body.unwrap().local_id

From c235ba4d0b7b8ff74b0fe020df6625ec9ce74ceb Mon Sep 17 00:00:00 2001
From: "Felix S. Klock II" <pnkfelix@pnkfx.org>
Date: Fri, 24 May 2019 14:02:05 +0200
Subject: [PATCH 12/29] Regression test for issue #60654.

---
 .../gat-dont-ice-on-absent-feature.rs              | 14 ++++++++++++++
 .../gat-dont-ice-on-absent-feature.stderr          | 12 ++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 src/test/ui/rfc1598-generic-associated-types/gat-dont-ice-on-absent-feature.rs
 create mode 100644 src/test/ui/rfc1598-generic-associated-types/gat-dont-ice-on-absent-feature.stderr

diff --git a/src/test/ui/rfc1598-generic-associated-types/gat-dont-ice-on-absent-feature.rs b/src/test/ui/rfc1598-generic-associated-types/gat-dont-ice-on-absent-feature.rs
new file mode 100644
index 0000000000000..84fbb47301f04
--- /dev/null
+++ b/src/test/ui/rfc1598-generic-associated-types/gat-dont-ice-on-absent-feature.rs
@@ -0,0 +1,14 @@
+// rust-lang/rust#60654: Do not ICE on an attempt to use GATs that is
+// missing the feature gate.
+
+struct Foo;
+
+impl Iterator for Foo {
+    type Item<'b> = &'b Foo; //~ ERROR generic associated types are unstable [E0658]
+
+    fn next(&mut self) -> Option<Self::Item> {
+        None
+    }
+}
+
+fn main() { }
diff --git a/src/test/ui/rfc1598-generic-associated-types/gat-dont-ice-on-absent-feature.stderr b/src/test/ui/rfc1598-generic-associated-types/gat-dont-ice-on-absent-feature.stderr
new file mode 100644
index 0000000000000..27b1d73d0434a
--- /dev/null
+++ b/src/test/ui/rfc1598-generic-associated-types/gat-dont-ice-on-absent-feature.stderr
@@ -0,0 +1,12 @@
+error[E0658]: generic associated types are unstable
+  --> $DIR/gat-dont-ice-on-absent-feature.rs:7:5
+   |
+LL |     type Item<'b> = &'b Foo;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: for more information, see https://github.com/rust-lang/rust/issues/44265
+   = help: add #![feature(generic_associated_types)] to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.

From d01ef7d9185a113fa5e089ce1ce71bb1fb6eac32 Mon Sep 17 00:00:00 2001
From: Ralf Jung <post@ralfj.de>
Date: Fri, 24 May 2019 13:03:28 +0200
Subject: [PATCH 13/29] improve debug-printing of scalars

Before: Immediate(ScalarMaybeUndef(Scalar(Ptr(Pointer { alloc_id: AllocId(3401), offset: Size { raw: 4 }, tag: Tagged(7723) }))))
After: Immediate(Scalar(AllocId(3401).0x4[<7723>]))

Before: Immediate(ScalarMaybeUndef(Scalar(Bits { size: 8, bits: 10 })))
After: Immediate(Scalar(0x000000000000000A))

Before: Immediate(ScalarMaybeUndef(Scalar(Bits { size: 1, bits: 1 })))
After: Immediate(Scalar(0x01))
---
 src/librustc/mir/interpret/pointer.rs | 16 ++++++++++++-
 src/librustc/mir/interpret/value.rs   | 34 +++++++++++++++++++++++++--
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/src/librustc/mir/interpret/pointer.rs b/src/librustc/mir/interpret/pointer.rs
index 59b7891b90fde..356c4cc16c23c 100644
--- a/src/librustc/mir/interpret/pointer.rs
+++ b/src/librustc/mir/interpret/pointer.rs
@@ -1,3 +1,5 @@
+use std::fmt;
+
 use crate::mir;
 use crate::ty::layout::{self, HasDataLayout, Size};
 use rustc_macros::HashStable;
@@ -70,7 +72,7 @@ impl<T: layout::HasDataLayout> PointerArithmetic for T {}
 ///
 /// Pointer is also generic over the `Tag` associated with each pointer,
 /// which is used to do provenance tracking during execution.
-#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd,
+#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd,
          RustcEncodable, RustcDecodable, Hash, HashStable)]
 pub struct Pointer<Tag=(),Id=AllocId> {
     pub alloc_id: Id,
@@ -80,6 +82,18 @@ pub struct Pointer<Tag=(),Id=AllocId> {
 
 static_assert_size!(Pointer, 16);
 
+impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Pointer<Tag, Id> {
+    default fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        write!(f, "{:?}.{:#x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
+    }
+}
+// Specialization for no tag
+impl<Id: fmt::Debug> fmt::Debug for Pointer<(), Id> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        write!(f, "{:?}.{:#x}", self.alloc_id, self.offset.bytes())
+    }
+}
+
 /// Produces a `Pointer` which points to the beginning of the Allocation
 impl From<AllocId> for Pointer {
     #[inline(always)]
diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs
index 551b86390db4c..e3d016ff4e03e 100644
--- a/src/librustc/mir/interpret/value.rs
+++ b/src/librustc/mir/interpret/value.rs
@@ -93,7 +93,7 @@ impl<'tcx> ConstValue<'tcx> {
 /// `memory::Allocation`. It is in many ways like a small chunk of a `Allocation`, up to 8 bytes in
 /// size. Like a range of bytes in an `Allocation`, a `Scalar` can either represent the raw bytes
 /// of a simple value or a pointer into another `Allocation`
-#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd,
+#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd,
          RustcEncodable, RustcDecodable, Hash, HashStable)]
 pub enum Scalar<Tag=(), Id=AllocId> {
     /// The raw bytes of a simple value.
@@ -113,6 +113,27 @@ pub enum Scalar<Tag=(), Id=AllocId> {
 #[cfg(target_arch = "x86_64")]
 static_assert_size!(Scalar, 24);
 
+impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Scalar<Tag, Id> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match self {
+            Scalar::Ptr(ptr) =>
+                write!(f, "{:?}", ptr),
+            &Scalar::Bits { bits, size } => {
+                if size == 0 {
+                    assert_eq!(bits, 0, "ZST value must be 0");
+                    write!(f, "<ZST>")
+                } else {
+                    assert_eq!(truncate(bits, Size::from_bytes(size as u64)), bits,
+                            "Scalar value {:#x} exceeds size of {} bytes", bits, size);
+                    // Format as hex number wide enough to fit any value of the given `size`.
+                    // So e.g. bits=20, size=1 will be "0x14", but with size=4 it'll be "0x00000014".
+                    write!(f, "0x{:>0width$x}", bits, width=(size*2) as usize)
+                }
+            }
+        }
+    }
+}
+
 impl<Tag> fmt::Display for Scalar<Tag> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match self {
@@ -412,7 +433,7 @@ impl<Tag> From<Pointer<Tag>> for Scalar<Tag> {
     }
 }
 
-#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)]
 pub enum ScalarMaybeUndef<Tag=(), Id=AllocId> {
     Scalar(Scalar<Tag, Id>),
     Undef,
@@ -425,6 +446,15 @@ impl<Tag> From<Scalar<Tag>> for ScalarMaybeUndef<Tag> {
     }
 }
 
+impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for ScalarMaybeUndef<Tag, Id> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match self {
+            ScalarMaybeUndef::Undef => write!(f, "Undef"),
+            ScalarMaybeUndef::Scalar(s) => write!(f, "{:?}", s),
+        }
+    }
+}
+
 impl<Tag> fmt::Display for ScalarMaybeUndef<Tag> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match self {

From a90cdcca7eb189901a666cbee194f08719e10b94 Mon Sep 17 00:00:00 2001
From: Ralf Jung <post@ralfj.de>
Date: Fri, 24 May 2019 16:44:52 +0200
Subject: [PATCH 14/29] this is for tidy

---
 src/librustc/mir/interpret/value.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs
index e3d016ff4e03e..6b6f7f7a30740 100644
--- a/src/librustc/mir/interpret/value.rs
+++ b/src/librustc/mir/interpret/value.rs
@@ -126,7 +126,7 @@ impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Scalar<Tag, Id> {
                     assert_eq!(truncate(bits, Size::from_bytes(size as u64)), bits,
                             "Scalar value {:#x} exceeds size of {} bytes", bits, size);
                     // Format as hex number wide enough to fit any value of the given `size`.
-                    // So e.g. bits=20, size=1 will be "0x14", but with size=4 it'll be "0x00000014".
+                    // So bits=20, size=1 will be "0x14", but with size=4 it'll be "0x00000014".
                     write!(f, "0x{:>0width$x}", bits, width=(size*2) as usize)
                 }
             }

From aba152d14cb6071bbfa02283b4b19b1135b193a4 Mon Sep 17 00:00:00 2001
From: Erin <xampprocky@gmail.com>
Date: Fri, 24 May 2019 18:32:22 +0200
Subject: [PATCH 15/29] Updated my mailmap entry

---
 .mailmap | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.mailmap b/.mailmap
index 63a49cd413287..2d5759b539e5d 100644
--- a/.mailmap
+++ b/.mailmap
@@ -6,7 +6,7 @@
 #
 
 Aaron Todd <github@opprobrio.us>
-Aaron Power <theaaronepower@gmail.com>
+Aaron Power <theaaronepower@gmail.com> Erin Power <xampprocky@gmail.com>
 Abhishek Chanda <abhishek.becs@gmail.com> Abhishek Chanda <abhishek@cloudscaling.com>
 Adolfo Ochagavía <aochagavia92@gmail.com>
 Adrien Tétar <adri-from-59@hotmail.fr>

From 24160171e48a277ef71e84e14fbffffe3c81438a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Tue, 21 May 2019 17:47:23 -0700
Subject: [PATCH 16/29] Tweak macro parse errors when reaching EOF during macro
 call parse

- Add detail on origin of current parser when reaching EOF and stop
  saying "found <eof>" and point at the end of macro calls
- Handle empty `cfg_attr` attribute
- Reword empty `derive` attribute error
---
 src/libfmt_macros/lib.rs                      |  4 +-
 src/librustc/traits/on_unimplemented.rs       | 24 ++---
 src/libsyntax/attr/mod.rs                     |  9 +-
 src/libsyntax/config.rs                       | 13 ++-
 src/libsyntax/ext/base.rs                     |  6 +-
 src/libsyntax/ext/derive.rs                   |  7 +-
 src/libsyntax/ext/tt/macro_parser.rs          |  9 +-
 src/libsyntax/ext/tt/macro_rules.rs           |  2 +-
 src/libsyntax/parse/mod.rs                    | 12 ++-
 src/libsyntax/parse/parser.rs                 | 91 ++++++++++++-------
 src/libsyntax_ext/asm.rs                      |  6 +-
 src/libsyntax_ext/deriving/custom.rs          |  2 +-
 src/test/ui/macros/format-parse-errors.stderr | 12 +--
 .../ui/malformed/malformed-derive-entry.rs    | 12 +--
 .../malformed/malformed-derive-entry.stderr   | 12 ++-
 .../ui/malformed/malformed-special-attrs.rs   |  6 +-
 .../malformed/malformed-special-attrs.stderr  | 26 ++++--
 src/test/ui/parser/bad-macro-argument.rs      |  4 +
 src/test/ui/parser/bad-macro-argument.stderr  |  8 ++
 src/test/ui/proc-macro/attr-invalid-exprs.rs  |  2 +-
 .../ui/proc-macro/attr-invalid-exprs.stderr   |  2 +-
 21 files changed, 176 insertions(+), 93 deletions(-)
 create mode 100644 src/test/ui/parser/bad-macro-argument.rs
 create mode 100644 src/test/ui/parser/bad-macro-argument.stderr

diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs
index 6fed83021609d..c84d15b3adb8c 100644
--- a/src/libfmt_macros/lib.rs
+++ b/src/libfmt_macros/lib.rs
@@ -627,7 +627,7 @@ mod tests {
     use super::*;
 
     fn same(fmt: &'static str, p: &[Piece<'static>]) {
-        let parser = Parser::new(fmt, None, vec![], false);
+        let parser = Parser::new(fmt, None, vec![], false, None);
         assert!(parser.collect::<Vec<Piece<'static>>>() == p);
     }
 
@@ -643,7 +643,7 @@ mod tests {
     }
 
     fn musterr(s: &str) {
-        let mut p = Parser::new(s, None, vec![], false);
+        let mut p = Parser::new(s, None, vec![], false, None);
         p.next();
         assert!(!p.errors.is_empty());
     }
diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs
index f9ceeb5bfc01b..1c17ace90c2fb 100644
--- a/src/librustc/traits/on_unimplemented.rs
+++ b/src/librustc/traits/on_unimplemented.rs
@@ -226,12 +226,12 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
         Ok(result)
     }
 
-    fn verify(&self,
-              tcx: TyCtxt<'a, 'gcx, 'tcx>,
-              trait_def_id: DefId,
-              span: Span)
-              -> Result<(), ErrorReported>
-    {
+    fn verify(
+        &self,
+        tcx: TyCtxt<'a, 'gcx, 'tcx>,
+        trait_def_id: DefId,
+        span: Span,
+    ) -> Result<(), ErrorReported> {
         let name = tcx.item_name(trait_def_id);
         let generics = tcx.generics_of(trait_def_id);
         let parser = Parser::new(&self.0, None, vec![], false);
@@ -272,12 +272,12 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
         result
     }
 
-    pub fn format(&self,
-                  tcx: TyCtxt<'a, 'gcx, 'tcx>,
-                  trait_ref: ty::TraitRef<'tcx>,
-                  options: &FxHashMap<String, String>)
-                  -> String
-    {
+    pub fn format(
+        &self,
+        tcx: TyCtxt<'a, 'gcx, 'tcx>,
+        trait_ref: ty::TraitRef<'tcx>,
+        options: &FxHashMap<String, String>,
+    ) -> String {
         let name = tcx.item_name(trait_ref.def_id);
         let trait_str = tcx.def_path_str(trait_ref.def_id);
         let generics = tcx.generics_of(trait_ref.def_id);
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs
index 2f75a8c9db57e..48948e4d0d79c 100644
--- a/src/libsyntax/attr/mod.rs
+++ b/src/libsyntax/attr/mod.rs
@@ -278,7 +278,14 @@ impl Attribute {
     pub fn parse<'a, T, F>(&self, sess: &'a ParseSess, mut f: F) -> PResult<'a, T>
         where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>,
     {
-        let mut parser = Parser::new(sess, self.tokens.clone(), None, false, false);
+        let mut parser = Parser::new(
+            sess,
+            self.tokens.clone(),
+            None,
+            false,
+            false,
+            Some("attribute"),
+        );
         let result = f(&mut parser)?;
         if parser.token != token::Eof {
             parser.unexpected()?;
diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs
index c82936afa3d9f..ca047dc66cb16 100644
--- a/src/libsyntax/config.rs
+++ b/src/libsyntax/config.rs
@@ -94,6 +94,17 @@ impl<'a> StripUnconfigured<'a> {
         if !attr.check_name(sym::cfg_attr) {
             return vec![attr];
         }
+        if attr.tokens.len() == 0 {
+            self.sess.span_diagnostic.struct_span_err(attr.span, "bad `cfg_attr` attribute")
+                .span_label(attr.span, "missing condition and attribute")
+                .note("`cfg_attr` must be of the form: \
+                       `#[cfg_attr(condition, attribute)]`")
+                .note("for more information, visit \
+                       <https://doc.rust-lang.org/reference/conditional-compilation.html\
+                       #the-cfg_attr-attribute>")
+                .emit();
+            return vec![];
+        }
 
         let (cfg_predicate, expanded_attrs) = match attr.parse(self.sess, |parser| {
             parser.expect(&token::OpenDelim(token::Paren))?;
@@ -117,7 +128,7 @@ impl<'a> StripUnconfigured<'a> {
             Ok(result) => result,
             Err(mut e) => {
                 e.emit();
-                return Vec::new();
+                return vec![];
             }
         };
 
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index f1a20d5406574..ef7317e00389a 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -850,7 +850,11 @@ impl<'a> ExtCtxt<'a> {
     }
 
     pub fn new_parser_from_tts(&self, tts: &[tokenstream::TokenTree]) -> parser::Parser<'a> {
-        parse::stream_to_parser(self.parse_sess, tts.iter().cloned().collect())
+        parse::stream_to_parser(
+            self.parse_sess,
+            tts.iter().cloned().collect(),
+            Some("macro arguments"),
+        )
     }
     pub fn source_map(&self) -> &'a SourceMap { self.parse_sess.source_map() }
     pub fn parse_sess(&self) -> &'a parse::ParseSess { self.parse_sess }
diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs
index 6e789c4c7086b..bbdda4932f117 100644
--- a/src/libsyntax/ext/derive.rs
+++ b/src/libsyntax/ext/derive.rs
@@ -17,8 +17,11 @@ pub fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec<ast::Attribute>) ->
             return true;
         }
         if !attr.is_meta_item_list() {
-            cx.span_err(attr.span,
-                        "attribute must be of the form `#[derive(Trait1, Trait2, ...)]`");
+            cx.struct_span_err(attr.span, "bad `derive` attribute")
+                .span_label(attr.span, "missing traits to be derived")
+                .note("`derive` must be of the form: \
+                       `#[derive(Trait1, Trait2, ...)]`")
+                .emit();
             return false;
         }
 
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index fa1f85c0e7b57..02e986c9e75b6 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -658,7 +658,14 @@ pub fn parse(
     recurse_into_modules: bool,
 ) -> NamedParseResult {
     // Create a parser that can be used for the "black box" parts.
-    let mut parser = Parser::new(sess, tts, directory, recurse_into_modules, true);
+    let mut parser = Parser::new(
+        sess,
+        tts,
+        directory,
+        recurse_into_modules,
+        true,
+        Some("macro arguments"),
+    );
 
     // A queue of possible matcher positions. We initialize it with the matcher position in which
     // the "dot" is before the first token of the first token tree in `ms`. `inner_parse_loop` then
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 37c49112dcaac..2debd8f048bc3 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -172,7 +172,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt<'_>,
                     path: Cow::from(cx.current_expansion.module.directory.as_path()),
                     ownership: cx.current_expansion.directory_ownership,
                 };
-                let mut p = Parser::new(cx.parse_sess(), tts, Some(directory), true, false);
+                let mut p = Parser::new(cx.parse_sess(), tts, Some(directory), true, false, None);
                 p.root_module_name = cx.current_expansion.module.mod_path.last()
                     .map(|id| id.as_str().to_string());
 
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 1073fc6f3ab4d..ece6137e881b8 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -236,7 +236,7 @@ fn maybe_source_file_to_parser(
 ) -> Result<Parser<'_>, Vec<Diagnostic>> {
     let end_pos = source_file.end_pos;
     let (stream, unclosed_delims) = maybe_file_to_stream(sess, source_file, None)?;
-    let mut parser = stream_to_parser(sess, stream);
+    let mut parser = stream_to_parser(sess, stream, None);
     parser.unclosed_delims = unclosed_delims;
     if parser.token == token::Eof && parser.span.is_dummy() {
         parser.span = Span::new(end_pos, end_pos, parser.span.ctxt());
@@ -248,7 +248,7 @@ fn maybe_source_file_to_parser(
 // must preserve old name for now, because quote! from the *existing*
 // compiler expands into it
 pub fn new_parser_from_tts(sess: &ParseSess, tts: Vec<TokenTree>) -> Parser<'_> {
-    stream_to_parser(sess, tts.into_iter().collect())
+    stream_to_parser(sess, tts.into_iter().collect(), Some("macro arguments"))
 }
 
 
@@ -328,8 +328,12 @@ pub fn maybe_file_to_stream(
 }
 
 /// Given stream and the `ParseSess`, produces a parser.
-pub fn stream_to_parser(sess: &ParseSess, stream: TokenStream) -> Parser<'_> {
-    Parser::new(sess, stream, None, true, false)
+pub fn stream_to_parser<'a>(
+    sess: &'a ParseSess,
+    stream: TokenStream,
+    is_subparser: Option<&'static str>,
+) -> Parser<'a> {
+    Parser::new(sess, stream, None, true, false, is_subparser)
 }
 
 /// Given stream, the `ParseSess` and the base directory, produces a parser.
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 11c566b65e50a..38aa5091f9898 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -51,7 +51,7 @@ use crate::symbol::{kw, sym, Symbol};
 use errors::{Applicability, DiagnosticBuilder, DiagnosticId, FatalError};
 use rustc_target::spec::abi::{self, Abi};
 use syntax_pos::{
-    Span, MultiSpan, BytePos, FileName,
+    BytePos, DUMMY_SP, FileName, MultiSpan, Span,
     hygiene::CompilerDesugaringKind,
 };
 use log::{debug, trace};
@@ -233,6 +233,8 @@ pub struct Parser<'a> {
     /// error.
     crate unclosed_delims: Vec<UnmatchedBrace>,
     last_unexpected_token_span: Option<Span>,
+    /// If `true`, this `Parser` is not parsing Rust code but rather a macro call.
+    is_subparser: Option<&'static str>,
 }
 
 impl<'a> Drop for Parser<'a> {
@@ -309,7 +311,7 @@ impl TokenCursor {
                 self.frame = frame;
                 continue
             } else {
-                return TokenAndSpan { tok: token::Eof, sp: syntax_pos::DUMMY_SP }
+                return TokenAndSpan { tok: token::Eof, sp: DUMMY_SP }
             };
 
             match self.frame.last_token {
@@ -533,17 +535,19 @@ enum TokenExpectType {
 }
 
 impl<'a> Parser<'a> {
-    pub fn new(sess: &'a ParseSess,
-               tokens: TokenStream,
-               directory: Option<Directory<'a>>,
-               recurse_into_file_modules: bool,
-               desugar_doc_comments: bool)
-               -> Self {
+    pub fn new(
+        sess: &'a ParseSess,
+        tokens: TokenStream,
+        directory: Option<Directory<'a>>,
+        recurse_into_file_modules: bool,
+        desugar_doc_comments: bool,
+        is_subparser: Option<&'static str>,
+    ) -> Self {
         let mut parser = Parser {
             sess,
             token: token::Whitespace,
-            span: syntax_pos::DUMMY_SP,
-            prev_span: syntax_pos::DUMMY_SP,
+            span: DUMMY_SP,
+            prev_span: DUMMY_SP,
             meta_var_span: None,
             prev_token_kind: PrevTokenKind::Other,
             restrictions: Restrictions::empty(),
@@ -568,6 +572,7 @@ impl<'a> Parser<'a> {
             max_angle_bracket_count: 0,
             unclosed_delims: Vec::new(),
             last_unexpected_token_span: None,
+            is_subparser,
         };
 
         let tok = parser.next_tok();
@@ -639,16 +644,28 @@ impl<'a> Parser<'a> {
             } else {
                 let token_str = pprust::token_to_string(t);
                 let this_token_str = self.this_token_descr();
-                let mut err = self.fatal(&format!("expected `{}`, found {}",
-                                                  token_str,
-                                                  this_token_str));
-
-                let sp = if self.token == token::Token::Eof {
-                    // EOF, don't want to point at the following char, but rather the last token
-                    self.prev_span
-                } else {
-                    self.sess.source_map().next_point(self.prev_span)
+                let (prev_sp, sp) = match (&self.token, self.is_subparser) {
+                    // Point at the end of the macro call when reaching end of macro arguments.
+                    (token::Token::Eof, Some(_)) => {
+                        let sp = self.sess.source_map().next_point(self.span);
+                        (sp, sp)
+                    }
+                    // We don't want to point at the following span after DUMMY_SP.
+                    // This happens when the parser finds an empty TokenStream.
+                    _ if self.prev_span == DUMMY_SP => (self.span, self.span),
+                    // EOF, don't want to point at the following char, but rather the last token.
+                    (token::Token::Eof, None) => (self.prev_span, self.span),
+                    _ => (self.sess.source_map().next_point(self.prev_span), self.span),
                 };
+                let msg = format!(
+                    "expected `{}`, found {}",
+                    token_str,
+                    match (&self.token, self.is_subparser) {
+                        (token::Token::Eof, Some(origin)) => format!("end of {}", origin),
+                        _ => this_token_str,
+                    },
+                );
+                let mut err = self.struct_span_err(sp, &msg);
                 let label_exp = format!("expected `{}`", token_str);
                 match self.recover_closing_delimiter(&[t.clone()], err) {
                     Err(e) => err = e,
@@ -657,15 +674,15 @@ impl<'a> Parser<'a> {
                     }
                 }
                 let cm = self.sess.source_map();
-                match (cm.lookup_line(self.span.lo()), cm.lookup_line(sp.lo())) {
+                match (cm.lookup_line(prev_sp.lo()), cm.lookup_line(sp.lo())) {
                     (Ok(ref a), Ok(ref b)) if a.line == b.line => {
                         // When the spans are in the same line, it means that the only content
                         // between them is whitespace, point only at the found token.
-                        err.span_label(self.span, label_exp);
+                        err.span_label(sp, label_exp);
                     }
                     _ => {
-                        err.span_label(sp, label_exp);
-                        err.span_label(self.span, "unexpected token");
+                        err.span_label(prev_sp, label_exp);
+                        err.span_label(sp, "unexpected token");
                     }
                 }
                 Err(err)
@@ -812,7 +829,7 @@ impl<'a> Parser<'a> {
                     //   |                   expected one of 8 possible tokens here
                     err.span_label(self.span, label_exp);
                 }
-                _ if self.prev_span == syntax_pos::DUMMY_SP => {
+                _ if self.prev_span == DUMMY_SP => {
                     // Account for macro context where the previous span might not be
                     // available to avoid incorrect output (#54841).
                     err.span_label(self.span, "unexpected token");
@@ -2041,7 +2058,7 @@ impl<'a> Parser<'a> {
             path = self.parse_path(PathStyle::Type)?;
             path_span = path_lo.to(self.prev_span);
         } else {
-            path = ast::Path { segments: Vec::new(), span: syntax_pos::DUMMY_SP };
+            path = ast::Path { segments: Vec::new(), span: DUMMY_SP };
             path_span = self.span.to(self.span);
         }
 
@@ -2627,16 +2644,24 @@ impl<'a> Parser<'a> {
                         }
                         Err(mut err) => {
                             self.cancel(&mut err);
-                            let msg = format!("expected expression, found {}",
-                                              self.this_token_descr());
-                            let mut err = self.fatal(&msg);
+                            let (span, msg) = match (&self.token, self.is_subparser) {
+                                (&token::Token::Eof, Some(origin)) => {
+                                    let sp = self.sess.source_map().next_point(self.span);
+                                    (sp, format!( "expected expression, found end of {}", origin))
+                                }
+                                _ => (self.span, format!(
+                                    "expected expression, found {}",
+                                    self.this_token_descr(),
+                                )),
+                            };
+                            let mut err = self.struct_span_err(span, &msg);
                             let sp = self.sess.source_map().start_point(self.span);
                             if let Some(sp) = self.sess.ambiguous_block_expr_parse.borrow()
                                 .get(&sp)
                             {
                                 self.sess.expr_parentheses_needed(&mut err, *sp, None);
                             }
-                            err.span_label(self.span, "expected expression");
+                            err.span_label(span, "expected expression");
                             return Err(err);
                         }
                     }
@@ -5592,7 +5617,7 @@ impl<'a> Parser<'a> {
                 where_clause: WhereClause {
                     id: ast::DUMMY_NODE_ID,
                     predicates: Vec::new(),
-                    span: syntax_pos::DUMMY_SP,
+                    span: DUMMY_SP,
                 },
                 span: span_lo.to(self.prev_span),
             })
@@ -5838,7 +5863,7 @@ impl<'a> Parser<'a> {
         let mut where_clause = WhereClause {
             id: ast::DUMMY_NODE_ID,
             predicates: Vec::new(),
-            span: syntax_pos::DUMMY_SP,
+            span: DUMMY_SP,
         };
 
         if !self.eat_keyword(kw::Where) {
@@ -7005,7 +7030,7 @@ impl<'a> Parser<'a> {
                             Ident::with_empty_ctxt(sym::warn_directory_ownership)),
                         tokens: TokenStream::empty(),
                         is_sugared_doc: false,
-                        span: syntax_pos::DUMMY_SP,
+                        span: DUMMY_SP,
                     };
                     attr::mark_known(&attr);
                     attrs.push(attr);
@@ -7013,7 +7038,7 @@ impl<'a> Parser<'a> {
                 Ok((id, ItemKind::Mod(module), Some(attrs)))
             } else {
                 let placeholder = ast::Mod {
-                    inner: syntax_pos::DUMMY_SP,
+                    inner: DUMMY_SP,
                     items: Vec::new(),
                     inline: false
                 };
diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs
index b8e89c3ecf876..704665e0a84d6 100644
--- a/src/libsyntax_ext/asm.rs
+++ b/src/libsyntax_ext/asm.rs
@@ -138,7 +138,11 @@ fn parse_inline_asm<'a>(
                 if p2.token != token::Eof {
                     let mut extra_tts = p2.parse_all_token_trees()?;
                     extra_tts.extend(tts[first_colon..].iter().cloned());
-                    p = parse::stream_to_parser(cx.parse_sess, extra_tts.into_iter().collect());
+                    p = parse::stream_to_parser(
+                        cx.parse_sess,
+                        extra_tts.into_iter().collect(),
+                        Some("inline assembly"),
+                    );
                 }
 
                 asm = s;
diff --git a/src/libsyntax_ext/deriving/custom.rs b/src/libsyntax_ext/deriving/custom.rs
index e73110717e979..975d96951dc55 100644
--- a/src/libsyntax_ext/deriving/custom.rs
+++ b/src/libsyntax_ext/deriving/custom.rs
@@ -89,7 +89,7 @@ impl MultiItemModifier for ProcMacroDerive {
         let error_count_before = ecx.parse_sess.span_diagnostic.err_count();
         let msg = "proc-macro derive produced unparseable tokens";
 
-        let mut parser = parse::stream_to_parser(ecx.parse_sess, stream);
+        let mut parser = parse::stream_to_parser(ecx.parse_sess, stream, Some("proc-macro derive"));
         let mut items = vec![];
 
         loop {
diff --git a/src/test/ui/macros/format-parse-errors.stderr b/src/test/ui/macros/format-parse-errors.stderr
index b634cf2d9944c..fd4f93091944c 100644
--- a/src/test/ui/macros/format-parse-errors.stderr
+++ b/src/test/ui/macros/format-parse-errors.stderr
@@ -12,17 +12,17 @@ error: expected expression, found keyword `struct`
 LL |     format!(struct);
    |             ^^^^^^ expected expression
 
-error: expected expression, found `<eof>`
-  --> $DIR/format-parse-errors.rs:4:23
+error: expected expression, found end of macro arguments
+  --> $DIR/format-parse-errors.rs:4:24
    |
 LL |     format!("s", name =);
-   |                       ^ expected expression
+   |                        ^ expected expression
 
-error: expected `=`, found `<eof>`
-  --> $DIR/format-parse-errors.rs:5:29
+error: expected `=`, found end of macro arguments
+  --> $DIR/format-parse-errors.rs:5:32
    |
 LL |     format!("s", foo = foo, bar);
-   |                             ^^^ expected `=`
+   |                                ^ expected `=`
 
 error: expected expression, found keyword `struct`
   --> $DIR/format-parse-errors.rs:6:24
diff --git a/src/test/ui/malformed/malformed-derive-entry.rs b/src/test/ui/malformed/malformed-derive-entry.rs
index 74d22102c664d..1a87cd2d11cb5 100644
--- a/src/test/ui/malformed/malformed-derive-entry.rs
+++ b/src/test/ui/malformed/malformed-derive-entry.rs
@@ -1,17 +1,13 @@
-#[derive(Copy(Bad))]
-//~^ ERROR expected one of `)`, `,`, or `::`, found `(`
+#[derive(Copy(Bad))] //~ ERROR expected one of `)`, `,`, or `::`, found `(`
 struct Test1;
 
-#[derive(Copy="bad")]
-//~^ ERROR expected one of `)`, `,`, or `::`, found `=`
+#[derive(Copy="bad")] //~ ERROR expected one of `)`, `,`, or `::`, found `=`
 struct Test2;
 
-#[derive()]
-//~^ WARNING empty trait list
+#[derive()] //~ WARNING empty trait list
 struct Test3;
 
-#[derive]
-//~^ ERROR attribute must be of the form
+#[derive] //~ ERROR bad `derive` attribute
 struct Test4;
 
 fn main() {}
diff --git a/src/test/ui/malformed/malformed-derive-entry.stderr b/src/test/ui/malformed/malformed-derive-entry.stderr
index f546f74220a1c..aa1334d21a86a 100644
--- a/src/test/ui/malformed/malformed-derive-entry.stderr
+++ b/src/test/ui/malformed/malformed-derive-entry.stderr
@@ -5,22 +5,24 @@ LL | #[derive(Copy(Bad))]
    |              ^ expected one of `)`, `,`, or `::` here
 
 error: expected one of `)`, `,`, or `::`, found `=`
-  --> $DIR/malformed-derive-entry.rs:5:14
+  --> $DIR/malformed-derive-entry.rs:4:14
    |
 LL | #[derive(Copy="bad")]
    |              ^ expected one of `)`, `,`, or `::` here
 
 warning: empty trait list in `derive`
-  --> $DIR/malformed-derive-entry.rs:9:1
+  --> $DIR/malformed-derive-entry.rs:7:1
    |
 LL | #[derive()]
    | ^^^^^^^^^^^
 
-error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
-  --> $DIR/malformed-derive-entry.rs:13:1
+error: bad `derive` attribute
+  --> $DIR/malformed-derive-entry.rs:10:1
    |
 LL | #[derive]
-   | ^^^^^^^^^
+   | ^^^^^^^^^ missing traits to be derived
+   |
+   = note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]`
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/malformed/malformed-special-attrs.rs b/src/test/ui/malformed/malformed-special-attrs.rs
index f91c6bedb2b21..5f1c4795a89b0 100644
--- a/src/test/ui/malformed/malformed-special-attrs.rs
+++ b/src/test/ui/malformed/malformed-special-attrs.rs
@@ -1,13 +1,13 @@
-#[cfg_attr] //~ ERROR expected `(`, found `<eof>`
+#[cfg_attr] //~ ERROR bad `cfg_attr` attribute
 struct S1;
 
 #[cfg_attr = ""] //~ ERROR expected `(`, found `=`
 struct S2;
 
-#[derive] //~ ERROR attribute must be of the form
+#[derive] //~ ERROR bad `derive` attribute
 struct S3;
 
-#[derive = ""] //~ ERROR attribute must be of the form
+#[derive = ""] //~ ERROR bad `derive` attribute
 struct S4;
 
 fn main() {}
diff --git a/src/test/ui/malformed/malformed-special-attrs.stderr b/src/test/ui/malformed/malformed-special-attrs.stderr
index 8c23424087c04..483ecf7338734 100644
--- a/src/test/ui/malformed/malformed-special-attrs.stderr
+++ b/src/test/ui/malformed/malformed-special-attrs.stderr
@@ -1,25 +1,33 @@
-error: expected `(`, found `<eof>`
+error: bad `cfg_attr` attribute
+  --> $DIR/malformed-special-attrs.rs:1:1
+   |
+LL | #[cfg_attr]
+   | ^^^^^^^^^^^ missing condition and attribute
+   |
+   = note: `cfg_attr` must be of the form: `#[cfg_attr(condition, attribute)]`
+   = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
 
 error: expected `(`, found `=`
   --> $DIR/malformed-special-attrs.rs:4:12
    |
-LL | #[cfg_attr]
-   | - expected `(`
-...
 LL | #[cfg_attr = ""]
-   |            ^ unexpected token
+   |            ^ expected `(`
 
-error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
+error: bad `derive` attribute
   --> $DIR/malformed-special-attrs.rs:7:1
    |
 LL | #[derive]
-   | ^^^^^^^^^
+   | ^^^^^^^^^ missing traits to be derived
+   |
+   = note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]`
 
-error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
+error: bad `derive` attribute
   --> $DIR/malformed-special-attrs.rs:10:1
    |
 LL | #[derive = ""]
-   | ^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^ missing traits to be derived
+   |
+   = note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]`
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/parser/bad-macro-argument.rs b/src/test/ui/parser/bad-macro-argument.rs
new file mode 100644
index 0000000000000..4b6d23890653d
--- /dev/null
+++ b/src/test/ui/parser/bad-macro-argument.rs
@@ -0,0 +1,4 @@
+fn main() {
+    let message = "world";
+    println!("Hello, {}", message/); //~ ERROR expected expression
+}
diff --git a/src/test/ui/parser/bad-macro-argument.stderr b/src/test/ui/parser/bad-macro-argument.stderr
new file mode 100644
index 0000000000000..3cd8accb66294
--- /dev/null
+++ b/src/test/ui/parser/bad-macro-argument.stderr
@@ -0,0 +1,8 @@
+error: expected expression, found end of macro arguments
+  --> $DIR/bad-macro-argument.rs:3:35
+   |
+LL |     println!("Hello, {}", message/);
+   |                                   ^ expected expression
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/proc-macro/attr-invalid-exprs.rs b/src/test/ui/proc-macro/attr-invalid-exprs.rs
index c609cae90240c..fab98f0ce5ebe 100644
--- a/src/test/ui/proc-macro/attr-invalid-exprs.rs
+++ b/src/test/ui/proc-macro/attr-invalid-exprs.rs
@@ -9,7 +9,7 @@ use attr_stmt_expr::{duplicate, no_output};
 
 fn main() {
     let _ = #[no_output] "Hello, world!";
-    //~^ ERROR expected expression, found `<eof>`
+    //~^ ERROR expected expression, found end of macro arguments
 
     let _ = #[duplicate] "Hello, world!";
     //~^ ERROR macro expansion ignores token `,` and any following
diff --git a/src/test/ui/proc-macro/attr-invalid-exprs.stderr b/src/test/ui/proc-macro/attr-invalid-exprs.stderr
index 5d2fb59ff1f66..49fe0bd0fcfe2 100644
--- a/src/test/ui/proc-macro/attr-invalid-exprs.stderr
+++ b/src/test/ui/proc-macro/attr-invalid-exprs.stderr
@@ -1,4 +1,4 @@
-error: expected expression, found `<eof>`
+error: expected expression, found end of macro arguments
   --> $DIR/attr-invalid-exprs.rs:11:13
    |
 LL |     let _ = #[no_output] "Hello, world!";

From 5c5fa775e568bc42f876aa7efcb386b404906df4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Tue, 21 May 2019 22:17:53 -0700
Subject: [PATCH 17/29] review comments

---
 src/libfmt_macros/lib.rs                      |  4 +-
 src/libsyntax/config.rs                       |  2 +-
 src/libsyntax/ext/base.rs                     |  8 +--
 src/libsyntax/ext/tt/macro_parser.rs          |  2 +-
 src/libsyntax/lib.rs                          |  2 +
 src/libsyntax/parse/diagnostics.rs            | 56 +++++++++++++++++-
 src/libsyntax/parse/mod.rs                    |  6 +-
 src/libsyntax/parse/parser.rs                 | 57 +++----------------
 .../malformed/malformed-special-attrs.stderr  |  2 +-
 .../parser/{ => macro}/bad-macro-argument.rs  |  0
 .../{ => macro}/bad-macro-argument.stderr     |  0
 11 files changed, 73 insertions(+), 66 deletions(-)
 rename src/test/ui/parser/{ => macro}/bad-macro-argument.rs (100%)
 rename src/test/ui/parser/{ => macro}/bad-macro-argument.stderr (100%)

diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs
index c84d15b3adb8c..6fed83021609d 100644
--- a/src/libfmt_macros/lib.rs
+++ b/src/libfmt_macros/lib.rs
@@ -627,7 +627,7 @@ mod tests {
     use super::*;
 
     fn same(fmt: &'static str, p: &[Piece<'static>]) {
-        let parser = Parser::new(fmt, None, vec![], false, None);
+        let parser = Parser::new(fmt, None, vec![], false);
         assert!(parser.collect::<Vec<Piece<'static>>>() == p);
     }
 
@@ -643,7 +643,7 @@ mod tests {
     }
 
     fn musterr(s: &str) {
-        let mut p = Parser::new(s, None, vec![], false, None);
+        let mut p = Parser::new(s, None, vec![], false);
         p.next();
         assert!(!p.errors.is_empty());
     }
diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs
index ca047dc66cb16..5ccec05dda20b 100644
--- a/src/libsyntax/config.rs
+++ b/src/libsyntax/config.rs
@@ -98,7 +98,7 @@ impl<'a> StripUnconfigured<'a> {
             self.sess.span_diagnostic.struct_span_err(attr.span, "bad `cfg_attr` attribute")
                 .span_label(attr.span, "missing condition and attribute")
                 .note("`cfg_attr` must be of the form: \
-                       `#[cfg_attr(condition, attribute)]`")
+                       `#[cfg_attr(condition, attribute, other_attribute, ...)]`")
                 .note("for more information, visit \
                        <https://doc.rust-lang.org/reference/conditional-compilation.html\
                        #the-cfg_attr-attribute>")
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index ef7317e00389a..dbec379e76995 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -11,7 +11,7 @@ use crate::parse::{self, parser, DirectoryOwnership};
 use crate::parse::token;
 use crate::ptr::P;
 use crate::symbol::{kw, sym, Ident, Symbol};
-use crate::ThinVec;
+use crate::{ThinVec, MACRO_ARGUMENTS};
 use crate::tokenstream::{self, TokenStream};
 
 use errors::{DiagnosticBuilder, DiagnosticId};
@@ -850,11 +850,7 @@ impl<'a> ExtCtxt<'a> {
     }
 
     pub fn new_parser_from_tts(&self, tts: &[tokenstream::TokenTree]) -> parser::Parser<'a> {
-        parse::stream_to_parser(
-            self.parse_sess,
-            tts.iter().cloned().collect(),
-            Some("macro arguments"),
-        )
+        parse::stream_to_parser(self.parse_sess, tts.iter().cloned().collect(), MACRO_ARGUMENTS)
     }
     pub fn source_map(&self) -> &'a SourceMap { self.parse_sess.source_map() }
     pub fn parse_sess(&self) -> &'a parse::ParseSess { self.parse_sess }
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 02e986c9e75b6..e55226b8579bd 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -664,7 +664,7 @@ pub fn parse(
         directory,
         recurse_into_modules,
         true,
-        Some("macro arguments"),
+        crate::MACRO_ARGUMENTS,
     );
 
     // A queue of possible matcher positions. We initialize it with the matcher position in which
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index 5eda975bc9ee4..4229121b3d075 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -31,6 +31,8 @@ pub use rustc_data_structures::thin_vec::ThinVec;
 use ast::AttrId;
 use syntax_pos::edition::Edition;
 
+const MACRO_ARGUMENTS: Option<&'static str> = Some("macro arguments");
+
 // A variant of 'try!' that panics on an Err. This is used as a crutch on the
 // way towards a non-panic!-prone parser. It should be used for fatal parsing
 // errors; eventually we plan to convert all code using panictry to just use
diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs
index 8ac5beb21b530..8174367ca4531 100644
--- a/src/libsyntax/parse/diagnostics.rs
+++ b/src/libsyntax/parse/diagnostics.rs
@@ -13,7 +13,7 @@ use crate::symbol::kw;
 use crate::ThinVec;
 use errors::{Applicability, DiagnosticBuilder};
 use log::debug;
-use syntax_pos::Span;
+use syntax_pos::{Span, DUMMY_SP};
 
 pub trait RecoverQPath: Sized + 'static {
     const PATH_STYLE: PathStyle = PathStyle::Expr;
@@ -201,7 +201,7 @@ impl<'a> Parser<'a> {
 
         let mut path = ast::Path {
             segments: Vec::new(),
-            span: syntax_pos::DUMMY_SP,
+            span: DUMMY_SP,
         };
         self.parse_path_segments(&mut path.segments, T::PATH_STYLE)?;
         path.span = ty_span.to(self.prev_span);
@@ -267,6 +267,58 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Create a `DiagnosticBuilder` for an unexpected token `t` and try to recover if it is a
+    /// closing delimiter.
+    pub fn unexpected_try_recover(
+        &mut self,
+        t: &token::Token,
+    ) -> PResult<'a, bool /* recovered */> {
+        let token_str = pprust::token_to_string(t);
+        let this_token_str = self.this_token_descr();
+        let (prev_sp, sp) = match (&self.token, self.subparser_name) {
+            // Point at the end of the macro call when reaching end of macro arguments.
+            (token::Token::Eof, Some(_)) => {
+                let sp = self.sess.source_map().next_point(self.span);
+                (sp, sp)
+            }
+            // We don't want to point at the following span after DUMMY_SP.
+            // This happens when the parser finds an empty TokenStream.
+            _ if self.prev_span == DUMMY_SP => (self.span, self.span),
+            // EOF, don't want to point at the following char, but rather the last token.
+            (token::Token::Eof, None) => (self.prev_span, self.span),
+            _ => (self.sess.source_map().next_point(self.prev_span), self.span),
+        };
+        let msg = format!(
+            "expected `{}`, found {}",
+            token_str,
+            match (&self.token, self.subparser_name) {
+                (token::Token::Eof, Some(origin)) => format!("end of {}", origin),
+                _ => this_token_str,
+            },
+        );
+        let mut err = self.struct_span_err(sp, &msg);
+        let label_exp = format!("expected `{}`", token_str);
+        match self.recover_closing_delimiter(&[t.clone()], err) {
+            Err(e) => err = e,
+            Ok(recovered) => {
+                return Ok(recovered);
+            }
+        }
+        let cm = self.sess.source_map();
+        match (cm.lookup_line(prev_sp.lo()), cm.lookup_line(sp.lo())) {
+            (Ok(ref a), Ok(ref b)) if a.line == b.line => {
+                // When the spans are in the same line, it means that the only content
+                // between them is whitespace, point only at the found token.
+                err.span_label(sp, label_exp);
+            }
+            _ => {
+                err.span_label(prev_sp, label_exp);
+                err.span_label(sp, "unexpected token");
+            }
+        }
+        Err(err)
+    }
+
     /// Consume alternative await syntaxes like `await <expr>`, `await? <expr>`, `await(<expr>)`
     /// and `await { <expr> }`.
     crate fn parse_incorrect_await_syntax(
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index ece6137e881b8..fc76987c17530 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -248,7 +248,7 @@ fn maybe_source_file_to_parser(
 // must preserve old name for now, because quote! from the *existing*
 // compiler expands into it
 pub fn new_parser_from_tts(sess: &ParseSess, tts: Vec<TokenTree>) -> Parser<'_> {
-    stream_to_parser(sess, tts.into_iter().collect(), Some("macro arguments"))
+    stream_to_parser(sess, tts.into_iter().collect(), crate::MACRO_ARGUMENTS)
 }
 
 
@@ -331,9 +331,9 @@ pub fn maybe_file_to_stream(
 pub fn stream_to_parser<'a>(
     sess: &'a ParseSess,
     stream: TokenStream,
-    is_subparser: Option<&'static str>,
+    subparser_name: Option<&'static str>,
 ) -> Parser<'a> {
-    Parser::new(sess, stream, None, true, false, is_subparser)
+    Parser::new(sess, stream, None, true, false, subparser_name)
 }
 
 /// Given stream, the `ParseSess` and the base directory, produces a parser.
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 38aa5091f9898..77b41aaa117f7 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -233,8 +233,8 @@ pub struct Parser<'a> {
     /// error.
     crate unclosed_delims: Vec<UnmatchedBrace>,
     last_unexpected_token_span: Option<Span>,
-    /// If `true`, this `Parser` is not parsing Rust code but rather a macro call.
-    is_subparser: Option<&'static str>,
+    /// If present, this `Parser` is not parsing Rust code but rather a macro call.
+    crate subparser_name: Option<&'static str>,
 }
 
 impl<'a> Drop for Parser<'a> {
@@ -541,7 +541,7 @@ impl<'a> Parser<'a> {
         directory: Option<Directory<'a>>,
         recurse_into_file_modules: bool,
         desugar_doc_comments: bool,
-        is_subparser: Option<&'static str>,
+        subparser_name: Option<&'static str>,
     ) -> Self {
         let mut parser = Parser {
             sess,
@@ -572,7 +572,7 @@ impl<'a> Parser<'a> {
             max_angle_bracket_count: 0,
             unclosed_delims: Vec::new(),
             last_unexpected_token_span: None,
-            is_subparser,
+            subparser_name,
         };
 
         let tok = parser.next_tok();
@@ -636,56 +636,13 @@ impl<'a> Parser<'a> {
     }
 
     /// Expects and consumes the token `t`. Signals an error if the next token is not `t`.
-    pub fn expect(&mut self, t: &token::Token) -> PResult<'a,  bool /* recovered */> {
+    pub fn expect(&mut self, t: &token::Token) -> PResult<'a, bool /* recovered */> {
         if self.expected_tokens.is_empty() {
             if self.token == *t {
                 self.bump();
                 Ok(false)
             } else {
-                let token_str = pprust::token_to_string(t);
-                let this_token_str = self.this_token_descr();
-                let (prev_sp, sp) = match (&self.token, self.is_subparser) {
-                    // Point at the end of the macro call when reaching end of macro arguments.
-                    (token::Token::Eof, Some(_)) => {
-                        let sp = self.sess.source_map().next_point(self.span);
-                        (sp, sp)
-                    }
-                    // We don't want to point at the following span after DUMMY_SP.
-                    // This happens when the parser finds an empty TokenStream.
-                    _ if self.prev_span == DUMMY_SP => (self.span, self.span),
-                    // EOF, don't want to point at the following char, but rather the last token.
-                    (token::Token::Eof, None) => (self.prev_span, self.span),
-                    _ => (self.sess.source_map().next_point(self.prev_span), self.span),
-                };
-                let msg = format!(
-                    "expected `{}`, found {}",
-                    token_str,
-                    match (&self.token, self.is_subparser) {
-                        (token::Token::Eof, Some(origin)) => format!("end of {}", origin),
-                        _ => this_token_str,
-                    },
-                );
-                let mut err = self.struct_span_err(sp, &msg);
-                let label_exp = format!("expected `{}`", token_str);
-                match self.recover_closing_delimiter(&[t.clone()], err) {
-                    Err(e) => err = e,
-                    Ok(recovered) => {
-                        return Ok(recovered);
-                    }
-                }
-                let cm = self.sess.source_map();
-                match (cm.lookup_line(prev_sp.lo()), cm.lookup_line(sp.lo())) {
-                    (Ok(ref a), Ok(ref b)) if a.line == b.line => {
-                        // When the spans are in the same line, it means that the only content
-                        // between them is whitespace, point only at the found token.
-                        err.span_label(sp, label_exp);
-                    }
-                    _ => {
-                        err.span_label(prev_sp, label_exp);
-                        err.span_label(sp, "unexpected token");
-                    }
-                }
-                Err(err)
+                self.unexpected_try_recover(t)
             }
         } else {
             self.expect_one_of(slice::from_ref(t), &[])
@@ -2644,7 +2601,7 @@ impl<'a> Parser<'a> {
                         }
                         Err(mut err) => {
                             self.cancel(&mut err);
-                            let (span, msg) = match (&self.token, self.is_subparser) {
+                            let (span, msg) = match (&self.token, self.subparser_name) {
                                 (&token::Token::Eof, Some(origin)) => {
                                     let sp = self.sess.source_map().next_point(self.span);
                                     (sp, format!( "expected expression, found end of {}", origin))
diff --git a/src/test/ui/malformed/malformed-special-attrs.stderr b/src/test/ui/malformed/malformed-special-attrs.stderr
index 483ecf7338734..ad8015bf385a5 100644
--- a/src/test/ui/malformed/malformed-special-attrs.stderr
+++ b/src/test/ui/malformed/malformed-special-attrs.stderr
@@ -4,7 +4,7 @@ error: bad `cfg_attr` attribute
 LL | #[cfg_attr]
    | ^^^^^^^^^^^ missing condition and attribute
    |
-   = note: `cfg_attr` must be of the form: `#[cfg_attr(condition, attribute)]`
+   = note: `cfg_attr` must be of the form: `#[cfg_attr(condition, attribute, other_attribute, ...)]`
    = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
 
 error: expected `(`, found `=`
diff --git a/src/test/ui/parser/bad-macro-argument.rs b/src/test/ui/parser/macro/bad-macro-argument.rs
similarity index 100%
rename from src/test/ui/parser/bad-macro-argument.rs
rename to src/test/ui/parser/macro/bad-macro-argument.rs
diff --git a/src/test/ui/parser/bad-macro-argument.stderr b/src/test/ui/parser/macro/bad-macro-argument.stderr
similarity index 100%
rename from src/test/ui/parser/bad-macro-argument.stderr
rename to src/test/ui/parser/macro/bad-macro-argument.stderr

From a2f853a69108faab4d45a55cc4f6633a4a517c73 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Tue, 21 May 2019 23:13:31 -0700
Subject: [PATCH 18/29] Fix rebase

---
 src/libsyntax/parse/mod.rs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index fc76987c17530..f7a7aba9ecbaa 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -347,10 +347,12 @@ pub fn stream_to_parser<'a>(
 /// The main usage of this function is outside of rustc, for those who uses
 /// libsyntax as a library. Please do not remove this function while refactoring
 /// just because it is not used in rustc codebase!
-pub fn stream_to_parser_with_base_dir<'a>(sess: &'a ParseSess,
-                                          stream: TokenStream,
-                                          base_dir: Directory<'a>) -> Parser<'a> {
-    Parser::new(sess, stream, Some(base_dir), true, false)
+pub fn stream_to_parser_with_base_dir<'a>(
+    sess: &'a ParseSess,
+    stream: TokenStream,
+    base_dir: Directory<'a>,
+) -> Parser<'a> {
+    Parser::new(sess, stream, Some(base_dir), true, false, None)
 }
 
 /// A sequence separator.

From da57ac38a669573ab693546775eb3ee5dc5b3fc4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Tue, 21 May 2019 23:16:46 -0700
Subject: [PATCH 19/29] Move diagnostic logic out of parser

---
 src/libsyntax/parse/diagnostics.rs | 19 +++++++++++++++++++
 src/libsyntax/parse/parser.rs      | 20 +-------------------
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs
index 8174367ca4531..e93c0bdb8336a 100644
--- a/src/libsyntax/parse/diagnostics.rs
+++ b/src/libsyntax/parse/diagnostics.rs
@@ -614,4 +614,23 @@ impl<'a> Parser<'a> {
         }
     }
 
+    crate fn expected_expression_found(&self) -> DiagnosticBuilder<'a> {
+        let (span, msg) = match (&self.token, self.subparser_name) {
+            (&token::Token::Eof, Some(origin)) => {
+                let sp = self.sess.source_map().next_point(self.span);
+                (sp, format!( "expected expression, found end of {}", origin))
+            }
+            _ => (self.span, format!(
+                "expected expression, found {}",
+                self.this_token_descr(),
+            )),
+        };
+        let mut err = self.struct_span_err(span, &msg);
+        let sp = self.sess.source_map().start_point(self.span);
+        if let Some(sp) = self.sess.ambiguous_block_expr_parse.borrow().get(&sp) {
+            self.sess.expr_parentheses_needed(&mut err, *sp, None);
+        }
+        err.span_label(span, "expected expression");
+        err
+    }
 }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 77b41aaa117f7..56951ae08012a 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2601,25 +2601,7 @@ impl<'a> Parser<'a> {
                         }
                         Err(mut err) => {
                             self.cancel(&mut err);
-                            let (span, msg) = match (&self.token, self.subparser_name) {
-                                (&token::Token::Eof, Some(origin)) => {
-                                    let sp = self.sess.source_map().next_point(self.span);
-                                    (sp, format!( "expected expression, found end of {}", origin))
-                                }
-                                _ => (self.span, format!(
-                                    "expected expression, found {}",
-                                    self.this_token_descr(),
-                                )),
-                            };
-                            let mut err = self.struct_span_err(span, &msg);
-                            let sp = self.sess.source_map().start_point(self.span);
-                            if let Some(sp) = self.sess.ambiguous_block_expr_parse.borrow()
-                                .get(&sp)
-                            {
-                                self.sess.expr_parentheses_needed(&mut err, *sp, None);
-                            }
-                            err.span_label(span, "expected expression");
-                            return Err(err);
+                            return Err(self.expected_expression_found());
                         }
                     }
                 }

From 035f651df77056d7d698e5ed47eb4b85d775fafa Mon Sep 17 00:00:00 2001
From: Nikolai Vazquez <nikvzqz@gmail.com>
Date: Fri, 24 May 2019 22:26:34 +0200
Subject: [PATCH 20/29] Annotate each `reverse_bits` with `#[must_use]`

Because the name sounds like an in-place mutation like
`[T]::reverse(&mut self)`, it may be confused for one.
---
 src/libcore/num/mod.rs      | 2 ++
 src/libcore/num/wrapping.rs | 1 +
 2 files changed, 3 insertions(+)

diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 562a7a4b3c719..0d776c9842d14 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -472,6 +472,7 @@ assert_eq!(m, ", $reversed, ");
             #[unstable(feature = "reverse_bits", issue = "48763")]
             #[rustc_const_unstable(feature = "const_int_conversion")]
             #[inline]
+            #[must_use]
             pub const fn reverse_bits(self) -> Self {
                 (self as $UnsignedT).reverse_bits() as Self
             }
@@ -2521,6 +2522,7 @@ assert_eq!(m, ", $reversed, ");
 ```"),
             #[unstable(feature = "reverse_bits", issue = "48763")]
             #[inline]
+            #[must_use]
             pub const fn reverse_bits(self) -> Self {
                 intrinsics::bitreverse(self as $ActualT) as Self
             }
diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs
index a3491bc3dc664..5eb5ec558f8c1 100644
--- a/src/libcore/num/wrapping.rs
+++ b/src/libcore/num/wrapping.rs
@@ -524,6 +524,7 @@ assert_eq!(n.trailing_zeros(), 3);
             /// ```
             #[unstable(feature = "reverse_bits", issue = "48763")]
             #[inline]
+            #[must_use]
             pub const fn reverse_bits(self) -> Self {
                 Wrapping(self.0.reverse_bits())
             }

From 59762baf8a1ee14e9398e2f3759afd7c0cf4fdea Mon Sep 17 00:00:00 2001
From: varkor <github@varkor.com>
Date: Fri, 24 May 2019 21:49:34 +0100
Subject: [PATCH 21/29] Move async/await tests to test/ui/async-await

---
 src/test/{run-pass => ui/async-await}/async-await.rs   |  2 ++
 .../{ => async-await}/async-fn-multiple-lifetimes.rs   |  0
 .../async-fn-multiple-lifetimes.stderr                 |  0
 src/test/ui/{ => async-await}/async-fn-path-elision.rs |  0
 .../ui/{ => async-await}/async-fn-path-elision.stderr  |  0
 src/test/ui/{ => async-await}/async-matches-expr.rs    |  0
 src/test/ui/{ => async-await}/async-with-closure.rs    |  0
 .../2015-edition-error-in-non-macro-position.rs        |  0
 .../2015-edition-error-in-non-macro-position.stderr    |  0
 .../await-keyword/2015-edition-warning.fixed           |  0
 .../await-keyword/2015-edition-warning.rs              |  0
 .../await-keyword/2015-edition-warning.stderr          |  0
 .../2018-edition-error-in-non-macro-position.rs        |  0
 .../2018-edition-error-in-non-macro-position.stderr    |  0
 .../await-keyword/2018-edition-error.rs                |  0
 .../await-keyword/2018-edition-error.stderr            |  0
 .../await-keyword/incorrect-syntax-suggestions.rs      |  0
 .../await-keyword/incorrect-syntax-suggestions.stderr  |  0
 .../await-keyword/post_expansion_error.rs              |  0
 .../await-keyword/post_expansion_error.stderr          |  0
 src/test/{run-pass => ui/async-await}/await-macro.rs   |  2 ++
 .../{nll => async-await}/dont-print-desugared-async.rs |  0
 .../dont-print-desugared-async.stderr                  |  0
 .../edition-deny-async-fns-2015.rs                     |  0
 .../edition-deny-async-fns-2015.stderr                 |  0
 src/test/ui/{issues => async-await}/issue-51719.rs     |  0
 src/test/ui/{issues => async-await}/issue-51719.stderr |  0
 src/test/ui/{issues => async-await}/issue-51751.rs     |  0
 src/test/ui/{issues => async-await}/issue-51751.stderr |  0
 src/test/ui/{ => async-await}/issue-53249.rs           |  0
 .../async-await}/issue-54752-async-block.rs            |  6 ++++--
 src/test/ui/{issues => async-await}/issue-54974.rs     |  0
 src/test/ui/{issues => async-await}/issue-55324.rs     |  0
 src/test/{run-pass => ui/async-await}/issue-55809.rs   |  0
 src/test/ui/{issues => async-await}/issue-58885.rs     |  0
 src/test/ui/{issues => async-await}/issue-59001.rs     |  0
 .../generator => ui/async-await}/issue-59972.rs        |  2 ++
 .../issue-60655-latebound-regions.rs                   |  0
 .../no-args-non-move-async-closure.rs                  |  0
 .../async-await/no-args-non-move-async-closure.stderr  | 10 ++++++++++
 .../recursive-async-impl-trait-type.rs                 |  0
 .../recursive-async-impl-trait-type.stderr             |  0
 .../unresolved_type_param.rs                           |  0
 .../unresolved_type_param.stderr                       |  0
 44 files changed, 20 insertions(+), 2 deletions(-)
 rename src/test/{run-pass => ui/async-await}/async-await.rs (99%)
 rename src/test/ui/{ => async-await}/async-fn-multiple-lifetimes.rs (100%)
 rename src/test/ui/{ => async-await}/async-fn-multiple-lifetimes.stderr (100%)
 rename src/test/ui/{ => async-await}/async-fn-path-elision.rs (100%)
 rename src/test/ui/{ => async-await}/async-fn-path-elision.stderr (100%)
 rename src/test/ui/{ => async-await}/async-matches-expr.rs (100%)
 rename src/test/ui/{ => async-await}/async-with-closure.rs (100%)
 rename src/test/ui/{ => async-await}/await-keyword/2015-edition-error-in-non-macro-position.rs (100%)
 rename src/test/ui/{ => async-await}/await-keyword/2015-edition-error-in-non-macro-position.stderr (100%)
 rename src/test/ui/{ => async-await}/await-keyword/2015-edition-warning.fixed (100%)
 rename src/test/ui/{ => async-await}/await-keyword/2015-edition-warning.rs (100%)
 rename src/test/ui/{ => async-await}/await-keyword/2015-edition-warning.stderr (100%)
 rename src/test/ui/{ => async-await}/await-keyword/2018-edition-error-in-non-macro-position.rs (100%)
 rename src/test/ui/{ => async-await}/await-keyword/2018-edition-error-in-non-macro-position.stderr (100%)
 rename src/test/ui/{ => async-await}/await-keyword/2018-edition-error.rs (100%)
 rename src/test/ui/{ => async-await}/await-keyword/2018-edition-error.stderr (100%)
 rename src/test/ui/{ => async-await}/await-keyword/incorrect-syntax-suggestions.rs (100%)
 rename src/test/ui/{ => async-await}/await-keyword/incorrect-syntax-suggestions.stderr (100%)
 rename src/test/ui/{ => async-await}/await-keyword/post_expansion_error.rs (100%)
 rename src/test/ui/{ => async-await}/await-keyword/post_expansion_error.stderr (100%)
 rename src/test/{run-pass => ui/async-await}/await-macro.rs (99%)
 rename src/test/ui/{nll => async-await}/dont-print-desugared-async.rs (100%)
 rename src/test/ui/{nll => async-await}/dont-print-desugared-async.stderr (100%)
 rename src/test/ui/{editions => async-await}/edition-deny-async-fns-2015.rs (100%)
 rename src/test/ui/{editions => async-await}/edition-deny-async-fns-2015.stderr (100%)
 rename src/test/ui/{issues => async-await}/issue-51719.rs (100%)
 rename src/test/ui/{issues => async-await}/issue-51719.stderr (100%)
 rename src/test/ui/{issues => async-await}/issue-51751.rs (100%)
 rename src/test/ui/{issues => async-await}/issue-51751.stderr (100%)
 rename src/test/ui/{ => async-await}/issue-53249.rs (100%)
 rename src/test/{pretty => ui/async-await}/issue-54752-async-block.rs (90%)
 rename src/test/ui/{issues => async-await}/issue-54974.rs (100%)
 rename src/test/ui/{issues => async-await}/issue-55324.rs (100%)
 rename src/test/{run-pass => ui/async-await}/issue-55809.rs (100%)
 rename src/test/ui/{issues => async-await}/issue-58885.rs (100%)
 rename src/test/ui/{issues => async-await}/issue-59001.rs (100%)
 rename src/test/{run-pass/generator => ui/async-await}/issue-59972.rs (96%)
 rename src/test/ui/{existential_types => async-await}/issue-60655-latebound-regions.rs (100%)
 rename src/test/ui/{ => async-await}/no-args-non-move-async-closure.rs (100%)
 create mode 100644 src/test/ui/async-await/no-args-non-move-async-closure.stderr
 rename src/test/ui/{impl-trait => async-await}/recursive-async-impl-trait-type.rs (100%)
 rename src/test/ui/{impl-trait => async-await}/recursive-async-impl-trait-type.stderr (100%)
 rename src/test/ui/{generator => async-await}/unresolved_type_param.rs (100%)
 rename src/test/ui/{generator => async-await}/unresolved_type_param.stderr (100%)

diff --git a/src/test/run-pass/async-await.rs b/src/test/ui/async-await/async-await.rs
similarity index 99%
rename from src/test/run-pass/async-await.rs
rename to src/test/ui/async-await/async-await.rs
index 49fd8b8b1ce27..6fa013e5c54ca 100644
--- a/src/test/run-pass/async-await.rs
+++ b/src/test/ui/async-await/async-await.rs
@@ -1,3 +1,5 @@
+// run-pass
+
 // edition:2018
 // aux-build:arc_wake.rs
 
diff --git a/src/test/ui/async-fn-multiple-lifetimes.rs b/src/test/ui/async-await/async-fn-multiple-lifetimes.rs
similarity index 100%
rename from src/test/ui/async-fn-multiple-lifetimes.rs
rename to src/test/ui/async-await/async-fn-multiple-lifetimes.rs
diff --git a/src/test/ui/async-fn-multiple-lifetimes.stderr b/src/test/ui/async-await/async-fn-multiple-lifetimes.stderr
similarity index 100%
rename from src/test/ui/async-fn-multiple-lifetimes.stderr
rename to src/test/ui/async-await/async-fn-multiple-lifetimes.stderr
diff --git a/src/test/ui/async-fn-path-elision.rs b/src/test/ui/async-await/async-fn-path-elision.rs
similarity index 100%
rename from src/test/ui/async-fn-path-elision.rs
rename to src/test/ui/async-await/async-fn-path-elision.rs
diff --git a/src/test/ui/async-fn-path-elision.stderr b/src/test/ui/async-await/async-fn-path-elision.stderr
similarity index 100%
rename from src/test/ui/async-fn-path-elision.stderr
rename to src/test/ui/async-await/async-fn-path-elision.stderr
diff --git a/src/test/ui/async-matches-expr.rs b/src/test/ui/async-await/async-matches-expr.rs
similarity index 100%
rename from src/test/ui/async-matches-expr.rs
rename to src/test/ui/async-await/async-matches-expr.rs
diff --git a/src/test/ui/async-with-closure.rs b/src/test/ui/async-await/async-with-closure.rs
similarity index 100%
rename from src/test/ui/async-with-closure.rs
rename to src/test/ui/async-await/async-with-closure.rs
diff --git a/src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.rs b/src/test/ui/async-await/await-keyword/2015-edition-error-in-non-macro-position.rs
similarity index 100%
rename from src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.rs
rename to src/test/ui/async-await/await-keyword/2015-edition-error-in-non-macro-position.rs
diff --git a/src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.stderr b/src/test/ui/async-await/await-keyword/2015-edition-error-in-non-macro-position.stderr
similarity index 100%
rename from src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.stderr
rename to src/test/ui/async-await/await-keyword/2015-edition-error-in-non-macro-position.stderr
diff --git a/src/test/ui/await-keyword/2015-edition-warning.fixed b/src/test/ui/async-await/await-keyword/2015-edition-warning.fixed
similarity index 100%
rename from src/test/ui/await-keyword/2015-edition-warning.fixed
rename to src/test/ui/async-await/await-keyword/2015-edition-warning.fixed
diff --git a/src/test/ui/await-keyword/2015-edition-warning.rs b/src/test/ui/async-await/await-keyword/2015-edition-warning.rs
similarity index 100%
rename from src/test/ui/await-keyword/2015-edition-warning.rs
rename to src/test/ui/async-await/await-keyword/2015-edition-warning.rs
diff --git a/src/test/ui/await-keyword/2015-edition-warning.stderr b/src/test/ui/async-await/await-keyword/2015-edition-warning.stderr
similarity index 100%
rename from src/test/ui/await-keyword/2015-edition-warning.stderr
rename to src/test/ui/async-await/await-keyword/2015-edition-warning.stderr
diff --git a/src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.rs b/src/test/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.rs
similarity index 100%
rename from src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.rs
rename to src/test/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.rs
diff --git a/src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.stderr b/src/test/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.stderr
similarity index 100%
rename from src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.stderr
rename to src/test/ui/async-await/await-keyword/2018-edition-error-in-non-macro-position.stderr
diff --git a/src/test/ui/await-keyword/2018-edition-error.rs b/src/test/ui/async-await/await-keyword/2018-edition-error.rs
similarity index 100%
rename from src/test/ui/await-keyword/2018-edition-error.rs
rename to src/test/ui/async-await/await-keyword/2018-edition-error.rs
diff --git a/src/test/ui/await-keyword/2018-edition-error.stderr b/src/test/ui/async-await/await-keyword/2018-edition-error.stderr
similarity index 100%
rename from src/test/ui/await-keyword/2018-edition-error.stderr
rename to src/test/ui/async-await/await-keyword/2018-edition-error.stderr
diff --git a/src/test/ui/await-keyword/incorrect-syntax-suggestions.rs b/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs
similarity index 100%
rename from src/test/ui/await-keyword/incorrect-syntax-suggestions.rs
rename to src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.rs
diff --git a/src/test/ui/await-keyword/incorrect-syntax-suggestions.stderr b/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr
similarity index 100%
rename from src/test/ui/await-keyword/incorrect-syntax-suggestions.stderr
rename to src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr
diff --git a/src/test/ui/await-keyword/post_expansion_error.rs b/src/test/ui/async-await/await-keyword/post_expansion_error.rs
similarity index 100%
rename from src/test/ui/await-keyword/post_expansion_error.rs
rename to src/test/ui/async-await/await-keyword/post_expansion_error.rs
diff --git a/src/test/ui/await-keyword/post_expansion_error.stderr b/src/test/ui/async-await/await-keyword/post_expansion_error.stderr
similarity index 100%
rename from src/test/ui/await-keyword/post_expansion_error.stderr
rename to src/test/ui/async-await/await-keyword/post_expansion_error.stderr
diff --git a/src/test/run-pass/await-macro.rs b/src/test/ui/async-await/await-macro.rs
similarity index 99%
rename from src/test/run-pass/await-macro.rs
rename to src/test/ui/async-await/await-macro.rs
index e1b4328debd9a..1b807588d6ac2 100644
--- a/src/test/run-pass/await-macro.rs
+++ b/src/test/ui/async-await/await-macro.rs
@@ -1,3 +1,5 @@
+// run-pass
+
 // edition:2018
 // aux-build:arc_wake.rs
 
diff --git a/src/test/ui/nll/dont-print-desugared-async.rs b/src/test/ui/async-await/dont-print-desugared-async.rs
similarity index 100%
rename from src/test/ui/nll/dont-print-desugared-async.rs
rename to src/test/ui/async-await/dont-print-desugared-async.rs
diff --git a/src/test/ui/nll/dont-print-desugared-async.stderr b/src/test/ui/async-await/dont-print-desugared-async.stderr
similarity index 100%
rename from src/test/ui/nll/dont-print-desugared-async.stderr
rename to src/test/ui/async-await/dont-print-desugared-async.stderr
diff --git a/src/test/ui/editions/edition-deny-async-fns-2015.rs b/src/test/ui/async-await/edition-deny-async-fns-2015.rs
similarity index 100%
rename from src/test/ui/editions/edition-deny-async-fns-2015.rs
rename to src/test/ui/async-await/edition-deny-async-fns-2015.rs
diff --git a/src/test/ui/editions/edition-deny-async-fns-2015.stderr b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr
similarity index 100%
rename from src/test/ui/editions/edition-deny-async-fns-2015.stderr
rename to src/test/ui/async-await/edition-deny-async-fns-2015.stderr
diff --git a/src/test/ui/issues/issue-51719.rs b/src/test/ui/async-await/issue-51719.rs
similarity index 100%
rename from src/test/ui/issues/issue-51719.rs
rename to src/test/ui/async-await/issue-51719.rs
diff --git a/src/test/ui/issues/issue-51719.stderr b/src/test/ui/async-await/issue-51719.stderr
similarity index 100%
rename from src/test/ui/issues/issue-51719.stderr
rename to src/test/ui/async-await/issue-51719.stderr
diff --git a/src/test/ui/issues/issue-51751.rs b/src/test/ui/async-await/issue-51751.rs
similarity index 100%
rename from src/test/ui/issues/issue-51751.rs
rename to src/test/ui/async-await/issue-51751.rs
diff --git a/src/test/ui/issues/issue-51751.stderr b/src/test/ui/async-await/issue-51751.stderr
similarity index 100%
rename from src/test/ui/issues/issue-51751.stderr
rename to src/test/ui/async-await/issue-51751.stderr
diff --git a/src/test/ui/issue-53249.rs b/src/test/ui/async-await/issue-53249.rs
similarity index 100%
rename from src/test/ui/issue-53249.rs
rename to src/test/ui/async-await/issue-53249.rs
diff --git a/src/test/pretty/issue-54752-async-block.rs b/src/test/ui/async-await/issue-54752-async-block.rs
similarity index 90%
rename from src/test/pretty/issue-54752-async-block.rs
rename to src/test/ui/async-await/issue-54752-async-block.rs
index 6930ee1a386fe..0036de90b2579 100644
--- a/src/test/pretty/issue-54752-async-block.rs
+++ b/src/test/ui/async-await/issue-54752-async-block.rs
@@ -1,7 +1,9 @@
-#![feature(async_await)]
-#![allow(unused_parens)]
+// run-pass
 
 // edition:2018
 // pp-exact
 
+#![feature(async_await)]
+#![allow(unused_parens)]
+
 fn main() { let _a = (async  { }); }
diff --git a/src/test/ui/issues/issue-54974.rs b/src/test/ui/async-await/issue-54974.rs
similarity index 100%
rename from src/test/ui/issues/issue-54974.rs
rename to src/test/ui/async-await/issue-54974.rs
diff --git a/src/test/ui/issues/issue-55324.rs b/src/test/ui/async-await/issue-55324.rs
similarity index 100%
rename from src/test/ui/issues/issue-55324.rs
rename to src/test/ui/async-await/issue-55324.rs
diff --git a/src/test/run-pass/issue-55809.rs b/src/test/ui/async-await/issue-55809.rs
similarity index 100%
rename from src/test/run-pass/issue-55809.rs
rename to src/test/ui/async-await/issue-55809.rs
diff --git a/src/test/ui/issues/issue-58885.rs b/src/test/ui/async-await/issue-58885.rs
similarity index 100%
rename from src/test/ui/issues/issue-58885.rs
rename to src/test/ui/async-await/issue-58885.rs
diff --git a/src/test/ui/issues/issue-59001.rs b/src/test/ui/async-await/issue-59001.rs
similarity index 100%
rename from src/test/ui/issues/issue-59001.rs
rename to src/test/ui/async-await/issue-59001.rs
diff --git a/src/test/run-pass/generator/issue-59972.rs b/src/test/ui/async-await/issue-59972.rs
similarity index 96%
rename from src/test/run-pass/generator/issue-59972.rs
rename to src/test/ui/async-await/issue-59972.rs
index 995da4fb3ff3c..31e7a65dc98e3 100644
--- a/src/test/run-pass/generator/issue-59972.rs
+++ b/src/test/ui/async-await/issue-59972.rs
@@ -1,3 +1,5 @@
+// run-pass
+
 // compile-flags: --edition=2018
 
 #![feature(async_await, await_macro)]
diff --git a/src/test/ui/existential_types/issue-60655-latebound-regions.rs b/src/test/ui/async-await/issue-60655-latebound-regions.rs
similarity index 100%
rename from src/test/ui/existential_types/issue-60655-latebound-regions.rs
rename to src/test/ui/async-await/issue-60655-latebound-regions.rs
diff --git a/src/test/ui/no-args-non-move-async-closure.rs b/src/test/ui/async-await/no-args-non-move-async-closure.rs
similarity index 100%
rename from src/test/ui/no-args-non-move-async-closure.rs
rename to src/test/ui/async-await/no-args-non-move-async-closure.rs
diff --git a/src/test/ui/async-await/no-args-non-move-async-closure.stderr b/src/test/ui/async-await/no-args-non-move-async-closure.stderr
new file mode 100644
index 0000000000000..1b4b86210f840
--- /dev/null
+++ b/src/test/ui/async-await/no-args-non-move-async-closure.stderr
@@ -0,0 +1,10 @@
+error[E0708]: `async` non-`move` closures with arguments are not currently supported
+  --> $DIR/no-args-non-move-async-closure.rs:6:13
+   |
+LL |     let _ = async |x: u8| {};
+   |             ^^^^^^^^^^^^^
+   |
+   = help: consider using `let` statements to manually capture variables by reference before entering an `async move` closure
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/impl-trait/recursive-async-impl-trait-type.rs b/src/test/ui/async-await/recursive-async-impl-trait-type.rs
similarity index 100%
rename from src/test/ui/impl-trait/recursive-async-impl-trait-type.rs
rename to src/test/ui/async-await/recursive-async-impl-trait-type.rs
diff --git a/src/test/ui/impl-trait/recursive-async-impl-trait-type.stderr b/src/test/ui/async-await/recursive-async-impl-trait-type.stderr
similarity index 100%
rename from src/test/ui/impl-trait/recursive-async-impl-trait-type.stderr
rename to src/test/ui/async-await/recursive-async-impl-trait-type.stderr
diff --git a/src/test/ui/generator/unresolved_type_param.rs b/src/test/ui/async-await/unresolved_type_param.rs
similarity index 100%
rename from src/test/ui/generator/unresolved_type_param.rs
rename to src/test/ui/async-await/unresolved_type_param.rs
diff --git a/src/test/ui/generator/unresolved_type_param.stderr b/src/test/ui/async-await/unresolved_type_param.stderr
similarity index 100%
rename from src/test/ui/generator/unresolved_type_param.stderr
rename to src/test/ui/async-await/unresolved_type_param.stderr

From d289a5ba40d19bbd243700fd167bb1d5d0c574ed Mon Sep 17 00:00:00 2001
From: varkor <github@varkor.com>
Date: Fri, 24 May 2019 21:49:52 +0100
Subject: [PATCH 22/29] Move some issues into the issues folder

---
 src/test/ui/{ => issues}/issue-59508-1.rs     | 0
 src/test/ui/{ => issues}/issue-59508-1.stderr | 0
 src/test/ui/{ => issues}/issue-59508.fixed    | 0
 src/test/ui/{ => issues}/issue-59508.rs       | 0
 src/test/ui/{ => issues}/issue-59508.stderr   | 0
 src/test/ui/{ => issues}/issue-59756.fixed    | 0
 src/test/ui/{ => issues}/issue-59756.rs       | 0
 src/test/ui/{ => issues}/issue-59756.stderr   | 0
 src/test/ui/{ => issues}/issue-59764.rs       | 0
 src/test/ui/{ => issues}/issue-59764.stderr   | 0
 src/test/ui/{ => issues}/issue-60075.rs       | 0
 src/test/ui/{ => issues}/issue-60075.stderr   | 0
 src/test/ui/{ => issues}/issue-60622.rs       | 0
 src/test/ui/{ => issues}/issue-60622.stderr   | 0
 14 files changed, 0 insertions(+), 0 deletions(-)
 rename src/test/ui/{ => issues}/issue-59508-1.rs (100%)
 rename src/test/ui/{ => issues}/issue-59508-1.stderr (100%)
 rename src/test/ui/{ => issues}/issue-59508.fixed (100%)
 rename src/test/ui/{ => issues}/issue-59508.rs (100%)
 rename src/test/ui/{ => issues}/issue-59508.stderr (100%)
 rename src/test/ui/{ => issues}/issue-59756.fixed (100%)
 rename src/test/ui/{ => issues}/issue-59756.rs (100%)
 rename src/test/ui/{ => issues}/issue-59756.stderr (100%)
 rename src/test/ui/{ => issues}/issue-59764.rs (100%)
 rename src/test/ui/{ => issues}/issue-59764.stderr (100%)
 rename src/test/ui/{ => issues}/issue-60075.rs (100%)
 rename src/test/ui/{ => issues}/issue-60075.stderr (100%)
 rename src/test/ui/{ => issues}/issue-60622.rs (100%)
 rename src/test/ui/{ => issues}/issue-60622.stderr (100%)

diff --git a/src/test/ui/issue-59508-1.rs b/src/test/ui/issues/issue-59508-1.rs
similarity index 100%
rename from src/test/ui/issue-59508-1.rs
rename to src/test/ui/issues/issue-59508-1.rs
diff --git a/src/test/ui/issue-59508-1.stderr b/src/test/ui/issues/issue-59508-1.stderr
similarity index 100%
rename from src/test/ui/issue-59508-1.stderr
rename to src/test/ui/issues/issue-59508-1.stderr
diff --git a/src/test/ui/issue-59508.fixed b/src/test/ui/issues/issue-59508.fixed
similarity index 100%
rename from src/test/ui/issue-59508.fixed
rename to src/test/ui/issues/issue-59508.fixed
diff --git a/src/test/ui/issue-59508.rs b/src/test/ui/issues/issue-59508.rs
similarity index 100%
rename from src/test/ui/issue-59508.rs
rename to src/test/ui/issues/issue-59508.rs
diff --git a/src/test/ui/issue-59508.stderr b/src/test/ui/issues/issue-59508.stderr
similarity index 100%
rename from src/test/ui/issue-59508.stderr
rename to src/test/ui/issues/issue-59508.stderr
diff --git a/src/test/ui/issue-59756.fixed b/src/test/ui/issues/issue-59756.fixed
similarity index 100%
rename from src/test/ui/issue-59756.fixed
rename to src/test/ui/issues/issue-59756.fixed
diff --git a/src/test/ui/issue-59756.rs b/src/test/ui/issues/issue-59756.rs
similarity index 100%
rename from src/test/ui/issue-59756.rs
rename to src/test/ui/issues/issue-59756.rs
diff --git a/src/test/ui/issue-59756.stderr b/src/test/ui/issues/issue-59756.stderr
similarity index 100%
rename from src/test/ui/issue-59756.stderr
rename to src/test/ui/issues/issue-59756.stderr
diff --git a/src/test/ui/issue-59764.rs b/src/test/ui/issues/issue-59764.rs
similarity index 100%
rename from src/test/ui/issue-59764.rs
rename to src/test/ui/issues/issue-59764.rs
diff --git a/src/test/ui/issue-59764.stderr b/src/test/ui/issues/issue-59764.stderr
similarity index 100%
rename from src/test/ui/issue-59764.stderr
rename to src/test/ui/issues/issue-59764.stderr
diff --git a/src/test/ui/issue-60075.rs b/src/test/ui/issues/issue-60075.rs
similarity index 100%
rename from src/test/ui/issue-60075.rs
rename to src/test/ui/issues/issue-60075.rs
diff --git a/src/test/ui/issue-60075.stderr b/src/test/ui/issues/issue-60075.stderr
similarity index 100%
rename from src/test/ui/issue-60075.stderr
rename to src/test/ui/issues/issue-60075.stderr
diff --git a/src/test/ui/issue-60622.rs b/src/test/ui/issues/issue-60622.rs
similarity index 100%
rename from src/test/ui/issue-60622.rs
rename to src/test/ui/issues/issue-60622.rs
diff --git a/src/test/ui/issue-60622.stderr b/src/test/ui/issues/issue-60622.stderr
similarity index 100%
rename from src/test/ui/issue-60622.stderr
rename to src/test/ui/issues/issue-60622.stderr

From df26dd8fd1979570bfc71adc02d898806e0c76fc Mon Sep 17 00:00:00 2001
From: varkor <github@varkor.com>
Date: Fri, 24 May 2019 22:03:14 +0100
Subject: [PATCH 23/29] Add auxiliary issue file

---
 src/test/ui/{ => issues}/auxiliary/issue-59764.rs | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename src/test/ui/{ => issues}/auxiliary/issue-59764.rs (100%)

diff --git a/src/test/ui/auxiliary/issue-59764.rs b/src/test/ui/issues/auxiliary/issue-59764.rs
similarity index 100%
rename from src/test/ui/auxiliary/issue-59764.rs
rename to src/test/ui/issues/auxiliary/issue-59764.rs

From 06b85709d496c768e031b7d89735afce9dd55a27 Mon Sep 17 00:00:00 2001
From: varkor <github@varkor.com>
Date: Fri, 24 May 2019 22:05:57 +0100
Subject: [PATCH 24/29] Add drop-order folder in test/ui/async-await

---
 src/test/ui/async-await/auxiliary/issue-60674.rs     | 12 ------------
 .../{ => drop-order}/auxiliary/arc_wake.rs           |  0
 ...p-order-for-async-fn-parameters-by-ref-binding.rs |  0
 .../drop-order-for-async-fn-parameters.rs            |  0
 .../{ => drop-order}/drop-order-locals-are-hidden.rs |  0
 .../drop-order-locals-are-hidden.stderr              |  0
 6 files changed, 12 deletions(-)
 delete mode 100644 src/test/ui/async-await/auxiliary/issue-60674.rs
 rename src/test/ui/async-await/{ => drop-order}/auxiliary/arc_wake.rs (100%)
 rename src/test/ui/async-await/{ => drop-order}/drop-order-for-async-fn-parameters-by-ref-binding.rs (100%)
 rename src/test/ui/async-await/{ => drop-order}/drop-order-for-async-fn-parameters.rs (100%)
 rename src/test/ui/async-await/{ => drop-order}/drop-order-locals-are-hidden.rs (100%)
 rename src/test/ui/async-await/{ => drop-order}/drop-order-locals-are-hidden.stderr (100%)

diff --git a/src/test/ui/async-await/auxiliary/issue-60674.rs b/src/test/ui/async-await/auxiliary/issue-60674.rs
deleted file mode 100644
index 680c6e55e5668..0000000000000
--- a/src/test/ui/async-await/auxiliary/issue-60674.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// force-host
-// no-prefer-dynamic
-#![crate_type = "proc-macro"]
-
-extern crate proc_macro;
-use proc_macro::TokenStream;
-
-#[proc_macro_attribute]
-pub fn attr(_args: TokenStream, input: TokenStream) -> TokenStream {
-    println!("{}", input);
-    TokenStream::new()
-}
diff --git a/src/test/ui/async-await/auxiliary/arc_wake.rs b/src/test/ui/async-await/drop-order/auxiliary/arc_wake.rs
similarity index 100%
rename from src/test/ui/async-await/auxiliary/arc_wake.rs
rename to src/test/ui/async-await/drop-order/auxiliary/arc_wake.rs
diff --git a/src/test/ui/async-await/drop-order-for-async-fn-parameters-by-ref-binding.rs b/src/test/ui/async-await/drop-order/drop-order-for-async-fn-parameters-by-ref-binding.rs
similarity index 100%
rename from src/test/ui/async-await/drop-order-for-async-fn-parameters-by-ref-binding.rs
rename to src/test/ui/async-await/drop-order/drop-order-for-async-fn-parameters-by-ref-binding.rs
diff --git a/src/test/ui/async-await/drop-order-for-async-fn-parameters.rs b/src/test/ui/async-await/drop-order/drop-order-for-async-fn-parameters.rs
similarity index 100%
rename from src/test/ui/async-await/drop-order-for-async-fn-parameters.rs
rename to src/test/ui/async-await/drop-order/drop-order-for-async-fn-parameters.rs
diff --git a/src/test/ui/async-await/drop-order-locals-are-hidden.rs b/src/test/ui/async-await/drop-order/drop-order-locals-are-hidden.rs
similarity index 100%
rename from src/test/ui/async-await/drop-order-locals-are-hidden.rs
rename to src/test/ui/async-await/drop-order/drop-order-locals-are-hidden.rs
diff --git a/src/test/ui/async-await/drop-order-locals-are-hidden.stderr b/src/test/ui/async-await/drop-order/drop-order-locals-are-hidden.stderr
similarity index 100%
rename from src/test/ui/async-await/drop-order-locals-are-hidden.stderr
rename to src/test/ui/async-await/drop-order/drop-order-locals-are-hidden.stderr

From cb7e0d0dd3d3af62f76190d3f5f03332bb191023 Mon Sep 17 00:00:00 2001
From: varkor <github@varkor.com>
Date: Fri, 24 May 2019 22:06:09 +0100
Subject: [PATCH 25/29] Add issues folder in async-await

---
 .../ui/async-await/issues/auxiliary/issue-60674.rs   | 12 ++++++++++++
 src/test/ui/async-await/{ => issues}/issue-51719.rs  |  0
 .../ui/async-await/{ => issues}/issue-51719.stderr   |  0
 src/test/ui/async-await/{ => issues}/issue-51751.rs  |  0
 .../ui/async-await/{ => issues}/issue-51751.stderr   |  0
 src/test/ui/async-await/{ => issues}/issue-53249.rs  |  0
 .../{ => issues}/issue-54752-async-block.rs          |  0
 src/test/ui/async-await/{ => issues}/issue-54974.rs  |  0
 src/test/ui/async-await/{ => issues}/issue-55324.rs  |  0
 src/test/ui/async-await/{ => issues}/issue-55809.rs  |  0
 src/test/ui/async-await/{ => issues}/issue-58885.rs  |  0
 src/test/ui/async-await/{ => issues}/issue-59001.rs  |  0
 src/test/ui/async-await/{ => issues}/issue-59972.rs  |  0
 src/test/ui/async-await/{ => issues}/issue-60518.rs  |  0
 .../{ => issues}/issue-60655-latebound-regions.rs    |  0
 src/test/ui/async-await/{ => issues}/issue-60674.rs  |  0
 .../ui/async-await/{ => issues}/issue-60674.stdout   |  0
 17 files changed, 12 insertions(+)
 create mode 100644 src/test/ui/async-await/issues/auxiliary/issue-60674.rs
 rename src/test/ui/async-await/{ => issues}/issue-51719.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-51719.stderr (100%)
 rename src/test/ui/async-await/{ => issues}/issue-51751.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-51751.stderr (100%)
 rename src/test/ui/async-await/{ => issues}/issue-53249.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-54752-async-block.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-54974.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-55324.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-55809.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-58885.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-59001.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-59972.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-60518.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-60655-latebound-regions.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-60674.rs (100%)
 rename src/test/ui/async-await/{ => issues}/issue-60674.stdout (100%)

diff --git a/src/test/ui/async-await/issues/auxiliary/issue-60674.rs b/src/test/ui/async-await/issues/auxiliary/issue-60674.rs
new file mode 100644
index 0000000000000..680c6e55e5668
--- /dev/null
+++ b/src/test/ui/async-await/issues/auxiliary/issue-60674.rs
@@ -0,0 +1,12 @@
+// force-host
+// no-prefer-dynamic
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+use proc_macro::TokenStream;
+
+#[proc_macro_attribute]
+pub fn attr(_args: TokenStream, input: TokenStream) -> TokenStream {
+    println!("{}", input);
+    TokenStream::new()
+}
diff --git a/src/test/ui/async-await/issue-51719.rs b/src/test/ui/async-await/issues/issue-51719.rs
similarity index 100%
rename from src/test/ui/async-await/issue-51719.rs
rename to src/test/ui/async-await/issues/issue-51719.rs
diff --git a/src/test/ui/async-await/issue-51719.stderr b/src/test/ui/async-await/issues/issue-51719.stderr
similarity index 100%
rename from src/test/ui/async-await/issue-51719.stderr
rename to src/test/ui/async-await/issues/issue-51719.stderr
diff --git a/src/test/ui/async-await/issue-51751.rs b/src/test/ui/async-await/issues/issue-51751.rs
similarity index 100%
rename from src/test/ui/async-await/issue-51751.rs
rename to src/test/ui/async-await/issues/issue-51751.rs
diff --git a/src/test/ui/async-await/issue-51751.stderr b/src/test/ui/async-await/issues/issue-51751.stderr
similarity index 100%
rename from src/test/ui/async-await/issue-51751.stderr
rename to src/test/ui/async-await/issues/issue-51751.stderr
diff --git a/src/test/ui/async-await/issue-53249.rs b/src/test/ui/async-await/issues/issue-53249.rs
similarity index 100%
rename from src/test/ui/async-await/issue-53249.rs
rename to src/test/ui/async-await/issues/issue-53249.rs
diff --git a/src/test/ui/async-await/issue-54752-async-block.rs b/src/test/ui/async-await/issues/issue-54752-async-block.rs
similarity index 100%
rename from src/test/ui/async-await/issue-54752-async-block.rs
rename to src/test/ui/async-await/issues/issue-54752-async-block.rs
diff --git a/src/test/ui/async-await/issue-54974.rs b/src/test/ui/async-await/issues/issue-54974.rs
similarity index 100%
rename from src/test/ui/async-await/issue-54974.rs
rename to src/test/ui/async-await/issues/issue-54974.rs
diff --git a/src/test/ui/async-await/issue-55324.rs b/src/test/ui/async-await/issues/issue-55324.rs
similarity index 100%
rename from src/test/ui/async-await/issue-55324.rs
rename to src/test/ui/async-await/issues/issue-55324.rs
diff --git a/src/test/ui/async-await/issue-55809.rs b/src/test/ui/async-await/issues/issue-55809.rs
similarity index 100%
rename from src/test/ui/async-await/issue-55809.rs
rename to src/test/ui/async-await/issues/issue-55809.rs
diff --git a/src/test/ui/async-await/issue-58885.rs b/src/test/ui/async-await/issues/issue-58885.rs
similarity index 100%
rename from src/test/ui/async-await/issue-58885.rs
rename to src/test/ui/async-await/issues/issue-58885.rs
diff --git a/src/test/ui/async-await/issue-59001.rs b/src/test/ui/async-await/issues/issue-59001.rs
similarity index 100%
rename from src/test/ui/async-await/issue-59001.rs
rename to src/test/ui/async-await/issues/issue-59001.rs
diff --git a/src/test/ui/async-await/issue-59972.rs b/src/test/ui/async-await/issues/issue-59972.rs
similarity index 100%
rename from src/test/ui/async-await/issue-59972.rs
rename to src/test/ui/async-await/issues/issue-59972.rs
diff --git a/src/test/ui/async-await/issue-60518.rs b/src/test/ui/async-await/issues/issue-60518.rs
similarity index 100%
rename from src/test/ui/async-await/issue-60518.rs
rename to src/test/ui/async-await/issues/issue-60518.rs
diff --git a/src/test/ui/async-await/issue-60655-latebound-regions.rs b/src/test/ui/async-await/issues/issue-60655-latebound-regions.rs
similarity index 100%
rename from src/test/ui/async-await/issue-60655-latebound-regions.rs
rename to src/test/ui/async-await/issues/issue-60655-latebound-regions.rs
diff --git a/src/test/ui/async-await/issue-60674.rs b/src/test/ui/async-await/issues/issue-60674.rs
similarity index 100%
rename from src/test/ui/async-await/issue-60674.rs
rename to src/test/ui/async-await/issues/issue-60674.rs
diff --git a/src/test/ui/async-await/issue-60674.stdout b/src/test/ui/async-await/issues/issue-60674.stdout
similarity index 100%
rename from src/test/ui/async-await/issue-60674.stdout
rename to src/test/ui/async-await/issues/issue-60674.stdout

From aea04009e47195caaf13701fbb042f9e7c6828bd Mon Sep 17 00:00:00 2001
From: varkor <github@varkor.com>
Date: Fri, 24 May 2019 22:07:35 +0100
Subject: [PATCH 26/29] Move error code tests to error code folder

---
 src/test/ui/{ => error-codes}/E0501.rs                            | 0
 src/test/ui/{ => error-codes}/E0501.stderr                        | 0
 src/test/ui/{ => error-codes}/E0506.rs                            | 0
 src/test/ui/{ => error-codes}/E0506.stderr                        | 0
 src/test/ui/{ => error-codes}/E0508-fail.rs                       | 0
 src/test/ui/{ => error-codes}/E0508-fail.stderr                   | 0
 src/test/ui/{ => error-codes}/E0508.rs                            | 0
 src/test/ui/{ => error-codes}/E0508.stderr                        | 0
 src/test/ui/{ => error-codes}/E0583.rs                            | 0
 src/test/ui/{ => error-codes}/E0583.stderr                        | 0
 src/test/ui/{ => error-codes}/E0594.rs                            | 0
 src/test/ui/{ => error-codes}/E0594.stderr                        | 0
 src/test/ui/{ => error-codes}/E0596.rs                            | 0
 src/test/ui/{ => error-codes}/E0596.stderr                        | 0
 src/test/ui/{ => error-codes}/E0642.rs                            | 0
 src/test/ui/{ => error-codes}/E0642.stderr                        | 0
 src/test/ui/{ => error-codes}/E0660.rs                            | 0
 src/test/ui/{ => error-codes}/E0660.stderr                        | 0
 src/test/ui/{ => error-codes}/E0661.rs                            | 0
 src/test/ui/{ => error-codes}/E0661.stderr                        | 0
 src/test/ui/{ => error-codes}/E0662.rs                            | 0
 src/test/ui/{ => error-codes}/E0662.stderr                        | 0
 src/test/ui/{ => error-codes}/E0663.rs                            | 0
 src/test/ui/{ => error-codes}/E0663.stderr                        | 0
 src/test/ui/{ => error-codes}/E0664.rs                            | 0
 src/test/ui/{ => error-codes}/E0664.stderr                        | 0
 src/test/ui/{ => error-codes}/E0665.rs                            | 0
 src/test/ui/{ => error-codes}/E0665.stderr                        | 0
 src/test/ui/{ => error-codes}/E0705.rs                            | 0
 src/test/ui/{ => error-codes}/E0705.stderr                        | 0
 .../ui/{ => error-codes}/e0119/auxiliary/complex_impl_support.rs  | 0
 src/test/ui/{ => error-codes}/e0119/auxiliary/issue-23563-a.rs    | 0
 src/test/ui/{ => error-codes}/e0119/complex-impl.rs               | 0
 src/test/ui/{ => error-codes}/e0119/complex-impl.stderr           | 0
 src/test/ui/{ => error-codes}/e0119/conflict-with-std.rs          | 0
 src/test/ui/{ => error-codes}/e0119/conflict-with-std.stderr      | 0
 src/test/ui/{ => error-codes}/e0119/issue-23563.rs                | 0
 src/test/ui/{ => error-codes}/e0119/issue-23563.stderr            | 0
 src/test/ui/{ => error-codes}/e0119/issue-27403.rs                | 0
 src/test/ui/{ => error-codes}/e0119/issue-27403.stderr            | 0
 src/test/ui/{ => error-codes}/e0119/issue-28981.rs                | 0
 src/test/ui/{ => error-codes}/e0119/issue-28981.stderr            | 0
 src/test/ui/{ => error-codes}/e0119/so-37347311.rs                | 0
 src/test/ui/{ => error-codes}/e0119/so-37347311.stderr            | 0
 44 files changed, 0 insertions(+), 0 deletions(-)
 rename src/test/ui/{ => error-codes}/E0501.rs (100%)
 rename src/test/ui/{ => error-codes}/E0501.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0506.rs (100%)
 rename src/test/ui/{ => error-codes}/E0506.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0508-fail.rs (100%)
 rename src/test/ui/{ => error-codes}/E0508-fail.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0508.rs (100%)
 rename src/test/ui/{ => error-codes}/E0508.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0583.rs (100%)
 rename src/test/ui/{ => error-codes}/E0583.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0594.rs (100%)
 rename src/test/ui/{ => error-codes}/E0594.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0596.rs (100%)
 rename src/test/ui/{ => error-codes}/E0596.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0642.rs (100%)
 rename src/test/ui/{ => error-codes}/E0642.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0660.rs (100%)
 rename src/test/ui/{ => error-codes}/E0660.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0661.rs (100%)
 rename src/test/ui/{ => error-codes}/E0661.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0662.rs (100%)
 rename src/test/ui/{ => error-codes}/E0662.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0663.rs (100%)
 rename src/test/ui/{ => error-codes}/E0663.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0664.rs (100%)
 rename src/test/ui/{ => error-codes}/E0664.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0665.rs (100%)
 rename src/test/ui/{ => error-codes}/E0665.stderr (100%)
 rename src/test/ui/{ => error-codes}/E0705.rs (100%)
 rename src/test/ui/{ => error-codes}/E0705.stderr (100%)
 rename src/test/ui/{ => error-codes}/e0119/auxiliary/complex_impl_support.rs (100%)
 rename src/test/ui/{ => error-codes}/e0119/auxiliary/issue-23563-a.rs (100%)
 rename src/test/ui/{ => error-codes}/e0119/complex-impl.rs (100%)
 rename src/test/ui/{ => error-codes}/e0119/complex-impl.stderr (100%)
 rename src/test/ui/{ => error-codes}/e0119/conflict-with-std.rs (100%)
 rename src/test/ui/{ => error-codes}/e0119/conflict-with-std.stderr (100%)
 rename src/test/ui/{ => error-codes}/e0119/issue-23563.rs (100%)
 rename src/test/ui/{ => error-codes}/e0119/issue-23563.stderr (100%)
 rename src/test/ui/{ => error-codes}/e0119/issue-27403.rs (100%)
 rename src/test/ui/{ => error-codes}/e0119/issue-27403.stderr (100%)
 rename src/test/ui/{ => error-codes}/e0119/issue-28981.rs (100%)
 rename src/test/ui/{ => error-codes}/e0119/issue-28981.stderr (100%)
 rename src/test/ui/{ => error-codes}/e0119/so-37347311.rs (100%)
 rename src/test/ui/{ => error-codes}/e0119/so-37347311.stderr (100%)

diff --git a/src/test/ui/E0501.rs b/src/test/ui/error-codes/E0501.rs
similarity index 100%
rename from src/test/ui/E0501.rs
rename to src/test/ui/error-codes/E0501.rs
diff --git a/src/test/ui/E0501.stderr b/src/test/ui/error-codes/E0501.stderr
similarity index 100%
rename from src/test/ui/E0501.stderr
rename to src/test/ui/error-codes/E0501.stderr
diff --git a/src/test/ui/E0506.rs b/src/test/ui/error-codes/E0506.rs
similarity index 100%
rename from src/test/ui/E0506.rs
rename to src/test/ui/error-codes/E0506.rs
diff --git a/src/test/ui/E0506.stderr b/src/test/ui/error-codes/E0506.stderr
similarity index 100%
rename from src/test/ui/E0506.stderr
rename to src/test/ui/error-codes/E0506.stderr
diff --git a/src/test/ui/E0508-fail.rs b/src/test/ui/error-codes/E0508-fail.rs
similarity index 100%
rename from src/test/ui/E0508-fail.rs
rename to src/test/ui/error-codes/E0508-fail.rs
diff --git a/src/test/ui/E0508-fail.stderr b/src/test/ui/error-codes/E0508-fail.stderr
similarity index 100%
rename from src/test/ui/E0508-fail.stderr
rename to src/test/ui/error-codes/E0508-fail.stderr
diff --git a/src/test/ui/E0508.rs b/src/test/ui/error-codes/E0508.rs
similarity index 100%
rename from src/test/ui/E0508.rs
rename to src/test/ui/error-codes/E0508.rs
diff --git a/src/test/ui/E0508.stderr b/src/test/ui/error-codes/E0508.stderr
similarity index 100%
rename from src/test/ui/E0508.stderr
rename to src/test/ui/error-codes/E0508.stderr
diff --git a/src/test/ui/E0583.rs b/src/test/ui/error-codes/E0583.rs
similarity index 100%
rename from src/test/ui/E0583.rs
rename to src/test/ui/error-codes/E0583.rs
diff --git a/src/test/ui/E0583.stderr b/src/test/ui/error-codes/E0583.stderr
similarity index 100%
rename from src/test/ui/E0583.stderr
rename to src/test/ui/error-codes/E0583.stderr
diff --git a/src/test/ui/E0594.rs b/src/test/ui/error-codes/E0594.rs
similarity index 100%
rename from src/test/ui/E0594.rs
rename to src/test/ui/error-codes/E0594.rs
diff --git a/src/test/ui/E0594.stderr b/src/test/ui/error-codes/E0594.stderr
similarity index 100%
rename from src/test/ui/E0594.stderr
rename to src/test/ui/error-codes/E0594.stderr
diff --git a/src/test/ui/E0596.rs b/src/test/ui/error-codes/E0596.rs
similarity index 100%
rename from src/test/ui/E0596.rs
rename to src/test/ui/error-codes/E0596.rs
diff --git a/src/test/ui/E0596.stderr b/src/test/ui/error-codes/E0596.stderr
similarity index 100%
rename from src/test/ui/E0596.stderr
rename to src/test/ui/error-codes/E0596.stderr
diff --git a/src/test/ui/E0642.rs b/src/test/ui/error-codes/E0642.rs
similarity index 100%
rename from src/test/ui/E0642.rs
rename to src/test/ui/error-codes/E0642.rs
diff --git a/src/test/ui/E0642.stderr b/src/test/ui/error-codes/E0642.stderr
similarity index 100%
rename from src/test/ui/E0642.stderr
rename to src/test/ui/error-codes/E0642.stderr
diff --git a/src/test/ui/E0660.rs b/src/test/ui/error-codes/E0660.rs
similarity index 100%
rename from src/test/ui/E0660.rs
rename to src/test/ui/error-codes/E0660.rs
diff --git a/src/test/ui/E0660.stderr b/src/test/ui/error-codes/E0660.stderr
similarity index 100%
rename from src/test/ui/E0660.stderr
rename to src/test/ui/error-codes/E0660.stderr
diff --git a/src/test/ui/E0661.rs b/src/test/ui/error-codes/E0661.rs
similarity index 100%
rename from src/test/ui/E0661.rs
rename to src/test/ui/error-codes/E0661.rs
diff --git a/src/test/ui/E0661.stderr b/src/test/ui/error-codes/E0661.stderr
similarity index 100%
rename from src/test/ui/E0661.stderr
rename to src/test/ui/error-codes/E0661.stderr
diff --git a/src/test/ui/E0662.rs b/src/test/ui/error-codes/E0662.rs
similarity index 100%
rename from src/test/ui/E0662.rs
rename to src/test/ui/error-codes/E0662.rs
diff --git a/src/test/ui/E0662.stderr b/src/test/ui/error-codes/E0662.stderr
similarity index 100%
rename from src/test/ui/E0662.stderr
rename to src/test/ui/error-codes/E0662.stderr
diff --git a/src/test/ui/E0663.rs b/src/test/ui/error-codes/E0663.rs
similarity index 100%
rename from src/test/ui/E0663.rs
rename to src/test/ui/error-codes/E0663.rs
diff --git a/src/test/ui/E0663.stderr b/src/test/ui/error-codes/E0663.stderr
similarity index 100%
rename from src/test/ui/E0663.stderr
rename to src/test/ui/error-codes/E0663.stderr
diff --git a/src/test/ui/E0664.rs b/src/test/ui/error-codes/E0664.rs
similarity index 100%
rename from src/test/ui/E0664.rs
rename to src/test/ui/error-codes/E0664.rs
diff --git a/src/test/ui/E0664.stderr b/src/test/ui/error-codes/E0664.stderr
similarity index 100%
rename from src/test/ui/E0664.stderr
rename to src/test/ui/error-codes/E0664.stderr
diff --git a/src/test/ui/E0665.rs b/src/test/ui/error-codes/E0665.rs
similarity index 100%
rename from src/test/ui/E0665.rs
rename to src/test/ui/error-codes/E0665.rs
diff --git a/src/test/ui/E0665.stderr b/src/test/ui/error-codes/E0665.stderr
similarity index 100%
rename from src/test/ui/E0665.stderr
rename to src/test/ui/error-codes/E0665.stderr
diff --git a/src/test/ui/E0705.rs b/src/test/ui/error-codes/E0705.rs
similarity index 100%
rename from src/test/ui/E0705.rs
rename to src/test/ui/error-codes/E0705.rs
diff --git a/src/test/ui/E0705.stderr b/src/test/ui/error-codes/E0705.stderr
similarity index 100%
rename from src/test/ui/E0705.stderr
rename to src/test/ui/error-codes/E0705.stderr
diff --git a/src/test/ui/e0119/auxiliary/complex_impl_support.rs b/src/test/ui/error-codes/e0119/auxiliary/complex_impl_support.rs
similarity index 100%
rename from src/test/ui/e0119/auxiliary/complex_impl_support.rs
rename to src/test/ui/error-codes/e0119/auxiliary/complex_impl_support.rs
diff --git a/src/test/ui/e0119/auxiliary/issue-23563-a.rs b/src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs
similarity index 100%
rename from src/test/ui/e0119/auxiliary/issue-23563-a.rs
rename to src/test/ui/error-codes/e0119/auxiliary/issue-23563-a.rs
diff --git a/src/test/ui/e0119/complex-impl.rs b/src/test/ui/error-codes/e0119/complex-impl.rs
similarity index 100%
rename from src/test/ui/e0119/complex-impl.rs
rename to src/test/ui/error-codes/e0119/complex-impl.rs
diff --git a/src/test/ui/e0119/complex-impl.stderr b/src/test/ui/error-codes/e0119/complex-impl.stderr
similarity index 100%
rename from src/test/ui/e0119/complex-impl.stderr
rename to src/test/ui/error-codes/e0119/complex-impl.stderr
diff --git a/src/test/ui/e0119/conflict-with-std.rs b/src/test/ui/error-codes/e0119/conflict-with-std.rs
similarity index 100%
rename from src/test/ui/e0119/conflict-with-std.rs
rename to src/test/ui/error-codes/e0119/conflict-with-std.rs
diff --git a/src/test/ui/e0119/conflict-with-std.stderr b/src/test/ui/error-codes/e0119/conflict-with-std.stderr
similarity index 100%
rename from src/test/ui/e0119/conflict-with-std.stderr
rename to src/test/ui/error-codes/e0119/conflict-with-std.stderr
diff --git a/src/test/ui/e0119/issue-23563.rs b/src/test/ui/error-codes/e0119/issue-23563.rs
similarity index 100%
rename from src/test/ui/e0119/issue-23563.rs
rename to src/test/ui/error-codes/e0119/issue-23563.rs
diff --git a/src/test/ui/e0119/issue-23563.stderr b/src/test/ui/error-codes/e0119/issue-23563.stderr
similarity index 100%
rename from src/test/ui/e0119/issue-23563.stderr
rename to src/test/ui/error-codes/e0119/issue-23563.stderr
diff --git a/src/test/ui/e0119/issue-27403.rs b/src/test/ui/error-codes/e0119/issue-27403.rs
similarity index 100%
rename from src/test/ui/e0119/issue-27403.rs
rename to src/test/ui/error-codes/e0119/issue-27403.rs
diff --git a/src/test/ui/e0119/issue-27403.stderr b/src/test/ui/error-codes/e0119/issue-27403.stderr
similarity index 100%
rename from src/test/ui/e0119/issue-27403.stderr
rename to src/test/ui/error-codes/e0119/issue-27403.stderr
diff --git a/src/test/ui/e0119/issue-28981.rs b/src/test/ui/error-codes/e0119/issue-28981.rs
similarity index 100%
rename from src/test/ui/e0119/issue-28981.rs
rename to src/test/ui/error-codes/e0119/issue-28981.rs
diff --git a/src/test/ui/e0119/issue-28981.stderr b/src/test/ui/error-codes/e0119/issue-28981.stderr
similarity index 100%
rename from src/test/ui/e0119/issue-28981.stderr
rename to src/test/ui/error-codes/e0119/issue-28981.stderr
diff --git a/src/test/ui/e0119/so-37347311.rs b/src/test/ui/error-codes/e0119/so-37347311.rs
similarity index 100%
rename from src/test/ui/e0119/so-37347311.rs
rename to src/test/ui/error-codes/e0119/so-37347311.rs
diff --git a/src/test/ui/e0119/so-37347311.stderr b/src/test/ui/error-codes/e0119/so-37347311.stderr
similarity index 100%
rename from src/test/ui/e0119/so-37347311.stderr
rename to src/test/ui/error-codes/e0119/so-37347311.stderr

From 79816bb9e3dd8d52aad69288b0cd4a4afec4b8e7 Mon Sep 17 00:00:00 2001
From: varkor <github@varkor.com>
Date: Fri, 24 May 2019 22:36:57 +0100
Subject: [PATCH 27/29] Delete stray .stderr

---
 src/test/ui/no-args-non-move-async-closure.stderr | 10 ----------
 1 file changed, 10 deletions(-)
 delete mode 100644 src/test/ui/no-args-non-move-async-closure.stderr

diff --git a/src/test/ui/no-args-non-move-async-closure.stderr b/src/test/ui/no-args-non-move-async-closure.stderr
deleted file mode 100644
index 1b4b86210f840..0000000000000
--- a/src/test/ui/no-args-non-move-async-closure.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error[E0708]: `async` non-`move` closures with arguments are not currently supported
-  --> $DIR/no-args-non-move-async-closure.rs:6:13
-   |
-LL |     let _ = async |x: u8| {};
-   |             ^^^^^^^^^^^^^
-   |
-   = help: consider using `let` statements to manually capture variables by reference before entering an `async move` closure
-
-error: aborting due to previous error
-

From ee7593e0ac83a1b18e7489b852952cd21e2a6947 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Fri, 24 May 2019 15:17:32 -0700
Subject: [PATCH 28/29] Revert changes that belong to separate PR

---
 src/libsyntax/config.rs                       | 13 +------------
 src/libsyntax/ext/derive.rs                   |  7 ++-----
 src/libsyntax/parse/diagnostics.rs            |  2 +-
 .../ui/malformed/malformed-derive-entry.rs    |  2 +-
 .../malformed/malformed-derive-entry.stderr   |  6 ++----
 .../ui/malformed/malformed-special-attrs.rs   |  6 +++---
 .../malformed/malformed-special-attrs.stderr  | 19 ++++++-------------
 7 files changed, 16 insertions(+), 39 deletions(-)

diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs
index 5ccec05dda20b..c82936afa3d9f 100644
--- a/src/libsyntax/config.rs
+++ b/src/libsyntax/config.rs
@@ -94,17 +94,6 @@ impl<'a> StripUnconfigured<'a> {
         if !attr.check_name(sym::cfg_attr) {
             return vec![attr];
         }
-        if attr.tokens.len() == 0 {
-            self.sess.span_diagnostic.struct_span_err(attr.span, "bad `cfg_attr` attribute")
-                .span_label(attr.span, "missing condition and attribute")
-                .note("`cfg_attr` must be of the form: \
-                       `#[cfg_attr(condition, attribute, other_attribute, ...)]`")
-                .note("for more information, visit \
-                       <https://doc.rust-lang.org/reference/conditional-compilation.html\
-                       #the-cfg_attr-attribute>")
-                .emit();
-            return vec![];
-        }
 
         let (cfg_predicate, expanded_attrs) = match attr.parse(self.sess, |parser| {
             parser.expect(&token::OpenDelim(token::Paren))?;
@@ -128,7 +117,7 @@ impl<'a> StripUnconfigured<'a> {
             Ok(result) => result,
             Err(mut e) => {
                 e.emit();
-                return vec![];
+                return Vec::new();
             }
         };
 
diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs
index bbdda4932f117..6e789c4c7086b 100644
--- a/src/libsyntax/ext/derive.rs
+++ b/src/libsyntax/ext/derive.rs
@@ -17,11 +17,8 @@ pub fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec<ast::Attribute>) ->
             return true;
         }
         if !attr.is_meta_item_list() {
-            cx.struct_span_err(attr.span, "bad `derive` attribute")
-                .span_label(attr.span, "missing traits to be derived")
-                .note("`derive` must be of the form: \
-                       `#[derive(Trait1, Trait2, ...)]`")
-                .emit();
+            cx.span_err(attr.span,
+                        "attribute must be of the form `#[derive(Trait1, Trait2, ...)]`");
             return false;
         }
 
diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs
index e93c0bdb8336a..810acc9cc923e 100644
--- a/src/libsyntax/parse/diagnostics.rs
+++ b/src/libsyntax/parse/diagnostics.rs
@@ -618,7 +618,7 @@ impl<'a> Parser<'a> {
         let (span, msg) = match (&self.token, self.subparser_name) {
             (&token::Token::Eof, Some(origin)) => {
                 let sp = self.sess.source_map().next_point(self.span);
-                (sp, format!( "expected expression, found end of {}", origin))
+                (sp, format!("expected expression, found end of {}", origin))
             }
             _ => (self.span, format!(
                 "expected expression, found {}",
diff --git a/src/test/ui/malformed/malformed-derive-entry.rs b/src/test/ui/malformed/malformed-derive-entry.rs
index 1a87cd2d11cb5..36cc58f7e268e 100644
--- a/src/test/ui/malformed/malformed-derive-entry.rs
+++ b/src/test/ui/malformed/malformed-derive-entry.rs
@@ -7,7 +7,7 @@ struct Test2;
 #[derive()] //~ WARNING empty trait list
 struct Test3;
 
-#[derive] //~ ERROR bad `derive` attribute
+#[derive] //~ ERROR attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
 struct Test4;
 
 fn main() {}
diff --git a/src/test/ui/malformed/malformed-derive-entry.stderr b/src/test/ui/malformed/malformed-derive-entry.stderr
index aa1334d21a86a..0dc18f6811117 100644
--- a/src/test/ui/malformed/malformed-derive-entry.stderr
+++ b/src/test/ui/malformed/malformed-derive-entry.stderr
@@ -16,13 +16,11 @@ warning: empty trait list in `derive`
 LL | #[derive()]
    | ^^^^^^^^^^^
 
-error: bad `derive` attribute
+error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
   --> $DIR/malformed-derive-entry.rs:10:1
    |
 LL | #[derive]
-   | ^^^^^^^^^ missing traits to be derived
-   |
-   = note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]`
+   | ^^^^^^^^^
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/malformed/malformed-special-attrs.rs b/src/test/ui/malformed/malformed-special-attrs.rs
index 5f1c4795a89b0..4d00755aea09d 100644
--- a/src/test/ui/malformed/malformed-special-attrs.rs
+++ b/src/test/ui/malformed/malformed-special-attrs.rs
@@ -1,13 +1,13 @@
-#[cfg_attr] //~ ERROR bad `cfg_attr` attribute
+#[cfg_attr] //~ ERROR expected `(`, found end of attribute
 struct S1;
 
 #[cfg_attr = ""] //~ ERROR expected `(`, found `=`
 struct S2;
 
-#[derive] //~ ERROR bad `derive` attribute
+#[derive] //~ ERROR attribute must be of the form
 struct S3;
 
-#[derive = ""] //~ ERROR bad `derive` attribute
+#[derive = ""] //~ ERROR attribute must be of the form
 struct S4;
 
 fn main() {}
diff --git a/src/test/ui/malformed/malformed-special-attrs.stderr b/src/test/ui/malformed/malformed-special-attrs.stderr
index ad8015bf385a5..a93f03589e383 100644
--- a/src/test/ui/malformed/malformed-special-attrs.stderr
+++ b/src/test/ui/malformed/malformed-special-attrs.stderr
@@ -1,11 +1,8 @@
-error: bad `cfg_attr` attribute
+error: expected `(`, found end of attribute
   --> $DIR/malformed-special-attrs.rs:1:1
    |
 LL | #[cfg_attr]
-   | ^^^^^^^^^^^ missing condition and attribute
-   |
-   = note: `cfg_attr` must be of the form: `#[cfg_attr(condition, attribute, other_attribute, ...)]`
-   = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
+   | ^ expected `(`
 
 error: expected `(`, found `=`
   --> $DIR/malformed-special-attrs.rs:4:12
@@ -13,21 +10,17 @@ error: expected `(`, found `=`
 LL | #[cfg_attr = ""]
    |            ^ expected `(`
 
-error: bad `derive` attribute
+error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
   --> $DIR/malformed-special-attrs.rs:7:1
    |
 LL | #[derive]
-   | ^^^^^^^^^ missing traits to be derived
-   |
-   = note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]`
+   | ^^^^^^^^^
 
-error: bad `derive` attribute
+error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
   --> $DIR/malformed-special-attrs.rs:10:1
    |
 LL | #[derive = ""]
-   | ^^^^^^^^^^^^^^ missing traits to be derived
-   |
-   = note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]`
+   | ^^^^^^^^^^^^^^
 
 error: aborting due to 4 previous errors
 

From c91ab64048a32861c48d94f31f31b609addfdda7 Mon Sep 17 00:00:00 2001
From: varkor <github@varkor.com>
Date: Sat, 25 May 2019 00:23:15 +0100
Subject: [PATCH 29/29] Add extra arc_wake

---
 src/test/ui/async-await/auxiliary/arc_wake.rs | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 src/test/ui/async-await/auxiliary/arc_wake.rs

diff --git a/src/test/ui/async-await/auxiliary/arc_wake.rs b/src/test/ui/async-await/auxiliary/arc_wake.rs
new file mode 100644
index 0000000000000..c21886f26f467
--- /dev/null
+++ b/src/test/ui/async-await/auxiliary/arc_wake.rs
@@ -0,0 +1,64 @@
+// edition:2018
+
+use std::sync::Arc;
+use std::task::{
+    Waker, RawWaker, RawWakerVTable,
+};
+
+macro_rules! waker_vtable {
+    ($ty:ident) => {
+        &RawWakerVTable::new(
+            clone_arc_raw::<$ty>,
+            wake_arc_raw::<$ty>,
+            wake_by_ref_arc_raw::<$ty>,
+            drop_arc_raw::<$ty>,
+        )
+    };
+}
+
+pub trait ArcWake {
+    fn wake(self: Arc<Self>);
+
+    fn wake_by_ref(arc_self: &Arc<Self>) {
+        arc_self.clone().wake()
+    }
+
+    fn into_waker(wake: Arc<Self>) -> Waker where Self: Sized
+    {
+        let ptr = Arc::into_raw(wake) as *const ();
+
+        unsafe {
+            Waker::from_raw(RawWaker::new(ptr, waker_vtable!(Self)))
+        }
+    }
+}
+
+unsafe fn increase_refcount<T: ArcWake>(data: *const ()) {
+    // Retain Arc by creating a copy
+    let arc: Arc<T> = Arc::from_raw(data as *const T);
+    let arc_clone = arc.clone();
+    // Forget the Arcs again, so that the refcount isn't decrased
+    let _ = Arc::into_raw(arc);
+    let _ = Arc::into_raw(arc_clone);
+}
+
+unsafe fn clone_arc_raw<T: ArcWake>(data: *const ()) -> RawWaker {
+    increase_refcount::<T>(data);
+    RawWaker::new(data, waker_vtable!(T))
+}
+
+unsafe fn drop_arc_raw<T: ArcWake>(data: *const ()) {
+    // Drop Arc
+    let _: Arc<T> = Arc::from_raw(data as *const T);
+}
+
+unsafe fn wake_arc_raw<T: ArcWake>(data: *const ()) {
+    let arc: Arc<T> = Arc::from_raw(data as *const T);
+    ArcWake::wake(arc);
+}
+
+unsafe fn wake_by_ref_arc_raw<T: ArcWake>(data: *const ()) {
+    let arc: Arc<T> = Arc::from_raw(data as *const T);
+    ArcWake::wake_by_ref(&arc);
+    let _ = Arc::into_raw(arc);
+}