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/error.rs b/src/librustc/ty/error.rs index bcbd8a529f6a7..49fffaa375b2f 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -13,7 +13,7 @@ use ty::{self, BoundRegion, Region, Ty, TyCtxt}; use std::fmt; use rustc_target::spec::abi; use syntax::ast; -use errors::DiagnosticBuilder; +use errors::{Applicability, DiagnosticBuilder}; use syntax_pos::Span; use hir; @@ -250,6 +250,21 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { db.note("no two closures, even if identical, have the same type"); db.help("consider boxing your closure and/or using it as a trait object"); } + match (&values.found.sty, &values.expected.sty) { // Issue #53280 + (ty::TyInfer(ty::IntVar(_)), ty::TyFloat(_)) => { + if let Ok(snippet) = self.sess.codemap().span_to_snippet(sp) { + if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') { + db.span_suggestion_with_applicability( + sp, + "use a float literal", + format!("{}.0", snippet), + Applicability::MachineApplicable + ); + } + } + }, + _ => {} + } }, OldStyleLUB(err) => { db.note("this was previously accepted by the compiler but has been phased out"); 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/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..68a21a537070b 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -1564,7 +1564,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/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_llvm/lib.rs b/src/librustc_llvm/lib.rs index ffa97bd6fa59d..387660473a887 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/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(static_nobundle)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_lsan/lib.rs b/src/librustc_lsan/lib.rs index 0c78fd74a234e..b3ba86ad8a4b3 100644 --- a/src/librustc_lsan/lib.rs +++ b/src/librustc_lsan/lib.rs @@ -10,6 +10,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 05c843096d27d..42682c34407ca 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -14,6 +14,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! */ +#![cfg_attr(not(stage0), feature(nll))] #![feature(infer_outlives_requirements)] #![feature(in_band_lifetimes)] #![feature(slice_patterns)] diff --git a/src/librustc_msan/lib.rs b/src/librustc_msan/lib.rs index 0c78fd74a234e..b3ba86ad8a4b3 100644 --- a/src/librustc_msan/lib.rs +++ b/src/librustc_msan/lib.rs @@ -10,6 +10,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] +#![cfg_attr(not(stage0), feature(nll))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_platform_intrinsics/lib.rs b/src/librustc_platform_intrinsics/lib.rs index b57debdd99486..d41f4cd61f763 100644 --- a/src/librustc_platform_intrinsics/lib.rs +++ b/src/librustc_platform_intrinsics/lib.rs @@ -10,6 +10,8 @@ #![allow(bad_style)] +#![cfg_attr(not(stage0), feature(nll))] + pub struct Intrinsic { pub inputs: &'static [&'static Type], pub output: &'static Type, diff --git a/src/librustc_target/spec/aarch64_unknown_netbsd.rs b/src/librustc_target/spec/aarch64_unknown_netbsd.rs new file mode 100644 index 0000000000000..c300855b02187 --- /dev/null +++ b/src/librustc_target/spec/aarch64_unknown_netbsd.rs @@ -0,0 +1,31 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 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/mod.rs b/src/librustc_target/spec/mod.rs index 4945784659517..ce3d61cecbb69 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), 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/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/lib.rs b/src/libsyntax/lib.rs index c8e60620248b3..0948ebea15df4 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -21,6 +21,7 @@ #![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)] 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/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/ui/catch-block-type-error.stderr b/src/test/ui/catch-block-type-error.stderr index 0ae8d4862f7c8..288168c699263 100644 --- a/src/test/ui/catch-block-type-error.stderr +++ b/src/test/ui/catch-block-type-error.stderr @@ -2,7 +2,10 @@ error[E0271]: type mismatch resolving ` as std::ops::Tr --> $DIR/catch-block-type-error.rs:18:9 | LL | 42 - | ^^ expected f32, found integral variable + | ^^ + | | + | expected f32, found integral variable + | help: use a float literal: `42.0` | = note: expected type `f32` found type `{integer}` diff --git a/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs b/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs new file mode 100644 index 0000000000000..243e3a65f391a --- /dev/null +++ b/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let sixteen: f32 = 16; + //~^ ERROR mismatched types + //~| HELP use a float literal + let a_million_and_seventy: f64 = 1_000_070; + //~^ ERROR mismatched types + //~| HELP use a float literal + let negative_nine: f32 = -9; + //~^ ERROR mismatched types + //~| HELP use a float literal + + + // only base-10 literals get the suggestion + + let sixteen_again: f64 = 0x10; + //~^ ERROR mismatched types + let and_once_more: f32 = 0o20; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr b/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr new file mode 100644 index 0000000000000..caaa9541417fb --- /dev/null +++ b/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr @@ -0,0 +1,57 @@ +error[E0308]: mismatched types + --> $DIR/issue-53280-expected-float-found-integer-literal.rs:12:24 + | +LL | let sixteen: f32 = 16; + | ^^ + | | + | expected f32, found integral variable + | help: use a float literal: `16.0` + | + = note: expected type `f32` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/issue-53280-expected-float-found-integer-literal.rs:15:38 + | +LL | let a_million_and_seventy: f64 = 1_000_070; + | ^^^^^^^^^ + | | + | expected f64, found integral variable + | help: use a float literal: `1_000_070.0` + | + = note: expected type `f64` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/issue-53280-expected-float-found-integer-literal.rs:18:30 + | +LL | let negative_nine: f32 = -9; + | ^^ + | | + | expected f32, found integral variable + | help: use a float literal: `-9.0` + | + = note: expected type `f32` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/issue-53280-expected-float-found-integer-literal.rs:25:30 + | +LL | let sixteen_again: f64 = 0x10; + | ^^^^ expected f64, found integral variable + | + = note: expected type `f64` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/issue-53280-expected-float-found-integer-literal.rs:27:30 + | +LL | let and_once_more: f32 = 0o20; + | ^^^^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0308`. 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/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() {