]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #53238 - nrc:update, r=kennytm
authorbors <bors@rust-lang.org>
Mon, 13 Aug 2018 06:42:15 +0000 (06:42 +0000)
committerbors <bors@rust-lang.org>
Mon, 13 Aug 2018 06:42:15 +0000 (06:42 +0000)
Update RLS

Should fix RLS toolstate

76 files changed:
src/bootstrap/native.rs
src/liballoc/string.rs
src/libcore/alloc.rs
src/libcore/char/mod.rs
src/libcore/lib.rs
src/libcore/num/mod.rs
src/libcore/ptr.rs
src/libcore/slice/mod.rs
src/libcore/str/lossy.rs
src/libcore/str/mod.rs
src/libproc_macro/lib.rs
src/libprofiler_builtins/lib.rs
src/librustc/infer/mod.rs
src/librustc/infer/outlives/obligations.rs
src/librustc/lib.rs
src/librustc/traits/fulfill.rs
src/librustc/traits/project.rs
src/librustc/traits/select.rs
src/librustc/ty/error.rs
src/librustc/ty/layout.rs
src/librustc/ty/sty.rs
src/librustc_allocator/lib.rs
src/librustc_codegen_llvm/lib.rs
src/librustc_codegen_llvm/llvm/ffi.rs
src/librustc_codegen_llvm/type_of.rs
src/librustc_codegen_utils/lib.rs
src/librustc_data_structures/base_n.rs
src/librustc_data_structures/bitslice.rs
src/librustc_data_structures/bitvec.rs
src/librustc_data_structures/flock.rs
src/librustc_data_structures/graph/dominators/mod.rs
src/librustc_data_structures/graph/implementation/mod.rs
src/librustc_data_structures/indexed_set.rs
src/librustc_data_structures/lib.rs
src/librustc_data_structures/obligation_forest/mod.rs
src/librustc_data_structures/small_vec.rs
src/librustc_data_structures/snapshot_map/mod.rs
src/librustc_data_structures/snapshot_map/test.rs
src/librustc_data_structures/tiny_list.rs
src/librustc_data_structures/transitive_relation.rs
src/librustc_llvm/lib.rs
src/librustc_lsan/lib.rs
src/librustc_mir/lib.rs
src/librustc_msan/lib.rs
src/librustc_passes/diagnostics.rs
src/librustc_platform_intrinsics/lib.rs
src/librustc_target/spec/aarch64_unknown_netbsd.rs [new file with mode: 0644]
src/librustc_target/spec/mod.rs
src/librustc_typeck/lib.rs
src/librustdoc/html/static/main.js
src/librustdoc/html/static/themes/dark.css
src/librustdoc/html/static/themes/light.css
src/librustdoc/lib.rs
src/libserialize/lib.rs
src/libstd/ffi/c_str.rs
src/libstd/ffi/os_str.rs
src/libstd/keyword_docs.rs
src/libstd/lib.rs
src/libstd/os/raw/mod.rs
src/libstd/path.rs
src/libstd/process.rs
src/libstd/sys/windows/ext/ffi.rs
src/libsyntax/ast.rs
src/libsyntax/lib.rs
src/libsyntax/parse/parser.rs
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/lib.rs
src/libtest/lib.rs
src/test/COMPILER_TESTS.md
src/test/ui/E0642.rs [new file with mode: 0644]
src/test/ui/E0642.stderr [new file with mode: 0644]
src/test/ui/catch-block-type-error.stderr
src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs [new file with mode: 0644]
src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr [new file with mode: 0644]
src/tools/remote-test-server/src/main.rs
src/tools/tidy/src/deps.rs

index 9aeb4e0edaed5d6db137cb3cfeaf857e04305f5b..d5e1ed02b44c173d5e4159b35e92f70a7de0b4b0 100644 (file)
@@ -607,6 +607,7 @@ fn run(self, builder: &Builder) {
             "aarch64-linux-android" => "linux-aarch64",
             "aarch64-unknown-linux-gnu" => "linux-aarch64",
             "aarch64-unknown-linux-musl" => "linux-aarch64",
+            "aarch64-unknown-netbsd" => "BSD-generic64",
             "arm-linux-androideabi" => "android",
             "arm-unknown-linux-gnueabi" => "linux-armv4",
             "arm-unknown-linux-gnueabihf" => "linux-armv4",
index 631779a17a1655e6e261e9864f277d3ae32bc881..dd559df08cce6b356e77e8efa9e538018f0f3507 100644 (file)
@@ -519,10 +519,11 @@ pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
     /// between the two. Not all byte slices are valid strings, however: strings
     /// are required to be valid UTF-8. During this conversion,
     /// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with
-    /// `U+FFFD REPLACEMENT CHARACTER`, which looks like this: �
+    /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: �
     ///
     /// [`u8`]: ../../std/primitive.u8.html
     /// [byteslice]: ../../std/primitive.slice.html
+    /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
     ///
     /// If you are sure that the byte slice is valid UTF-8, and you don't want
     /// to incur the overhead of the conversion, there is an unsafe version
@@ -621,7 +622,7 @@ pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error> {
     }
 
     /// Decode a UTF-16 encoded slice `v` into a `String`, replacing
-    /// invalid data with the replacement character (U+FFFD).
+    /// invalid data with [the replacement character (`U+FFFD`)][U+FFFD].
     ///
     /// Unlike [`from_utf8_lossy`] which returns a [`Cow<'a, str>`],
     /// `from_utf16_lossy` returns a `String` since the UTF-16 to UTF-8
@@ -629,6 +630,7 @@ pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error> {
     ///
     /// [`from_utf8_lossy`]: #method.from_utf8_lossy
     /// [`Cow<'a, str>`]: ../borrow/enum.Cow.html
+    /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
     ///
     /// # Examples
     ///
index 39ec5d6411c16c26b3161414426cc6722f18e809..35e4eea756d41ca0cceef932b15751a3928f1331 100644 (file)
@@ -217,7 +217,7 @@ pub fn padding_needed_for(&self, align: usize) -> usize {
 
         let len_rounded_up = len.wrapping_add(align).wrapping_sub(1)
             & !align.wrapping_sub(1);
-        return len_rounded_up.wrapping_sub(len);
+        len_rounded_up.wrapping_sub(len)
     }
 
     /// Creates a layout describing the record for `n` instances of
@@ -971,9 +971,9 @@ unsafe fn grow_in_place(&mut self,
         // _l <= layout.size()                       [guaranteed by usable_size()]
         //       layout.size() <= new_layout.size()  [required by this method]
         if new_size <= u {
-            return Ok(());
+            Ok(())
         } else {
-            return Err(CannotReallocInPlace);
+            Err(CannotReallocInPlace)
         }
     }
 
@@ -1026,9 +1026,9 @@ unsafe fn shrink_in_place(&mut self,
         //                      layout.size() <= _u  [guaranteed by usable_size()]
         // new_layout.size() <= layout.size()        [required by this method]
         if l <= new_size {
-            return Ok(());
+            Ok(())
         } else {
-            return Err(CannotReallocInPlace);
+            Err(CannotReallocInPlace)
         }
     }
 
index 5be673db3200d8b3696749443520c48bafeb964b..7e1313747eef205f2d92d6e54645b8914159216a 100644 (file)
@@ -312,8 +312,8 @@ fn nth(&mut self, n: usize) -> Option<char> {
                     None
                 }
             },
-            EscapeDefaultState::Done => return None,
-            EscapeDefaultState::Unicode(ref mut i) => return i.nth(n),
+            EscapeDefaultState::Done => None,
+            EscapeDefaultState::Unicode(ref mut i) => i.nth(n),
         }
     }
 
index dc4a2d7c0d7b15ebdc9e3946a4c4fb01538ccddf..178ae62dd3dfa88efdd89de7e878d645e9a6bd22 100644 (file)
@@ -92,6 +92,7 @@
 #![feature(lang_items)]
 #![feature(link_llvm_intrinsics)]
 #![feature(never_type)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(exhaustive_patterns)]
 #![feature(macro_at_most_once_rep)]
 #![feature(no_core)]
