diff --git a/src/Cargo.lock b/src/Cargo.lock index 1ef6b2a571e9c..97e0bf0a99bb1 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1770,7 +1770,7 @@ dependencies = [ [[package]] name = "rls" -version = "0.130.4" +version = "0.130.5" dependencies = [ "cargo 0.30.0", "cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 9aeb4e0edaed5..d5e1ed02b44c1 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -607,6 +607,7 @@ impl Step for Openssl { "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", diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 631779a17a165..dd559df08cce6 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -519,10 +519,11 @@ impl String { /// 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 @@ impl String { } /// 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 @@ impl String { /// /// [`from_utf8_lossy`]: #method.from_utf8_lossy /// [`Cow<'a, str>`]: ../borrow/enum.Cow.html + /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html /// /// # Examples /// diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index 39ec5d6411c16..35e4eea756d41 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -217,7 +217,7 @@ impl Layout { 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 @@ pub unsafe trait Alloc { // _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 @@ pub unsafe trait Alloc { // 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) } } diff --git a/src/libcore/char/mod.rs b/src/libcore/char/mod.rs index 5be673db3200d..7e1313747eef2 100644 --- a/src/libcore/char/mod.rs +++ b/src/libcore/char/mod.rs @@ -312,8 +312,8 @@ impl Iterator for EscapeDefault { 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), } } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index dc4a2d7c0d7b1..178ae62dd3dfa 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -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)] diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 960853333f6c7..eb63966354b86 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -188,7 +188,8 @@ mod wrapping; // `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 @@ assert_eq!(n.rotate_right(", $rot, "), m); (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 @@ $EndFeature, " #[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 @@ assert_eq!(n.rotate_right(", $rot, "), m); } } - /// 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 @@ $EndFeature, " #[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 @@ impl u8 { #[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. diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index c8670e5ec34d3..61033e7511253 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2318,7 +2318,7 @@ pub(crate) unsafe fn align_offset(p: *const T, a: 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 @@ pub(crate) unsafe fn align_offset(p: *const T, a: usize) -> usize { } // Cannot be aligned at all. - return usize::max_value(); + usize::max_value() } diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 187ac3c7a7f06..88fdd76763893 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -1727,7 +1727,7 @@ impl [T] { ctz_b = ::intrinsics::cttz_nonzero(b); } } - return a << k; + a << k } let gcd: usize = gcd(::mem::size_of::(), ::mem::size_of::()); let ts: usize = ::mem::size_of::() / gcd; @@ -1737,7 +1737,7 @@ impl [T] { 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 @@ impl [T] { let ptr = self.as_ptr(); let offset = ::ptr::align_offset(ptr, ::mem::align_of::()); if offset > self.len() { - return (self, &[], &[]); + (self, &[], &[]) } else { let (left, rest) = self.split_at(offset); let (us_len, ts_len) = rest.align_to_offsets::(); - 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 @@ impl [T] { let ptr = self.as_ptr(); let offset = ::ptr::align_offset(ptr, ::mem::align_of::()); 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::(); 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)) } } } diff --git a/src/libcore/str/lossy.rs b/src/libcore/str/lossy.rs index 5cfb36d3b195b..186d6adbc91cf 100644 --- a/src/libcore/str/lossy.rs +++ b/src/libcore/str/lossy.rs @@ -146,7 +146,7 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> { broken: &[], }; self.source = &[]; - return Some(r); + Some(r) } } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 356534a91879c..810d19df0c5ba 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -244,7 +244,10 @@ impl Utf8Error { /// 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 { self.error_len.map(|len| len as usize) @@ -1567,7 +1570,7 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [ #[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. diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index bf6e4a3aaa405..fec90008c6701 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -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)] diff --git a/src/libprofiler_builtins/lib.rs b/src/libprofiler_builtins/lib.rs index 6d0d6d115b716..a85593253b100 100644 --- a/src/libprofiler_builtins/lib.rs +++ b/src/libprofiler_builtins/lib.rs @@ -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)] diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 0b84c6a0aa77a..eed6215150fdb 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -709,7 +709,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.projection_cache .borrow_mut() - .commit(projection_cache_snapshot); + .commit(&projection_cache_snapshot); self.type_variables .borrow_mut() .commit(type_snapshot); diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index c74783f5e4db5..3598d66060bf2 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -151,12 +151,14 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { 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::>(); - 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, diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 55a5e342947fb..e250b7549a052 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -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)] diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index b7d3ad76588f7..5113f3cde3284 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -146,7 +146,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { debug!("normalize_projection_type(projection_ty={:?})", projection_ty); - assert!(!projection_ty.has_escaping_regions()); + debug_assert!(!projection_ty.has_escaping_regions()); // FIXME(#20304) -- cache diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 1ce60d8f05599..1224cdd76d85b 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -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 @@ impl<'tcx> ProjectionCache<'tcx> { } 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 diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 1e3fe70535bcc..fbd12c9fe8eca 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -563,7 +563,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { 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 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { 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 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { 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 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { 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; diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 81cc897232ab0..0da4d5ddea2f2 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -466,7 +466,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { 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 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> { tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>) -> Result, 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 @@ impl<'a, 'tcx> SizeSkeleton<'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) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 96b4edce86b30..65e31f21792d2 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -708,7 +708,7 @@ impl<'a, 'gcx, 'tcx> ExistentialTraitRef<'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 Binder { pub fn dummy<'tcx>(value: T) -> Binder where T: TypeFoldable<'tcx> { - assert!(!value.has_escaping_regions()); + debug_assert!(!value.has_escaping_regions()); Binder(value) } @@ -1247,7 +1247,7 @@ impl<'a, 'tcx, 'gcx> ExistentialProjection<'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 { diff --git a/src/librustc_allocator/lib.rs b/src/librustc_allocator/lib.rs index b217d3665a245..a920bb0f2b918 100644 --- a/src/librustc_allocator/lib.rs +++ b/src/librustc_allocator/lib.rs @@ -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; diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index cdfa874b1772a..97f3cf614d628 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -182,6 +182,8 @@ pub fn target_machine_factory(sess: &Session, find_features: bool) let is_pie_binary = !find_features && is_pie_binary(sess); let trap_unreachable = sess.target.target.options.trap_unreachable; + let asm_comments = sess.asm_comments(); + Arc::new(move || { let tm = unsafe { llvm::LLVMRustCreateTargetMachine( @@ -195,6 +197,7 @@ pub fn target_machine_factory(sess: &Session, find_features: bool) fdata_sections, trap_unreachable, singlethread, + asm_comments, ) }; diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index fafc0e723225d..80db21d0d338f 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -230,7 +230,6 @@ pub fn get_static(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll Value { } cx.instances.borrow_mut().insert(instance, g); - cx.statics.borrow_mut().insert(g, def_id); g } diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 7a308bb6e8823..0cf8d72be1b2a 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -13,7 +13,6 @@ use common; use llvm; use rustc::dep_graph::DepGraphSafe; use rustc::hir; -use rustc::hir::def_id::DefId; use debuginfo; use callee; use base; @@ -77,9 +76,6 @@ pub struct CodegenCx<'a, 'tcx: 'a> { /// Cache of emitted const globals (value -> global) pub const_globals: RefCell>, - /// Mapping from static definitions to their DefId's. - pub statics: RefCell>, - /// List of globals for static variables which need to be passed to the /// LLVM function ReplaceAllUsesWith (RAUW) when codegen is complete. /// (We have to make sure we don't invalidate any Values referring @@ -297,7 +293,6 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> { const_cstr_cache: RefCell::new(FxHashMap()), const_unsized: RefCell::new(FxHashMap()), const_globals: RefCell::new(FxHashMap()), - statics: RefCell::new(FxHashMap()), statics_to_rauw: RefCell::new(Vec::new()), used_statics: RefCell::new(Vec::new()), lltypes: RefCell::new(FxHashMap()), diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 4572f5891a420..390a1df02b88e 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -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)] diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index a894f8e2fdb96..eec8a3a169ced 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -1455,7 +1455,8 @@ extern "C" { FunctionSections: bool, DataSections: bool, TrapUnreachable: bool, - Singlethread: bool) + Singlethread: bool, + AsmComments: bool) -> Option<&'static mut TargetMachine>; pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine); pub fn LLVMRustAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module); @@ -1564,7 +1565,7 @@ extern "C" { -> 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>); diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs index a528008e3b4bd..80c4df1d6b005 100644 --- a/src/librustc_codegen_llvm/mono_item.rs +++ b/src/librustc_codegen_llvm/mono_item.rs @@ -143,7 +143,6 @@ fn predefine_static<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, } cx.instances.borrow_mut().insert(instance, g); - cx.statics.borrow_mut().insert(g, def_id); } fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, diff --git a/src/librustc_codegen_llvm/type_of.rs b/src/librustc_codegen_llvm/type_of.rs index 5fd4f15acd157..69d91b327283d 100644 --- a/src/librustc_codegen_llvm/type_of.rs +++ b/src/librustc_codegen_llvm/type_of.rs @@ -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 } diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index 3ff2388beea2a..635819e94e867 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -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)] diff --git a/src/librustc_data_structures/base_n.rs b/src/librustc_data_structures/base_n.rs index d333b6393b9cc..d3b47daa5b4b8 100644 --- a/src/librustc_data_structures/base_n.rs +++ b/src/librustc_data_structures/base_n.rs @@ -17,7 +17,7 @@ pub const MAX_BASE: usize = 64; 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()); } diff --git a/src/librustc_data_structures/bitslice.rs b/src/librustc_data_structures/bitslice.rs index b8f191c2f57d8..a63033c436528 100644 --- a/src/librustc_data_structures/bitslice.rs +++ b/src/librustc_data_structures/bitslice.rs @@ -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] diff --git a/src/librustc_data_structures/bitvec.rs b/src/librustc_data_structures/bitvec.rs index 6e8a45d034250..49ab3e58812dc 100644 --- a/src/librustc_data_structures/bitvec.rs +++ b/src/librustc_data_structures/bitvec.rs @@ -196,7 +196,8 @@ impl<'a, C: Idx> Iterator for BitIter<'a, 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) { @@ -299,7 +300,7 @@ impl BitMatrix { let v1 = vector[write_index]; let v2 = v1 | vector[read_index]; vector[write_index] = v2; - changed = changed | (v1 != v2); + changed |= v1 != v2; } changed } diff --git a/src/librustc_data_structures/flock.rs b/src/librustc_data_structures/flock.rs index ff1ebb11b7221..3f248dadb66c1 100644 --- a/src/librustc_data_structures/flock.rs +++ b/src/librustc_data_structures/flock.rs @@ -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; diff --git a/src/librustc_data_structures/graph/dominators/mod.rs b/src/librustc_data_structures/graph/dominators/mod.rs index d134fad2855bb..e54147cbe7c87 100644 --- a/src/librustc_data_structures/graph/dominators/mod.rs +++ b/src/librustc_data_structures/graph/dominators/mod.rs @@ -107,7 +107,8 @@ fn intersect( node2 = immediate_dominators[node2].unwrap(); } } - return node1; + + node1 } #[derive(Clone, Debug)] diff --git a/src/librustc_data_structures/graph/implementation/mod.rs b/src/librustc_data_structures/graph/implementation/mod.rs index cf9403db658f4..baac756586865 100644 --- a/src/librustc_data_structures/graph/implementation/mod.rs +++ b/src/librustc_data_structures/graph/implementation/mod.rs @@ -90,7 +90,7 @@ pub const INCOMING: Direction = Direction { repr: 1 }; 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 @@ impl Graph { 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 { @@ -261,8 +261,8 @@ impl Graph { 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 { diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs index 2e95a45479c4f..404272d69c863 100644 --- a/src/librustc_data_structures/indexed_set.rs +++ b/src/librustc_data_structures/indexed_set.rs @@ -59,16 +59,13 @@ impl rustc_serialize::Decodable for IdxSetBuf { // pnkfelix wants to have this be `IdxSet([Word]) and then pass // around `&mut IdxSet` or `&IdxSet`. -// -// WARNING: Mapping a `&IdxSetBuf` to `&IdxSet` (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 { _pd: PhantomData, bits: [Word], @@ -134,11 +131,11 @@ impl IdxSetBuf { impl IdxSet { 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 = idx_buf.iter().collect(); let expected: Vec = (0..i).collect(); assert_eq!(elems, expected); diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 3aa15f472a274..bfe7273dc4c7a 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -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)] diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs index 0d6cf260dcd98..7ef88852685d5 100644 --- a/src/librustc_data_structures/obligation_forest/mod.rs +++ b/src/librustc_data_structures/obligation_forest/mod.rs @@ -573,7 +573,7 @@ impl ObligationForest { } 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()); diff --git a/src/librustc_data_structures/small_vec.rs b/src/librustc_data_structures/small_vec.rs index 76b01beb4bad3..e958fd7da613e 100644 --- a/src/librustc_data_structures/small_vec.rs +++ b/src/librustc_data_structures/small_vec.rs @@ -210,7 +210,12 @@ impl Decodable for SmallVec A::Element: Decodable { fn decode(d: &mut D) -> Result, 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 + for i in 0..len { + vec.push(d.read_seq_elt(i, |d| Decodable::decode(d))?); + } + Ok(vec) }) } } diff --git a/src/librustc_data_structures/snapshot_map/mod.rs b/src/librustc_data_structures/snapshot_map/mod.rs index 6ee8c3579f543..5030bf98dffd5 100644 --- a/src/librustc_data_structures/snapshot_map/mod.rs +++ b/src/librustc_data_structures/snapshot_map/mod.rs @@ -92,7 +92,7 @@ impl SnapshotMap 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 @@ impl SnapshotMap }); } - 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 @@ impl SnapshotMap } } - 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); diff --git a/src/librustc_data_structures/snapshot_map/test.rs b/src/librustc_data_structures/snapshot_map/test.rs index 4114082839b0b..b163e0fe420ec 100644 --- a/src/librustc_data_structures/snapshot_map/test.rs +++ b/src/librustc_data_structures/snapshot_map/test.rs @@ -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"); } diff --git a/src/librustc_data_structures/tiny_list.rs b/src/librustc_data_structures/tiny_list.rs index c12fc22baf020..e1bfdf35b274e 100644 --- a/src/librustc_data_structures/tiny_list.rs +++ b/src/librustc_data_structures/tiny_list.rs @@ -107,7 +107,8 @@ impl Element { }; self.next = new_next; - return true + + true } fn len(&self) -> usize { diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs index a8124fb7c5b62..18a1e9129b342 100644 --- a/src/librustc_data_structures/transitive_relation.rs +++ b/src/librustc_data_structures/transitive_relation.rs @@ -77,7 +77,7 @@ impl TransitiveRelation { .. } = self; - map.entry(a.clone()) + *map.entry(a.clone()) .or_insert_with(|| { elements.push(a); @@ -86,7 +86,6 @@ impl TransitiveRelation { Index(elements.len() - 1) }) - .clone() } /// Applies the (partial) function to each edge and returns a new @@ -98,14 +97,12 @@ impl TransitiveRelation { { 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 @@ impl TransitiveRelation { 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); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index c3bdf07cd2079..df7ab101fec3b 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1513,7 +1513,7 @@ pub fn in_named_rustc_thread(name: String, f: F) -> Result(name: String, f: F) -> Result or the MIT license +// , 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, + }) +} diff --git a/src/librustc_target/spec/aarch64_unknown_none.rs b/src/librustc_target/spec/aarch64_unknown_none.rs new file mode 100644 index 0000000000000..cfba0614adcd6 --- /dev/null +++ b/src/librustc_target/spec/aarch64_unknown_none.rs @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Generic AArch64 target for bare-metal code +// +// Can be used in conjunction with the `target-feature` and +// `target-cpu` compiler flags to opt-in more hardware-specific +// features. +// +// For example, `-C target-cpu=cortex-a53`. + +use super::{LldFlavor, LinkerFlavor, Target, TargetOptions, PanicStrategy}; + +pub fn target() -> Result { + let opts = TargetOptions { + linker: Some("rust-lld".to_owned()), + executables: true, + relocation_model: "static".to_string(), + disable_redzone: true, + linker_is_gnu: true, + max_atomic_width: Some(128), + panic_strategy: PanicStrategy::Abort, + abi_blacklist: super::arm_base::abi_blacklist(), + .. Default::default() + }; + Ok(Target { + llvm_target: "aarch64-unknown-none".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "64".to_string(), + target_c_int_width: "32".to_string(), + target_os: "none".to_string(), + target_env: "".to_string(), + target_vendor: "".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(), + linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), + options: opts, + }) +} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 4945784659517..d434f4beb2e38 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -319,6 +319,7 @@ supported_targets! { ("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), @@ -379,6 +380,8 @@ supported_targets! { ("x86_64-unknown-hermit", x86_64_unknown_hermit), ("riscv32imac-unknown-none-elf", riscv32imac_unknown_none_elf), + + ("aarch64-unknown-none", aarch64_unknown_none), } /// Everything `rustc` knows about how to compile for a specific target. diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index ecc167d5a1967..62f93ea20e48c 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -76,6 +76,7 @@ This API is completely unstable and subject to change. #![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)] diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 07507047dc2c9..b63abec1f0e8b 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2214,7 +2214,6 @@ 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 diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index faca264ea1006..a2cb79582a14c 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -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; } diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index 5725a41d939d5..6a3c1988977e7 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -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; } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 78ecfd13e2f96..7581965cc0cad 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -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)] diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index a5f4b32b329e7..794fc095096a4 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -24,6 +24,7 @@ Core encoding and decoding interfaces. #![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}; diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index b2777f5c48541..2b87094926cf5 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -1175,9 +1175,9 @@ impl CStr { /// 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 @@ impl CStr { /// [`Owned`]: ../borrow/enum.Cow.html#variant.Owned /// [`str`]: ../primitive.str.html /// [`String`]: ../string/struct.String.html + /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html /// /// # Examples /// diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 9e501a84e05ec..6bcd62dbd59c2 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -520,10 +520,12 @@ impl OsStr { /// 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 /// diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 01bd3edaee981..4f6bda6cfe379 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -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. // @@ -26,3 +26,33 @@ /// /// [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 { } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 0bc968b6c5cda..5d463225ae93b 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -273,6 +273,7 @@ #![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)] diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs index 4b8dda493b097..dc33747c05b06 100644 --- a/src/libstd/os/raw/mod.rs +++ b/src/libstd/os/raw/mod.rs @@ -29,7 +29,8 @@ use fmt; 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 @@ use fmt; 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"))))] diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 688a7e99f10ed..ca8be75fab5be 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1737,9 +1737,11 @@ impl Path { /// Converts a `Path` to a [`Cow`]. /// - /// 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`]: ../borrow/enum.Cow.html + /// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html /// /// # Examples /// diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 39692836866ba..53babd449a992 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -381,6 +381,39 @@ impl fmt::Debug for ChildStderr { /// /// 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, diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 08c3e15497843..f8f0bbd5bc250 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -414,12 +414,8 @@ pub fn env() -> Env { unsafe { let _guard = ENV_LOCK.lock(); let mut environ = *environ(); - if environ == ptr::null() { - panic!("os::env() failure getting env string from OS: {}", - io::Error::last_os_error()); - } let mut result = Vec::new(); - while *environ != ptr::null() { + while environ != ptr::null() && *environ != ptr::null() { if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { result.push(key_value); } diff --git a/src/libstd/sys/windows/ext/ffi.rs b/src/libstd/sys/windows/ext/ffi.rs index 98d4355248990..bae0d02786a09 100644 --- a/src/libstd/sys/windows/ext/ffi.rs +++ b/src/libstd/sys/windows/ext/ffi.rs @@ -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")] diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 28c1e4324de7a..6925ed2afb83b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -501,7 +501,11 @@ impl Pat { 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::>>()?; + let mut tys = Vec::with_capacity(pats.len()); + // FIXME(#48994) - could just be collected into an Option + for pat in pats { + tys.push(pat.to_ty()?); + } TyKind::Tup(tys) } _ => return None, diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index 15abad555f4b6..89af57a085807 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -382,8 +382,9 @@ Erroneous code example: ```ignore (limited to a warning during 2018 edition development) #![feature(rust_2018_preview)] -#![feature(raw_identifiers)] // error: the feature `raw_identifiers` is - // included in the Rust 2018 edition +#![feature(impl_header_lifetime_elision)] // error: the feature + // `impl_header_lifetime_elision` is + // included in the Rust 2018 edition ``` "##, diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 976708ae78816..ea65e4f8ccd0c 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -433,9 +433,6 @@ declare_features! ( // `use path as _;` and `extern crate c as _;` (active, underscore_imports, "1.26.0", Some(48216), None), - // Allows keywords to be escaped for use as identifiers - (active, raw_identifiers, "1.26.0", Some(48589), Some(Edition::Edition2018)), - // Allows macro invocations in `extern {}` blocks (active, macros_in_extern, "1.27.0", Some(49476), None), @@ -646,6 +643,8 @@ declare_features! ( (accepted, repr_transparent, "1.28.0", Some(43036), None), // Defining procedural macros in `proc-macro` crates (accepted, proc_macro, "1.29.0", Some(38356), None), + // Allows keywords to be escaped for use as identifiers + (accepted, raw_identifiers, "1.30.0", Some(48589), None), ); // If you change this, please modify src/doc/unstable-book as well. You must @@ -1862,10 +1861,15 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { "existential types are unstable" ); } - - ast::ImplItemKind::Type(_) if !ii.generics.params.is_empty() => { - gate_feature_post!(&self, generic_associated_types, ii.span, - "generic associated types are unstable"); + ast::ImplItemKind::Type(_) => { + if !ii.generics.params.is_empty() { + gate_feature_post!(&self, generic_associated_types, ii.span, + "generic associated types are unstable"); + } + if !ii.generics.where_clause.predicates.is_empty() { + gate_feature_post!(&self, generic_associated_types, ii.span, + "where clauses on associated types are unstable"); + } } _ => {} } @@ -2016,16 +2020,6 @@ pub fn check_crate(krate: &ast::Crate, plugin_attributes, }; - if !features.raw_identifiers { - for &span in sess.raw_identifier_spans.borrow().iter() { - if !span.allows_unstable() { - gate_feature!(&ctx, raw_identifiers, span, - "raw identifiers are experimental and subject to change" - ); - } - } - } - let visitor = &mut PostExpansionVisitor { context: &ctx }; visitor.whole_crate_feature_gates(krate); visit::walk_crate(visitor, krate); diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index c8e60620248b3..12ce478fe1d8b 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -21,11 +21,13 @@ #![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"] diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9011b6e48b974..746e03d771a88 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -44,7 +44,7 @@ use ast::{RangeEnd, RangeSyntax}; 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 @@ impl<'a> Parser<'a> { 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 @@ impl<'a> Parser<'a> { (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 diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index e0f985c26c7a1..f5e607fc23d22 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -554,7 +554,7 @@ impl<'a> TraitDef<'a> { 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| { diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index f0d33835cd0fb..1ba4ab474258c 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -16,6 +16,7 @@ #![feature(proc_macro_internals)] #![feature(decl_macro)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(str_escape)] #![feature(rustc_diagnostic_macros)] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 3f8be97571fd7..30094223d0858 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -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)] diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 7305dc71cbf63..d9fbd494ab348 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -366,7 +366,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( bool PositionIndependentExecutable, bool FunctionSections, bool DataSections, bool TrapUnreachable, - bool Singlethread) { + bool Singlethread, + bool AsmComments) { auto OptLevel = fromRust(RustOptLevel); auto RM = fromRust(RustReloc); @@ -393,6 +394,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( } Options.DataSections = DataSections; Options.FunctionSections = FunctionSections; + Options.MCOptions.AsmVerbose = AsmComments; + Options.MCOptions.PreserveAsmComments = AsmComments; if (TrapUnreachable) { // Tell LLVM to codegen `unreachable` into an explicit trap instruction. diff --git a/src/test/COMPILER_TESTS.md b/src/test/COMPILER_TESTS.md index 7dabb1bddea77..81a46ea0fe718 100644 --- a/src/test/COMPILER_TESTS.md +++ b/src/test/COMPILER_TESTS.md @@ -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//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/run-pass/auxiliary/edition-kw-macro-2015.rs b/src/test/run-pass/auxiliary/edition-kw-macro-2015.rs index 69952e9f90af6..f8ed2c7f432eb 100644 --- a/src/test/run-pass/auxiliary/edition-kw-macro-2015.rs +++ b/src/test/run-pass/auxiliary/edition-kw-macro-2015.rs @@ -10,8 +10,6 @@ // edition:2015 -#![feature(raw_identifiers)] - #[macro_export] macro_rules! produces_async { () => (pub fn async() {}) diff --git a/src/test/run-pass/edition-keywords-2015-2015.rs b/src/test/run-pass/edition-keywords-2015-2015.rs index 73869e63de7c4..1751eacc6b7ce 100644 --- a/src/test/run-pass/edition-keywords-2015-2015.rs +++ b/src/test/run-pass/edition-keywords-2015-2015.rs @@ -11,8 +11,6 @@ // edition:2015 // aux-build:edition-kw-macro-2015.rs -#![feature(raw_identifiers)] - #[macro_use] extern crate edition_kw_macro_2015; diff --git a/src/test/run-pass/edition-keywords-2015-2018.rs b/src/test/run-pass/edition-keywords-2015-2018.rs index 0a1c6505854c9..f2794a4b8d81a 100644 --- a/src/test/run-pass/edition-keywords-2015-2018.rs +++ b/src/test/run-pass/edition-keywords-2015-2018.rs @@ -11,8 +11,6 @@ // edition:2015 // aux-build:edition-kw-macro-2018.rs -#![feature(raw_identifiers)] - #[macro_use] extern crate edition_kw_macro_2018; diff --git a/src/test/ui/feature-gate-raw-identifiers.rs b/src/test/run-pass/env-null-vars.rs similarity index 60% rename from src/test/ui/feature-gate-raw-identifiers.rs rename to src/test/run-pass/env-null-vars.rs index 38024feb432d9..296764269dec0 100644 --- a/src/test/ui/feature-gate-raw-identifiers.rs +++ b/src/test/run-pass/env-null-vars.rs @@ -8,7 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-windows +// ignore-wasm32-bare no libc to test ffi with + +// issue-53200 + +#![feature(libc)] +extern crate libc; + +use std::env; + +// FIXME: more platforms? +#[cfg(target_os = "linux")] fn main() { - let r#foo = 3; //~ ERROR raw identifiers are experimental and subject to change - println!("{}", foo); + unsafe { libc::clearenv(); } + assert_eq!(env::vars().count(), 0); } + +#[cfg(not(target_os = "linux"))] +fn main() {} diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs index 6cea75cf1d11e..2ef9fba2076ad 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(raw_identifiers)] - use std::mem; #[r#repr(r#C, r#packed)] diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs index 5d495c4e9e557..eefce3981bec1 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(raw_identifiers)] - fn r#fn(r#match: u32) -> u32 { r#match } diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/items.rs b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs index 256bd263d38d4..4306ffe2042af 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/items.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(raw_identifiers)] - #[derive(Debug, PartialEq, Eq)] struct IntWrapper(u32); diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs index 4bd16ded52fbd..9e89b79266cfa 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs @@ -9,7 +9,6 @@ // except according to those terms. #![feature(decl_macro)] -#![feature(raw_identifiers)] r#macro_rules! r#struct { ($r#struct:expr) => { $r#struct } diff --git a/src/test/ui/E0642.rs b/src/test/ui/E0642.rs new file mode 100644 index 0000000000000..58ccfc56ab79a --- /dev/null +++ b/src/test/ui/E0642.rs @@ -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 or the MIT license +// , 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 index 0000000000000..34c163e210970 --- /dev/null +++ b/src/test/ui/E0642.stderr @@ -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`. diff --git a/src/test/ui/E0705.rs b/src/test/ui/E0705.rs index a0ce95e3e02c1..0d3f68ee7c464 100644 --- a/src/test/ui/E0705.rs +++ b/src/test/ui/E0705.rs @@ -11,10 +11,7 @@ // compile-pass #![feature(rust_2018_preview)] -#![feature(raw_identifiers)] -//~^ WARN the feature `raw_identifiers` is included in the Rust 2018 edition +#![feature(impl_header_lifetime_elision)] +//~^ WARN the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition -fn main() { - let foo = 0; - let bar = r#foo; -} +fn main() {} diff --git a/src/test/ui/E0705.stderr b/src/test/ui/E0705.stderr index ebb8dd4975d6f..2bdb6dc354a67 100644 --- a/src/test/ui/E0705.stderr +++ b/src/test/ui/E0705.stderr @@ -1,6 +1,6 @@ -warning[E0705]: the feature `raw_identifiers` is included in the Rust 2018 edition +warning[E0705]: the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition --> $DIR/E0705.rs:14:12 | -LL | #![feature(raw_identifiers)] - | ^^^^^^^^^^^^^^^ +LL | #![feature(impl_header_lifetime_elision)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/auxiliary/edition-kw-macro-2015.rs b/src/test/ui/auxiliary/edition-kw-macro-2015.rs index 8f80e000e3caf..5b8832ddaf27c 100644 --- a/src/test/ui/auxiliary/edition-kw-macro-2015.rs +++ b/src/test/ui/auxiliary/edition-kw-macro-2015.rs @@ -10,7 +10,6 @@ // edition:2015 -#![feature(raw_identifiers)] #![allow(async_idents)] #[macro_export] diff --git a/src/test/ui/edition-keywords-2015-2015-expansion.rs b/src/test/ui/edition-keywords-2015-2015-expansion.rs index 3b78ce80be208..a9037a50ecb6b 100644 --- a/src/test/ui/edition-keywords-2015-2015-expansion.rs +++ b/src/test/ui/edition-keywords-2015-2015-expansion.rs @@ -12,7 +12,6 @@ // aux-build:edition-kw-macro-2015.rs // compile-pass -#![feature(raw_identifiers)] #![allow(async_idents)] #[macro_use] diff --git a/src/test/ui/edition-keywords-2015-2015-parsing.rs b/src/test/ui/edition-keywords-2015-2015-parsing.rs index 08cba2d2908a6..bdb190c748ace 100644 --- a/src/test/ui/edition-keywords-2015-2015-parsing.rs +++ b/src/test/ui/edition-keywords-2015-2015-parsing.rs @@ -11,8 +11,6 @@ // edition:2015 // aux-build:edition-kw-macro-2015.rs -#![feature(raw_identifiers)] - #[macro_use] extern crate edition_kw_macro_2015; diff --git a/src/test/ui/edition-keywords-2015-2015-parsing.stderr b/src/test/ui/edition-keywords-2015-2015-parsing.stderr index 5b6fd3e1c9c43..a629d13e6c31b 100644 --- a/src/test/ui/edition-keywords-2015-2015-parsing.stderr +++ b/src/test/ui/edition-keywords-2015-2015-parsing.stderr @@ -1,11 +1,11 @@ error: no rules expected the token `r#async` - --> $DIR/edition-keywords-2015-2015-parsing.rs:24:31 + --> $DIR/edition-keywords-2015-2015-parsing.rs:22:31 | LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` | ^^^^^^^ error: no rules expected the token `async` - --> $DIR/edition-keywords-2015-2015-parsing.rs:25:35 + --> $DIR/edition-keywords-2015-2015-parsing.rs:23:35 | LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ diff --git a/src/test/ui/edition-keywords-2015-2018-expansion.rs b/src/test/ui/edition-keywords-2015-2018-expansion.rs index 41d5ebd3e7db1..291fd0285e57c 100644 --- a/src/test/ui/edition-keywords-2015-2018-expansion.rs +++ b/src/test/ui/edition-keywords-2015-2018-expansion.rs @@ -11,8 +11,6 @@ // edition:2015 // aux-build:edition-kw-macro-2018.rs -#![feature(raw_identifiers)] - #[macro_use] extern crate edition_kw_macro_2018; diff --git a/src/test/ui/edition-keywords-2015-2018-expansion.stderr b/src/test/ui/edition-keywords-2015-2018-expansion.stderr index 5852d56e6d374..d087146d7a14a 100644 --- a/src/test/ui/edition-keywords-2015-2018-expansion.stderr +++ b/src/test/ui/edition-keywords-2015-2018-expansion.stderr @@ -1,5 +1,5 @@ error: expected identifier, found reserved keyword `async` - --> $DIR/edition-keywords-2015-2018-expansion.rs:20:5 + --> $DIR/edition-keywords-2015-2018-expansion.rs:18:5 | LL | produces_async! {} //~ ERROR expected identifier, found reserved keyword | ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword diff --git a/src/test/ui/edition-keywords-2015-2018-parsing.rs b/src/test/ui/edition-keywords-2015-2018-parsing.rs index 337d6be6bbcd8..1b7bfb530596a 100644 --- a/src/test/ui/edition-keywords-2015-2018-parsing.rs +++ b/src/test/ui/edition-keywords-2015-2018-parsing.rs @@ -11,8 +11,6 @@ // edition:2015 // aux-build:edition-kw-macro-2018.rs -#![feature(raw_identifiers)] - #[macro_use] extern crate edition_kw_macro_2018; diff --git a/src/test/ui/edition-keywords-2015-2018-parsing.stderr b/src/test/ui/edition-keywords-2015-2018-parsing.stderr index 60cfbce3ff0e4..ab8a34a4a9e3d 100644 --- a/src/test/ui/edition-keywords-2015-2018-parsing.stderr +++ b/src/test/ui/edition-keywords-2015-2018-parsing.stderr @@ -1,11 +1,11 @@ error: no rules expected the token `r#async` - --> $DIR/edition-keywords-2015-2018-parsing.rs:24:31 + --> $DIR/edition-keywords-2015-2018-parsing.rs:22:31 | LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` | ^^^^^^^ error: no rules expected the token `async` - --> $DIR/edition-keywords-2015-2018-parsing.rs:25:35 + --> $DIR/edition-keywords-2015-2018-parsing.rs:23:35 | LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ diff --git a/src/test/ui/feature-gate-generic_associated_types.rs b/src/test/ui/feature-gate-generic_associated_types.rs index 3470662686643..bbaae1ef449fc 100644 --- a/src/test/ui/feature-gate-generic_associated_types.rs +++ b/src/test/ui/feature-gate-generic_associated_types.rs @@ -19,6 +19,7 @@ trait PointerFamily { } struct Foo; + impl PointerFamily for Foo { type Pointer = Box; //~^ ERROR generic associated types are unstable @@ -31,5 +32,9 @@ trait Bar { //~^ ERROR where clauses on associated types are unstable } +impl Bar for Foo { + type Assoc where Self: Sized = Foo; + //~^ ERROR where clauses on associated types are unstable +} fn main() {} diff --git a/src/test/ui/feature-gate-generic_associated_types.stderr b/src/test/ui/feature-gate-generic_associated_types.stderr index d7891f13c6b4d..f12cbe727fbed 100644 --- a/src/test/ui/feature-gate-generic_associated_types.stderr +++ b/src/test/ui/feature-gate-generic_associated_types.stderr @@ -23,7 +23,7 @@ LL | type Pointer2: Deref where T: Clone, U: Clone; = help: add #![feature(generic_associated_types)] to the crate attributes to enable error[E0658]: generic associated types are unstable (see issue #44265) - --> $DIR/feature-gate-generic_associated_types.rs:23:5 + --> $DIR/feature-gate-generic_associated_types.rs:24:5 | LL | type Pointer = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | type Pointer = Box; = help: add #![feature(generic_associated_types)] to the crate attributes to enable error[E0658]: generic associated types are unstable (see issue #44265) - --> $DIR/feature-gate-generic_associated_types.rs:25:5 + --> $DIR/feature-gate-generic_associated_types.rs:26:5 | LL | type Pointer2 = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,21 @@ LL | type Pointer2 = Box; = help: add #![feature(generic_associated_types)] to the crate attributes to enable error[E0658]: where clauses on associated types are unstable (see issue #44265) - --> $DIR/feature-gate-generic_associated_types.rs:30:5 + --> $DIR/feature-gate-generic_associated_types.rs:31:5 | LL | type Assoc where Self: Sized; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(generic_associated_types)] to the crate attributes to enable -error: aborting due to 6 previous errors +error[E0658]: where clauses on associated types are unstable (see issue #44265) + --> $DIR/feature-gate-generic_associated_types.rs:36:5 + | +LL | type Assoc where Self: Sized = Foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(generic_associated_types)] to the crate attributes to enable + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gate-raw-identifiers.stderr b/src/test/ui/feature-gate-raw-identifiers.stderr deleted file mode 100644 index 02eff7247c47b..0000000000000 --- a/src/test/ui/feature-gate-raw-identifiers.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: raw identifiers are experimental and subject to change (see issue #48589) - --> $DIR/feature-gate-raw-identifiers.rs:12:9 - | -LL | let r#foo = 3; //~ ERROR raw identifiers are experimental and subject to change - | ^^^^^ - | - = help: add #![feature(raw_identifiers)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/raw-literal-keywords.rs b/src/test/ui/raw-literal-keywords.rs index 9bb6653d77080..f1bfbc95eb395 100644 --- a/src/test/ui/raw-literal-keywords.rs +++ b/src/test/ui/raw-literal-keywords.rs @@ -10,8 +10,6 @@ // compile-flags: -Z parse-only -#![feature(raw_identifiers)] - fn test_if() { r#if true { } //~ ERROR found `true` } diff --git a/src/test/ui/raw-literal-keywords.stderr b/src/test/ui/raw-literal-keywords.stderr index 022f80ae8a4ec..8a6b91b4b4b6f 100644 --- a/src/test/ui/raw-literal-keywords.stderr +++ b/src/test/ui/raw-literal-keywords.stderr @@ -1,17 +1,17 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true` - --> $DIR/raw-literal-keywords.rs:16:10 + --> $DIR/raw-literal-keywords.rs:14:10 | LL | r#if true { } //~ ERROR found `true` | ^^^^ expected one of 8 possible tokens here error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` - --> $DIR/raw-literal-keywords.rs:20:14 + --> $DIR/raw-literal-keywords.rs:18:14 | LL | r#struct Test; //~ ERROR found `Test` | ^^^^ expected one of 8 possible tokens here error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` - --> $DIR/raw-literal-keywords.rs:24:13 + --> $DIR/raw-literal-keywords.rs:22:13 | LL | r#union Test; //~ ERROR found `Test` | ^^^^ expected one of 8 possible tokens here diff --git a/src/test/ui/raw-literal-self.rs b/src/test/ui/raw-literal-self.rs index f88d6cf9a67bd..17496d767b622 100644 --- a/src/test/ui/raw-literal-self.rs +++ b/src/test/ui/raw-literal-self.rs @@ -10,8 +10,6 @@ // compile-flags: -Z parse-only -#![feature(raw_identifiers)] - fn self_test(r#self: u32) { //~^ ERROR `r#self` is not currently supported. } diff --git a/src/test/ui/raw-literal-self.stderr b/src/test/ui/raw-literal-self.stderr index e3345847aa895..f4b759372471c 100644 --- a/src/test/ui/raw-literal-self.stderr +++ b/src/test/ui/raw-literal-self.stderr @@ -1,5 +1,5 @@ error: `r#self` is not currently supported. - --> $DIR/raw-literal-self.rs:15:14 + --> $DIR/raw-literal-self.rs:13:14 | LL | fn self_test(r#self: u32) { | ^^^^^^ diff --git a/src/test/ui/rust-2018/async-ident-allowed.stderr b/src/test/ui/rust-2018/async-ident-allowed.stderr index 1644102cdca1a..741c1c70209bc 100644 --- a/src/test/ui/rust-2018/async-ident-allowed.stderr +++ b/src/test/ui/rust-2018/async-ident-allowed.stderr @@ -2,7 +2,7 @@ error: `async` is a keyword in the 2018 edition --> $DIR/async-ident-allowed.rs:19:9 | LL | let async = 3; //~ ERROR: is a keyword - | ^^^^^ + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` | note: lint level defined here --> $DIR/async-ident-allowed.rs:13:9 diff --git a/src/test/ui/rust-2018/async-ident.fixed b/src/test/ui/rust-2018/async-ident.fixed index 228bf91125337..15b8eec3bea99 100644 --- a/src/test/ui/rust-2018/async-ident.fixed +++ b/src/test/ui/rust-2018/async-ident.fixed @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(raw_identifiers)] #![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)] #![deny(async_idents)] diff --git a/src/test/ui/rust-2018/async-ident.rs b/src/test/ui/rust-2018/async-ident.rs index cc400c2a92e0e..6087d2c16423e 100644 --- a/src/test/ui/rust-2018/async-ident.rs +++ b/src/test/ui/rust-2018/async-ident.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(raw_identifiers)] #![allow(dead_code, unused_variables, non_camel_case_types, non_upper_case_globals)] #![deny(async_idents)] diff --git a/src/test/ui/rust-2018/async-ident.stderr b/src/test/ui/rust-2018/async-ident.stderr index 94fd3e70434cb..06d68a38c5f38 100644 --- a/src/test/ui/rust-2018/async-ident.stderr +++ b/src/test/ui/rust-2018/async-ident.stderr @@ -1,11 +1,11 @@ error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:18:4 + --> $DIR/async-ident.rs:17:4 | LL | fn async() {} //~ ERROR async | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` | note: lint level defined here - --> $DIR/async-ident.rs:13:9 + --> $DIR/async-ident.rs:12:9 | LL | #![deny(async_idents)] | ^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | #![deny(async_idents)] = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:23:7 + --> $DIR/async-ident.rs:22:7 | LL | ($async:expr, async) => {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -22,7 +22,7 @@ LL | ($async:expr, async) => {}; = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:23:19 + --> $DIR/async-ident.rs:22:19 | LL | ($async:expr, async) => {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -31,7 +31,7 @@ LL | ($async:expr, async) => {}; = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:37:11 + --> $DIR/async-ident.rs:36:11 | LL | trait async {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -40,7 +40,7 @@ LL | trait async {} = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:41:10 + --> $DIR/async-ident.rs:40:10 | LL | impl async for MyStruct {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -49,7 +49,7 @@ LL | impl async for MyStruct {} = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:47:12 + --> $DIR/async-ident.rs:46:12 | LL | static async: u32 = 0; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -58,7 +58,7 @@ LL | static async: u32 = 0; = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:53:11 + --> $DIR/async-ident.rs:52:11 | LL | const async: u32 = 0; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -67,7 +67,7 @@ LL | const async: u32 = 0; = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:59:15 + --> $DIR/async-ident.rs:58:15 | LL | impl Foo { fn async() {} } | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -76,7 +76,7 @@ LL | impl Foo { fn async() {} } = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:64:12 + --> $DIR/async-ident.rs:63:12 | LL | struct async {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -85,7 +85,7 @@ LL | struct async {} = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:67:9 + --> $DIR/async-ident.rs:66:9 | LL | let async: async = async {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -94,7 +94,7 @@ LL | let async: async = async {}; = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:67:16 + --> $DIR/async-ident.rs:66:16 | LL | let async: async = async {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -103,7 +103,7 @@ LL | let async: async = async {}; = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:67:24 + --> $DIR/async-ident.rs:66:24 | LL | let async: async = async {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -112,7 +112,7 @@ LL | let async: async = async {}; = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:78:19 + --> $DIR/async-ident.rs:77:19 | LL | () => (pub fn async() {}) | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -121,7 +121,7 @@ LL | () => (pub fn async() {}) = note: for more information, see issue #49716 error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:85:6 + --> $DIR/async-ident.rs:84:6 | LL | (async) => (1) | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` diff --git a/src/tools/compiletest/src/raise_fd_limit.rs b/src/tools/compiletest/src/raise_fd_limit.rs index 220082799a8b0..d1071231530d6 100644 --- a/src/tools/compiletest/src/raise_fd_limit.rs +++ b/src/tools/compiletest/src/raise_fd_limit.rs @@ -57,14 +57,16 @@ pub unsafe fn raise_fd_limit() { panic!("raise_fd_limit: error calling getrlimit: {}", err); } - // Bump the soft limit to the smaller of kern.maxfilesperproc and the hard - // limit - rlim.rlim_cur = cmp::min(maxfiles as libc::rlim_t, rlim.rlim_max); + // Make sure we're only ever going to increase the rlimit. + if rlim.rlim_cur < maxfiles as libc::rlim_t { + // Bump the soft limit to the smaller of kern.maxfilesperproc and the hard limit. + rlim.rlim_cur = cmp::min(maxfiles as libc::rlim_t, rlim.rlim_max); - // Set our newly-increased resource limit - if libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) != 0 { - let err = io::Error::last_os_error(); - panic!("raise_fd_limit: error calling setrlimit: {}", err); + // Set our newly-increased resource limit. + if libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) != 0 { + let err = io::Error::last_os_error(); + panic!("raise_fd_limit: error calling setrlimit: {}", err); + } } } diff --git a/src/tools/remote-test-server/src/main.rs b/src/tools/remote-test-server/src/main.rs index 5116f6662ff4d..9501adb938616 100644 --- a/src/tools/remote-test-server/src/main.rs +++ b/src/tools/remote-test-server/src/main.rs @@ -267,7 +267,7 @@ fn recv(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) { diff --git a/src/tools/rls b/src/tools/rls index c51e3ff2f07f8..9e4d8d520390c 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit c51e3ff2f07f84f26f57fcb51808b1ec7cbe45a6 +Subproject commit 9e4d8d520390c6aeebc33260026c6ae2946c67ac diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 42f4e46085ebe..d63f479f29d94 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -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() {