index 960853333f6c7179b7a2a9c37f3abfc8ae1ed361..eb63966354b8644f86a8dcc373403b0d566d7d87 100644 (file)
@@ -188,7 +188,8 @@ macro_rules! doc_comment {
 // `Int` + `SignedInt` implemented for signed integers
 macro_rules! int_impl {
     ($SelfT:ty, $ActualT:ident, $UnsignedT:ty, $BITS:expr, $Min:expr, $Max:expr, $Feature:expr,
-     $EndFeature:expr, $rot:expr, $rot_op:expr, $rot_result:expr) => {
+     $EndFeature:expr, $rot:expr, $rot_op:expr, $rot_result:expr, $swap_op:expr, $swapped:expr,
+     $reversed:expr) => {
         doc_comment! {
             concat!("Returns the smallest value that can be represented by this integer type.
 
@@ -380,55 +381,48 @@ pub fn rotate_right(self, n: u32) -> Self {
                 (self as $UnsignedT).rotate_right(n) as Self
             }
         }
-        /// Reverses the byte order of the integer.
-        ///
-        /// # Examples
-        ///
-        /// Please note that this example is shared between integer types.
-        /// Which explains why `i16` is used here.
-        ///
-        /// Basic usage:
-        ///
-        /// ```
-        /// let n: i16 = 0b0000000_01010101;
-        /// assert_eq!(n, 85);
-        ///
-        /// let m = n.swap_bytes();
-        ///
-        /// assert_eq!(m, 0b01010101_00000000);
-        /// assert_eq!(m, 21760);
-        /// ```
-        #[stable(feature = "rust1", since = "1.0.0")]
-        #[rustc_const_unstable(feature = "const_int_ops")]
-        #[inline]
-        pub const fn swap_bytes(self) -> Self {
-            (self as $UnsignedT).swap_bytes() as Self
+        doc_comment! {
+            concat!("Reverses the byte order of the integer.
+
+# Examples
+
+Basic usage:
+
+```
+let n = ", $swap_op, stringify!($SelfT), ";
+
+let m = n.swap_bytes();
+
+assert_eq!(m, ", $swapped, ");
+```"),
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[rustc_const_unstable(feature = "const_int_ops")]
+            #[inline]
+            pub const fn swap_bytes(self) -> Self {
+                (self as $UnsignedT).swap_bytes() as Self
+            }
         }
 
-        /// Reverses the bit pattern of the integer.
-        ///
-        /// # Examples
-        ///
-        /// Please note that this example is shared between integer types.
-        /// Which explains why `i16` is used here.
-        ///
-        /// Basic usage:
-        ///
-        /// ```
-        /// #![feature(reverse_bits)]
-        ///
-        /// let n: i16 = 0b0000000_01010101;
-        /// assert_eq!(n, 85);
-        ///
-        /// let m = n.reverse_bits();
-        ///
-        /// assert_eq!(m as u16, 0b10101010_00000000);
-        /// assert_eq!(m, -22016);
-        /// ```
-        #[unstable(feature = "reverse_bits", issue = "48763")]
-        #[inline]
-        pub fn reverse_bits(self) -> Self {
-            (self as $UnsignedT).reverse_bits() as Self
+        doc_comment! {
+            concat!("Reverses the bit pattern of the integer.
+
+# Examples
+
+Basic usage:
+
+```
+#![feature(reverse_bits)]
+
+let n = ", $swap_op, stringify!($SelfT), ";
+let m = n.reverse_bits();
+
+assert_eq!(m, ", $reversed, ");
+```"),
+            #[unstable(feature = "reverse_bits", issue = "48763")]
+            #[inline]
+            pub fn reverse_bits(self) -> Self {
+                (self as $UnsignedT).reverse_bits() as Self
+            }
         }
 
         doc_comment! {
@@ -2009,50 +2003,57 @@ pub fn is_negative(self) -> bool { self < 0 }
 
 #[lang = "i8"]
 impl i8 {
-    int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa" }
+    int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa", "0x12", "0x12", "0x48" }
 }
 
 #[lang = "i16"]
 impl i16 {
-    int_impl! { i16, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" }
+    int_impl! { i16, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
+        "0x2c48" }
 }
 
 #[lang = "i32"]
 impl i32 {
-    int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" }
+    int_impl! { i32, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301",
+        "0x12345678", "0x78563412", "0x1e6a2c48" }
 }
 
 #[lang = "i64"]
 impl i64 {
     int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "", 12,
-                "0xaa00000000006e1", "0x6e10aa" }
+         "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
+         "0x6a2c48091e6a2c48" }
 }
 
 #[lang = "i128"]
 impl i128 {
     int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728,
         170141183460469231731687303715884105727, "", "", 16,
-        "0x13f40000000000000000000000004f76", "0x4f7613f4"
+        "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
+        "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48"
     }
 }
 
 #[cfg(target_pointer_width = "16")]
 #[lang = "isize"]
 impl isize {
-    int_impl! { isize, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a" }
+    int_impl! { isize, i16, u16, 16, -32768, 32767, "", "", 4, "-0x5ffd", "0x3a", "0x1234",
+        "0x3412", "0x2c48" }
 }
 
 #[cfg(target_pointer_width = "32")]
 #[lang = "isize"]
 impl isize {
-    int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301" }
+    int_impl! { isize, i32, u32, 32, -2147483648, 2147483647, "", "", 8, "0x10000b3", "0xb301",
+        "0x12345678", "0x78563412", "0x1e6a2c48" }
 }
 
 #[cfg(target_pointer_width = "64")]
 #[lang = "isize"]
 impl isize {
     int_impl! { isize, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "",
-        12, "0xaa00000000006e1", "0x6e10aa" }
+        12, "0xaa00000000006e1", "0x6e10aa",  "0x1234567890123456", "0x5634129078563412",
+         "0x6a2c48091e6a2c48" }
 }
 
 // Emits the correct `cttz` call, depending on the size of the type.
@@ -2071,7 +2072,8 @@ macro_rules! uint_cttz_call {
 // `Int` + `UnsignedInt` implemented for unsigned integers
 macro_rules! uint_impl {
     ($SelfT:ty, $ActualT:ty, $BITS:expr, $MaxV:expr, $Feature:expr, $EndFeature:expr,
-        $rot:expr, $rot_op:expr, $rot_result:expr) => {
+        $rot:expr, $rot_op:expr, $rot_result:expr, $swap_op:expr, $swapped:expr,
+        $reversed:expr ) => {
         doc_comment! {
             concat!("Returns the smallest value that can be represented by this integer type.
 
@@ -2263,55 +2265,48 @@ pub fn rotate_right(self, n: u32) -> Self {
             }
         }
 
-        /// Reverses the byte order of the integer.
-        ///
-        /// # Examples
-        ///
-        /// Basic usage:
-        ///
-        /// Please note that this example is shared between integer types.
-        /// Which explains why `u16` is used here.
-        ///
-        /// ```
-        /// let n: u16 = 0b0000000_01010101;
-        /// assert_eq!(n, 85);
-        ///
-        /// let m = n.swap_bytes();
-        ///
-        /// assert_eq!(m, 0b01010101_00000000);
-        /// assert_eq!(m, 21760);
-        /// ```
-        #[stable(feature = "rust1", since = "1.0.0")]
-        #[rustc_const_unstable(feature = "const_int_ops")]
-        #[inline]
-        pub const fn swap_bytes(self) -> Self {
-            unsafe { intrinsics::bswap(self as $ActualT) as Self }
+        doc_comment! {
+            concat!("
+Reverses the byte order of the integer.
+
+# Examples
+
+Basic usage:
+
+```
+let n = ", $swap_op, stringify!($SelfT), ";
+let m = n.swap_bytes();
+
+assert_eq!(m, ", $swapped, ");
+```"),
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[rustc_const_unstable(feature = "const_int_ops")]
+            #[inline]
+            pub const fn swap_bytes(self) -> Self {
+                unsafe { intrinsics::bswap(self as $ActualT) as Self }
+            }
         }
 
-        /// Reverses the bit pattern of the integer.
-        ///
-        /// # Examples
-        ///
-        /// Basic usage:
-        ///
-        /// Please note that this example is shared between integer types.
-        /// Which explains why `u16` is used here.
-        ///
-        /// ```
-        /// #![feature(reverse_bits)]
-        ///
-        /// let n: u16 = 0b0000000_01010101;
-        /// assert_eq!(n, 85);
-        ///
-        /// let m = n.reverse_bits();
-        ///
-        /// assert_eq!(m, 0b10101010_00000000);
-        /// assert_eq!(m, 43520);
-        /// ```
-        #[unstable(feature = "reverse_bits", issue = "48763")]
-        #[inline]
-        pub fn reverse_bits(self) -> Self {
-            unsafe { intrinsics::bitreverse(self as $ActualT) as Self }
+        doc_comment! {
+            concat!("Reverses the bit pattern of the integer.
+
+# Examples
+
+Basic usage:
+
+```
+#![feature(reverse_bits)]
+
+let n = ", $swap_op, stringify!($SelfT), ";
+let m = n.reverse_bits();
+
+assert_eq!(m, ", $reversed, ");
+```"),
+            #[unstable(feature = "reverse_bits", issue = "48763")]
+            #[inline]
+            pub fn reverse_bits(self) -> Self {
+                unsafe { intrinsics::bitreverse(self as $ActualT) as Self }
+            }
         }
 
         doc_comment! {
@@ -3621,7 +3616,7 @@ pub fn wrapping_next_power_of_two(self) -> Self {
 
 #[lang = "u8"]
 impl u8 {
-    uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa" }
+    uint_impl! { u8, u8, 8, 255, "", "", 2, "0x82", "0xa", "0x12", "0x12", "0x48" }
 
 
     /// Checks if the value is within the ASCII range.
@@ -4147,41 +4142,45 @@ pub fn is_ascii_control(&self) -> bool {
 
 #[lang = "u16"]
 impl u16 {
-    uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a" }
+    uint_impl! { u16, u16, 16, 65535, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48" }
 }
 
 #[lang = "u32"]
 impl u32 {
-    uint_impl! { u32, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" }
+    uint_impl! { u32, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301", "0x12345678",
+        "0x78563412", "0x1e6a2c48" }
 }
 
 #[lang = "u64"]
 impl u64 {
-    uint_impl! { u64, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa" }
+    uint_impl! { u64, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa",
+        "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48" }
 }
 
 #[lang = "u128"]
 impl u128 {
     uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16,
-        "0x13f40000000000000000000000004f76", "0x4f7613f4" }
+        "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
+        "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48" }
 }
 
 #[cfg(target_pointer_width = "16")]
 #[lang = "usize"]
 impl usize {
-    uint_impl! { usize, u16, 16, 65536, "", "", 4, "0xa003", "0x3a" }
+    uint_impl! { usize, u16, 16, 65536, "", "", 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48" }
 }
 #[cfg(target_pointer_width = "32")]
 #[lang = "usize"]
 impl usize {
-    uint_impl! { usize, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301" }
+    uint_impl! { usize, u32, 32, 4294967295, "", "", 8, "0x10000b3", "0xb301", "0x12345678",
+        "0x78563412", "0x1e6a2c48" }
 }
 
 #[cfg(target_pointer_width = "64")]
 #[lang = "usize"]
 impl usize {
-    uint_impl! { usize, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1",
-        "0x6e10aa" }
+    uint_impl! { usize, u64, 64, 18446744073709551615, "", "", 12, "0xaa00000000006e1", "0x6e10aa",
+        "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48" }
 }
 
 /// A classification of floating point numbers.
index c8670e5ec34d347b9f2f5aef6180ee29f10a0b4f..61033e7511253c858ee790bbbd2d0f292b48c121 100644 (file)
@@ -2318,7 +2318,7 @@ fn mod_inv(x: usize, m: usize) -> usize {
 
         let table_inverse = INV_TABLE_MOD_16[(x & (INV_TABLE_MOD - 1)) >> 1];
         if m <= INV_TABLE_MOD {
-            return table_inverse & (m - 1);
+            table_inverse & (m - 1)
         } else {
             // We iterate "up" using the following formula:
             //
@@ -2405,7 +2405,7 @@ fn mod_inv(x: usize, m: usize) -> usize {
     }
 
     // Cannot be aligned at all.
-    return usize::max_value();
+    usize::max_value()
 }
 
 
index 187ac3c7a7f06ab7b1bea4c1ea6f2e4fa2466bf5..88fdd767638934774afb20d85215c624f13001f0 100644 (file)
@@ -1727,7 +1727,7 @@ fn gcd(a: usize, b: usize) -> usize {
                     ctz_b = ::intrinsics::cttz_nonzero(b);
                 }
             }
-            return a << k;
+            a << k
         }
         let gcd: usize = gcd(::mem::size_of::<T>(), ::mem::size_of::<U>());
         let ts: usize = ::mem::size_of::<U>() / gcd;
@@ -1737,7 +1737,7 @@ fn gcd(a: usize, b: usize) -> usize {
         let us_len = self.len() / ts * us;
         // And how many `T`s will be in the trailing slice!
         let ts_len = self.len() % ts;
-        return (us_len, ts_len);
+        (us_len, ts_len)
     }
 
     /// Transmute the slice to a slice of another type, ensuring aligment of the types is
@@ -1782,13 +1782,13 @@ pub unsafe fn align_to<U>(&self) -> (&[T], &[U], &[T]) {
         let ptr = self.as_ptr();
         let offset = ::ptr::align_offset(ptr, ::mem::align_of::<U>());
         if offset > self.len() {
-            return (self, &[], &[]);
+            (self, &[], &[])
         } else {
             let (left, rest) = self.split_at(offset);
             let (us_len, ts_len) = rest.align_to_offsets::<U>();
-            return (left,
-                    from_raw_parts(rest.as_ptr() as *const U, us_len),
-                    from_raw_parts(rest.as_ptr().offset((rest.len() - ts_len) as isize), ts_len))
+            (left,
+             from_raw_parts(rest.as_ptr() as *const U, us_len),
+             from_raw_parts(rest.as_ptr().offset((rest.len() - ts_len) as isize), ts_len))
         }
     }
 
@@ -1834,14 +1834,14 @@ pub unsafe fn align_to_mut<U>(&mut self) -> (&mut [T], &mut [U], &mut [T]) {
         let ptr = self.as_ptr();
         let offset = ::ptr::align_offset(ptr, ::mem::align_of::<U>());
         if offset > self.len() {
-            return (self, &mut [], &mut []);
+            (self, &mut [], &mut [])
         } else {
             let (left, rest) = self.split_at_mut(offset);
             let (us_len, ts_len) = rest.align_to_offsets::<U>();
             let mut_ptr = rest.as_mut_ptr();
-            return (left,
-                    from_raw_parts_mut(mut_ptr as *mut U, us_len),
-                    from_raw_parts_mut(mut_ptr.offset((rest.len() - ts_len) as isize), ts_len))
+            (left,
+             from_raw_parts_mut(mut_ptr as *mut U, us_len),
+             from_raw_parts_mut(mut_ptr.offset((rest.len() - ts_len) as isize), ts_len))
         }
     }
 }
index 5cfb36d3b195bbcc2673673b2c2155cd74f8975f..186d6adbc91cf67ecb6c88df1acf286c943cebf4 100644 (file)
@@ -146,7 +146,7 @@ macro_rules! error { () => ({
             broken: &[],
         };
         self.source = &[];
-        return Some(r);
+        Some(r)
     }
 }
 
index 356534a91879cde36e2ef26405b6e1030c910a7b..810d19df0c5ba460a8dd707193c406c4af08a13f 100644 (file)
@@ -244,7 +244,10 @@ pub fn valid_up_to(&self) -> usize { self.valid_up_to }
     ///   The length provided is that of the invalid byte sequence
     ///   that starts at the index given by `valid_up_to()`.
     ///   Decoding should resume after that sequence
-    ///   (after inserting a U+FFFD REPLACEMENT CHARACTER) in case of lossy decoding.
+    ///   (after inserting a [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD]) in case of
+    ///   lossy decoding.
+    ///
+    /// [U+FFFD]: ../../std/char/constant.REPLACEMENT_CHARACTER.html
     #[stable(feature = "utf8_error_error_len", since = "1.20.0")]
     pub fn error_len(&self) -> Option<usize> {
         self.error_len.map(|len| len as usize)
@@ -1567,7 +1570,7 @@ macro_rules! next { () => {{
 #[unstable(feature = "str_internals", issue = "0")]
 #[inline]
 pub fn utf8_char_width(b: u8) -> usize {
-    return UTF8_CHAR_WIDTH[b as usize] as usize;
+    UTF8_CHAR_WIDTH[b as usize] as usize
 }
 
 /// Mask of the value bits of a continuation byte.
index bf6e4a3aaa40585cf8b668908b449ae94ca56a65..fec90008c6701ec2d074091d68c8302cf58ca8fd 100644 (file)
@@ -31,6 +31,7 @@
        test(no_crate_inject, attr(deny(warnings))),
        test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
 
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(rustc_private)]
 #![feature(staged_api)]
 #![feature(lang_items)]
index 6d0d6d115b7163528e3e0a54737ce114124ffe32..a85593253b100f8f184ab7a336335ef7961ea5e8 100644 (file)
@@ -15,4 +15,5 @@
             reason = "internal implementation detail of rustc right now",
             issue = "0")]
 #![allow(unused_features)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(staged_api)]
index 0b84c6a0aa77abdee3a7fc4cf09290036d10e9c9..eed6215150fdbf829eafa24d7b22fcf7d54d1e0b 100644 (file)
@@ -709,7 +709,7 @@ fn commit_from(&self, snapshot: CombinedSnapshot<'a, 'tcx>) {
 
         self.projection_cache
             .borrow_mut()
-            .commit(projection_cache_snapshot);
+            .commit(&projection_cache_snapshot);
         self.type_variables
             .borrow_mut()
             .commit(type_snapshot);
index c74783f5e4db5ce3cbf943ab9c3b526b15db920f..3598d66060bf227363a3277073369dd30b21f7fc 100644 (file)
@@ -151,12 +151,14 @@ pub fn process_registered_region_obligations(
         debug!("process_registered_region_obligations()");
 
         // pull out the region obligations with the given `body_id` (leaving the rest)
-        let my_region_obligations = {
+        let mut my_region_obligations = Vec::with_capacity(self.region_obligations.borrow().len());
+        {
             let mut r_o = self.region_obligations.borrow_mut();
-            let my_r_o = r_o.drain_filter(|(ro_body_id, _)| *ro_body_id == body_id)
-                            .map(|(_, obligation)| obligation).collect::<Vec<_>>();
-            my_r_o
-        };
+            my_region_obligations.extend(
+                r_o.drain_filter(|(ro_body_id, _)| *ro_body_id == body_id)
+                   .map(|(_, obligation)| obligation)
+            );
+        }
 
         let outlives = &mut TypeOutlives::new(
             self,
index 55a5e342947fb461c2ff4dc96f9a37432295c182..e250b7549a0520484e6ee7e02da32d4ec1f36c5c 100644 (file)
@@ -51,6 +51,7 @@
 #![feature(never_type)]
 #![feature(exhaustive_patterns)]
 #![feature(extern_types)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(non_exhaustive)]
 #![feature(proc_macro_internals)]
 #![feature(quote)]
index b7d3ad76588f7253a8d596a4412eb76b675e8ce2..5113f3cde32843b588faee72e8e485fd5d0e2677 100644 (file)
@@ -146,7 +146,7 @@ fn normalize_projection_type<'a, 'gcx>(&mut self,
         debug!("normalize_projection_type(projection_ty={:?})",
                projection_ty);
 
-        assert!(!projection_ty.has_escaping_regions());
+        debug_assert!(!projection_ty.has_escaping_regions());
 
         // FIXME(#20304) -- cache
 
index 1ce60d8f05599e630905b5cf04fa5571106c8492..1224cdd76d85ba4891f1fea429392fd73bab3d62 100644 (file)
@@ -1142,7 +1142,7 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>(
                 if !is_default {
                     true
                 } else if obligation.param_env.reveal == Reveal::All {
-                    assert!(!poly_trait_ref.needs_infer());
+                    debug_assert!(!poly_trait_ref.needs_infer());
                     if !poly_trait_ref.needs_subst() {
                         true
                     } else {
@@ -1668,15 +1668,15 @@ pub fn snapshot(&mut self) -> ProjectionCacheSnapshot {
     }
 
     pub fn rollback_to(&mut self, snapshot: ProjectionCacheSnapshot) {
-        self.map.rollback_to(snapshot.snapshot);
+        self.map.rollback_to(&snapshot.snapshot);
     }
 
     pub fn rollback_skolemized(&mut self, snapshot: &ProjectionCacheSnapshot) {
         self.map.partial_rollback(&snapshot.snapshot, &|k| k.ty.has_re_skol());
     }
 
-    pub fn commit(&mut self, snapshot: ProjectionCacheSnapshot) {
-        self.map.commit(snapshot.snapshot);
+    pub fn commit(&mut self, snapshot: &ProjectionCacheSnapshot) {
+        self.map.commit(&snapshot.snapshot);
     }
 
     /// Try to start normalize `key`; returns an error if
index 1e3fe70535bcc591e4206a1c7d678d317a91aaec..fbd12c9fe8ecaf796a8f2be66c3c5944fa69d979 100644 (file)
@@ -563,7 +563,7 @@ fn commit_if_ok<T, E, F>(&mut self, f: F) -> Result<T, E> where
     pub fn select(&mut self, obligation: &TraitObligation<'tcx>)
                   -> SelectionResult<'tcx, Selection<'tcx>> {
         debug!("select({:?})", obligation);
-        assert!(!obligation.predicate.has_escaping_regions());
+        debug_assert!(!obligation.predicate.has_escaping_regions());
 
         let stack = self.push_stack(TraitObligationStackList::empty(), obligation);
 
@@ -662,7 +662,7 @@ fn evaluate_predicate_recursively<'o>(&mut self,
 
         match obligation.predicate {
             ty::Predicate::Trait(ref t) => {
-                assert!(!t.has_escaping_regions());
+                debug_assert!(!t.has_escaping_regions());
                 let obligation = obligation.with(t.clone());
                 self.evaluate_trait_predicate_recursively(previous_stack, obligation)
             }
@@ -1076,7 +1076,7 @@ fn candidate_from_obligation<'o>(&mut self,
         debug!("candidate_from_obligation(cache_fresh_trait_pred={:?}, obligation={:?})",
                cache_fresh_trait_pred,
                stack);
-        assert!(!stack.obligation.predicate.has_escaping_regions());
+        debug_assert!(!stack.obligation.predicate.has_escaping_regions());
 
         if let Some(c) = self.check_candidate_cache(stack.obligation.param_env,
                                                     &cache_fresh_trait_pred) {
@@ -1586,7 +1586,7 @@ fn match_projection(&mut self,
                         snapshot: &infer::CombinedSnapshot<'cx, 'tcx>)
                         -> bool
     {
-        assert!(!skol_trait_ref.has_escaping_regions());
+        debug_assert!(!skol_trait_ref.has_escaping_regions());
         if self.infcx.at(&obligation.cause, obligation.param_env)
                      .sup(ty::Binder::dummy(skol_trait_ref), trait_bound).is_err() {
             return false;
index bcbd8a529f6a7e9f87e6586e459c9ed1f92267a5..49fffaa375b2f705c91f891cdbdb24d38cb57433 100644 (file)
@@ -13,7 +13,7 @@
 use std::fmt;
 use rustc_target::spec::abi;
 use syntax::ast;
-use errors::DiagnosticBuilder;
+use errors::{Applicability, DiagnosticBuilder};
 use syntax_pos::Span;
 
 use hir;
@@ -250,6 +250,21 @@ pub fn note_and_explain_type_err(self,
                     db.note("no two closures, even if identical, have the same type");
                     db.help("consider boxing your closure and/or using it as a trait object");
                 }
+                match (&values.found.sty, &values.expected.sty) { // Issue #53280
+                    (ty::TyInfer(ty::IntVar(_)), ty::TyFloat(_)) => {
+                        if let Ok(snippet) = self.sess.codemap().span_to_snippet(sp) {
+                            if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') {
+                                db.span_suggestion_with_applicability(
+                                    sp,
+                                    "use a float literal",
+                                    format!("{}.0", snippet),
+                                    Applicability::MachineApplicable
+                                );
+                            }
+                        }
+                    },
+                    _ => {}
+                }
             },
             OldStyleLUB(err) => {
                 db.note("this was previously accepted by the compiler but has been phased out");
index 81cc897232ab05da5b11bfc8f0885a56971a890b..0da4d5ddea2f264a5bea4abb08f7d51866f6ef1a 100644 (file)
@@ -466,7 +466,7 @@ enum StructKind {
         let univariant = |fields: &[TyLayout], repr: &ReprOptions, kind| {
             Ok(tcx.intern_layout(univariant_uninterned(fields, repr, kind)?))
         };
-        assert!(!ty.has_infer_types());
+        debug_assert!(!ty.has_infer_types());
 
         Ok(match ty.sty {
             // Basic scalars.
@@ -1283,7 +1283,7 @@ pub fn compute(ty: Ty<'tcx>,
                    tcx: TyCtxt<'a, 'tcx, 'tcx>,
                    param_env: ty::ParamEnv<'tcx>)
                    -> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
-        assert!(!ty.has_infer_types());
+        debug_assert!(!ty.has_infer_types());
 
         // First try computing a static layout.
         let err = match tcx.layout_of(param_env.and(ty)) {
@@ -1300,7 +1300,7 @@ pub fn compute(ty: Ty<'tcx>,
                 let tail = tcx.struct_tail(pointee);
                 match tail.sty {
                     ty::TyParam(_) | ty::TyProjection(_) => {
-                        assert!(tail.has_param_types() || tail.has_self_ty());
+                        debug_assert!(tail.has_param_types() || tail.has_self_ty());
                         Ok(SizeSkeleton::Pointer {
                             non_zero,
                             tail: tcx.erase_regions(&tail)
index 96b4edce86b30f5603b33af3f259b4bd62ce213e..65e31f21792d209fc42d3fddbbff94f98db1d094 100644 (file)
@@ -708,7 +708,7 @@ pub fn erase_self_ty(tcx: TyCtxt<'a, 'gcx, 'tcx>,
     pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, self_ty: Ty<'tcx>)
         -> ty::TraitRef<'tcx>  {
         // otherwise the escaping regions would be captured by the binder
-        assert!(!self_ty.has_escaping_regions());
+        debug_assert!(!self_ty.has_escaping_regions());
 
         ty::TraitRef {
             def_id: self.def_id,
@@ -753,7 +753,7 @@ impl<T> Binder<T> {
     pub fn dummy<'tcx>(value: T) -> Binder<T>
         where T: TypeFoldable<'tcx>
     {
-        assert!(!value.has_escaping_regions());
+        debug_assert!(!value.has_escaping_regions());
         Binder(value)
     }
 
@@ -1247,7 +1247,7 @@ pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
                         -> ty::ProjectionPredicate<'tcx>
     {
         // otherwise the escaping regions would be captured by the binders
-        assert!(!self_ty.has_escaping_regions());
+        debug_assert!(!self_ty.has_escaping_regions());
 
         ty::ProjectionPredicate {
             projection_ty: ty::ProjectionTy {
index b217d3665a24542306a6dceb838acbf80f7ab428..a920bb0f2b91800522f83a5722bf63aa1138405d 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(rustc_private)]
 
 #[macro_use] extern crate log;
index 4572f5891a420a20c1e77acd1542fffd04c2e114..390a1df02b88ef0055db39744b0cde198e3b4792 100644 (file)
@@ -26,6 +26,7 @@
 #![feature(in_band_lifetimes)]
 #![allow(unused_attributes)]
 #![feature(libc)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(quote)]
 #![feature(range_contains)]
 #![feature(rustc_diagnostic_macros)]
index a894f8e2fdb96a95686ceec3986ba3b4308870ba..68a21a537070bb8d24672b531159796a82a2677a 100644 (file)
@@ -1564,7 +1564,7 @@ pub fn LLVMRustWriteArchive(Dst: *const c_char,
                                 -> LLVMRustResult;
     pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
                                     Name: *const c_char,
-                                    Child: Option<&'a ArchiveChild>)
+                                    Child: Option<&ArchiveChild<'a>>)
                                     -> &'a mut RustArchiveMember<'a>;
     pub fn LLVMRustArchiveMemberFree(Member: &'a mut RustArchiveMember<'a>);
 
index 5fd4f15acd1574c719cda4a117994e0c2bd0f3b6..69d91b327283d87050616d6b3494423c367cadb9 100644 (file)
@@ -89,7 +89,7 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
                     Type::struct_(cx, &[fill], packed)
                 }
                 Some(ref name) => {
-                    let mut llty = Type::named_struct(cx, name);
+                    let llty = Type::named_struct(cx, name);
                     llty.set_struct_body(&[fill], packed);
                     llty
                 }
index 3ff2388beea2ad55af1bbf216c3c513dcc777eee..635819e94e8679bfed6b729350c25cb400ce79c9 100644 (file)
@@ -19,6 +19,7 @@
 #![feature(box_patterns)]
 #![feature(box_syntax)]
 #![feature(custom_attribute)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![allow(unused_attributes)]
 #![feature(quote)]
 #![feature(rustc_diagnostic_macros)]
index d333b6393b9cc4466c32a4ac56fec2238db1040b..d3b47daa5b4b89aa7569b7167736bfe924270fb7 100644 (file)
@@ -17,7 +17,7 @@
 pub const ALPHANUMERIC_ONLY: usize = 62;
 pub const CASE_INSENSITIVE: usize = 36;
 
-const BASE_64: &'static [u8; MAX_BASE as usize] =
+const BASE_64: &[u8; MAX_BASE as usize] =
     b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@$";
 
 #[inline]
@@ -37,7 +37,8 @@ pub fn push_str(mut n: u128, base: usize, output: &mut String) {
             break;
         }
     }
-    &mut s[0..index].reverse();
+    s[0..index].reverse();
+
     output.push_str(str::from_utf8(&s[0..index]).unwrap());
 }
 
index b8f191c2f57d8d68fcb2ce3447d6b9c9c73a11c7..a63033c436528bc866e32f5877f17f86be911a32 100644 (file)
@@ -75,7 +75,7 @@ fn bit_lookup(bit: usize) -> BitLookup {
     let word = bit / word_bits;
     let bit_in_word = bit % word_bits;
     let bit_mask = 1 << bit_in_word;
-    BitLookup { word: word, bit_in_word: bit_in_word, bit_mask: bit_mask }
+    BitLookup { word, bit_in_word, bit_mask }
 }
 
 pub fn bits_to_string(words: &[Word], bits: usize) -> String {
@@ -105,7 +105,8 @@ pub fn bits_to_string(words: &[Word], bits: usize) -> String {
         sep = '|';
     }
     result.push(']');
-    return result
+
+    result
 }
 
 #[inline]
index 6e8a45d034250e2d4f7b195aa45c11d564c1561d..49ab3e58812dcfb703ea926798cc610a7ed57024 100644 (file)
@@ -196,7 +196,8 @@ fn next(&mut self) -> Option<C> {
         self.current >>= offset;
         self.current >>= 1; // shift otherwise overflows for 0b1000_0000_…_0000
         self.idx += offset + 1;
-        return Some(C::new(self.idx - 1));
+
+        Some(C::new(self.idx - 1))
     }
 
     fn size_hint(&self) -> (usize, Option<usize>) {
@@ -299,7 +300,7 @@ pub fn merge(&mut self, read: R, write: R) -> bool {
             let v1 = vector[write_index];
             let v2 = v1 | vector[read_index];
             vector[write_index] = v2;
-            changed = changed | (v1 != v2);
+            changed |= v1 != v2;
         }
         changed
     }
index ff1ebb11b72215df9dcc966d327396509249ddfb..3f248dadb66c14b02a556996ffacc77abb4a29bd 100644 (file)
@@ -254,8 +254,8 @@ mod imp {
     type ULONG_PTR = usize;
 
     type LPOVERLAPPED = *mut OVERLAPPED;
-    const LOCKFILE_EXCLUSIVE_LOCK: DWORD = 0x00000002;
-    const LOCKFILE_FAIL_IMMEDIATELY: DWORD = 0x00000001;
+    const LOCKFILE_EXCLUSIVE_LOCK: DWORD = 0x0000_0002;
+    const LOCKFILE_FAIL_IMMEDIATELY: DWORD = 0x0000_0001;
 
     const FILE_SHARE_DELETE: DWORD = 0x4;
     const FILE_SHARE_READ: DWORD = 0x1;
index d134fad2855bbdd999907698e10e7e17cfd8e07b..e54147cbe7c8793a9e4d36925f14c5d5c296d4e7 100644 (file)
@@ -107,7 +107,8 @@ fn intersect<Node: Idx>(
             node2 = immediate_dominators[node2].unwrap();
         }
     }
-    return node1;
+
+    node1
 }
 
 #[derive(Clone, Debug)]
index cf9403db658f4fa9fcb5a6dcb4cec900de1b5b76..baac75658686545e0eddd4f3ee84b7163b4fc7eb 100644 (file)
@@ -90,7 +90,7 @@ pub struct Direction {
 
 impl NodeIndex {
     /// Returns unique id (unique with respect to the graph holding associated node).
-    pub fn node_id(&self) -> usize {
+    pub fn node_id(self) -> usize {
         self.0
     }
 }
@@ -187,7 +187,7 @@ pub fn add_edge(&mut self, source: NodeIndex, target: NodeIndex, data: E) -> Edg
         self.nodes[source.0].first_edge[OUTGOING.repr] = idx;
         self.nodes[target.0].first_edge[INCOMING.repr] = idx;
 
-        return idx;
+        idx
     }
 
     pub fn edge(&self, idx: EdgeIndex) -> &Edge<E> {
@@ -261,8 +261,8 @@ pub fn depth_traverse<'a>(
         DepthFirstTraversal::with_start_node(self, start, direction)
     }
 
-    pub fn nodes_in_postorder<'a>(
-        &'a self,
+    pub fn nodes_in_postorder(
+        &self,
         direction: Direction,
         entry_node: NodeIndex,
     ) -> Vec<NodeIndex> {
index 2e95a45479c4f966fd0feb956eaa538780d0f944..404272d69c863e6314efba24865a92971878fac9 100644 (file)
@@ -59,16 +59,13 @@ fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<IdxSetBuf<T>, D::Err
 
 // pnkfelix wants to have this be `IdxSet<T>([Word]) and then pass
 // around `&mut IdxSet<T>` or `&IdxSet<T>`.
-//
-// WARNING: Mapping a `&IdxSetBuf<T>` to `&IdxSet<T>` (at least today)
-// requires a transmute relying on representation guarantees that may
-// not hold in the future.
 
 /// Represents a set (or packed family of sets), of some element type
 /// E, where each E is identified by some unique index type `T`.
 ///
 /// In other words, `T` is the type used to index into the bitslice
 /// this type uses to represent the set of object it holds.
+#[repr(transparent)]
 pub struct IdxSet<T: Idx> {
     _pd: PhantomData<fn(&T)>,
     bits: [Word],
@@ -134,11 +131,11 @@ pub fn new_empty(universe_size: usize) -> Self {
 
 impl<T: Idx> IdxSet<T> {
     unsafe fn from_slice(s: &[Word]) -> &Self {
-        mem::transmute(s) // (see above WARNING)
+        &*(s as *const [Word] as *const Self)
     }
 
     unsafe fn from_slice_mut(s: &mut [Word]) -> &mut Self {
-        mem::transmute(s) // (see above WARNING)
+        &mut *(s as *mut [Word] as *mut Self)
     }
 }
 
@@ -326,7 +323,7 @@ fn test_set_up_to() {
 #[test]
 fn test_new_filled() {
     for i in 0..128 {
-        let mut idx_buf = IdxSetBuf::new_filled(i);
+        let idx_buf = IdxSetBuf::new_filled(i);
         let elems: Vec<usize> = idx_buf.iter().collect();
         let expected: Vec<usize> = (0..i).collect();
         assert_eq!(elems, expected);
index 3aa15f472a2740f5538ff8ae49514922f07d4f17..bfe7273dc4c7a4762181def645b0fc1eda2a0add 100644 (file)
@@ -26,6 +26,7 @@
 #![feature(specialization)]
 #![feature(optin_builtin_traits)]
 #![feature(macro_vis_matcher)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(allow_internal_unstable)]
 #![feature(vec_resize_with)]
 
index 0d6cf260dcd98978bf18cc33416c906ccb77bb70..7ef88852685d5bd33a836f193e20bad0b6834c2b 100644 (file)
@@ -573,7 +573,7 @@ fn apply_rewrites(&mut self, node_rewrites: &[usize]) {
         }
 
         let mut kill_list = vec![];
-        for (predicate, index) in self.waiting_cache.iter_mut() {
+        for (predicate, index) in &mut self.waiting_cache {
             let new_index = node_rewrites[index.get()];
             if new_index >= nodes_len {
                 kill_list.push(predicate.clone());
index 76b01beb4bad3dbcd524fb2c07bee6ccb210f434..e958fd7da613e4ab54c5ef58d21ec1a1fd50cbb5 100644 (file)
@@ -210,7 +210,12 @@ impl<A> Decodable for SmallVec<A>
           A::Element: Decodable {
     fn decode<D: Decoder>(d: &mut D) -> Result<SmallVec<A>, D::Error> {
         d.read_seq(|d, len| {
-            (0..len).map(|i| d.read_seq_elt(i, |d| Decodable::decode(d))).collect()
+            let mut vec = SmallVec::with_capacity(len);
+            // FIXME(#48994) - could just be collected into a Result<SmallVec, D::Error>
+            for i in 0..len {
+                vec.push(d.read_seq_elt(i, |d| Decodable::decode(d))?);
+            }
+            Ok(vec)
         })
     }
 }
index 6ee8c3579f5437c4d0f4602dd5bc339a2abebaee..5030bf98dffd54f0b90e5bb5195da0e0bc3e72c9 100644 (file)
@@ -92,7 +92,7 @@ pub fn get(&self, key: &K) -> Option<&V> {
     pub fn snapshot(&mut self) -> Snapshot {
         self.undo_log.push(UndoLog::OpenSnapshot);
         let len = self.undo_log.len() - 1;
-        Snapshot { len: len }
+        Snapshot { len }
     }
 
     fn assert_open_snapshot(&self, snapshot: &Snapshot) {
@@ -103,8 +103,8 @@ fn assert_open_snapshot(&self, snapshot: &Snapshot) {
         });
     }
 
-    pub fn commit(&mut self, snapshot: Snapshot) {
-        self.assert_open_snapshot(&snapshot);
+    pub fn commit(&mut self, snapshot: &Snapshot) {
+        self.assert_open_snapshot(snapshot);
         if snapshot.len == 0 {
             // The root snapshot.
             self.undo_log.truncate(0);
@@ -135,8 +135,8 @@ pub fn partial_rollback<F>(&mut self,
         }
     }
 
-    pub fn rollback_to(&mut self, snapshot: Snapshot) {
-        self.assert_open_snapshot(&snapshot);
+    pub fn rollback_to(&mut self, snapshot: &Snapshot) {
+        self.assert_open_snapshot(snapshot);
         while self.undo_log.len() > snapshot.len + 1 {
             let entry = self.undo_log.pop().unwrap();
             self.reverse(entry);
index 4114082839b0b9a6a3a10e4f9cde5ba9f26c4031..b163e0fe420ec7f222338c7b4dfc9c7e52679576 100644 (file)
@@ -20,7 +20,7 @@ fn basic() {
     map.insert(44, "fourty-four");
     assert_eq!(map[&44], "fourty-four");
     assert_eq!(map.get(&33), None);
-    map.rollback_to(snapshot);
+    map.rollback_to(&snapshot);
     assert_eq!(map[&22], "twenty-two");
     assert_eq!(map.get(&33), None);
     assert_eq!(map.get(&44), None);
@@ -33,7 +33,7 @@ fn out_of_order() {
     map.insert(22, "twenty-two");
     let snapshot1 = map.snapshot();
     let _snapshot2 = map.snapshot();
-    map.rollback_to(snapshot1);
+    map.rollback_to(&snapshot1);
 }
 
 #[test]
@@ -43,8 +43,8 @@ fn nested_commit_then_rollback() {
     let snapshot1 = map.snapshot();
     let snapshot2 = map.snapshot();
     map.insert(22, "thirty-three");
-    map.commit(snapshot2);
+    map.commit(&snapshot2);
     assert_eq!(map[&22], "thirty-three");
-    map.rollback_to(snapshot1);
+    map.rollback_to(&snapshot1);
     assert_eq!(map[&22], "twenty-two");
 }
index c12fc22baf02021db2514a854d0f79e731b1b3cd..e1bfdf35b274e0d31ff7be040948e0319cf9d0bb 100644 (file)
@@ -107,7 +107,8 @@ fn remove_next(&mut self, data: &T) -> bool {
         };
 
         self.next = new_next;
-        return true
+
+        true
     }
 
     fn len(&self) -> usize {
index a8124fb7c5b622bdbed52ca8f2434598f178fcbd..18a1e9129b34284bd6949794742d7b83bedba6ef 100644 (file)
@@ -77,7 +77,7 @@ fn add_index(&mut self, a: T) -> Index {
             ..
         } = self;
 
-        map.entry(a.clone())
+        *map.entry(a.clone())
            .or_insert_with(|| {
                elements.push(a);
 
@@ -86,7 +86,6 @@ fn add_index(&mut self, a: T) -> Index {
 
                Index(elements.len() - 1)
            })
-           .clone()
     }
 
     /// Applies the (partial) function to each edge and returns a new
@@ -98,14 +97,12 @@ pub fn maybe_map<F, U>(&self, mut f: F) -> Option<TransitiveRelation<U>>
     {
         let mut result = TransitiveRelation::new();
         for edge in &self.edges {
-            let r = f(&self.elements[edge.source.0]).and_then(|source| {
+            f(&self.elements[edge.source.0]).and_then(|source| {
                 f(&self.elements[edge.target.0]).and_then(|target| {
-                    Some(result.add(source, target))
+                    result.add(source, target);
+                    Some(())
                 })
-            });
-            if r.is_none() {
-                return None;
-            }
+            })?;
         }
         Some(result)
     }
@@ -372,7 +369,7 @@ fn compute_closure(&self) -> BitMatrix<usize, usize> {
         let mut changed = true;
         while changed {
             changed = false;
-            for edge in self.edges.iter() {
+            for edge in &self.edges {
                 // add an edge from S -> T
                 changed |= matrix.add(edge.source.0, edge.target.0);
 
index ffa97bd6fa59d3a385d5738440a54d8527134871..387660473a887dea0a2524a4bdceefbd0b78b515 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(static_nobundle)]
 
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
index 0c78fd74a234ee01091ae813c400b30afc8c575f..b3ba86ad8a4b32af8f7f6629cca53f8891221b8f 100644 (file)
@@ -10,6 +10,7 @@
 
 #![sanitizer_runtime]
 #![feature(alloc_system)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(sanitizer_runtime)]
 #![feature(staged_api)]
 #![no_std]
index 05c843096d27d1f2655f219eb3fc26696a789d6e..42682c34407cab08c713731ac8fc89d4dadbc097 100644 (file)
@@ -14,6 +14,7 @@
 
 */
 
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(infer_outlives_requirements)]
 #![feature(in_band_lifetimes)]
 #![feature(slice_patterns)]
index 0c78fd74a234ee01091ae813c400b30afc8c575f..b3ba86ad8a4b32af8f7f6629cca53f8891221b8f 100644 (file)
@@ -10,6 +10,7 @@
 
 #![sanitizer_runtime]
 #![feature(alloc_system)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(sanitizer_runtime)]
 #![feature(staged_api)]
 #![no_std]
index f1ec3371c3b9ab0400bd0b3a60daecff1497dcd3..f1d0a4fee341e92502ddb9906fc58c3684d1c6d0 100644 (file)
@@ -261,6 +261,27 @@ fn foo() {}
 ```
 "##,
 
+E0642: r##"
+Trait methods currently cannot take patterns as arguments.
+
+Example of erroneous code:
+
+```compile_fail,E0642
+trait Foo {
+    fn foo((x, y): (i32, i32)); // error: patterns aren't allowed
+                                //        in trait methods
+}
+```
+
+You can instead use a single name for the argument:
+
+```
+trait Foo {
+    fn foo(x_and_y: (i32, i32)); // ok!
+}
+```
+"##,
+
 E0695: r##"
 A `break` statement without a label appeared inside a labeled block.
 
@@ -306,7 +327,6 @@ fn foo() {}
     E0561, // patterns aren't allowed in function pointer types
     E0567, // auto traits can not have generic parameters
     E0568, // auto traits can not have super traits
-    E0642, // patterns aren't allowed in methods without bodies
     E0666, // nested `impl Trait` is illegal
     E0667, // `impl Trait` in projections
     E0696, // `continue` pointing to a labeled block
index b57debdd99486bda802323fe72cbc624d136d530..d41f4cd61f763a5e95da78c570ab07690d55b7b0 100644 (file)
@@ -10,6 +10,8 @@
 
 #![allow(bad_style)]
 
+#![cfg_attr(not(stage0), feature(nll))]
+
 pub struct Intrinsic {
     pub inputs: &'static [&'static Type],
     pub output: &'static Type,
diff --git a/src/librustc_target/spec/aarch64_unknown_netbsd.rs b/src/librustc_target/spec/aarch64_unknown_netbsd.rs
new file mode 100644 (file)
index 0000000..c300855
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use spec::{LinkerFlavor, Target, TargetResult};
+
+pub fn target() -> TargetResult {
+    let mut base = super::netbsd_base::opts();
+    base.max_atomic_width = Some(128);
+    base.abi_blacklist = super::arm_base::abi_blacklist();
+
+    Ok(Target {
+        llvm_target: "aarch64-unknown-netbsd".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "64".to_string(),
+        target_c_int_width: "32".to_string(),
+        data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
+        arch: "aarch64".to_string(),
+        target_os: "netbsd".to_string(),
+        target_env: "".to_string(),
+        target_vendor: "unknown".to_string(),
+        linker_flavor: LinkerFlavor::Gcc,
+        options: base,
+    })
+}
index 4945784659517b63537ed5d85ac08b9cb9edf120..ce3d61cecbb691dbebd12aa02198c1b2f9f4e601 100644 (file)
@@ -319,6 +319,7 @@ fn $module() {
     ("i686-unknown-openbsd", i686_unknown_openbsd),
     ("x86_64-unknown-openbsd", x86_64_unknown_openbsd),
 
+    ("aarch64-unknown-netbsd", aarch64_unknown_netbsd),
     ("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
     ("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf),
     ("i686-unknown-netbsd", i686_unknown_netbsd),
index ecc167d5a196776c77214d05298198bdc03ca6e7..62f93ea20e48cc09dbaf3ec2c816d45ca221c5c0 100644 (file)
@@ -76,6 +76,7 @@
 #![feature(crate_visibility_modifier)]
 #![feature(exhaustive_patterns)]
 #![feature(iterator_find_map)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(quote)]
 #![feature(refcell_replace_swap)]
 #![feature(rustc_diagnostic_macros)]
index 07507047dc2c95c76039fcfe245a33a20cce7938..b63abec1f0e8b0cc145e27a57bca142d257bddab 100644 (file)
         if (hash !== null) {
             var elem = document.getElementById(hash);
             if (elem && elem.offsetParent === null) {
-                console.log(elem, elem.parentNode);
                 if (elem.parentNode && elem.parentNode.previousSibling) {
                     var collapses = elem.parentNode
                                         .previousSibling
index faca264ea1006c47467f224a07053e13457748af..a2cb79582a14c94cd6aa5da7335ce5a4ee054dc5 100644 (file)
@@ -165,8 +165,8 @@ a {
        color: #ddd;
 }
 
-.docblock a:not(.srclink):not(.test-arrow), .docblock-short a:not(.srclink):not(.test-arrow),
-.stability a {
+.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow), .docblock-short
+a:not(.srclink):not(.test-arrow), .stability a {
        color: #D2991D;
 }
 
index 5725a41d939d55947b321e74944e04fa7abb72d0..6a3c1988977e7a66c87705316fec21eda58a16c6 100644 (file)
@@ -165,8 +165,8 @@ a {
        color: #000;
 }
 
-.docblock a:not(.srclink):not(.test-arrow), .docblock-short a:not(.srclink):not(.test-arrow),
-.stability a {
+.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow), .docblock-short
+a:not(.srclink):not(.test-arrow), .stability a {
        color: #3873AD;
 }
 
index 78ecfd13e2f96bdf647cd7ef7e6403d15b3ec2c3..7581965cc0cadc49c6d8a860f2f23c637b711d49 100644 (file)
@@ -17,6 +17,7 @@
 #![feature(box_patterns)]
 #![feature(box_syntax)]
 #![feature(iterator_find_map)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(set_stdio)]
 #![feature(slice_sort_by_cached_key)]
 #![feature(test)]
index a5f4b32b329e7c22a51c791035a9cb05d168076d..794fc095096a479c754f07e26562fc8ae6989ca7 100644 (file)
@@ -24,6 +24,7 @@
 #![feature(core_intrinsics)]
 #![feature(specialization)]
 #![feature(never_type)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![cfg_attr(test, feature(test))]
 
 pub use self::serialize::{Decoder, Encoder, Decodable, Encodable};
index b2777f5c48541f13171259a711e7885a159da6b4..2b87094926cf5f012c28bcb52aa3c388841c634b 100644 (file)
@@ -1175,9 +1175,9 @@ pub fn to_str(&self) -> Result<&str, str::Utf8Error> {
     /// If the contents of the `CStr` are valid UTF-8 data, this
     /// function will return a [`Cow`]`::`[`Borrowed`]`(`[`&str`]`)`
     /// with the the corresponding [`&str`] slice. Otherwise, it will
-    /// replace any invalid UTF-8 sequences with `U+FFFD REPLACEMENT
-    /// CHARACTER` and return a [`Cow`]`::`[`Owned`]`(`[`String`]`)`
-    /// with the result.
+    /// replace any invalid UTF-8 sequences with
+    /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD] and return a
+    /// [`Cow`]`::`[`Owned`]`(`[`String`]`)` with the result.
     ///
     /// > **Note**: This method is currently implemented to check for validity
     /// > after a constant-time cast, but it is planned to alter its definition
@@ -1189,6 +1189,7 @@ pub fn to_str(&self) -> Result<&str, str::Utf8Error> {
     /// [`Owned`]: ../borrow/enum.Cow.html#variant.Owned
     /// [`str`]: ../primitive.str.html
     /// [`String`]: ../string/struct.String.html
+    /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
     ///
     /// # Examples
     ///
index 9e501a84e05ec6e9176a5904c31f4674dfb746e0..6bcd62dbd59c27052063bdc44389a7768b516afa 100644 (file)
@@ -520,10 +520,12 @@ pub fn to_str(&self) -> Option<&str> {
 
     /// Converts an `OsStr` to a [`Cow`]`<`[`str`]`>`.
     ///
-    /// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
+    /// Any non-Unicode sequences are replaced with
+    /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD].
     ///
     /// [`Cow`]: ../../std/borrow/enum.Cow.html
     /// [`str`]: ../../std/primitive.str.html
+    /// [U+FFFD]: ../../std/char/constant.REPLACEMENT_CHARACTER.html
     ///
     /// # Examples
     ///
index 01bd3edaee981d5973142d5e797aca352ddcad1f..4f6bda6cfe3798337bcf44c79f9b4fba54208684 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
 ///
 /// [book]: https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html
 mod fn_keyword { }
+
+#[doc(keyword = "let")]
+//
+/// The `let` keyword.
+///
+/// The `let` keyword is used to declare a variable.
+///
+/// Example:
+///
+/// ```rust
+/// # #![allow(unused_assignments)]
+/// let x = 3; // We create a variable named `x` with the value `3`.
+/// ```
+///
+/// By default, all variables are **not** mutable. If you want a mutable variable,
+/// you'll have to use the `mut` keyword.
+///
+/// Example:
+///
+/// ```rust
+/// # #![allow(unused_assignments)]
+/// let mut x = 3; // We create a mutable variable named `x` with the value `3`.
+///
+/// x += 4; // `x` is now equal to `7`.
+/// ```
+///
+/// For more information about the `let` keyword, take a look at the [Rust Book][book].
+///
+/// [book]: https://doc.rust-lang.org/book/second-edition/ch03-01-variables-and-mutability.html
+mod let_keyword { }
index 0bc968b6c5cda20b8937fba1ab76f2b1811865b0..5d463225ae93b646f3ef3e8612806a6870e9f2b5 100644 (file)
 #![feature(macro_vis_matcher)]
 #![feature(needs_panic_runtime)]
 #![feature(never_type)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(exhaustive_patterns)]
 #![feature(on_unimplemented)]
 #![feature(optin_builtin_traits)]
index 4b8dda493b0979be056b3bb0ef3ab897b367f6b8..dc33747c05b0670da0c514c6f8dd098efa6b591a 100644 (file)
@@ -29,7 +29,8 @@
           all(target_os = "android", any(target_arch = "aarch64",
                                          target_arch = "arm")),
           all(target_os = "l4re", target_arch = "x86_64"),
-          all(target_os = "netbsd", any(target_arch = "arm",
+          all(target_os = "netbsd", any(target_arch = "aarch64",
+                                        target_arch = "arm",
                                         target_arch = "powerpc")),
           all(target_os = "openbsd", target_arch = "aarch64"),
           all(target_os = "fuchsia", target_arch = "aarch64")))]
@@ -43,7 +44,8 @@
               all(target_os = "android", any(target_arch = "aarch64",
                                              target_arch = "arm")),
               all(target_os = "l4re", target_arch = "x86_64"),
-              all(target_os = "netbsd", any(target_arch = "arm",
+              all(target_os = "netbsd", any(target_arch = "aarch64",
+                                            target_arch = "arm",
                                             target_arch = "powerpc")),
               all(target_os = "openbsd", target_arch = "aarch64"),
               all(target_os = "fuchsia", target_arch = "aarch64"))))]
index 688a7e99f10edf0b7cb57fc136122d2e2a016c50..ca8be75fab5beee3a11841b3b79870c23c615a1a 100644 (file)
@@ -1737,9 +1737,11 @@ pub fn to_str(&self) -> Option<&str> {
 
     /// Converts a `Path` to a [`Cow<str>`].
     ///
-    /// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
+    /// Any non-Unicode sequences are replaced with
+    /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD].
     ///
     /// [`Cow<str>`]: ../borrow/enum.Cow.html
+    /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
     ///
     /// # Examples
     ///
index 39692836866baab6e7873920c7159ed3bb605be3..53babd449a992fbfe5653a67b1e3d36525cafdd3 100644 (file)
@@ -381,6 +381,39 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 ///
 /// let hello = output.stdout;
 /// ```
+///
+/// `Command` can be reused to spawn multiple processes. The builder methods
+/// change the command without needing to immediately spawn the process.
+///
+/// ```no_run
+/// use std::process::Command;
+///
+/// let mut echo_hello = Command::new("sh");
+/// echo_hello.arg("-c")
+///           .arg("echo hello");
+/// let hello_1 = echo_hello.output().expect("failed to execute process");
+/// let hello_2 = echo_hello.output().expect("failed to execute process");
+/// ```
+///
+/// Similarly, you can call builder methods after spawning a process and then
+/// spawn a new process with the modified settings.
+///
+/// ```no_run
+/// use std::process::Command;
+///
+/// let mut list_dir = Command::new("ls");
+///
+/// // Execute `ls` in the current directory of the program.
+/// list_dir.status().expect("process failed to execute");
+///
+/// println!("");
+///
+/// // Change `ls` to execute in the root directory.
+/// list_dir.current_dir("/");
+///
+/// // And then execute `ls` again but in the root directory.
+/// list_dir.status().expect("process failed to execute");
+/// ```
 #[stable(feature = "process", since = "1.0.0")]
 pub struct Command {
     inner: imp::Command,
index 98d4355248990a92ec748b667409e91b1e5a1f2d..bae0d02786a092dd8134a428fb2ab7a2fbf0cbd5 100644 (file)
@@ -31,7 +31,7 @@
 //!
 //! If Rust code *does* need to look into those strings, it can
 //! convert them to valid UTF-8, possibly lossily, by substituting
-//! invalid sequences with U+FFFD REPLACEMENT CHARACTER, as is
+//! invalid sequences with [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], as is
 //! conventionally done in other Rust APIs that deal with string
 //! encodings.
 //!
@@ -65,6 +65,7 @@
 //! [`from_wide`]: trait.OsStringExt.html#tymethod.from_wide
 //! [`encode_wide`]: trait.OsStrExt.html#tymethod.encode_wide
 //! [`collect`]: ../../../iter/trait.Iterator.html#method.collect
+//! [U+FFFD]: ../../../char/constant.REPLACEMENT_CHARACTER.html
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
index 28c1e4324de7a3070c90f2c4cce5a694dc3ce2e8..6925ed2afb83b51e947b108bc1a2c8aa4562070c 100644 (file)
@@ -501,7 +501,11 @@ pub(super) fn to_ty(&self) -> Option<P<Ty>> {
             PatKind::Slice(pats, None, _) if pats.len() == 1 =>
                 pats[0].to_ty().map(TyKind::Slice)?,
             PatKind::Tuple(pats, None) => {
-                let tys = pats.iter().map(|pat| pat.to_ty()).collect::<Option<Vec<_>>>()?;
+                let mut tys = Vec::with_capacity(pats.len());
+                // FIXME(#48994) - could just be collected into an Option<Vec>
+                for pat in pats {
+                    tys.push(pat.to_ty()?);
+                }
                 TyKind::Tup(tys)
             }
             _ => return None,
index c8e60620248b3c9205304b630171dc70720d2d69..12ce478fe1d8ba02241f01d19cf7862c73cafb86 100644 (file)
 
 #![feature(crate_visibility_modifier)]
 #![feature(macro_at_most_once_rep)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(rustc_attrs)]
 #![feature(rustc_diagnostic_macros)]
 #![feature(slice_sort_by_cached_key)]
 #![feature(str_escape)]
 #![feature(unicode_internals)]
+#![feature(catch_expr)]
 
 #![recursion_limit="256"]
 
index 9011b6e48b974185cca711f9a549631827eb9e6a..746e03d771a880d3ac40851ec865066ee9a41e68 100644 (file)
@@ -44,7 +44,7 @@
 use {ast, attr};
 use codemap::{self, CodeMap, Spanned, respan};
 use syntax_pos::{self, Span, MultiSpan, BytePos, FileName, edition::Edition};
-use errors::{self, Applicability, DiagnosticBuilder};
+use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId};
 use parse::{self, SeqSep, classify, token};
 use parse::lexer::TokenAndSpan;
 use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
@@ -1371,7 +1371,7 @@ fn parse_trait_item_(&mut self,
             let ident = self.parse_ident()?;
             let mut generics = self.parse_generics()?;
 
-            let d = self.parse_fn_decl_with_self(|p: &mut Parser<'a>|{
+            let d = self.parse_fn_decl_with_self(|p: &mut Parser<'a>| {
                 // This is somewhat dubious; We don't want to allow
                 // argument names to be left off if there is a
                 // definition...
@@ -1753,21 +1753,59 @@ fn parse_arg_general(&mut self, require_name: bool) -> PResult<'a, Arg> {
             (pat, self.parse_ty()?)
         } else {
             debug!("parse_arg_general ident_to_pat");
-            let ident = Ident::new(keywords::Invalid.name(), self.prev_span);
-            let ty = self.parse_ty()?;
-            let pat = P(Pat {
-                id: ast::DUMMY_NODE_ID,
-                node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None),
-                span: ty.span,
-            });
-            (pat, ty)
+
+            let parser_snapshot_before_pat = self.clone();
+
+            // We're going to try parsing the argument as a pattern (even though it's not
+            // allowed). This way we can provide better errors to the user.
+            let pat_arg: PResult<'a, _> = do catch {
+                let pat = self.parse_pat()?;
+                self.expect(&token::Colon)?;
+                (pat, self.parse_ty()?)
+            };
+
+            match pat_arg {
+                Ok((pat, ty)) => {
+                    let mut err = self.diagnostic().struct_span_err_with_code(
+                        pat.span,
+                        "patterns aren't allowed in methods without bodies",
+                        DiagnosticId::Error("E0642".into()),
+                    );
+                    err.span_suggestion_short_with_applicability(
+                        pat.span,
+                        "give this argument a name or use an underscore to ignore it",
+                        "_".to_owned(),
+                        Applicability::MachineApplicable,
+                    );
+                    err.emit();
+                    // Pretend the pattern is `_`, to avoid duplicate errors from AST validation.
+                    let pat = P(Pat {
+                        node: PatKind::Wild,
+                        span: pat.span,
+                        id: ast::DUMMY_NODE_ID
+                    });
+                    (pat, ty)
+                }
+                Err(mut err) => {
+                    err.cancel();
+                    // Recover from attempting to parse the argument as a pattern. This means
+                    // the type is alone, with no name, e.g. `fn foo(u32)`.
+                    mem::replace(self, parser_snapshot_before_pat);
+                    debug!("parse_arg_general ident_to_pat");
+                    let ident = Ident::new(keywords::Invalid.name(), self.prev_span);
+                    let ty = self.parse_ty()?;
+                    let pat = P(Pat {
+                        id: ast::DUMMY_NODE_ID,
+                        node: PatKind::Ident(
+                            BindingMode::ByValue(Mutability::Immutable), ident, None),
+                        span: ty.span,
+                    });
+                    (pat, ty)
+                }
+            }
         };
 
-        Ok(Arg {
-            ty,
-            pat,
-            id: ast::DUMMY_NODE_ID,
-        })
+        Ok(Arg { ty, pat, id: ast::DUMMY_NODE_ID })
     }
 
     /// Parse a single function argument
index e0f985c26c7a1cd9efd69bc3b09e3b0ab09afd80..f5e607fc23d22ea45acfa0f921c4483c1c57edec 100644 (file)
@@ -554,7 +554,7 @@ fn create_derived_impl(&self,
             GenericParamKind::Type { .. } => {
                 // I don't think this can be moved out of the loop, since
                 // a GenericBound requires an ast id
-                let mut bounds: Vec<_> =
+                let bounds: Vec<_> =
                     // extra restrictions on the generics parameters to the
                     // type being derived upon
                     self.additional_bounds.iter().map(|p| {
index f0d33835cd0fbf730754419dee276b3dcaeb0940..1ba4ab474258c76939a18a9ee8e6d0c81b78a667 100644 (file)
@@ -16,6 +16,7 @@
 
 #![feature(proc_macro_internals)]
 #![feature(decl_macro)]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(str_escape)]
 
 #![feature(rustc_diagnostic_macros)]
index 3f8be97571fd7e356f039cdfd7b441e73fb19884..30094223d08585c81e7beb4d0d0044acdeb4a615 100644 (file)
@@ -35,6 +35,7 @@
 #![feature(asm)]
 #![feature(fnbox)]
 #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
+#![cfg_attr(not(stage0), feature(nll))]
 #![feature(set_stdio)]
 #![feature(panic_unwind)]
 #![feature(staged_api)]
index 7dabb1bddea77e1877837d4bdcba726c261bd477..81a46ea0fe718b1ff5e90b4a06422dcb49091afe 100644 (file)
@@ -1,186 +1,4 @@
 # Compiler Test Documentation
 
-In the Rust project, we use a special set of commands embedded in
-comments to test the Rust compiler. There are two groups of commands:
-
-1. Header commands
-2. Error info commands
-
-Both types of commands are inside comments, but header commands should
-be in a comment before any code.
-
-## Summary of Error Info Commands
-
-Error commands specify something about certain lines of the
-program. They tell the test what kind of error and what message you
-are expecting.
-
-* `~`: Associates the following error level and message with the
-  current line
-* `~|`: Associates the following error level and message with the same
-  line as the previous comment
-* `~^`: Associates the following error level and message with the
-  previous line. Each caret (`^`) that you add adds a line to this, so
-  `~^^^^^^^` is seven lines up.
-
-The error levels that you can have are:
-
-1. `ERROR`
-2. `WARNING`
-3. `NOTE`
-4. `HELP` and `SUGGESTION`*
-
-\* **Note**: `SUGGESTION` must follow immediately after `HELP`.
-
-## Summary of Header Commands
-
-Header commands specify something about the entire test file as a
-whole. They are normally put right after the copyright comment, e.g.:
-
-```Rust
-// Copyright blah blah blah
-// except according to those terms.
-
-// ignore-test This doesn't actually work
-```
-
-### Ignoring tests
-
-These are used to ignore the test in some situations, which means the test won't
-be compiled or run.
-
-* `ignore-X` where `X` is a target detail or stage will ignore the test accordingly (see below)
-* `ignore-pretty` will not compile the pretty-printed test (this is done to test the pretty-printer, but might not always work)
-* `ignore-test` always ignores the test
-* `ignore-lldb` and `ignore-gdb` will skip a debuginfo test on that debugger.
-
-`only-X` is the opposite. The test will run only when `X` matches.
-
-Some examples of `X` in `ignore-X`:
-
-* Architecture: `aarch64`, `arm`, `asmjs`, `mips`, `wasm32`, `x86_64`, `x86`, ...
-* OS: `android`, `emscripten`, `freebsd`, `ios`, `linux`, `macos`, `windows`, ...
-* Environment (fourth word of the target triple): `gnu`, `msvc`, `musl`.
-* Pointer width: `32bit`, `64bit`.
-* Stage: `stage0`, `stage1`, `stage2`.
-
-### Other Header Commands
-
-* `min-{gdb,lldb}-version`
-* `min-llvm-version`
-* `compile-pass` for UI tests, indicates that the test is supposed
-  to compile, as opposed to the default where the test is supposed to error out.
-* `compile-flags` passes extra command-line args to the compiler,
-  e.g. `compile-flags -g` which forces debuginfo to be enabled.
-* `should-fail` indicates that the test should fail; used for "meta testing",
-  where we test the compiletest program itself to check that it will generate
-  errors in appropriate scenarios. This header is ignored for pretty-printer tests.
-* `gate-test-X` where `X` is a feature marks the test as "gate test" for feature X.
-  Such tests are supposed to ensure that the compiler errors when usage of a gated
-  feature is attempted without the proper `#![feature(X)]` tag.
-  Each unstable lang feature is required to have a gate test.
-
-## Revisions
-
-Certain classes of tests support "revisions" (as of the time of this
-writing, this includes run-pass, compile-fail, run-fail, and
-incremental, though incremental tests are somewhat
-different). Revisions allow a single test file to be used for multiple
-tests. This is done by adding a special header at the top of the file:
-
-```
-// revisions: foo bar baz
-```
-
-This will result in the test being compiled (and tested) three times,
-once with `--cfg foo`, once with `--cfg bar`, and once with `--cfg
-baz`. You can therefore use `#[cfg(foo)]` etc within the test to tweak
-each of these results.
-
-You can also customize headers and expected error messages to a particular
-revision. To do this, add `[foo]` (or `bar`, `baz`, etc) after the `//`
-comment, like so:
-
-```
-// A flag to pass in only for cfg `foo`:
-//[foo]compile-flags: -Z verbose
-
-#[cfg(foo)]
-fn test_foo() {
-    let x: usize = 32_u32; //[foo]~ ERROR mismatched types
-}
-```
-
-Note that not all headers have meaning when customized to a revision.
-For example, the `ignore-test` header (and all "ignore" headers)
-currently only apply to the test as a whole, not to particular
-revisions. The only headers that are intended to really work when
-customized to a revision are error patterns and compiler flags.
-
-## Guide to the UI Tests
-
-The UI tests are intended to capture the compiler's complete output,
-so that we can test all aspects of the presentation. They work by
-compiling a file (e.g., `ui/hello_world/main.rs`), capturing the output,
-and then applying some normalization (see below). This normalized
-result is then compared against reference files named
-`ui/hello_world/main.stderr` and `ui/hello_world/main.stdout`. If either of
-those files doesn't exist, the output must be empty. If the test run
-fails, we will print out the current output, but it is also saved in
-`build/<target-triple>/test/ui/hello_world/main.stdout` (this path is
-printed as part of the test failure message), so you can run `diff` and
-so forth.
-
-Normally, the test-runner checks that UI tests fail compilation. If you want
-to do a UI test for code that *compiles* (e.g. to test warnings, or if you
-have a collection of tests, only some of which error out), you can use the
-`// compile-pass` header command to have the test runner instead
-check that the test compiles successfully.
-
-### Editing and updating the reference files
-
-If you have changed the compiler's output intentionally, or you are
-making a new test, you can pass `--bless` to the command you used to
-run the tests. This will then copy over the files
-from the build directory and use them as the new reference.
-
-### Normalization
-
-The normalization applied is aimed at eliminating output difference
-between platforms, mainly about filenames:
-
-- the test directory is replaced with `$DIR`
-- all backslashes (`\`) are converted to forward slashes (`/`) (for Windows)
-- all CR LF newlines are converted to LF
-
-Sometimes these built-in normalizations are not enough. In such cases, you
-may provide custom normalization rules using the header commands, e.g.
-
-```
-// normalize-stdout-test: "foo" -> "bar"
-// normalize-stderr-32bit: "fn\(\) \(32 bits\)" -> "fn\(\) \($$PTR bits\)"
-// normalize-stderr-64bit: "fn\(\) \(64 bits\)" -> "fn\(\) \($$PTR bits\)"
-```
-
-This tells the test, on 32-bit platforms, whenever the compiler writes
-`fn() (32 bits)` to stderr, it should be normalized to read `fn() ($PTR bits)`
-instead. Similar for 64-bit. The replacement is performed by regexes using
-default regex flavor provided by `regex` crate.
-
-The corresponding reference file will use the normalized output to test both
-32-bit and 64-bit platforms:
-
-```
-...
-   |
-   = note: source type: fn() ($PTR bits)
-   = note: target type: u16 (16 bits)
-...
-```
-
-Please see `ui/transmute/main.rs` and `.stderr` for a concrete usage example.
-
-Besides `normalize-stderr-32bit` and `-64bit`, one may use any target
-information or stage supported by `ignore-X` here as well (e.g.
-`normalize-stderr-windows` or simply `normalize-stderr-test` for unconditional
-replacement).
+Documentation the compiler testing framework has moved to
+[the rustc guide](https://rust-lang-nursery.github.io/rustc-guide/tests/intro.html).
diff --git a/src/test/ui/E0642.rs b/src/test/ui/E0642.rs
new file mode 100644 (file)
index 0000000..58ccfc5
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[derive(Clone, Copy)]
+struct S;
+
+trait T {
+    fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
+
+    fn bar((x, y): (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
+
+    fn f(&ident: &S) {} // ok
+    fn g(&&ident: &&S) {} // ok
+    fn h(mut ident: S) {} // ok
+}
+
+fn main() {}
diff --git a/src/test/ui/E0642.stderr b/src/test/ui/E0642.stderr
new file mode 100644 (file)
index 0000000..34c163e
--- /dev/null
@@ -0,0 +1,23 @@
+error[E0642]: patterns aren't allowed in methods without bodies
+  --> $DIR/E0642.rs:15:12
+   |
+LL |     fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
+   |            ^^^^^^
+help: give this argument a name or use an underscore to ignore it
+   |
+LL |     fn foo(_: (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
+   |            ^
+
+error[E0642]: patterns aren't allowed in methods without bodies
+  --> $DIR/E0642.rs:17:12
+   |
+LL |     fn bar((x, y): (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
+   |            ^^^^^^
+help: give this argument a name or use an underscore to ignore it
+   |
+LL |     fn bar(_: (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
+   |            ^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0642`.
index 0ae8d4862f7c8828f2077e583a070305297bdaa0..288168c699263e07871593c8c149a09954c5da00 100644 (file)
@@ -2,7 +2,10 @@ error[E0271]: type mismatch resolving `<std::option::Option<f32> as std::ops::Tr
   --> $DIR/catch-block-type-error.rs:18:9
    |
 LL |         42
-   |         ^^ expected f32, found integral variable
+   |         ^^
+   |         |
+   |         expected f32, found integral variable
+   |         help: use a float literal: `42.0`
    |
    = note: expected type `f32`
               found type `{integer}`
diff --git a/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs b/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs
new file mode 100644 (file)
index 0000000..243e3a6
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let sixteen: f32 = 16;
+    //~^ ERROR mismatched types
+    //~| HELP use a float literal
+    let a_million_and_seventy: f64 = 1_000_070;
+    //~^ ERROR mismatched types
+    //~| HELP use a float literal
+    let negative_nine: f32 = -9;
+    //~^ ERROR mismatched types
+    //~| HELP use a float literal
+
+
+    // only base-10 literals get the suggestion
+
+    let sixteen_again: f64 = 0x10;
+    //~^ ERROR mismatched types
+    let and_once_more: f32 = 0o20;
+    //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr b/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr
new file mode 100644 (file)
index 0000000..caaa954
--- /dev/null
@@ -0,0 +1,57 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-53280-expected-float-found-integer-literal.rs:12:24
+   |
+LL |     let sixteen: f32 = 16;
+   |                        ^^
+   |                        |
+   |                        expected f32, found integral variable
+   |                        help: use a float literal: `16.0`
+   |
+   = note: expected type `f32`
+              found type `{integer}`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-53280-expected-float-found-integer-literal.rs:15:38
+   |
+LL |     let a_million_and_seventy: f64 = 1_000_070;
+   |                                      ^^^^^^^^^
+   |                                      |
+   |                                      expected f64, found integral variable
+   |                                      help: use a float literal: `1_000_070.0`
+   |
+   = note: expected type `f64`
+              found type `{integer}`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-53280-expected-float-found-integer-literal.rs:18:30
+   |
+LL |     let negative_nine: f32 = -9;
+   |                              ^^
+   |                              |
+   |                              expected f32, found integral variable
+   |                              help: use a float literal: `-9.0`
+   |
+   = note: expected type `f32`
+              found type `{integer}`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-53280-expected-float-found-integer-literal.rs:25:30
+   |
+LL |     let sixteen_again: f64 = 0x10;
+   |                              ^^^^ expected f64, found integral variable
+   |
+   = note: expected type `f64`
+              found type `{integer}`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-53280-expected-float-found-integer-literal.rs:27:30
+   |
+LL |     let and_once_more: f32 = 0o20;
+   |                              ^^^^ expected f32, found integral variable
+   |
+   = note: expected type `f32`
+              found type `{integer}`
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
index 5116f6662ff4dc416b15294b88d2bb9ffa39a114..9501adb938616de359b3e44ce9c41f7b4d8d5860 100644 (file)
@@ -267,7 +267,7 @@ fn recv<B: BufRead>(dir: &Path, io: &mut B) -> PathBuf {
     t!(io::copy(&mut io.take(amt),
                 &mut t!(File::create(&dst))));
     t!(fs::set_permissions(&dst, Permissions::from_mode(0o755)));
-    return dst
+    dst
 }
 
 fn my_copy(src: &mut dyn Read, which: u8, dst: &Mutex<dyn Write>) {
index 42f4e46085ebe17249c091d63dd7f0f085e9bad2..d63f479f29d9467c67f0fbb798960b771f4aab78 100644 (file)
@@ -353,7 +353,7 @@ fn check_crate_duplicate(resolve: &Resolve, bad: &mut bool) {
         // versions of them accidentally sneak into our dependency graph to
         // ensure we keep our CI times under control
         // "cargo", // FIXME(#53005)
-        // "rustc-ap-syntax", // FIXME(#53006)
+        "rustc-ap-syntax",
     ];
     let mut name_to_id = HashMap::new();
     for node in resolve.nodes.iter() {