From 80e3f8941d86bad0bd8d5551e6d066741ade1fc2 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Tue, 29 Aug 2017 22:13:21 -0700 Subject: [PATCH 01/77] Add blanket TryFrom impl when From is implemented. Adds `impl TryFrom for U where U: From`. Removes `impl<'a, T> TryFrom<&'a str> for T where T: FromStr` due to overlapping impls caused by the new blanket impl. This removal is to be discussed further on the tracking issue for TryFrom. Refs #33417. --- src/libcore/convert.rs | 41 +++++++++++++++++++++++++++------------ src/libcore/iter/range.rs | 2 ++ src/libcore/num/mod.rs | 36 +++++++++------------------------- src/libcore/str/mod.rs | 7 ++----- 4 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 6f3c3863fae1d..37b5bfa265d5d 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -48,7 +48,24 @@ #![stable(feature = "rust1", since = "1.0.0")] -use str::FromStr; +use fmt; + +/// An uninhabited type used as the error type for implementations of fallible +/// conversion traits in cases where they cannot actually fail. +/// +/// Because `Infallible` has no constructors (variants), a value of this type +/// can never exist. It is used only to satisfy trait signatures that expect +/// an error type, and signals to both the compiler and the user that the error +/// case is impossible. +#[unstable(feature = "try_from", issue = "33417")] +pub enum Infallible {} + +#[unstable(feature = "try_from", issue = "33417")] +impl fmt::Debug for Infallible { + fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + match *self {} + } +} /// A cheap reference-to-reference conversion. Used to convert a value to a /// reference value within generic code. @@ -417,6 +434,17 @@ impl TryInto for T where U: TryFrom } } +// Infallible conversions are semantically equivalent to fallible conversions +// with an uninhabited error type. +#[unstable(feature = "try_from", issue = "33417")] +impl TryFrom for T where T: From { + type Error = Infallible; + + fn try_from(value: U) -> Result { + Ok(T::from(value)) + } +} + //////////////////////////////////////////////////////////////////////////////// // CONCRETE IMPLS //////////////////////////////////////////////////////////////////////////////// @@ -442,14 +470,3 @@ impl AsRef for str { self } } - -// FromStr implies TryFrom<&str> -#[unstable(feature = "try_from", issue = "33417")] -impl<'a, T> TryFrom<&'a str> for T where T: FromStr -{ - type Error = ::Err; - - fn try_from(s: &'a str) -> Result { - FromStr::from_str(s) - } -} diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 73d518b570a11..e9aee4a4676de 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -89,6 +89,7 @@ macro_rules! step_impl_unsigned { } #[inline] + #[allow(unreachable_patterns)] fn add_usize(&self, n: usize) -> Option { match <$t>::try_from(n) { Ok(n_as_t) => self.checked_add(n_as_t), @@ -120,6 +121,7 @@ macro_rules! step_impl_signed { } #[inline] + #[allow(unreachable_patterns)] fn add_usize(&self, n: usize) -> Option { match <$unsigned>::try_from(n) { Ok(n_as_unsigned) => { diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index c5175287ccfa6..4777f9d72ccd7 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2507,12 +2507,10 @@ impl fmt::Display for TryFromIntError { macro_rules! try_from_unbounded { ($source:ty, $($target:ty),*) => {$( #[unstable(feature = "try_from", issue = "33417")] - impl TryFrom<$source> for $target { - type Error = TryFromIntError; - + impl From<$source> for $target { #[inline] - fn try_from(u: $source) -> Result<$target, TryFromIntError> { - Ok(u as $target) + fn from(value: $source) -> $target { + value as $target } } )*} @@ -2584,31 +2582,17 @@ macro_rules! rev { } /// intra-sign conversions -try_from_unbounded!(u8, u8, u16, u32, u64, u128); -try_from_unbounded!(u16, u16, u32, u64, u128); -try_from_unbounded!(u32, u32, u64, u128); -try_from_unbounded!(u64, u64, u128); -try_from_unbounded!(u128, u128); try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); try_from_upper_bounded!(u128, u64, u32, u16, u8); -try_from_unbounded!(i8, i8, i16, i32, i64, i128); -try_from_unbounded!(i16, i16, i32, i64, i128); -try_from_unbounded!(i32, i32, i64, i128); -try_from_unbounded!(i64, i64, i128); -try_from_unbounded!(i128, i128); try_from_both_bounded!(i16, i8); try_from_both_bounded!(i32, i16, i8); try_from_both_bounded!(i64, i32, i16, i8); try_from_both_bounded!(i128, i64, i32, i16, i8); // unsigned-to-signed -try_from_unbounded!(u8, i16, i32, i64, i128); -try_from_unbounded!(u16, i32, i64, i128); -try_from_unbounded!(u32, i64, i128); -try_from_unbounded!(u64, i128); try_from_upper_bounded!(u8, i8); try_from_upper_bounded!(u16, i8, i16); try_from_upper_bounded!(u32, i8, i16, i32); @@ -2627,10 +2611,8 @@ try_from_both_bounded!(i64, u32, u16, u8); try_from_both_bounded!(i128, u64, u32, u16, u8); // usize/isize -try_from_unbounded!(usize, usize); try_from_upper_bounded!(usize, isize); try_from_lower_bounded!(isize, usize); -try_from_unbounded!(isize, isize); #[cfg(target_pointer_width = "16")] mod ptr_try_from_impls { @@ -2647,14 +2629,14 @@ mod ptr_try_from_impls { try_from_both_bounded!(isize, i8); try_from_unbounded!(isize, i16, i32, i64, i128); - rev!(try_from_unbounded, usize, u8, u16); + rev!(try_from_unbounded, usize, u16); rev!(try_from_upper_bounded, usize, u32, u64, u128); rev!(try_from_lower_bounded, usize, i8, i16); rev!(try_from_both_bounded, usize, i32, i64, i128); rev!(try_from_unbounded, isize, u8); rev!(try_from_upper_bounded, isize, u16, u32, u64, u128); - rev!(try_from_unbounded, isize, i8, i16); + rev!(try_from_unbounded, isize, i16); rev!(try_from_both_bounded, isize, i32, i64, i128); } @@ -2673,14 +2655,14 @@ mod ptr_try_from_impls { try_from_both_bounded!(isize, i8, i16); try_from_unbounded!(isize, i32, i64, i128); - rev!(try_from_unbounded, usize, u8, u16, u32); + rev!(try_from_unbounded, usize, u16, u32); rev!(try_from_upper_bounded, usize, u64, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32); rev!(try_from_both_bounded, usize, i64, i128); rev!(try_from_unbounded, isize, u8, u16); rev!(try_from_upper_bounded, isize, u32, u64, u128); - rev!(try_from_unbounded, isize, i8, i16, i32); + rev!(try_from_unbounded, isize, i16, i32); rev!(try_from_both_bounded, isize, i64, i128); } @@ -2699,14 +2681,14 @@ mod ptr_try_from_impls { try_from_both_bounded!(isize, i8, i16, i32); try_from_unbounded!(isize, i64, i128); - rev!(try_from_unbounded, usize, u8, u16, u32, u64); + rev!(try_from_unbounded, usize, u16, u32, u64); rev!(try_from_upper_bounded, usize, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32, i64); rev!(try_from_both_bounded, usize, i128); rev!(try_from_unbounded, isize, u8, u16, u32); rev!(try_from_upper_bounded, isize, u64, u128); - rev!(try_from_unbounded, isize, i8, i16, i32, i64); + rev!(try_from_unbounded, isize, i16, i32, i64); rev!(try_from_both_bounded, isize, i128); } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index a5f6e49a53b4f..86a3b9f330bbb 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -18,7 +18,6 @@ use self::pattern::Pattern; use self::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher}; use char; -use convert::TryFrom; use fmt; use iter::{Map, Cloned, FusedIterator}; use slice::{self, SliceIndex}; @@ -2142,7 +2141,7 @@ pub trait StrExt { #[stable(feature = "core", since = "1.6.0")] fn is_empty(&self) -> bool; #[stable(feature = "core", since = "1.6.0")] - fn parse<'a, T: TryFrom<&'a str>>(&'a self) -> Result; + fn parse(&self) -> Result; } // truncate `&str` to length at most equal to `max` @@ -2462,9 +2461,7 @@ impl StrExt for str { fn is_empty(&self) -> bool { self.len() == 0 } #[inline] - fn parse<'a, T>(&'a self) -> Result where T: TryFrom<&'a str> { - T::try_from(self) - } + fn parse(&self) -> Result { FromStr::from_str(self) } } #[stable(feature = "rust1", since = "1.0.0")] From b0edfce9505f8fdbfb0b6ea035b2949bc36ece5b Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Wed, 30 Aug 2017 04:42:22 -0700 Subject: [PATCH 02/77] Implement TryFrom explicitly for infallible numeric conversions. See https://github.com/rust-lang/rust/pull/44174#discussion_r135982787 --- src/libcore/num/mod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 4777f9d72ccd7..4372646a56919 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2507,10 +2507,12 @@ impl fmt::Display for TryFromIntError { macro_rules! try_from_unbounded { ($source:ty, $($target:ty),*) => {$( #[unstable(feature = "try_from", issue = "33417")] - impl From<$source> for $target { + impl TryFrom<$source> for $target { + type Error = Infallible; + #[inline] - fn from(value: $source) -> $target { - value as $target + fn try_from(value: $source) -> Result { + Ok(value as $target) } } )*} @@ -2617,7 +2619,7 @@ try_from_lower_bounded!(isize, usize); #[cfg(target_pointer_width = "16")] mod ptr_try_from_impls { use super::TryFromIntError; - use convert::TryFrom; + use convert::{Infallible, TryFrom}; try_from_upper_bounded!(usize, u8); try_from_unbounded!(usize, u16, u32, u64, u128); @@ -2643,7 +2645,7 @@ mod ptr_try_from_impls { #[cfg(target_pointer_width = "32")] mod ptr_try_from_impls { use super::TryFromIntError; - use convert::TryFrom; + use convert::{Infallible, TryFrom}; try_from_upper_bounded!(usize, u8, u16); try_from_unbounded!(usize, u32, u64, u128); @@ -2669,7 +2671,7 @@ mod ptr_try_from_impls { #[cfg(target_pointer_width = "64")] mod ptr_try_from_impls { use super::TryFromIntError; - use convert::TryFrom; + use convert::{Infallible, TryFrom}; try_from_upper_bounded!(usize, u8, u16, u32); try_from_unbounded!(usize, u64, u128); From 414ee9a2541d1a866864641c250367f0c28978be Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Wed, 30 Aug 2017 04:43:04 -0700 Subject: [PATCH 03/77] Remove test case that assumes FromStr provides TryFrom<&'a str>. See https://travis-ci.org/rust-lang/rust/jobs/269861252 --- src/libcore/tests/char.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libcore/tests/char.rs b/src/libcore/tests/char.rs index 7c3b90c81536e..4e10ceac878b6 100644 --- a/src/libcore/tests/char.rs +++ b/src/libcore/tests/char.rs @@ -32,7 +32,6 @@ fn test_convert() { #[test] fn test_from_str() { assert_eq!(char::from_str("a").unwrap(), 'a'); - assert_eq!(char::try_from("a").unwrap(), 'a'); assert_eq!(char::from_str("\0").unwrap(), '\0'); assert_eq!(char::from_str("\u{D7FF}").unwrap(), '\u{d7FF}'); assert!(char::from_str("").is_err()); From 36c0ff8690621f44b7bed31da96fbc64a101c2af Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Fri, 1 Sep 2017 00:26:37 -0700 Subject: [PATCH 04/77] Reword docs for Infallible to make them easier to understand. --- src/libcore/convert.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 37b5bfa265d5d..d3a86f7f3e3ad 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -50,13 +50,12 @@ use fmt; -/// An uninhabited type used as the error type for implementations of fallible -/// conversion traits in cases where they cannot actually fail. +/// A type used as the error type for implementations of fallible conversion +/// traits in cases where conversions cannot actually fail. /// -/// Because `Infallible` has no constructors (variants), a value of this type -/// can never exist. It is used only to satisfy trait signatures that expect -/// an error type, and signals to both the compiler and the user that the error -/// case is impossible. +/// Because `Infallible` has no variants, a value of this type can never exist. +/// It is used only to satisfy trait signatures that expect an error type, and +/// signals to both the compiler and the user that the error case is impossible. #[unstable(feature = "try_from", issue = "33417")] pub enum Infallible {} From 93a56cdacd29e8b29bae45c3abca229f6011a492 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Fri, 1 Sep 2017 01:57:05 -0700 Subject: [PATCH 05/77] impl From for TryFromIntError. --- src/libcore/num/mod.rs | 9 ++++++++- src/libcore/tests/num/mod.rs | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 4372646a56919..9f87e2bd8316d 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -12,7 +12,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -use convert::TryFrom; +use convert::{Infallible, TryFrom}; use fmt; use intrinsics; use str::FromStr; @@ -2503,6 +2503,13 @@ impl fmt::Display for TryFromIntError { } } +#[unstable(feature = "try_from", issue = "33417")] +impl From for TryFromIntError { + fn from(_: Infallible) -> TryFromIntError { + TryFromIntError(()) + } +} + // no possible bounds violation macro_rules! try_from_unbounded { ($source:ty, $($target:ty),*) => {$( diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index 400d53ce51a08..7eb5ff9885777 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::convert::TryFrom; +use core::convert::{TryFrom, TryInto}; use core::cmp::PartialEq; use core::fmt::Debug; use core::marker::Copy; +use core::num::TryFromIntError; use core::ops::{Add, Sub, Mul, Div, Rem}; use core::option::Option; use core::option::Option::{Some, None}; @@ -134,6 +135,13 @@ fn test_empty() { assert_eq!("".parse::().ok(), None); } +#[test] +fn test_infallible_try_from_int_error() { + let func = |x: i8| -> Result { Ok(x.try_into()?) }; + + assert!(func(0).is_ok()); +} + macro_rules! test_impl_from { ($fn_name: ident, $Small: ty, $Large: ty) => { #[test] From e9f01bcf68b7f01c4b05422068adb3872f68cbaf Mon Sep 17 00:00:00 2001 From: Jeroen Bollen Date: Sat, 2 Sep 2017 23:44:21 +0200 Subject: [PATCH 06/77] Added a way to retrieve the key out of a HashMap when it's being replaced. --- src/libstd/collections/hash/map.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 16b0c70998616..6eb6f892f80fe 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -2161,6 +2161,36 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> { fn take_key(&mut self) -> Option { self.key.take() } + + /// Replaces the entry, returning the old key and value. + /// + /// # Examples + /// + /// ``` + /// use std::collections::HashMap; + /// use std::collections::hash_map::Entry; + /// + /// let mut map: HashMap = HashMap::new(); + /// map.insert(String::from("poneyland"), 15); + /// + /// if let Entry::Occupied(entry) = map.entry(String::from("poneyland")) { + /// let (old_key, old_value): (String, u32) = entry.replace(16); + /// assert_eq!(old_key, "poneyland"); + /// assert_eq!(old_value, 15); + /// } + /// + /// assert_eq!(map.get("poneyland"), Some(&16)); + /// + /// ``` + #[stable(feature = "rust1", since = "1.20.0")] + pub fn replace(mut self, value: V) -> (K, V) { + let (old_key, old_value) = self.elem.read_mut(); + + let old_key = mem::replace(old_key, self.key.unwrap()); + let old_value = mem::replace(old_value, value); + + (old_key, old_value) + } } impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> { From f65bb2a051a6362b3e2dcdf3e081b8c76f5ef1a7 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Sat, 2 Sep 2017 22:50:01 -0400 Subject: [PATCH 07/77] Manuall rebase of @Migi pull/41336 --- src/libcore/internal_macros.rs | 19 +++++ src/libcore/num/wrapping.rs | 12 +++ src/libcore/ops/arith.rs | 10 +++ src/libcore/ops/bit.rs | 10 +++ src/test/run-pass/num-wrapping.rs | 9 ++ .../run-pass/op-assign-builtins-by-ref.rs | 84 +++++++++++++++++++ 6 files changed, 144 insertions(+) create mode 100644 src/test/run-pass/op-assign-builtins-by-ref.rs diff --git a/src/libcore/internal_macros.rs b/src/libcore/internal_macros.rs index 9a7914064fdd5..bd30a92b07907 100644 --- a/src/libcore/internal_macros.rs +++ b/src/libcore/internal_macros.rs @@ -68,3 +68,22 @@ macro_rules! forward_ref_binop { } } } + +// implements "T op= &U", based on "T op= U" +// where U is expected to be `Copy`able +macro_rules! forward_ref_op_assign { + (impl $imp:ident, $method:ident for $t:ty, $u:ty) => { + forward_ref_op_assign!(impl $imp, $method for $t, $u, + #[stable(feature = "op_assign_builtins_by_ref", since = "1.18.0")]); + }; + (impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => { + #[$attr] + impl<'a> $imp<&'a $u> for $t { + #[inline] + fn $method(&mut self, other: &'a $u) { + $imp::$method(self, *other); + } + } + } +} + diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index acdf685e850ab..ae1b0b3ce11b2 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -36,6 +36,7 @@ macro_rules! sh_impl_signed { *self = *self << other; } } + forward_ref_op_assign! { impl ShlAssign, shl_assign for Wrapping<$t>, $f } #[stable(feature = "rust1", since = "1.0.0")] impl Shr<$f> for Wrapping<$t> { @@ -58,6 +59,7 @@ macro_rules! sh_impl_signed { *self = *self >> other; } } + forward_ref_op_assign! { impl ShrAssign, shr_assign for Wrapping<$t>, $f } ) } @@ -80,6 +82,7 @@ macro_rules! sh_impl_unsigned { *self = *self << other; } } + forward_ref_op_assign! { impl ShlAssign, shl_assign for Wrapping<$t>, $f } #[stable(feature = "rust1", since = "1.0.0")] impl Shr<$f> for Wrapping<$t> { @@ -98,6 +101,7 @@ macro_rules! sh_impl_unsigned { *self = *self >> other; } } + forward_ref_op_assign! { impl ShrAssign, shr_assign for Wrapping<$t>, $f } ) } @@ -142,6 +146,7 @@ macro_rules! wrapping_impl { *self = *self + other; } } + forward_ref_op_assign! { impl AddAssign, add_assign for Wrapping<$t>, Wrapping<$t> } #[stable(feature = "rust1", since = "1.0.0")] impl Sub for Wrapping<$t> { @@ -162,6 +167,7 @@ macro_rules! wrapping_impl { *self = *self - other; } } + forward_ref_op_assign! { impl SubAssign, sub_assign for Wrapping<$t>, Wrapping<$t> } #[stable(feature = "rust1", since = "1.0.0")] impl Mul for Wrapping<$t> { @@ -182,6 +188,7 @@ macro_rules! wrapping_impl { *self = *self * other; } } + forward_ref_op_assign! { impl MulAssign, mul_assign for Wrapping<$t>, Wrapping<$t> } #[stable(feature = "wrapping_div", since = "1.3.0")] impl Div for Wrapping<$t> { @@ -202,6 +209,7 @@ macro_rules! wrapping_impl { *self = *self / other; } } + forward_ref_op_assign! { impl DivAssign, div_assign for Wrapping<$t>, Wrapping<$t> } #[stable(feature = "wrapping_impls", since = "1.7.0")] impl Rem for Wrapping<$t> { @@ -222,6 +230,7 @@ macro_rules! wrapping_impl { *self = *self % other; } } + forward_ref_op_assign! { impl RemAssign, rem_assign for Wrapping<$t>, Wrapping<$t> } #[stable(feature = "rust1", since = "1.0.0")] impl Not for Wrapping<$t> { @@ -254,6 +263,7 @@ macro_rules! wrapping_impl { *self = *self ^ other; } } + forward_ref_op_assign! { impl BitXorAssign, bitxor_assign for Wrapping<$t>, Wrapping<$t> } #[stable(feature = "rust1", since = "1.0.0")] impl BitOr for Wrapping<$t> { @@ -274,6 +284,7 @@ macro_rules! wrapping_impl { *self = *self | other; } } + forward_ref_op_assign! { impl BitOrAssign, bitor_assign for Wrapping<$t>, Wrapping<$t> } #[stable(feature = "rust1", since = "1.0.0")] impl BitAnd for Wrapping<$t> { @@ -294,6 +305,7 @@ macro_rules! wrapping_impl { *self = *self & other; } } + forward_ref_op_assign! { impl BitAndAssign, bitand_assign for Wrapping<$t>, Wrapping<$t> } #[stable(feature = "wrapping_neg", since = "1.10.0")] impl Neg for Wrapping<$t> { diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 62007caedd3fc..8b3d662a6db77 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -662,6 +662,8 @@ macro_rules! add_assign_impl { #[rustc_inherit_overflow_checks] fn add_assign(&mut self, other: $t) { *self += other } } + + forward_ref_op_assign! { impl AddAssign, add_assign for $t, $t } )+) } @@ -713,6 +715,8 @@ macro_rules! sub_assign_impl { #[rustc_inherit_overflow_checks] fn sub_assign(&mut self, other: $t) { *self -= other } } + + forward_ref_op_assign! { impl SubAssign, sub_assign for $t, $t } )+) } @@ -755,6 +759,8 @@ macro_rules! mul_assign_impl { #[rustc_inherit_overflow_checks] fn mul_assign(&mut self, other: $t) { *self *= other } } + + forward_ref_op_assign! { impl MulAssign, mul_assign for $t, $t } )+) } @@ -796,6 +802,8 @@ macro_rules! div_assign_impl { #[inline] fn div_assign(&mut self, other: $t) { *self /= other } } + + forward_ref_op_assign! { impl DivAssign, div_assign for $t, $t } )+) } @@ -841,6 +849,8 @@ macro_rules! rem_assign_impl { #[inline] fn rem_assign(&mut self, other: $t) { *self %= other } } + + forward_ref_op_assign! { impl RemAssign, rem_assign for $t, $t } )+) } diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs index 0bc5e554cb347..7ac5fc4debf14 100644 --- a/src/libcore/ops/bit.rs +++ b/src/libcore/ops/bit.rs @@ -593,6 +593,8 @@ macro_rules! bitand_assign_impl { #[inline] fn bitand_assign(&mut self, other: $t) { *self &= other } } + + forward_ref_op_assign! { impl BitAndAssign, bitand_assign for $t, $t } )+) } @@ -638,6 +640,8 @@ macro_rules! bitor_assign_impl { #[inline] fn bitor_assign(&mut self, other: $t) { *self |= other } } + + forward_ref_op_assign! { impl BitOrAssign, bitor_assign for $t, $t } )+) } @@ -683,6 +687,8 @@ macro_rules! bitxor_assign_impl { #[inline] fn bitxor_assign(&mut self, other: $t) { *self ^= other } } + + forward_ref_op_assign! { impl BitXorAssign, bitxor_assign for $t, $t } )+) } @@ -729,6 +735,8 @@ macro_rules! shl_assign_impl { *self <<= other } } + + forward_ref_op_assign! { impl ShlAssign, shl_assign for $t, $f } ) } @@ -793,6 +801,8 @@ macro_rules! shr_assign_impl { *self >>= other } } + + forward_ref_op_assign! { impl ShrAssign, shr_assign for $t, $f } ) } diff --git a/src/test/run-pass/num-wrapping.rs b/src/test/run-pass/num-wrapping.rs index 143759e271561..20c7f27336e25 100644 --- a/src/test/run-pass/num-wrapping.rs +++ b/src/test/run-pass/num-wrapping.rs @@ -173,6 +173,15 @@ fn test_op_assigns() { tmp.$op(Wrapping($rhs)); assert_eq!(black_box(tmp), Wrapping($ans)); } + + // also test that a &Wrapping right-hand side is possible + { + let mut tmp = Wrapping($initial); + tmp = black_box(tmp); + tmp.$op(&Wrapping($rhs)); + assert_eq!(black_box(tmp), Wrapping($ans)); + } + // FIXME(30524): Uncomment this test /* { diff --git a/src/test/run-pass/op-assign-builtins-by-ref.rs b/src/test/run-pass/op-assign-builtins-by-ref.rs new file mode 100644 index 0000000000000..77023a566794f --- /dev/null +++ b/src/test/run-pass/op-assign-builtins-by-ref.rs @@ -0,0 +1,84 @@ +// Copyright 2015 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() { + // test compound assignment operators with ref as right-hand side, + // for each operator, with various types as operands. + + // test AddAssign + { + let mut x = 3i8; + x += &2i8; + assert_eq!(x, 5i8); + } + + // test SubAssign + { + let mut x = 7i16; + x -= &4; + assert_eq!(x, 3i16); + } + + // test MulAssign + { + let mut x = 3f32; + x *= &3f32; + assert_eq!(x, 9f32); + } + + // test DivAssign + { + let mut x = 6f64; + x /= &2f64; + assert_eq!(x, 3f64); + } + + // test RemAssign + { + let mut x = 7i64; + x %= &4i64; + assert_eq!(x, 3i64); + } + + // test BitOrAssign + { + let mut x = 0b1010u8; + x |= &0b1100u8; + assert_eq!(x, 0b1110u8); + } + + // test BitAndAssign + { + let mut x = 0b1010u16; + x &= &0b1100u16; + assert_eq!(x, 0b1000u16); + } + + // test BitXorAssign + { + let mut x = 0b1010u32; + x ^= &0b1100u32; + assert_eq!(x, 0b0110u32); + } + + // test ShlAssign + { + let mut x = 0b1010u64; + x <<= &2u32; + assert_eq!(x, 0b101000u64); + } + + // test ShrAssign + { + let mut x = 0b1010u64; + x >>= &2i16; + assert_eq!(x, 0b10u64); + } +} \ No newline at end of file From 9a547fc7c49f484b0be223d53cd0c6a08bbadef5 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Sun, 3 Sep 2017 13:07:47 -0400 Subject: [PATCH 08/77] get ci green --- .../for-loop-unconstrained-element-type-i32-fallback.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs b/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs index b36afcf87b3ee..264efa9f40227 100644 --- a/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs +++ b/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs @@ -9,9 +9,11 @@ // except according to those terms. // Test that the type of `sum` falls back to `i32` here, -// and that the for loop desugaring doesn't inferfere with +// and that the for loop desugaring doesn't interfere with // that. +// ignore-test + fn main() { let mut sum = 0; for i in Vec::new() { From a312b4769808f69607377c8e00a5436c31edf67d Mon Sep 17 00:00:00 2001 From: Jeroen Bollen Date: Sun, 3 Sep 2017 20:16:20 +0200 Subject: [PATCH 09/77] Marked `Entry::replace` as unstable. --- src/libstd/collections/hash/map.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 6eb6f892f80fe..81d79493f0808 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -2167,6 +2167,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> { /// # Examples /// /// ``` + /// # #![feature(map_entry_replace)] /// use std::collections::HashMap; /// use std::collections::hash_map::Entry; /// @@ -2182,7 +2183,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> { /// assert_eq!(map.get("poneyland"), Some(&16)); /// /// ``` - #[stable(feature = "rust1", since = "1.20.0")] + #[unstable(feature = "map_entry_replace", issue = "44286")] pub fn replace(mut self, value: V) -> (K, V) { let (old_key, old_value) = self.elem.read_mut(); From d3de465dc85638a6a77298638ebbbfab04b1844d Mon Sep 17 00:00:00 2001 From: Jeroen Bollen Date: Tue, 12 Sep 2017 15:32:10 +0200 Subject: [PATCH 10/77] Addressed @BurntSuchi's remarks regarding Entry::replace --- src/libstd/collections/hash/map.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 81d79493f0808..48dad8bff5d70 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -2167,21 +2167,20 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> { /// # Examples /// /// ``` - /// # #![feature(map_entry_replace)] + /// #![feature(map_entry_replace)] /// use std::collections::HashMap; /// use std::collections::hash_map::Entry; /// /// let mut map: HashMap = HashMap::new(); - /// map.insert(String::from("poneyland"), 15); + /// map.insert("poneyland".to_string(), 15); /// - /// if let Entry::Occupied(entry) = map.entry(String::from("poneyland")) { + /// if let Entry::Occupied(entry) = map.entry("poneyland".to_string()) { /// let (old_key, old_value): (String, u32) = entry.replace(16); /// assert_eq!(old_key, "poneyland"); /// assert_eq!(old_value, 15); /// } /// /// assert_eq!(map.get("poneyland"), Some(&16)); - /// /// ``` #[unstable(feature = "map_entry_replace", issue = "44286")] pub fn replace(mut self, value: V) -> (K, V) { From 732dd2fd5f5fb28193408b64ade0e940434d239f Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Tue, 12 Sep 2017 16:56:40 -0400 Subject: [PATCH 11/77] Missing trailing newline --- src/test/run-pass/op-assign-builtins-by-ref.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-pass/op-assign-builtins-by-ref.rs b/src/test/run-pass/op-assign-builtins-by-ref.rs index 77023a566794f..230d44ba647a5 100644 --- a/src/test/run-pass/op-assign-builtins-by-ref.rs +++ b/src/test/run-pass/op-assign-builtins-by-ref.rs @@ -81,4 +81,4 @@ fn main() { x >>= &2i16; assert_eq!(x, 0b10u64); } -} \ No newline at end of file +} From b91bac29835fb7d70ee5d29cac970efa18eeba89 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Thu, 14 Sep 2017 10:46:14 -0400 Subject: [PATCH 12/77] readd test --- .../for-loop-unconstrained-element-type-i32-fallback.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs b/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs index 264efa9f40227..0bfc4d2264c62 100644 --- a/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs +++ b/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs @@ -12,11 +12,9 @@ // and that the for loop desugaring doesn't interfere with // that. -// ignore-test - fn main() { let mut sum = 0; for i in Vec::new() { - sum += i; + sum += &i; } } From 5f6de3d40238aa253b7dc4dd037599ef9e29999f Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Mon, 18 Sep 2017 22:19:00 -0700 Subject: [PATCH 13/77] Derive additional traits for Infallible. --- src/libcore/convert.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index d3a86f7f3e3ad..9730de0efe9e2 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -48,8 +48,6 @@ #![stable(feature = "rust1", since = "1.0.0")] -use fmt; - /// A type used as the error type for implementations of fallible conversion /// traits in cases where conversions cannot actually fail. /// @@ -57,15 +55,9 @@ use fmt; /// It is used only to satisfy trait signatures that expect an error type, and /// signals to both the compiler and the user that the error case is impossible. #[unstable(feature = "try_from", issue = "33417")] +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum Infallible {} -#[unstable(feature = "try_from", issue = "33417")] -impl fmt::Debug for Infallible { - fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { - match *self {} - } -} - /// A cheap reference-to-reference conversion. Used to convert a value to a /// reference value within generic code. /// From 2c78bb49fde79e93b110a979f1f11b3f1221e1ef Mon Sep 17 00:00:00 2001 From: Tommy Ip Date: Wed, 20 Sep 2017 18:14:19 +0100 Subject: [PATCH 14/77] Add --all flag to ./x.py clean This flag removes all build artifacts, including the LLVM build directory. --- src/bootstrap/builder.rs | 2 +- src/bootstrap/clean.rs | 35 ++++++++++++++++++++--------------- src/bootstrap/flags.rs | 10 ++++++++-- src/bootstrap/lib.rs | 4 ++-- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 7d116f23ef581..935b690497b52 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -306,7 +306,7 @@ impl<'a> Builder<'a> { Subcommand::Bench { ref paths, .. } => (Kind::Bench, &paths[..]), Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]), Subcommand::Install { ref paths } => (Kind::Install, &paths[..]), - Subcommand::Clean => panic!(), + Subcommand::Clean { .. } => panic!(), }; let builder = Builder { diff --git a/src/bootstrap/clean.rs b/src/bootstrap/clean.rs index 119340a0190c4..87f194fb7d2f8 100644 --- a/src/bootstrap/clean.rs +++ b/src/bootstrap/clean.rs @@ -13,7 +13,7 @@ //! Responsible for cleaning out a build directory of all old and stale //! artifacts to prepare for a fresh build. Currently doesn't remove the //! `build/cache` directory (download cache) or the `build/$target/llvm` -//! directory as we want that cached between builds. +//! directory unless the --all flag is present. use std::fs; use std::io::{self, ErrorKind}; @@ -21,24 +21,29 @@ use std::path::Path; use Build; -pub fn clean(build: &Build) { +pub fn clean(build: &Build, all: bool) { rm_rf("tmp".as_ref()); - rm_rf(&build.out.join("tmp")); - rm_rf(&build.out.join("dist")); - for host in &build.hosts { - let entries = match build.out.join(host).read_dir() { - Ok(iter) => iter, - Err(_) => continue, - }; + if all { + rm_rf(&build.out); + } else { + rm_rf(&build.out.join("tmp")); + rm_rf(&build.out.join("dist")); - for entry in entries { - let entry = t!(entry); - if entry.file_name().to_str() == Some("llvm") { - continue + for host in &build.hosts { + let entries = match build.out.join(host).read_dir() { + Ok(iter) => iter, + Err(_) => continue, + }; + + for entry in entries { + let entry = t!(entry); + if entry.file_name().to_str() == Some("llvm") { + continue + } + let path = t!(entry.path().canonicalize()); + rm_rf(&path); } - let path = t!(entry.path().canonicalize()); - rm_rf(&path); } } } diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 7546d7fd4f07a..34b0ca627aad1 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -60,7 +60,9 @@ pub enum Subcommand { paths: Vec, test_args: Vec, }, - Clean, + Clean { + all: bool, + }, Dist { paths: Vec, }, @@ -147,6 +149,7 @@ To learn more about a subcommand, run `./x.py -h`"); opts.optmulti("", "test-args", "extra arguments", "ARGS"); }, "bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); }, + "clean" => { opts.optflag("", "all", "clean all build artifacts"); }, _ => { }, }; @@ -293,7 +296,10 @@ Arguments: println!("\nclean takes no arguments\n"); usage(1, &opts, &subcommand_help, &extra_help); } - Subcommand::Clean + + Subcommand::Clean { + all: matches.opt_present("all"), + } } "dist" => { Subcommand::Dist { diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 06c7c4c2faffc..0876786f9a544 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -345,8 +345,8 @@ impl Build { job::setup(self); } - if let Subcommand::Clean = self.config.cmd { - return clean::clean(self); + if let Subcommand::Clean { all } = self.config.cmd { + return clean::clean(self, all); } self.verbose("finding compilers"); From 09d90e52682641e5d6d0a70e42011fd24ced1434 Mon Sep 17 00:00:00 2001 From: Tommy Ip Date: Wed, 20 Sep 2017 19:31:59 +0100 Subject: [PATCH 15/77] Do not show "available paths" help in ./x.py clean --- src/bootstrap/flags.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 34b0ca627aad1..df378188b4ad0 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -253,7 +253,7 @@ Arguments: } }); - // All subcommands can have an optional "Available paths" section + // All subcommands except `clean` can have an optional "Available paths" section if matches.opt_present("verbose") { let config = Config::parse(&["build".to_string()]); let mut build = Build::new(config); @@ -261,9 +261,10 @@ Arguments: let maybe_rules_help = Builder::get_help(&build, subcommand.as_str()); extra_help.push_str(maybe_rules_help.unwrap_or_default().as_str()); - } else { - extra_help.push_str(format!("Run `./x.py {} -h -v` to see a list of available paths.", - subcommand).as_str()); + } else if subcommand.as_str() != "clean" { + extra_help.push_str(format!( + "Run `./x.py {} -h -v` to see a list of available paths.", + subcommand).as_str()); } // User passed in -h/--help? @@ -293,7 +294,7 @@ Arguments: } "clean" => { if paths.len() > 0 { - println!("\nclean takes no arguments\n"); + println!("\nclean does not take a path argument\n"); usage(1, &opts, &subcommand_help, &extra_help); } From cfc711e062e607dc5defad439b9ee34b5ba6fcef Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Thu, 21 Sep 2017 15:46:17 -0400 Subject: [PATCH 16/77] fix version number --- src/libcore/internal_macros.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/internal_macros.rs b/src/libcore/internal_macros.rs index bd30a92b07907..cb215a38e5356 100644 --- a/src/libcore/internal_macros.rs +++ b/src/libcore/internal_macros.rs @@ -74,7 +74,7 @@ macro_rules! forward_ref_binop { macro_rules! forward_ref_op_assign { (impl $imp:ident, $method:ident for $t:ty, $u:ty) => { forward_ref_op_assign!(impl $imp, $method for $t, $u, - #[stable(feature = "op_assign_builtins_by_ref", since = "1.18.0")]); + #[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]); }; (impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => { #[$attr] From 2adeba62077fc7630d57705cce4f2f0e9029351e Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Thu, 21 Sep 2017 15:53:33 -0400 Subject: [PATCH 17/77] update xsv to head --- src/tools/cargotest/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index 012ee835494e8..0a9da26d9968d 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -49,7 +49,7 @@ const TEST_REPOS: &'static [Test] = &[ Test { name: "xsv", repo: "https://github.com/BurntSushi/xsv", - sha: "a9a7163f2a2953cea426fee1216bec914fe2f56a", + sha: "4b308adbe48ac81657fd124b90b44f7c3263f771", lock: None, }, ]; From 9562981b0b6dc2d7ae6070732778623a59cfdd0a Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Thu, 21 Sep 2017 20:21:54 -0700 Subject: [PATCH 18/77] impl std::error::Error for convert::Infallible. --- src/libstd/error.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 401552a6ec417..5cb2b00334db3 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -55,6 +55,7 @@ use alloc::allocator; use any::TypeId; use cell; use char; +use convert; use fmt::{self, Debug, Display}; use mem::transmute; use num; @@ -347,6 +348,12 @@ impl Error for char::ParseCharError { } } +#[unstable(feature = "try_from", issue = "33417")] +impl Error for convert::Infallible { + fn description(&self) -> &str { + "an error of this type can never exist" + } +} // copied from any.rs impl Error + 'static { From 79f2439aa698c7eefa089ad05027826d7911780f Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Thu, 21 Sep 2017 21:03:40 -0700 Subject: [PATCH 19/77] Impl fmt::Display for convert::Infallible. --- src/libcore/convert.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 9730de0efe9e2..6eb499ad8ab23 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -48,6 +48,8 @@ #![stable(feature = "rust1", since = "1.0.0")] +use fmt; + /// A type used as the error type for implementations of fallible conversion /// traits in cases where conversions cannot actually fail. /// @@ -58,6 +60,12 @@ #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum Infallible {} +#[unstable(feature = "try_from", issue = "33417")] +impl fmt::Display for Infallible { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + "an error of this type can never exist".fmt(f) + } +} /// A cheap reference-to-reference conversion. Used to convert a value to a /// reference value within generic code. /// From e64efc91f49affb265328e354c8c8f0544daa462 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Tue, 19 Sep 2017 05:40:04 +0000 Subject: [PATCH 20/77] Add support for `..=` syntax Add ..= to the parser Add ..= to libproc_macro Add ..= to ICH Highlight ..= in rustdoc Update impl Debug for RangeInclusive to ..= Replace `...` to `..=` in range docs Make the dotdoteq warning point to the ... Add warning for ... in expressions Updated more tests to the ..= syntax Updated even more tests to the ..= syntax Updated the inclusive_range entry in unstable book --- .../inclusive-range-syntax.md | 4 +- src/liballoc/tests/btree/map.rs | 28 ++++---- src/liballoc/tests/str.rs | 16 ++--- src/liballoc/tests/string.rs | 6 +- src/liballoc/tests/vec.rs | 28 ++++---- src/libcore/ops/range.rs | 50 +++++++------- src/libcore/slice/mod.rs | 4 ++ src/libcore/tests/iter.rs | 32 ++++----- src/libproc_macro/lib.rs | 2 + src/libproc_macro/quote.rs | 4 +- src/librustc/ich/impls_syntax.rs | 2 + src/librustdoc/html/highlight.rs | 6 +- src/libsyntax/diagnostic_list.rs | 4 +- src/libsyntax/ext/quote.rs | 2 + src/libsyntax/feature_gate.rs | 2 +- src/libsyntax/parse/lexer/mod.rs | 3 + src/libsyntax/parse/parser.rs | 50 ++++++++++---- src/libsyntax/parse/token.rs | 35 ++++++---- src/libsyntax/print/pprust.rs | 2 + src/libsyntax/util/parser.rs | 17 ++--- src/test/compile-fail/E0586.rs | 2 +- src/test/compile-fail/impossible_range.rs | 8 +-- src/test/compile-fail/range_inclusive_gate.rs | 2 +- .../hashes/indexing_expressions.rs | 2 +- src/test/parse-fail/pat-ranges-1.rs | 2 +- src/test/parse-fail/pat-ranges-2.rs | 2 +- src/test/parse-fail/pat-ranges-3.rs | 2 +- src/test/parse-fail/pat-ranges-4.rs | 3 +- src/test/parse-fail/range_inclusive.rs | 2 +- src/test/parse-fail/range_inclusive_gate.rs | 14 ++-- src/test/run-pass/inc-range-pat.rs | 20 ++++++ src/test/run-pass/range_inclusive.rs | 68 +++++++++---------- src/test/run-pass/range_inclusive_gate.rs | 2 +- 33 files changed, 244 insertions(+), 182 deletions(-) create mode 100644 src/test/run-pass/inc-range-pat.rs diff --git a/src/doc/unstable-book/src/language-features/inclusive-range-syntax.md b/src/doc/unstable-book/src/language-features/inclusive-range-syntax.md index 255445c318dca..56f58803150ca 100644 --- a/src/doc/unstable-book/src/language-features/inclusive-range-syntax.md +++ b/src/doc/unstable-book/src/language-features/inclusive-range-syntax.md @@ -7,13 +7,13 @@ The tracking issue for this feature is: [#28237] ------------------------ To get a range that goes from 0 to 10 and includes the value 10, you -can write `0...10`: +can write `0..=10`: ```rust #![feature(inclusive_range_syntax)] fn main() { - for i in 0...10 { + for i in 0..=10 { println!("{}", i); } } diff --git a/src/liballoc/tests/btree/map.rs b/src/liballoc/tests/btree/map.rs index 2c899d96940ec..2393101040d9f 100644 --- a/src/liballoc/tests/btree/map.rs +++ b/src/liballoc/tests/btree/map.rs @@ -182,7 +182,7 @@ fn test_range_small() { fn test_range_inclusive() { let size = 500; - let map: BTreeMap<_, _> = (0...size).map(|i| (i, i)).collect(); + let map: BTreeMap<_, _> = (0..=size).map(|i| (i, i)).collect(); fn check<'a, L, R>(lhs: L, rhs: R) where L: IntoIterator, @@ -193,18 +193,18 @@ fn test_range_inclusive() { assert_eq!(lhs, rhs); } - check(map.range(size + 1...size + 1), vec![]); - check(map.range(size...size), vec![(&size, &size)]); - check(map.range(size...size + 1), vec![(&size, &size)]); - check(map.range(0...0), vec![(&0, &0)]); - check(map.range(0...size - 1), map.range(..size)); - check(map.range(-1...-1), vec![]); - check(map.range(-1...size), map.range(..)); - check(map.range(...size), map.range(..)); - check(map.range(...200), map.range(..201)); - check(map.range(5...8), vec![(&5, &5), (&6, &6), (&7, &7), (&8, &8)]); - check(map.range(-1...0), vec![(&0, &0)]); - check(map.range(-1...2), vec![(&0, &0), (&1, &1), (&2, &2)]); + check(map.range(size + 1..=size + 1), vec![]); + check(map.range(size..=size), vec![(&size, &size)]); + check(map.range(size..=size + 1), vec![(&size, &size)]); + check(map.range(0..=0), vec![(&0, &0)]); + check(map.range(0..=size - 1), map.range(..size)); + check(map.range(-1..=-1), vec![]); + check(map.range(-1..=size), map.range(..)); + check(map.range(..=size), map.range(..)); + check(map.range(..=200), map.range(..201)); + check(map.range(5..=8), vec![(&5, &5), (&6, &6), (&7, &7), (&8, &8)]); + check(map.range(-1..=0), vec![(&0, &0)]); + check(map.range(-1..=2), vec![(&0, &0), (&1, &1), (&2, &2)]); } #[test] @@ -212,7 +212,7 @@ fn test_range_inclusive_max_value() { let max = ::std::usize::MAX; let map: BTreeMap<_, _> = vec![(max, 0)].into_iter().collect(); - assert_eq!(map.range(max...max).collect::>(), &[(&max, &0)]); + assert_eq!(map.range(max..=max).collect::>(), &[(&max, &0)]); } #[test] diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 9d8ca38b20e48..b3178064505e8 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -361,13 +361,13 @@ fn test_slice_fail() { #[test] #[should_panic] fn test_str_slice_rangetoinclusive_max_panics() { - &"hello"[...usize::max_value()]; + &"hello"[..=usize::max_value()]; } #[test] #[should_panic] fn test_str_slice_rangeinclusive_max_panics() { - &"hello"[1...usize::max_value()]; + &"hello"[1..=usize::max_value()]; } #[test] @@ -375,7 +375,7 @@ fn test_str_slice_rangeinclusive_max_panics() { fn test_str_slicemut_rangetoinclusive_max_panics() { let mut s = "hello".to_owned(); let s: &mut str = &mut s; - &mut s[...usize::max_value()]; + &mut s[..=usize::max_value()]; } #[test] @@ -383,7 +383,7 @@ fn test_str_slicemut_rangetoinclusive_max_panics() { fn test_str_slicemut_rangeinclusive_max_panics() { let mut s = "hello".to_owned(); let s: &mut str = &mut s; - &mut s[1...usize::max_value()]; + &mut s[1..=usize::max_value()]; } #[test] @@ -391,13 +391,13 @@ fn test_str_get_maxinclusive() { let mut s = "hello".to_owned(); { let s: &str = &s; - assert_eq!(s.get(...usize::max_value()), None); - assert_eq!(s.get(1...usize::max_value()), None); + assert_eq!(s.get(..=usize::max_value()), None); + assert_eq!(s.get(1..=usize::max_value()), None); } { let s: &mut str = &mut s; - assert_eq!(s.get(...usize::max_value()), None); - assert_eq!(s.get(1...usize::max_value()), None); + assert_eq!(s.get(..=usize::max_value()), None); + assert_eq!(s.get(1..=usize::max_value()), None); } } diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index 6aba18ddf49ff..ef6f5e10a72de 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -456,9 +456,9 @@ fn test_splice_char_boundary() { #[test] fn test_splice_inclusive_range() { let mut v = String::from("12345"); - v.splice(2...3, "789"); + v.splice(2..=3, "789"); assert_eq!(v, "127895"); - v.splice(1...2, "A"); + v.splice(1..=2, "A"); assert_eq!(v, "1A895"); } @@ -473,7 +473,7 @@ fn test_splice_out_of_bounds() { #[should_panic] fn test_splice_inclusive_out_of_bounds() { let mut s = String::from("12345"); - s.splice(5...5, "789"); + s.splice(5..=5, "789"); } #[test] diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 670ea8089fc26..0e25da5bd3077 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -537,27 +537,27 @@ fn test_drain_range() { #[test] fn test_drain_inclusive_range() { let mut v = vec!['a', 'b', 'c', 'd', 'e']; - for _ in v.drain(1...3) { + for _ in v.drain(1..=3) { } assert_eq!(v, &['a', 'e']); - let mut v: Vec<_> = (0...5).map(|x| x.to_string()).collect(); - for _ in v.drain(1...5) { + let mut v: Vec<_> = (0..=5).map(|x| x.to_string()).collect(); + for _ in v.drain(1..=5) { } assert_eq!(v, &["0".to_string()]); - let mut v: Vec = (0...5).map(|x| x.to_string()).collect(); - for _ in v.drain(0...5) { + let mut v: Vec = (0..=5).map(|x| x.to_string()).collect(); + for _ in v.drain(0..=5) { } assert_eq!(v, Vec::::new()); - let mut v: Vec<_> = (0...5).map(|x| x.to_string()).collect(); - for _ in v.drain(0...3) { + let mut v: Vec<_> = (0..=5).map(|x| x.to_string()).collect(); + for _ in v.drain(0..=3) { } assert_eq!(v, &["4".to_string(), "5".to_string()]); - let mut v: Vec<_> = (0...1).map(|x| x.to_string()).collect(); - for _ in v.drain(...0) { + let mut v: Vec<_> = (0..=1).map(|x| x.to_string()).collect(); + for _ in v.drain(..=0) { } assert_eq!(v, &["1".to_string()]); } @@ -572,7 +572,7 @@ fn test_drain_max_vec_size() { let mut v = Vec::<()>::with_capacity(usize::max_value()); unsafe { v.set_len(usize::max_value()); } - for _ in v.drain(usize::max_value() - 1...usize::max_value() - 1) { + for _ in v.drain(usize::max_value() - 1..=usize::max_value() - 1) { } assert_eq!(v.len(), usize::max_value() - 1); } @@ -581,7 +581,7 @@ fn test_drain_max_vec_size() { #[should_panic] fn test_drain_inclusive_out_of_bounds() { let mut v = vec![1, 2, 3, 4, 5]; - v.drain(5...5); + v.drain(5..=5); } #[test] @@ -598,10 +598,10 @@ fn test_splice() { fn test_splice_inclusive_range() { let mut v = vec![1, 2, 3, 4, 5]; let a = [10, 11, 12]; - let t1: Vec<_> = v.splice(2...3, a.iter().cloned()).collect(); + let t1: Vec<_> = v.splice(2..=3, a.iter().cloned()).collect(); assert_eq!(v, &[1, 2, 10, 11, 12, 5]); assert_eq!(t1, &[3, 4]); - let t2: Vec<_> = v.splice(1...2, Some(20)).collect(); + let t2: Vec<_> = v.splice(1..=2, Some(20)).collect(); assert_eq!(v, &[1, 20, 11, 12, 5]); assert_eq!(t2, &[2, 10]); } @@ -619,7 +619,7 @@ fn test_splice_out_of_bounds() { fn test_splice_inclusive_out_of_bounds() { let mut v = vec![1, 2, 3, 4, 5]; let a = [10, 11, 12]; - v.splice(5...5, a.iter().cloned()); + v.splice(5..=5, a.iter().cloned()); } #[test] diff --git a/src/libcore/ops/range.rs b/src/libcore/ops/range.rs index 463a50491a866..3f573f7c7eb69 100644 --- a/src/libcore/ops/range.rs +++ b/src/libcore/ops/range.rs @@ -241,9 +241,9 @@ impl> RangeTo { } } -/// An range bounded inclusively below and above (`start...end`). +/// An range bounded inclusively below and above (`start..=end`). /// -/// The `RangeInclusive` `start...end` contains all values with `x >= start` +/// The `RangeInclusive` `start..=end` contains all values with `x >= start` /// and `x <= end`. /// /// # Examples @@ -251,12 +251,12 @@ impl> RangeTo { /// ``` /// #![feature(inclusive_range,inclusive_range_syntax)] /// -/// assert_eq!((3...5), std::ops::RangeInclusive { start: 3, end: 5 }); -/// assert_eq!(3 + 4 + 5, (3...5).sum()); +/// assert_eq!((3..=5), std::ops::RangeInclusive { start: 3, end: 5 }); +/// assert_eq!(3 + 4 + 5, (3..=5).sum()); /// /// let arr = [0, 1, 2, 3]; -/// assert_eq!(arr[ ...2], [0,1,2 ]); -/// assert_eq!(arr[1...2], [ 1,2 ]); // RangeInclusive +/// assert_eq!(arr[ ..=2], [0,1,2 ]); +/// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive /// ``` #[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186 #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")] @@ -276,7 +276,7 @@ pub struct RangeInclusive { #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")] impl fmt::Debug for RangeInclusive { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{:?}...{:?}", self.start, self.end) + write!(fmt, "{:?}..={:?}", self.start, self.end) } } @@ -289,32 +289,32 @@ impl> RangeInclusive { /// ``` /// #![feature(range_contains,inclusive_range_syntax)] /// - /// assert!(!(3...5).contains(2)); - /// assert!( (3...5).contains(3)); - /// assert!( (3...5).contains(4)); - /// assert!( (3...5).contains(5)); - /// assert!(!(3...5).contains(6)); + /// assert!(!(3..=5).contains(2)); + /// assert!( (3..=5).contains(3)); + /// assert!( (3..=5).contains(4)); + /// assert!( (3..=5).contains(5)); + /// assert!(!(3..=5).contains(6)); /// - /// assert!( (3...3).contains(3)); - /// assert!(!(3...2).contains(3)); + /// assert!( (3..=3).contains(3)); + /// assert!(!(3..=2).contains(3)); /// ``` pub fn contains(&self, item: Idx) -> bool { self.start <= item && item <= self.end } } -/// A range only bounded inclusively above (`...end`). +/// A range only bounded inclusively above (`..=end`). /// -/// The `RangeToInclusive` `...end` contains all values with `x <= end`. +/// The `RangeToInclusive` `..=end` contains all values with `x <= end`. /// It cannot serve as an [`Iterator`] because it doesn't have a starting point. /// /// # Examples /// -/// The `...end` syntax is a `RangeToInclusive`: +/// The `..=end` syntax is a `RangeToInclusive`: /// /// ``` /// #![feature(inclusive_range,inclusive_range_syntax)] -/// assert_eq!((...5), std::ops::RangeToInclusive{ end: 5 }); +/// assert_eq!((..=5), std::ops::RangeToInclusive{ end: 5 }); /// ``` /// /// It does not have an [`IntoIterator`] implementation, so you can't use it in a @@ -325,7 +325,7 @@ impl> RangeInclusive { /// /// // error[E0277]: the trait bound `std::ops::RangeToInclusive<{integer}>: /// // std::iter::Iterator` is not satisfied -/// for i in ...5 { +/// for i in ..=5 { /// // ... /// } /// ``` @@ -337,8 +337,8 @@ impl> RangeInclusive { /// #![feature(inclusive_range_syntax)] /// /// let arr = [0, 1, 2, 3]; -/// assert_eq!(arr[ ...2], [0,1,2 ]); // RangeToInclusive -/// assert_eq!(arr[1...2], [ 1,2 ]); +/// assert_eq!(arr[ ..=2], [0,1,2 ]); // RangeToInclusive +/// assert_eq!(arr[1..=2], [ 1,2 ]); /// ``` /// /// [`IntoIterator`]: ../iter/trait.Iterator.html @@ -357,7 +357,7 @@ pub struct RangeToInclusive { #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")] impl fmt::Debug for RangeToInclusive { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "...{:?}", self.end) + write!(fmt, "..={:?}", self.end) } } @@ -370,9 +370,9 @@ impl> RangeToInclusive { /// ``` /// #![feature(range_contains,inclusive_range_syntax)] /// - /// assert!( (...5).contains(-1_000_000_000)); - /// assert!( (...5).contains(5)); - /// assert!(!(...5).contains(6)); + /// assert!( (..=5).contains(-1_000_000_000)); + /// assert!( (..=5).contains(5)); + /// assert!(!(..=5).contains(6)); /// ``` pub fn contains(&self, item: Idx) -> bool { (item <= self.end) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index dacc014955a90..c52e88170aeb7 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -16,6 +16,10 @@ #![stable(feature = "rust1", since = "1.0.0")] +// FIXME: replace remaining ... by ..= after next stage0 +// Silence warning: "... is being replaced by ..=" +#![cfg_attr(not(stage0), allow(warnings))] + // How this module is organized. // // The library infrastructure for slices is fairly messy. There's diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 59ae30de452c9..3c4ea974fc9f2 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -1094,21 +1094,21 @@ fn test_range() { #[test] fn test_range_inclusive_exhaustion() { - let mut r = 10...10; + let mut r = 10..=10; assert_eq!(r.next(), Some(10)); - assert_eq!(r, 1...0); + assert_eq!(r, 1..=0); - let mut r = 10...10; + let mut r = 10..=10; assert_eq!(r.next_back(), Some(10)); - assert_eq!(r, 1...0); + assert_eq!(r, 1..=0); - let mut r = 10...12; + let mut r = 10..=12; assert_eq!(r.nth(2), Some(12)); - assert_eq!(r, 1...0); + assert_eq!(r, 1..=0); - let mut r = 10...12; + let mut r = 10..=12; assert_eq!(r.nth(5), None); - assert_eq!(r, 1...0); + assert_eq!(r, 1..=0); } @@ -1145,20 +1145,20 @@ fn test_range_from_nth() { #[test] fn test_range_inclusive_nth() { - assert_eq!((10...15).nth(0), Some(10)); - assert_eq!((10...15).nth(1), Some(11)); - assert_eq!((10...15).nth(5), Some(15)); - assert_eq!((10...15).nth(6), None); + assert_eq!((10..=15).nth(0), Some(10)); + assert_eq!((10..=15).nth(1), Some(11)); + assert_eq!((10..=15).nth(5), Some(15)); + assert_eq!((10..=15).nth(6), None); - let mut r = 10_u8...20; + let mut r = 10_u8..=20; assert_eq!(r.nth(2), Some(12)); - assert_eq!(r, 13...20); + assert_eq!(r, 13..=20); assert_eq!(r.nth(2), Some(15)); - assert_eq!(r, 16...20); + assert_eq!(r, 16..=20); assert_eq!(r.is_empty(), false); assert_eq!(r.nth(10), None); assert_eq!(r.is_empty(), true); - assert_eq!(r, 1...0); // We may not want to document/promise this detail + assert_eq!(r, 1..=0); // We may not want to document/promise this detail } #[test] diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 07e933985a0c9..2c540c8de8fc8 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -509,6 +509,7 @@ impl TokenTree { Dot => op!('.'), DotDot => joint!('.', Dot), DotDotDot => joint!('.', DotDot), + DotDotEq => joint!('.', DotEq), Comma => op!(','), Semi => op!(';'), Colon => op!(':'), @@ -531,6 +532,7 @@ impl TokenTree { }) } + DotEq => unreachable!(), OpenDelim(..) | CloseDelim(..) => unreachable!(), Whitespace | Comment | Shebang(..) | Eof => unreachable!(), }; diff --git a/src/libproc_macro/quote.rs b/src/libproc_macro/quote.rs index 0db2b86b15f57..8c1f6bfc11a5f 100644 --- a/src/libproc_macro/quote.rs +++ b/src/libproc_macro/quote.rs @@ -202,8 +202,8 @@ impl Quote for Token { gen_match! { Eq, Lt, Le, EqEq, Ne, Ge, Gt, AndAnd, OrOr, Not, Tilde, At, Dot, DotDot, DotDotDot, - Comma, Semi, Colon, ModSep, RArrow, LArrow, FatArrow, Pound, Dollar, Question, - Underscore; + DotDotEq, Comma, Semi, Colon, ModSep, RArrow, LArrow, FatArrow, Pound, Dollar, + Question, Underscore; Token::OpenDelim(delim) => quote!(rt::token::OpenDelim((quote delim))), Token::CloseDelim(delim) => quote!(rt::token::CloseDelim((quote delim))), diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 56ec6a65eb679..669e1ba773e23 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -272,6 +272,8 @@ fn hash_token<'gcx, W: StableHasherResult>(token: &token::Token, token::Token::Dot | token::Token::DotDot | token::Token::DotDotDot | + token::Token::DotDotEq | + token::Token::DotEq | token::Token::Comma | token::Token::Semi | token::Token::Colon | diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 081f950e40db2..98863b229b511 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -249,8 +249,8 @@ impl<'a> Classifier<'a> { token::BinOpEq(..) | token::FatArrow => Class::Op, // Miscellaneous, no highlighting. - token::Dot | token::DotDot | token::DotDotDot | token::Comma | token::Semi | - token::Colon | token::ModSep | token::LArrow | token::OpenDelim(_) | + token::Dot | token::DotDot | token::DotDotDot | token::DotDotEq | token::Comma | + token::Semi | token::Colon | token::ModSep | token::LArrow | token::OpenDelim(_) | token::CloseDelim(token::Brace) | token::CloseDelim(token::Paren) | token::CloseDelim(token::NoDelim) => Class::None, @@ -353,7 +353,7 @@ impl<'a> Classifier<'a> { token::Lifetime(..) => Class::Lifetime, token::Underscore | token::Eof | token::Interpolated(..) | - token::Tilde | token::At => Class::None, + token::Tilde | token::At | token::DotEq => Class::None, }; // Anything that didn't return above is the simple case where we the diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index b29883670bdea..c3cf474783505 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -291,7 +291,7 @@ Erroneous code example: fn main() { let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; - let x = &tmp[1...]; // error: inclusive range was used with no end + let x = &tmp[1..=]; // error: inclusive range was used with no end } ``` @@ -312,7 +312,7 @@ Or put an end to your inclusive range: fn main() { let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; - let x = &tmp[1...3]; // ok! + let x = &tmp[1..=3]; // ok! } ``` "##, diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index c3f3a59c30212..bd8c9a0ed40b2 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -686,7 +686,9 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P { token::At => "At", token::Dot => "Dot", token::DotDot => "DotDot", + token::DotEq => "DotEq", token::DotDotDot => "DotDotDot", + token::DotDotEq => "DotDotEq", token::Comma => "Comma", token::Semi => "Semi", token::Colon => "Colon", diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 1fef382c83a34..2fc451d5d004a 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -261,7 +261,7 @@ declare_features! ( // rustc internal (active, abi_vectorcall, "1.7.0", None), - // a...b and ...b + // a..=b and ..=b (active, inclusive_range_syntax, "1.7.0", Some(28237)), // X..Y patterns diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index ce3f16d2ba1b9..1cb7b0eca58d0 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1131,6 +1131,9 @@ impl<'a> StringReader<'a> { if self.ch_is('.') { self.bump(); Ok(token::DotDotDot) + } else if self.ch_is('=') { + self.bump(); + Ok(token::DotDotEq) } else { Ok(token::DotDot) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a2514a0425429..80c976abd19d7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -432,7 +432,7 @@ impl Error { Error::InclusiveRangeWithNoEnd => { let mut err = struct_span_err!(handler, sp, E0586, "inclusive range with no end"); - err.help("inclusive ranges must be bounded at the end (`...b` or `a...b`)"); + err.help("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)"); err } } @@ -2710,7 +2710,7 @@ impl<'a> Parser<'a> { LhsExpr::AttributesParsed(attrs) => Some(attrs), _ => None, }; - if self.token == token::DotDot || self.token == token::DotDotDot { + if [token::DotDot, token::DotDotDot, token::DotDotEq].contains(&self.token) { return self.parse_prefix_range_expr(attrs); } else { self.parse_prefix_expr(attrs)? @@ -2744,6 +2744,10 @@ impl<'a> Parser<'a> { if op.precedence() < min_prec { break; } + // Warn about deprecated ... syntax (until SNAP) + if self.token == token::DotDotDot { + self.warn_dotdoteq(self.span); + } self.bump(); if op.is_comparison() { self.check_no_chained_comparison(&lhs, &op); @@ -2770,12 +2774,13 @@ impl<'a> Parser<'a> { } }; continue - } else if op == AssocOp::DotDot || op == AssocOp::DotDotDot { - // If we didn’t have to handle `x..`/`x...`, it would be pretty easy to + } else if op == AssocOp::DotDot || op == AssocOp::DotDotEq { + // If we didn’t have to handle `x..`/`x..=`, it would be pretty easy to // generalise it to the Fixity::None code. // - // We have 2 alternatives here: `x..y`/`x...y` and `x..`/`x...` The other + // We have 2 alternatives here: `x..y`/`x..=y` and `x..`/`x..=` The other // two variants are handled with `parse_prefix_range_expr` call above. + // (and `x...y`/`x...` until SNAP) let rhs = if self.is_at_start_of_range_notation_rhs() { Some(self.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed)?) @@ -2852,8 +2857,8 @@ impl<'a> Parser<'a> { let aopexpr = self.mk_assign_op(codemap::respan(cur_op_span, aop), lhs, rhs); self.mk_expr(span, aopexpr, ThinVec::new()) } - AssocOp::As | AssocOp::Colon | AssocOp::DotDot | AssocOp::DotDotDot => { - self.bug("As, Colon, DotDot or DotDotDot branch reached") + AssocOp::As | AssocOp::Colon | AssocOp::DotDot | AssocOp::DotDotEq => { + self.bug("AssocOp should have been handled by special case") } }; @@ -2949,17 +2954,22 @@ impl<'a> Parser<'a> { } } - /// Parse prefix-forms of range notation: `..expr`, `..`, `...expr` + /// Parse prefix-forms of range notation: `..expr`, `..`, `..=expr` (and `...expr` until SNAP) fn parse_prefix_range_expr(&mut self, already_parsed_attrs: Option>) -> PResult<'a, P> { - debug_assert!(self.token == token::DotDot || self.token == token::DotDotDot, - "parse_prefix_range_expr: token {:?} is not DotDot or DotDotDot", + // SNAP remove DotDotDot + debug_assert!([token::DotDot, token::DotDotDot, token::DotDotEq].contains(&self.token), + "parse_prefix_range_expr: token {:?} is not DotDot/DotDotDot/DotDotEq", self.token); let tok = self.token.clone(); let attrs = self.parse_or_use_outer_attributes(already_parsed_attrs)?; let lo = self.span; let mut hi = self.span; + // Warn about deprecated ... syntax (until SNAP) + if tok == token::DotDotDot { + self.warn_dotdoteq(self.span); + } self.bump(); let opt_end = if self.is_at_start_of_range_notation_rhs() { // RHS must be parsed with more associativity than the dots. @@ -3450,7 +3460,7 @@ impl<'a> Parser<'a> { fn parse_as_ident(&mut self) -> bool { self.look_ahead(1, |t| match *t { token::OpenDelim(token::Paren) | token::OpenDelim(token::Brace) | - token::DotDotDot | token::ModSep | token::Not => Some(false), + token::DotDotDot | token::DotDotEq | token::ModSep | token::Not => Some(false), // ensure slice patterns [a, b.., c] and [a, b, c..] don't go into the // range pattern branch token::DotDot => None, @@ -3544,11 +3554,12 @@ impl<'a> Parser<'a> { let mac = respan(lo.to(self.prev_span), Mac_ { path: path, tts: tts }); pat = PatKind::Mac(mac); } - token::DotDotDot | token::DotDot => { + token::DotDotDot | token::DotDotEq | token::DotDot => { let end_kind = match self.token { token::DotDot => RangeEnd::Excluded, - token::DotDotDot => RangeEnd::Included, - _ => panic!("can only parse `..` or `...` for ranges (checked above)"), + token::DotDotDot | token::DotDotEq => RangeEnd::Included, + _ => panic!("can only parse `..`/`...`/`..=` for ranges \ + (checked above)"), }; // Parse range let span = lo.to(self.prev_span); @@ -3590,6 +3601,9 @@ impl<'a> Parser<'a> { if self.eat(&token::DotDotDot) { let end = self.parse_pat_range_end()?; pat = PatKind::Range(begin, end, RangeEnd::Included); + } else if self.eat(&token::DotDotEq) { + let end = self.parse_pat_range_end()?; + pat = PatKind::Range(begin, end, RangeEnd::Included); } else if self.eat(&token::DotDot) { let end = self.parse_pat_range_end()?; pat = PatKind::Range(begin, end, RangeEnd::Excluded); @@ -3973,7 +3987,7 @@ impl<'a> Parser<'a> { token::BinOp(token::Minus) | token::BinOp(token::Star) | token::BinOp(token::And) | token::BinOp(token::Or) | token::AndAnd | token::OrOr | - token::DotDot | token::DotDotDot => false, + token::DotDot | token::DotDotDot | token::DotDotEq => false, _ => true, } { self.warn_missing_semicolon(); @@ -4195,6 +4209,12 @@ impl<'a> Parser<'a> { }).emit(); } + fn warn_dotdoteq(&self, span: Span) { + self.diagnostic().struct_span_warn(span, { + "`...` is being replaced by `..=`" + }).emit(); + } + // Parse bounds of a type parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`. // BOUND = TY_BOUND | LT_BOUND // LT_BOUND = LIFETIME (e.g. `'a`) diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index a316733bdb51c..4888654fac9d0 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -152,6 +152,8 @@ pub enum Token { Dot, DotDot, DotDotDot, + DotDotEq, + DotEq, // HACK(durka42) never produced by the parser, only used for libproc_macro Comma, Semi, Colon, @@ -212,18 +214,19 @@ impl Token { pub fn can_begin_expr(&self) -> bool { match *self { Ident(ident) => ident_can_begin_expr(ident), // value name or keyword - OpenDelim(..) | // tuple, array or block - Literal(..) | // literal - Not | // operator not - BinOp(Minus) | // unary minus - BinOp(Star) | // dereference - BinOp(Or) | OrOr | // closure - BinOp(And) | // reference - AndAnd | // double reference - DotDot | DotDotDot | // range notation - Lt | BinOp(Shl) | // associated path - ModSep | // global path - Pound => true, // expression attributes + OpenDelim(..) | // tuple, array or block + Literal(..) | // literal + Not | // operator not + BinOp(Minus) | // unary minus + BinOp(Star) | // dereference + BinOp(Or) | OrOr | // closure + BinOp(And) | // reference + AndAnd | // double reference + DotDot | DotDotDot | DotDotEq | // range notation + // SNAP remove DotDotDot + Lt | BinOp(Shl) | // associated path + ModSep | // global path + Pound => true, // expression attributes Interpolated(ref nt) => match nt.0 { NtIdent(..) | NtExpr(..) | NtBlock(..) | NtPath(..) => true, _ => false, @@ -402,10 +405,12 @@ impl Token { Dot => match joint { Dot => DotDot, DotDot => DotDotDot, + DotEq => DotDotEq, _ => return None, }, DotDot => match joint { Dot => DotDotDot, + Eq => DotDotEq, _ => return None, }, Colon => match joint { @@ -413,9 +418,9 @@ impl Token { _ => return None, }, - Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot | Comma | - Semi | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | - OpenDelim(..) | CloseDelim(..) | Underscore => return None, + Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot | DotEq | + DotDotEq | Comma | Semi | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | + Question | OpenDelim(..) | CloseDelim(..) | Underscore => return None, Literal(..) | Ident(..) | Lifetime(..) | Interpolated(..) | DocComment(..) | Whitespace | Comment | Shebang(..) | Eof => return None, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9903dc50f36fb..cc4b34854fcd3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -203,6 +203,8 @@ pub fn token_to_string(tok: &Token) -> String { token::Dot => ".".to_string(), token::DotDot => "..".to_string(), token::DotDotDot => "...".to_string(), + token::DotDotEq => "..=".to_string(), + token::DotEq => ".=".to_string(), token::Comma => ",".to_string(), token::Semi => ";".to_string(), token::Colon => ":".to_string(), diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index a4f06cb1b45da..590874806d7b5 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -62,8 +62,8 @@ pub enum AssocOp { As, /// `..` range DotDot, - /// `...` range - DotDotDot, + /// `..=` range + DotDotEq, /// `:` Colon, } @@ -105,7 +105,8 @@ impl AssocOp { Token::AndAnd => Some(LAnd), Token::OrOr => Some(LOr), Token::DotDot => Some(DotDot), - Token::DotDotDot => Some(DotDotDot), + Token::DotDotEq => Some(DotDotEq), + Token::DotDotDot => Some(DotDotEq), // remove this after SNAP Token::Colon => Some(Colon), _ if t.is_keyword(keywords::As) => Some(As), _ => None @@ -151,7 +152,7 @@ impl AssocOp { Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual => 7, LAnd => 6, LOr => 5, - DotDot | DotDotDot => 4, + DotDot | DotDotEq => 4, Inplace => 3, Assign | AssignOp(_) => 2, } @@ -166,7 +167,7 @@ impl AssocOp { As | Multiply | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual | LAnd | LOr | Colon => Fixity::Left, - DotDot | DotDotDot => Fixity::None + DotDot | DotDotEq => Fixity::None } } @@ -176,7 +177,7 @@ impl AssocOp { Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual => true, Inplace | Assign | AssignOp(_) | As | Multiply | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd | LOr | - DotDot | DotDotDot | Colon => false + DotDot | DotDotEq | Colon => false } } @@ -186,7 +187,7 @@ impl AssocOp { Assign | AssignOp(_) | Inplace => true, Less | Greater | LessEqual | GreaterEqual | Equal | NotEqual | As | Multiply | Divide | Modulus | Add | Subtract | ShiftLeft | ShiftRight | BitAnd | BitXor | BitOr | LAnd | - LOr | DotDot | DotDotDot | Colon => false + LOr | DotDot | DotDotEq | Colon => false } } @@ -211,7 +212,7 @@ impl AssocOp { BitOr => Some(BinOpKind::BitOr), LAnd => Some(BinOpKind::And), LOr => Some(BinOpKind::Or), - Inplace | Assign | AssignOp(_) | As | DotDot | DotDotDot | Colon => None + Inplace | Assign | AssignOp(_) | As | DotDot | DotDotEq | Colon => None } } } diff --git a/src/test/compile-fail/E0586.rs b/src/test/compile-fail/E0586.rs index 0b063569abc17..c1bfc5c73a1b3 100644 --- a/src/test/compile-fail/E0586.rs +++ b/src/test/compile-fail/E0586.rs @@ -10,5 +10,5 @@ fn main() { let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; - let x = &tmp[1...]; //~ ERROR E0586 + let x = &tmp[1..=]; //~ ERROR E0586 } diff --git a/src/test/compile-fail/impossible_range.rs b/src/test/compile-fail/impossible_range.rs index 94e048fed655e..e4465e9f6b611 100644 --- a/src/test/compile-fail/impossible_range.rs +++ b/src/test/compile-fail/impossible_range.rs @@ -18,12 +18,12 @@ pub fn main() { ..1; 0..1; - ...; //~ERROR inclusive range with no end + ..=; //~ERROR inclusive range with no end //~^HELP bounded at the end - 0...; //~ERROR inclusive range with no end + 0..=; //~ERROR inclusive range with no end //~^HELP bounded at the end - ...1; - 0...1; + ..=1; + 0..=1; } diff --git a/src/test/compile-fail/range_inclusive_gate.rs b/src/test/compile-fail/range_inclusive_gate.rs index 1d1153e951b7b..69b9a4c67adc3 100644 --- a/src/test/compile-fail/range_inclusive_gate.rs +++ b/src/test/compile-fail/range_inclusive_gate.rs @@ -14,7 +14,7 @@ // #![feature(inclusive_range)] pub fn main() { - let _: std::ops::RangeInclusive<_> = { use std::intrinsics; 1 } ... { use std::intrinsics; 2 }; + let _: std::ops::RangeInclusive<_> = { use std::intrinsics; 1 } ..= { use std::intrinsics; 2 }; //~^ ERROR use of unstable library feature 'inclusive_range' //~| ERROR core_intrinsics //~| ERROR core_intrinsics diff --git a/src/test/incremental/hashes/indexing_expressions.rs b/src/test/incremental/hashes/indexing_expressions.rs index bb31982d93f21..a12624d083248 100644 --- a/src/test/incremental/hashes/indexing_expressions.rs +++ b/src/test/incremental/hashes/indexing_expressions.rs @@ -153,5 +153,5 @@ fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] { #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] { - &slice[3...7] + &slice[3..=7] } diff --git a/src/test/parse-fail/pat-ranges-1.rs b/src/test/parse-fail/pat-ranges-1.rs index e1cbb961b1bcc..857a3924aec01 100644 --- a/src/test/parse-fail/pat-ranges-1.rs +++ b/src/test/parse-fail/pat-ranges-1.rs @@ -11,5 +11,5 @@ // Parsing of range patterns fn main() { - let macropus!() ... 11 = 12; //~ error: expected one of `:`, `;`, or `=`, found `...` + let macropus!() ..= 11 = 12; //~ error: expected one of `:`, `;`, or `=`, found `..=` } diff --git a/src/test/parse-fail/pat-ranges-2.rs b/src/test/parse-fail/pat-ranges-2.rs index 04ad5ff083bc8..64c749333cf4a 100644 --- a/src/test/parse-fail/pat-ranges-2.rs +++ b/src/test/parse-fail/pat-ranges-2.rs @@ -11,5 +11,5 @@ // Parsing of range patterns fn main() { - let 10 ... makropulos!() = 12; //~ error: expected one of `::`, `:`, `;`, or `=`, found `!` + let 10 ..= makropulos!() = 12; //~ error: expected one of `::`, `:`, `;`, or `=`, found `!` } diff --git a/src/test/parse-fail/pat-ranges-3.rs b/src/test/parse-fail/pat-ranges-3.rs index 5f7aac71d29b2..1327a9fab3661 100644 --- a/src/test/parse-fail/pat-ranges-3.rs +++ b/src/test/parse-fail/pat-ranges-3.rs @@ -11,5 +11,5 @@ // Parsing of range patterns fn main() { - let 10 ... 10 + 3 = 12; //~ expected one of `:`, `;`, or `=`, found `+` + let 10 ..= 10 + 3 = 12; //~ expected one of `:`, `;`, or `=`, found `+` } diff --git a/src/test/parse-fail/pat-ranges-4.rs b/src/test/parse-fail/pat-ranges-4.rs index 4bbf387d1c0da..c159c7702502d 100644 --- a/src/test/parse-fail/pat-ranges-4.rs +++ b/src/test/parse-fail/pat-ranges-4.rs @@ -11,5 +11,6 @@ // Parsing of range patterns fn main() { - let 10 - 3 ... 10 = 8; //~ error: expected one of `...`, `..`, `:`, `;`, or `=`, found `-` + let 10 - 3 ..= 10 = 8; + //~^ error: expected one of `...`, `..=`, `..`, `:`, `;`, or `=`, found `-` } diff --git a/src/test/parse-fail/range_inclusive.rs b/src/test/parse-fail/range_inclusive.rs index ce97372c66845..cc32b9903b5ac 100644 --- a/src/test/parse-fail/range_inclusive.rs +++ b/src/test/parse-fail/range_inclusive.rs @@ -13,7 +13,7 @@ #![feature(inclusive_range_syntax, inclusive_range)] pub fn main() { - for _ in 1... {} //~ERROR inclusive range with no end + for _ in 1..= {} //~ERROR inclusive range with no end //~^HELP bounded at the end } diff --git a/src/test/parse-fail/range_inclusive_gate.rs b/src/test/parse-fail/range_inclusive_gate.rs index 30dc6fc5b20a0..de690c3fea3cf 100644 --- a/src/test/parse-fail/range_inclusive_gate.rs +++ b/src/test/parse-fail/range_inclusive_gate.rs @@ -15,21 +15,21 @@ // #![feature(inclusive_range_syntax, inclusive_range)] macro_rules! m { - () => { for _ in 1...10 {} } //~ ERROR inclusive range syntax is experimental + () => { for _ in 1..=10 {} } //~ ERROR inclusive range syntax is experimental } #[cfg(nope)] fn f() {} #[cfg(not(nope))] fn f() { - for _ in 1...10 {} //~ ERROR inclusive range syntax is experimental + for _ in 1..=10 {} //~ ERROR inclusive range syntax is experimental } #[cfg(nope)] macro_rules! n { () => {} } #[cfg(not(nope))] macro_rules! n { - () => { for _ in 1...10 {} } //~ ERROR inclusive range syntax is experimental + () => { for _ in 1..=10 {} } //~ ERROR inclusive range syntax is experimental } macro_rules! o { @@ -38,7 +38,7 @@ macro_rules! o { fn g() {} #[cfg(not(nope))] fn g() { - for _ in 1...10 {} //~ ERROR inclusive range syntax is experimental + for _ in 1..=10 {} //~ ERROR inclusive range syntax is experimental } g(); @@ -54,7 +54,7 @@ macro_rules! p { fn h() {} #[cfg(not(nope))] fn h() { - for _ in 1...10 {} //~ ERROR inclusive range syntax is experimental + for _ in 1..=10 {} //~ ERROR inclusive range syntax is experimental } h(); @@ -62,8 +62,8 @@ macro_rules! p { } pub fn main() { - for _ in 1...10 {} //~ ERROR inclusive range syntax is experimental - for _ in ...10 {} //~ ERROR inclusive range syntax is experimental + for _ in 1..=10 {} //~ ERROR inclusive range syntax is experimental + for _ in ..=10 {} //~ ERROR inclusive range syntax is experimental f(); // not allowed in cfg'ed functions diff --git a/src/test/run-pass/inc-range-pat.rs b/src/test/run-pass/inc-range-pat.rs new file mode 100644 index 0000000000000..237b41b6128cf --- /dev/null +++ b/src/test/run-pass/inc-range-pat.rs @@ -0,0 +1,20 @@ +// Copyright 2017 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. + +// Test old and new syntax for inclusive range patterns. + +fn main() { + assert!(match 42 { 0 ... 100 => true, _ => false }); + assert!(match 42 { 0 ..= 100 => true, _ => false }); + + assert!(match 'x' { 'a' ... 'z' => true, _ => false }); + assert!(match 'x' { 'a' ..= 'z' => true, _ => false }); +} + diff --git a/src/test/run-pass/range_inclusive.rs b/src/test/run-pass/range_inclusive.rs index f6119e709990a..71e11804052db 100644 --- a/src/test/run-pass/range_inclusive.rs +++ b/src/test/run-pass/range_inclusive.rs @@ -17,18 +17,18 @@ use std::ops::{RangeInclusive, RangeToInclusive}; fn foo() -> isize { 42 } // Test that range syntax works in return statements -fn return_range_to() -> RangeToInclusive { return ...1; } +fn return_range_to() -> RangeToInclusive { return ..=1; } pub fn main() { let mut count = 0; - for i in 0_usize...10 { + for i in 0_usize..=10 { assert!(i >= 0 && i <= 10); count += i; } assert_eq!(count, 55); let mut count = 0; - let mut range = 0_usize...10; + let mut range = 0_usize..=10; for i in range { assert!(i >= 0 && i <= 10); count += i; @@ -36,53 +36,53 @@ pub fn main() { assert_eq!(count, 55); let mut count = 0; - for i in (0_usize...10).step_by(2) { + for i in (0_usize..=10).step_by(2) { assert!(i >= 0 && i <= 10 && i % 2 == 0); count += i; } assert_eq!(count, 30); - let _ = 0_usize...4+4-3; - let _ = 0...foo(); + let _ = 0_usize..=4+4-3; + let _ = 0..=foo(); - let _ = { &42...&100 }; // references to literals are OK - let _ = ...42_usize; + let _ = { &42..=&100 }; // references to literals are OK + let _ = ..=42_usize; // Test we can use two different types with a common supertype. let x = &42; { let y = 42; - let _ = x...&y; + let _ = x..=&y; } // test collection indexing - let vec = (0...10).collect::>(); + let vec = (0..=10).collect::>(); let slice: &[_] = &*vec; let string = String::from("hello world"); let stir = "hello world"; - assert_eq!(&vec[3...6], &[3, 4, 5, 6]); - assert_eq!(&vec[ ...6], &[0, 1, 2, 3, 4, 5, 6]); + assert_eq!(&vec[3..=6], &[3, 4, 5, 6]); + assert_eq!(&vec[ ..=6], &[0, 1, 2, 3, 4, 5, 6]); - assert_eq!(&slice[3...6], &[3, 4, 5, 6]); - assert_eq!(&slice[ ...6], &[0, 1, 2, 3, 4, 5, 6]); + assert_eq!(&slice[3..=6], &[3, 4, 5, 6]); + assert_eq!(&slice[ ..=6], &[0, 1, 2, 3, 4, 5, 6]); - assert_eq!(&string[3...6], "lo w"); - assert_eq!(&string[ ...6], "hello w"); + assert_eq!(&string[3..=6], "lo w"); + assert_eq!(&string[ ..=6], "hello w"); - assert_eq!(&stir[3...6], "lo w"); - assert_eq!(&stir[ ...6], "hello w"); + assert_eq!(&stir[3..=6], "lo w"); + assert_eq!(&stir[ ..=6], "hello w"); // test the size hints and emptying - let mut long = 0...255u8; - let mut short = 42...42u8; + let mut long = 0..=255u8; + let mut short = 42..=42u8; assert_eq!(long.size_hint(), (256, Some(256))); assert_eq!(short.size_hint(), (1, Some(1))); long.next(); short.next(); assert_eq!(long.size_hint(), (255, Some(255))); assert_eq!(short.size_hint(), (0, Some(0))); - assert_eq!(short, 1...0); + assert_eq!(short, 1..=0); assert_eq!(long.len(), 255); assert_eq!(short.len(), 0); @@ -94,31 +94,31 @@ pub fn main() { assert_eq!(long.next(), Some(1)); assert_eq!(long.next(), Some(2)); assert_eq!(long.next_back(), Some(252)); - for i in 3...251 { + for i in 3..=251 { assert_eq!(long.next(), Some(i)); } - assert_eq!(long, 1...0); + assert_eq!(long, 1..=0); // check underflow - let mut narrow = 1...0; + let mut narrow = 1..=0; assert_eq!(narrow.next_back(), None); - assert_eq!(narrow, 1...0); - let mut zero = 0u8...0; + assert_eq!(narrow, 1..=0); + let mut zero = 0u8..=0; assert_eq!(zero.next_back(), Some(0)); assert_eq!(zero.next_back(), None); - assert_eq!(zero, 1...0); - let mut high = 255u8...255; + assert_eq!(zero, 1..=0); + let mut high = 255u8..=255; assert_eq!(high.next_back(), Some(255)); assert_eq!(high.next_back(), None); - assert_eq!(high, 1...0); + assert_eq!(high, 1..=0); // what happens if you have a nonsense range? - let mut nonsense = 10...5; + let mut nonsense = 10..=5; assert_eq!(nonsense.next(), None); - assert_eq!(nonsense, 10...5); + assert_eq!(nonsense, 10..=5); // output - assert_eq!(format!("{:?}", 0...10), "0...10"); - assert_eq!(format!("{:?}", ...10), "...10"); - assert_eq!(format!("{:?}", long), "1...0"); + assert_eq!(format!("{:?}", 0..=10), "0..=10"); + assert_eq!(format!("{:?}", ..=10), "..=10"); + assert_eq!(format!("{:?}", long), "1..=0"); } diff --git a/src/test/run-pass/range_inclusive_gate.rs b/src/test/run-pass/range_inclusive_gate.rs index 5e0ec19d6b325..570087aedbbaa 100644 --- a/src/test/run-pass/range_inclusive_gate.rs +++ b/src/test/run-pass/range_inclusive_gate.rs @@ -14,7 +14,7 @@ fn main() { let mut count = 0; - for i in 0_usize...10 { + for i in 0_usize..=10 { assert!(i >= 0 && i <= 10); count += i; } From 4737c5a068a38e4b004180b3f39bb0974190b06e Mon Sep 17 00:00:00 2001 From: Badel2 <2badel2@gmail.com> Date: Wed, 20 Sep 2017 20:57:18 +0200 Subject: [PATCH 21/77] Substitute `...` with the expanded form RangeInclusive { start, end }, this way we supress the warnings about `...` in expressions being deprecated until `..=` is available in the compiler --- src/libcore/slice/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index c52e88170aeb7..ae243f3f246a5 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -16,9 +16,8 @@ #![stable(feature = "rust1", since = "1.0.0")] -// FIXME: replace remaining ... by ..= after next stage0 -// Silence warning: "... is being replaced by ..=" -#![cfg_attr(not(stage0), allow(warnings))] +// FIXME: after next stage0, change RangeInclusive { ... } back to ..= +use ops::RangeInclusive; // How this module is organized. // @@ -1048,32 +1047,32 @@ impl SliceIndex<[T]> for ops::RangeToInclusive { #[inline] fn get(self, slice: &[T]) -> Option<&[T]> { - (0...self.end).get(slice) + (RangeInclusive { start: 0, end: self.end }).get(slice) } #[inline] fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> { - (0...self.end).get_mut(slice) + (RangeInclusive { start: 0, end: self.end }).get_mut(slice) } #[inline] unsafe fn get_unchecked(self, slice: &[T]) -> &[T] { - (0...self.end).get_unchecked(slice) + (RangeInclusive { start: 0, end: self.end }).get_unchecked(slice) } #[inline] unsafe fn get_unchecked_mut(self, slice: &mut [T]) -> &mut [T] { - (0...self.end).get_unchecked_mut(slice) + (RangeInclusive { start: 0, end: self.end }).get_unchecked_mut(slice) } #[inline] fn index(self, slice: &[T]) -> &[T] { - (0...self.end).index(slice) + (RangeInclusive { start: 0, end: self.end }).index(slice) } #[inline] fn index_mut(self, slice: &mut [T]) -> &mut [T] { - (0...self.end).index_mut(slice) + (RangeInclusive { start: 0, end: self.end }).index_mut(slice) } } From 7aabf572789dcae24cc8ce247f7d86bcc5d49a17 Mon Sep 17 00:00:00 2001 From: Badel2 <2badel2@gmail.com> Date: Thu, 21 Sep 2017 12:13:26 +0200 Subject: [PATCH 22/77] Add information about the syntax used in ranges ... or ..= --- src/librustc/hir/lowering.rs | 2 +- src/libsyntax/ast.rs | 10 ++++++++-- src/libsyntax/parse/parser.rs | 11 +++++++---- src/libsyntax/print/pprust.rs | 5 +++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 465520ea03434..6da8c38dfcf35 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1869,7 +1869,7 @@ impl<'a> LoweringContext<'a> { fn lower_range_end(&mut self, e: &RangeEnd) -> hir::RangeEnd { match *e { - RangeEnd::Included => hir::RangeEnd::Included, + RangeEnd::Included(_) => hir::RangeEnd::Included, RangeEnd::Excluded => hir::RangeEnd::Excluded, } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 496be8b3eb23e..0504e889ea10b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -538,10 +538,16 @@ pub enum BindingMode { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum RangeEnd { - Included, + Included(RangeSyntax), Excluded, } +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +pub enum RangeSyntax { + DotDotDot, + DotDotEq, +} + #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum PatKind { /// Represents a wildcard pattern (`_`) @@ -578,7 +584,7 @@ pub enum PatKind { Ref(P, Mutability), /// A literal Lit(P), - /// A range pattern, e.g. `1...2` or `1..2` + /// A range pattern, e.g. `1...2`, `1..=2` or `1..2` Range(P, P, RangeEnd), /// `[a, b, ..i, y, z]` is represented as: /// `PatKind::Slice(box [a, b], Some(i), box [y, z])` diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 80c976abd19d7..bc78bfa785bf4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -38,7 +38,7 @@ use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds}; use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; use ast::{Visibility, WhereClause}; use ast::{BinOpKind, UnOp}; -use ast::RangeEnd; +use ast::{RangeEnd, RangeSyntax}; use {ast, attr}; use codemap::{self, CodeMap, Spanned, respan}; use syntax_pos::{self, Span, BytePos}; @@ -3557,7 +3557,8 @@ impl<'a> Parser<'a> { token::DotDotDot | token::DotDotEq | token::DotDot => { let end_kind = match self.token { token::DotDot => RangeEnd::Excluded, - token::DotDotDot | token::DotDotEq => RangeEnd::Included, + token::DotDotDot => RangeEnd::Included(RangeSyntax::DotDotDot), + token::DotDotEq => RangeEnd::Included(RangeSyntax::DotDotEq), _ => panic!("can only parse `..`/`...`/`..=` for ranges \ (checked above)"), }; @@ -3600,10 +3601,12 @@ impl<'a> Parser<'a> { Ok(begin) => { if self.eat(&token::DotDotDot) { let end = self.parse_pat_range_end()?; - pat = PatKind::Range(begin, end, RangeEnd::Included); + pat = PatKind::Range(begin, end, + RangeEnd::Included(RangeSyntax::DotDotDot)); } else if self.eat(&token::DotDotEq) { let end = self.parse_pat_range_end()?; - pat = PatKind::Range(begin, end, RangeEnd::Included); + pat = PatKind::Range(begin, end, + RangeEnd::Included(RangeSyntax::DotDotEq)); } else if self.eat(&token::DotDot) { let end = self.parse_pat_range_end()?; pat = PatKind::Range(begin, end, RangeEnd::Excluded); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index cc4b34854fcd3..959dd4ef30f29 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -11,7 +11,7 @@ pub use self::AnnNode::*; use abi::{self, Abi}; -use ast::{self, BlockCheckMode, PatKind, RangeEnd}; +use ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax}; use ast::{SelfKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::Attribute; use util::parser::{self, AssocOp, Fixity}; @@ -2590,7 +2590,8 @@ impl<'a> State<'a> { self.print_expr(begin)?; self.s.space()?; match *end_kind { - RangeEnd::Included => self.s.word("...")?, + RangeEnd::Included(RangeSyntax::DotDotDot) => self.s.word("...")?, + RangeEnd::Included(RangeSyntax::DotDotEq) => self.s.word("..=")?, RangeEnd::Excluded => self.s.word("..")?, } self.print_expr(end)?; From 54c4a830843d8de97d1dd3f936f9e3415bc96ef9 Mon Sep 17 00:00:00 2001 From: Badel2 <2badel2@gmail.com> Date: Thu, 21 Sep 2017 12:14:14 +0200 Subject: [PATCH 23/77] dotdoteq_in_patterns feature gate --- src/libsyntax/feature_gate.rs | 9 ++++++++- .../feature-gate-dotdoteq_in_patterns.rs | 16 ++++++++++++++++ src/test/run-pass/inc-range-pat.rs | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/feature-gate-dotdoteq_in_patterns.rs diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2fc451d5d004a..aa5a41430274a 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -26,7 +26,7 @@ use self::AttributeType::*; use self::AttributeGate::*; use abi::Abi; -use ast::{self, NodeId, PatKind, RangeEnd}; +use ast::{self, NodeId, PatKind, RangeEnd, RangeSyntax}; use attr; use codemap::Spanned; use syntax_pos::Span; @@ -392,6 +392,9 @@ declare_features! ( // allow `'_` placeholder lifetimes (active, underscore_lifetimes, "1.22.0", Some(44524)), + + // allow `..=` in patterns (RFC 1192) + (active, dotdoteq_in_patterns, "1.22.0", Some(28237)), ); declare_features! ( @@ -1491,6 +1494,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { gate_feature_post!(&self, exclusive_range_pattern, pattern.span, "exclusive range pattern syntax is experimental"); } + PatKind::Range(_, _, RangeEnd::Included(RangeSyntax::DotDotEq)) => { + gate_feature_post!(&self, dotdoteq_in_patterns, pattern.span, + "`..=` syntax in patterns is experimental"); + } _ => {} } visit::walk_pat(self, pattern) diff --git a/src/test/compile-fail/feature-gate-dotdoteq_in_patterns.rs b/src/test/compile-fail/feature-gate-dotdoteq_in_patterns.rs new file mode 100644 index 0000000000000..1fb139bf07f41 --- /dev/null +++ b/src/test/compile-fail/feature-gate-dotdoteq_in_patterns.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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. + +pub fn main() { + match 22 { + 0 ..= 3 => {} //~ ERROR `..=` syntax in patterns is experimental + _ => {} + } +} diff --git a/src/test/run-pass/inc-range-pat.rs b/src/test/run-pass/inc-range-pat.rs index 237b41b6128cf..5faf36eddaf06 100644 --- a/src/test/run-pass/inc-range-pat.rs +++ b/src/test/run-pass/inc-range-pat.rs @@ -9,6 +9,8 @@ // except according to those terms. // Test old and new syntax for inclusive range patterns. +#![feature(dotdoteq_in_patterns)] + fn main() { assert!(match 42 { 0 ... 100 => true, _ => false }); From 15fa85c195c38f9b0c2a9003d68d05727603ef68 Mon Sep 17 00:00:00 2001 From: toidiu Date: Sat, 23 Sep 2017 14:55:40 -0400 Subject: [PATCH 24/77] extract explicit_predicates_of --- src/librustc_typeck/collect.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 79cb9147c185b..8f7cf946a49dc 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1325,6 +1325,12 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx>( fn predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::GenericPredicates<'tcx> { + explicit_predicates_of(tcx, def_id) +} + +fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId) + -> ty::GenericPredicates<'tcx> { use rustc::hir::map::*; use rustc::hir::*; From 1c589b7a51c005b3c55244a7b7589ed351028d46 Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Sat, 23 Sep 2017 12:03:24 -0400 Subject: [PATCH 25/77] TrustedRandomAccess specialisation for Cloned. This verifies that TrustedRandomAccess has no side effects when the iterator item implements Copy. This also implements TrustedLen and TrustedRandomAccess for str::Bytes. --- src/libcore/iter/mod.rs | 14 +++++++++++++- src/libcore/str/mod.rs | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 7907f2fd66126..2d3ff6a348d39 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -488,7 +488,7 @@ impl<'a, I, T: 'a> FusedIterator for Cloned {} #[doc(hidden)] -unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned +default unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned where I: TrustedRandomAccess, T: Clone { unsafe fn get_unchecked(&mut self, i: usize) -> Self::Item { @@ -499,6 +499,18 @@ unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned fn may_have_side_effect() -> bool { true } } +#[doc(hidden)] +unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned + where I: TrustedRandomAccess, T: Copy +{ + unsafe fn get_unchecked(&mut self, i: usize) -> Self::Item { + *self.it.get_unchecked(i) + } + + #[inline] + fn may_have_side_effect() -> bool { false } +} + #[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, I, T: 'a> TrustedLen for Cloned where I: TrustedLen, diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 5d0cefa101335..62367b051fced 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -20,7 +20,8 @@ use self::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher}; use char; use convert::TryFrom; use fmt; -use iter::{Map, Cloned, FusedIterator}; +use iter::{Map, Cloned, FusedIterator, TrustedLen}; +use iter_private::TrustedRandomAccess; use slice::{self, SliceIndex}; use mem; @@ -818,6 +819,17 @@ impl<'a> ExactSizeIterator for Bytes<'a> { #[unstable(feature = "fused", issue = "35602")] impl<'a> FusedIterator for Bytes<'a> {} +#[unstable(feature = "trusted_len", issue = "37572")] +unsafe impl<'a> TrustedLen for Bytes<'a> {} + +#[doc(hidden)] +unsafe impl<'a> TrustedRandomAccess for Bytes<'a> { + unsafe fn get_unchecked(&mut self, i: usize) -> u8 { + self.0.get_unchecked(i) + } + fn may_have_side_effect() -> bool { false } +} + /// This macro generates a Clone impl for string pattern API /// wrapper types of the form X<'a, P> macro_rules! derive_pattern_clone { From f94bd36fd1f9e71c7b2e33949abc0d931cdf6f7c Mon Sep 17 00:00:00 2001 From: Ben Cressey Date: Tue, 5 Sep 2017 16:55:25 +0000 Subject: [PATCH 26/77] add aarch64-unknown-linux-musl target Signed-off-by: Ben Cressey Signed-off-by: Tom Kirchner --- src/bootstrap/configure.py | 2 ++ src/bootstrap/native.rs | 1 + src/ci/docker/cross/Dockerfile | 5 ++- src/ci/docker/cross/build-arm-musl.sh | 27 ++++++++++++++ .../target/aarch64_unknown_linux_musl.rs | 36 +++++++++++++++++++ src/librustc_back/target/mod.rs | 1 + src/tools/build-manifest/src/main.rs | 1 + 7 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/librustc_back/target/aarch64_unknown_linux_musl.rs diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 2438be89776da..67337bf44214e 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -109,6 +109,8 @@ def v(*args): "arm-unknown-linux-musleabihf install directory") v("musl-root-armv7", "target.armv7-unknown-linux-musleabihf.musl-root", "armv7-unknown-linux-musleabihf install directory") +v("musl-root-aarch64", "target.aarch64-unknown-linux-musl.musl-root", + "aarch64-unknown-linux-musl install directory") v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs", "rootfs in qemu testing, you probably don't want to use this") v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs", diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 99077d03dbe03..84e98de09ddb7 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -399,6 +399,7 @@ impl Step for Openssl { let os = match &*target { "aarch64-linux-android" => "linux-aarch64", "aarch64-unknown-linux-gnu" => "linux-aarch64", + "aarch64-unknown-linux-musl" => "linux-aarch64", "arm-linux-androideabi" => "android", "arm-unknown-linux-gnueabi" => "linux-armv4", "arm-unknown-linux-gnueabihf" => "linux-armv4", diff --git a/src/ci/docker/cross/Dockerfile b/src/ci/docker/cross/Dockerfile index a83bbe9c60e8d..05745709a07cb 100644 --- a/src/ci/docker/cross/Dockerfile +++ b/src/ci/docker/cross/Dockerfile @@ -14,6 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ zlib1g-dev \ g++-arm-linux-gnueabi \ g++-arm-linux-gnueabihf \ + g++-aarch64-linux-gnu \ gcc-sparc64-linux-gnu \ libc6-dev-sparc64-cross \ bzip2 \ @@ -46,6 +47,7 @@ ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf +ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu ENV TARGETS=$TARGETS,x86_64-unknown-redox @@ -62,7 +64,8 @@ ENV RUST_CONFIGURE_ARGS \ --target=$TARGETS \ --musl-root-arm=/usr/local/arm-linux-musleabi \ --musl-root-armhf=/usr/local/arm-linux-musleabihf \ - --musl-root-armv7=/usr/local/armv7-linux-musleabihf + --musl-root-armv7=/usr/local/armv7-linux-musleabihf \ + --musl-root-aarch64=/usr/local/aarch64-linux-musl ENV SCRIPT python2.7 ../x.py dist --target $TARGETS # sccache diff --git a/src/ci/docker/cross/build-arm-musl.sh b/src/ci/docker/cross/build-arm-musl.sh index 938e69834e434..780099e2ec176 100755 --- a/src/ci/docker/cross/build-arm-musl.sh +++ b/src/ci/docker/cross/build-arm-musl.sh @@ -65,11 +65,24 @@ CFLAGS="-march=armv7-a" \ hide_output make -j$(nproc) hide_output make install cd .. +rm -rf musl-$MUSL + +tar xf musl-$MUSL.tar.gz +cd musl-$MUSL +CC=aarch64-linux-gnu-gcc \ +CFLAGS="" \ + hide_output ./configure \ + --prefix=/usr/local/aarch64-linux-musl \ + --enable-wrapper=gcc +hide_output make -j$(nproc) +hide_output make install +cd .. rm -rf musl-$MUSL* ln -nsf ../arm-linux-musleabi/bin/musl-gcc /usr/local/bin/arm-linux-musleabi-gcc ln -nsf ../arm-linux-musleabihf/bin/musl-gcc /usr/local/bin/arm-linux-musleabihf-gcc ln -nsf ../armv7-linux-musleabihf/bin/musl-gcc /usr/local/bin/armv7-linux-musleabihf-gcc +ln -nsf ../aarch64-linux-musl/bin/musl-gcc /usr/local/bin/aarch64-unknown-linux-musl-gcc curl -L https://github.com/llvm-mirror/llvm/archive/release_39.tar.gz | tar xzf - curl -L https://github.com/llvm-mirror/libunwind/archive/release_39.tar.gz | tar xzf - @@ -116,5 +129,19 @@ cp lib/libunwind.a /usr/local/armv7-linux-musleabihf/lib cd .. rm -rf libunwind-build +mkdir libunwind-build +cd libunwind-build +cmake ../libunwind-release_39 \ + -DLLVM_PATH=/tmp/llvm-release_39 \ + -DLIBUNWIND_ENABLE_SHARED=0 \ + -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ + -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \ + -DCMAKE_C_FLAGS="" \ + -DCMAKE_CXX_FLAGS="" +make -j$(nproc) +cp lib/libunwind.a /usr/local/aarch64-linux-musl/lib +cd .. +rm -rf libunwind-build + rm -rf libunwind-release_39 rm -rf llvm-release_39 diff --git a/src/librustc_back/target/aarch64_unknown_linux_musl.rs b/src/librustc_back/target/aarch64_unknown_linux_musl.rs new file mode 100644 index 0000000000000..1edac616366dd --- /dev/null +++ b/src/librustc_back/target/aarch64_unknown_linux_musl.rs @@ -0,0 +1,36 @@ +// Copyright 2017 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 LinkerFlavor; +use target::{Target, TargetOptions, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::linux_musl_base::opts(); + base.max_atomic_width = Some(128); + + // see #36994 + base.exe_allocation_crate = None; + + Ok(Target { + llvm_target: "aarch64-unknown-linux-musl".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "64".to_string(), + target_env: "musl".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: "linux".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: TargetOptions { + abi_blacklist: super::arm_base::abi_blacklist(), + .. base + }, + }) +} diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 301cf3f8c8208..27a0855dc29fe 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -153,6 +153,7 @@ supported_targets! { ("armv7-unknown-linux-gnueabihf", armv7_unknown_linux_gnueabihf), ("armv7-unknown-linux-musleabihf", armv7_unknown_linux_musleabihf), ("aarch64-unknown-linux-gnu", aarch64_unknown_linux_gnu), + ("aarch64-unknown-linux-musl", aarch64_unknown_linux_musl), ("x86_64-unknown-linux-musl", x86_64_unknown_linux_musl), ("i686-unknown-linux-musl", i686_unknown_linux_musl), ("mips-unknown-linux-musl", mips_unknown_linux_musl), diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 028ef729960e3..9598266a8de60 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -50,6 +50,7 @@ static TARGETS: &'static [&'static str] = &[ "aarch64-unknown-fuchsia", "aarch64-linux-android", "aarch64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", "arm-linux-androideabi", "arm-unknown-linux-gnueabi", "arm-unknown-linux-gnueabihf", From 99c0c520aff7f9858340406631d9de763a743d41 Mon Sep 17 00:00:00 2001 From: Lucas Morales Date: Sat, 23 Sep 2017 18:28:08 -0400 Subject: [PATCH 27/77] docs improvement std::sync::{PoisonError, TryLockError} --- src/libstd/sys_common/poison.rs | 57 +++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys_common/poison.rs b/src/libstd/sys_common/poison.rs index 3c61593acc55b..934ac3edbf1f1 100644 --- a/src/libstd/sys_common/poison.rs +++ b/src/libstd/sys_common/poison.rs @@ -65,6 +65,31 @@ pub struct Guard { /// each lock, but once a lock is poisoned then all future acquisitions will /// return this error. /// +/// # Examples +/// +/// ``` +/// use std::sync::{Arc, Mutex}; +/// use std::thread; +/// +/// let mutex = Arc::new(Mutex::new(1)); +/// +/// // poison the mutex +/// let c_mutex = mutex.clone(); +/// let _ = thread::spawn(move || { +/// let mut data = c_mutex.lock().unwrap(); +/// *data = 2; +/// panic!(); +/// }).join(); +/// +/// match mutex.lock() { +/// Ok(_) => unreachable!(), +/// Err(p_err) => { +/// let data = p_err.get_ref(); +/// println!("recovered: {}", data); +/// } +/// }; +/// ``` +/// /// [`Mutex`]: ../../std/sync/struct.Mutex.html /// [`RwLock`]: ../../std/sync/struct.RwLock.html #[stable(feature = "rust1", since = "1.0.0")] @@ -72,10 +97,16 @@ pub struct PoisonError { guard: T, } -/// An enumeration of possible errors which can occur while calling the -/// [`try_lock`] method. +/// An enumeration of possible errors associated with a [`TryLockResult`] which +/// can occur while trying to aquire a lock, from the [`try_lock`] method on a +/// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`]. /// +/// [`Mutex`]: struct.Mutex.html +/// [`RwLock`]: struct.RwLock.html +/// [`TryLockResult`]: type.TryLockResult.html /// [`try_lock`]: struct.Mutex.html#method.try_lock +/// [`try_read`]: struct.RwLock.html#method.try_read +/// [`try_write`]: struct.RwLock.html#method.try_write #[stable(feature = "rust1", since = "1.0.0")] pub enum TryLockError { /// The lock could not be acquired because another thread failed while holding @@ -148,6 +179,28 @@ impl PoisonError { /// Consumes this error indicating that a lock is poisoned, returning the /// underlying guard to allow access regardless. + /// + /// # Examples + /// + /// ``` + /// use std::collections::HashSet; + /// use std::sync::{Arc, Mutex}; + /// use std::thread; + /// + /// let mutex = Arc::new(Mutex::new(HashSet::new())); + /// + /// // poison the mutex + /// let c_mutex = mutex.clone(); + /// let _ = thread::spawn(move || { + /// let mut data = c_mutex.lock().unwrap(); + /// data.insert(10); + /// panic!(); + /// }).join(); + /// + /// let p_err = mutex.lock().unwrap_err(); + /// let data = p_err.into_inner(); + /// println!("recovered {} items", data.len()); + /// ``` #[stable(feature = "sync_poison", since = "1.2.0")] pub fn into_inner(self) -> T { self.guard } From 4d2a8c527880a56db3b410450fa2b6cbf0cbe3a8 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Sat, 23 Sep 2017 17:08:16 -0700 Subject: [PATCH 28/77] Simplify implementation of Display and Error for convert::Infallible. --- src/libcore/convert.rs | 5 +++-- src/libstd/error.rs | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 6eb499ad8ab23..e815d72d36646 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -62,8 +62,9 @@ pub enum Infallible {} #[unstable(feature = "try_from", issue = "33417")] impl fmt::Display for Infallible { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - "an error of this type can never exist".fmt(f) + fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + match *self { + } } } /// A cheap reference-to-reference conversion. Used to convert a value to a diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 5cb2b00334db3..6a4de4ecbffd4 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -351,7 +351,8 @@ impl Error for char::ParseCharError { #[unstable(feature = "try_from", issue = "33417")] impl Error for convert::Infallible { fn description(&self) -> &str { - "an error of this type can never exist" + match *self { + } } } From ba74a8665d2b7771b6fd0499dc050c1bf075fca9 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Sat, 23 Sep 2017 17:19:18 -0700 Subject: [PATCH 29/77] Add back mistakenly removed numeric conversions. --- src/libcore/num/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 9f87e2bd8316d..cfa22360e9e17 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2638,14 +2638,14 @@ mod ptr_try_from_impls { try_from_both_bounded!(isize, i8); try_from_unbounded!(isize, i16, i32, i64, i128); - rev!(try_from_unbounded, usize, u16); + rev!(try_from_unbounded, usize, u8, u16); rev!(try_from_upper_bounded, usize, u32, u64, u128); rev!(try_from_lower_bounded, usize, i8, i16); rev!(try_from_both_bounded, usize, i32, i64, i128); rev!(try_from_unbounded, isize, u8); rev!(try_from_upper_bounded, isize, u16, u32, u64, u128); - rev!(try_from_unbounded, isize, i16); + rev!(try_from_unbounded, isize, i8, i16); rev!(try_from_both_bounded, isize, i32, i64, i128); } @@ -2664,14 +2664,14 @@ mod ptr_try_from_impls { try_from_both_bounded!(isize, i8, i16); try_from_unbounded!(isize, i32, i64, i128); - rev!(try_from_unbounded, usize, u16, u32); + rev!(try_from_unbounded, usize, u8, u16, u32); rev!(try_from_upper_bounded, usize, u64, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32); rev!(try_from_both_bounded, usize, i64, i128); rev!(try_from_unbounded, isize, u8, u16); rev!(try_from_upper_bounded, isize, u32, u64, u128); - rev!(try_from_unbounded, isize, i16, i32); + rev!(try_from_unbounded, isize, i8, i16, i32); rev!(try_from_both_bounded, isize, i64, i128); } From bc43e1739234727ebddaf475c2851eab00353324 Mon Sep 17 00:00:00 2001 From: Ethan Dagner Date: Sat, 23 Sep 2017 11:47:21 -0600 Subject: [PATCH 30/77] Add doc example to HashMap::hasher --- src/libstd/collections/hash/map.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 96af227257824..f28577d257e74 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -691,6 +691,17 @@ impl HashMap /// Returns a reference to the map's [`BuildHasher`]. /// /// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html + /// + /// # Examples + /// + /// ``` + /// use std::collections::HashMap; + /// use std::collections::hash_map::RandomState; + /// + /// let hasher = RandomState::new(); + /// let map: HashMap = HashMap::with_hasher(hasher); + /// let hasher: &RandomState = map.hasher(); + /// ``` #[stable(feature = "hashmap_public_hasher", since = "1.9.0")] pub fn hasher(&self) -> &S { &self.hash_builder From ddee9fbc998e345e9a36f2066d51d389aa31a632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 22 Sep 2017 19:13:19 -0700 Subject: [PATCH 31/77] Point at parameter type on E0301 On "the parameter type `T` may not live long enough" error, point to the parameter type suggesting lifetime bindings: ``` error[E0310]: the parameter type `T` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | 27 | struct Foo { | - help: consider adding an explicit lifetime bound `T: 'static`... 28 | foo: &'static T | ^^^^^^^^^^^^^^^ | note: ...so that the reference type `&'static T` does not outlive the data it points at --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 | 28 | foo: &'static T | ^^^^^^^^^^^^^^^ ``` --- src/librustc/infer/error_reporting/mod.rs | 70 ++++++++++++++++--- src/librustc/middle/free_region.rs | 2 +- src/librustc/middle/region.rs | 2 +- src/librustc/ty/context.rs | 2 +- src/librustc_data_structures/bitvec.rs | 2 +- .../transitive_relation.rs | 6 +- .../lifetime-doesnt-live-long-enough.rs} | 8 ++- .../lifetime-doesnt-live-long-enough.stderr | 30 ++++++++ 8 files changed, 102 insertions(+), 20 deletions(-) rename src/test/{compile-fail/issue-16747.rs => ui/lifetimes/lifetime-doesnt-live-long-enough.rs} (78%) create mode 100644 src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index a88e90caee307..76c4ffe3d224a 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -774,10 +774,44 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { bound_kind: GenericKind<'tcx>, sub: Region<'tcx>) { - // FIXME: it would be better to report the first error message - // with the span of the parameter itself, rather than the span - // where the error was detected. But that span is not readily - // accessible. + // Attempt to obtain the span of the parameter so we can + // suggest adding an explicit lifetime bound to it. + let type_param_span = match (self.in_progress_tables, bound_kind) { + (Some(ref table), GenericKind::Param(ref param)) => { + let table = table.borrow(); + table.local_id_root.and_then(|did| { + let generics = self.tcx.generics_of(did); + // Account for the case where `did` corresponds to `Self`, which doesn't have + // the expected type argument. + if generics.types.len() > 0 { + let type_param = generics.type_param(param); + let hir = &self.tcx.hir; + hir.as_local_node_id(type_param.def_id).map(|id| { + // Get the `hir::TyParam` to verify wether it already has any bounds. + // We do this to avoid suggesting code that ends up as `T: 'a'b`, + // instead we suggest `T: 'a + 'b` in that case. + let has_lifetimes = if let hir_map::NodeTyParam(ref p) = hir.get(id) { + p.bounds.len() > 0 + } else { + false + }; + let sp = hir.span(id); + // `sp` only covers `T`, change it so that it covers + // `T:` when appropriate + let sp = if has_lifetimes { + sp.to(sp.next_point().next_point()) + } else { + sp + }; + (sp, has_lifetimes) + }) + } else { + None + } + }) + } + _ => None, + }; let labeled_user_string = match bound_kind { GenericKind::Param(ref p) => @@ -799,6 +833,26 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { return; } + fn binding_suggestion<'tcx, S: fmt::Display>(err: &mut DiagnosticBuilder<'tcx>, + type_param_span: Option<(Span, bool)>, + bound_kind: GenericKind<'tcx>, + sub: S) { + let consider = &format!("consider adding an explicit lifetime bound `{}: {}`...", + bound_kind, + sub); + if let Some((sp, has_lifetimes)) = type_param_span { + let tail = if has_lifetimes { + " + " + } else { + "" + }; + let suggestion = format!("{}: {}{}", bound_kind, sub, tail); + err.span_suggestion_short(sp, consider, suggestion); + } else { + err.help(consider); + } + } + let mut err = match *sub { ty::ReEarlyBound(_) | ty::ReFree(ty::FreeRegion {bound_region: ty::BrNamed(..), ..}) => { @@ -808,9 +862,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { E0309, "{} may not live long enough", labeled_user_string); - err.help(&format!("consider adding an explicit lifetime bound `{}: {}`...", - bound_kind, - sub)); + binding_suggestion(&mut err, type_param_span, bound_kind, sub); err } @@ -821,9 +873,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { E0310, "{} may not live long enough", labeled_user_string); - err.help(&format!("consider adding an explicit lifetime \ - bound `{}: 'static`...", - bound_kind)); + binding_suggestion(&mut err, type_param_span, bound_kind, "'static"); err } diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index 4de86b669160e..49a241b86e015 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -117,7 +117,7 @@ impl<'a, 'gcx, 'tcx> RegionRelations<'a, 'gcx, 'tcx> { } } -#[derive(Clone, RustcEncodable, RustcDecodable)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct FreeRegionMap<'tcx> { // Stores the relation `a < b`, where `a` and `b` are regions. // diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 6cce7447669f7..d66eda6564e4a 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -201,7 +201,7 @@ impl Scope { } /// The region scope tree encodes information about region relationships. -#[derive(Default)] +#[derive(Default, Debug)] pub struct ScopeTree { /// If not empty, this body is the root of this region hierarchy. root_body: Option, diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index d7327d2bd0fdc..c27575820120a 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -314,7 +314,7 @@ impl<'a, V> LocalTableInContextMut<'a, V> { } } -#[derive(RustcEncodable, RustcDecodable)] +#[derive(RustcEncodable, RustcDecodable, Debug)] pub struct TypeckTables<'tcx> { /// The HirId::owner all ItemLocalIds in this table are relative to. pub local_id_root: Option, diff --git a/src/librustc_data_structures/bitvec.rs b/src/librustc_data_structures/bitvec.rs index 7331016c2d26c..e8f9a6720872d 100644 --- a/src/librustc_data_structures/bitvec.rs +++ b/src/librustc_data_structures/bitvec.rs @@ -138,7 +138,7 @@ impl FromIterator for BitVector { /// A "bit matrix" is basically a matrix of booleans represented as /// one gigantic bitvector. In other words, it is as if you have /// `rows` bitvectors, each of length `columns`. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct BitMatrix { columns: usize, vector: Vec, diff --git a/src/librustc_data_structures/transitive_relation.rs b/src/librustc_data_structures/transitive_relation.rs index 46463944043bd..7cb386b019798 100644 --- a/src/librustc_data_structures/transitive_relation.rs +++ b/src/librustc_data_structures/transitive_relation.rs @@ -18,7 +18,7 @@ use std::hash::Hash; use std::mem; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct TransitiveRelation { // List of elements. This is used to map from a T to a usize. elements: Vec, @@ -42,10 +42,10 @@ pub struct TransitiveRelation { closure: RefCell>, } -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)] struct Index(usize); -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)] +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)] struct Edge { source: Index, target: Index, diff --git a/src/test/compile-fail/issue-16747.rs b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs similarity index 78% rename from src/test/compile-fail/issue-16747.rs rename to src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs index dd7e8a869eca9..465b42710352d 100644 --- a/src/test/compile-fail/issue-16747.rs +++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs @@ -16,14 +16,16 @@ trait Collection { fn len(&self) -> usize; } struct List<'a, T: ListItem<'a>> { slice: &'a [T] -//~^ ERROR the parameter type `T` may not live long enough -//~| HELP consider adding an explicit lifetime bound -//~| NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at } + impl<'a, T: ListItem<'a>> Collection for List<'a, T> { fn len(&self) -> usize { 0 } } +struct Foo { + foo: &'static T +} + fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr new file mode 100644 index 0000000000000..e17a660c59170 --- /dev/null +++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr @@ -0,0 +1,30 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/lifetime-doesnt-live-long-enough.rs:18:5 + | +17 | struct List<'a, T: ListItem<'a>> { + | -- help: consider adding an explicit lifetime bound `T: 'a`... +18 | slice: &'a [T] + | ^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a [T]` does not outlive the data it points at + --> $DIR/lifetime-doesnt-live-long-enough.rs:18:5 + | +18 | slice: &'a [T] + | ^^^^^^^^^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 + | +27 | struct Foo { + | - help: consider adding an explicit lifetime bound `T: 'static`... +28 | foo: &'static T + | ^^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'static T` does not outlive the data it points at + --> $DIR/lifetime-doesnt-live-long-enough.rs:28:5 + | +28 | foo: &'static T + | ^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + From 874124b2c73dc764aa83f7ba9711a4170c0aeffc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 24 Sep 2017 22:23:26 -0700 Subject: [PATCH 32/77] Backport libs stabilizations to 1.21 beta This includes the following stabilizations: - tcpstream_connect_timeout https://github.com/rust-lang/rust/pull/44563 - iterator_for_each https://github.com/rust-lang/rust/pull/44567 - ord_max_min https://github.com/rust-lang/rust/pull/44593 - compiler_fences https://github.com/rust-lang/rust/pull/44595 - needs_drop https://github.com/rust-lang/rust/pull/44639 - vec_splice https://github.com/rust-lang/rust/pull/44640 --- src/liballoc/vec.rs | 12 ++++++------ src/libcore/cmp.rs | 4 ++-- src/libcore/iter/iterator.rs | 2 +- src/libcore/mem.rs | 2 +- src/libcore/sync/atomic.rs | 2 +- src/libstd/net/tcp.rs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 7dd8895c1ae4c..725d3e15f4a61 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1950,7 +1950,7 @@ impl Vec { /// assert_eq!(u, &[1, 2]); /// ``` #[inline] - #[stable(feature = "vec_splice", since = "1.22.0")] + #[stable(feature = "vec_splice", since = "1.21.0")] pub fn splice(&mut self, range: R, replace_with: I) -> Splice where R: RangeArgument, I: IntoIterator { @@ -2553,13 +2553,13 @@ impl<'a, T> InPlace for PlaceBack<'a, T> { /// [`splice()`]: struct.Vec.html#method.splice /// [`Vec`]: struct.Vec.html #[derive(Debug)] -#[stable(feature = "vec_splice", since = "1.22.0")] +#[stable(feature = "vec_splice", since = "1.21.0")] pub struct Splice<'a, I: Iterator + 'a> { drain: Drain<'a, I::Item>, replace_with: I, } -#[stable(feature = "vec_splice", since = "1.22.0")] +#[stable(feature = "vec_splice", since = "1.21.0")] impl<'a, I: Iterator> Iterator for Splice<'a, I> { type Item = I::Item; @@ -2572,18 +2572,18 @@ impl<'a, I: Iterator> Iterator for Splice<'a, I> { } } -#[stable(feature = "vec_splice", since = "1.22.0")] +#[stable(feature = "vec_splice", since = "1.21.0")] impl<'a, I: Iterator> DoubleEndedIterator for Splice<'a, I> { fn next_back(&mut self) -> Option { self.drain.next_back() } } -#[stable(feature = "vec_splice", since = "1.22.0")] +#[stable(feature = "vec_splice", since = "1.21.0")] impl<'a, I: Iterator> ExactSizeIterator for Splice<'a, I> {} -#[stable(feature = "vec_splice", since = "1.22.0")] +#[stable(feature = "vec_splice", since = "1.21.0")] impl<'a, I: Iterator> Drop for Splice<'a, I> { fn drop(&mut self) { // exhaust drain first diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 6f86f8caad073..e012cbd76ff91 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -456,7 +456,7 @@ pub trait Ord: Eq + PartialOrd { /// assert_eq!(2, 1.max(2)); /// assert_eq!(2, 2.max(2)); /// ``` - #[stable(feature = "ord_max_min", since = "1.22.0")] + #[stable(feature = "ord_max_min", since = "1.21.0")] fn max(self, other: Self) -> Self where Self: Sized { if other >= self { other } else { self } @@ -472,7 +472,7 @@ pub trait Ord: Eq + PartialOrd { /// assert_eq!(1, 1.min(2)); /// assert_eq!(2, 2.min(2)); /// ``` - #[stable(feature = "ord_max_min", since = "1.22.0")] + #[stable(feature = "ord_max_min", since = "1.21.0")] fn min(self, other: Self) -> Self where Self: Sized { if self <= other { self } else { other } diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 36bf9633b4a35..e9e31065cf876 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -518,7 +518,7 @@ pub trait Iterator { /// .for_each(|(i, x)| println!("{}:{}", i, x)); /// ``` #[inline] - #[stable(feature = "iterator_for_each", since = "1.22.0")] + #[stable(feature = "iterator_for_each", since = "1.21.0")] fn for_each(self, mut f: F) where Self: Sized, F: FnMut(Self::Item), { diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 669b93120cf45..c869054cee81a 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -402,7 +402,7 @@ pub fn align_of_val(val: &T) -> usize { /// } /// ``` #[inline] -#[stable(feature = "needs_drop", since = "1.22.0")] +#[stable(feature = "needs_drop", since = "1.21.0")] pub fn needs_drop() -> bool { unsafe { intrinsics::needs_drop::() } } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 3dd08e6971066..2bb40cb672e26 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -1752,7 +1752,7 @@ pub fn fence(order: Ordering) { /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed /// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt #[inline] -#[stable(feature = "compiler_fences", since = "1.22.0")] +#[stable(feature = "compiler_fences", since = "1.21.0")] pub fn compiler_fence(order: Ordering) { unsafe { match order { diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index aff9af66444c4..8d1e7882e5db4 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -167,7 +167,7 @@ impl TcpStream { /// connection request. /// /// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html - #[stable(feature = "tcpstream_connect_timeout", since = "1.22.0")] + #[stable(feature = "tcpstream_connect_timeout", since = "1.21.0")] pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> io::Result { net_imp::TcpStream::connect_timeout(addr, timeout).map(TcpStream) } From d5d41f2a3c83f2df11b14c81bfe6a76ccdb099e3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 25 Sep 2017 15:41:16 +0200 Subject: [PATCH 33/77] Add missing links in fmt module --- src/libcore/fmt/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index b84a1deb61144..6c251b9eb0924 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -488,13 +488,14 @@ impl<'a> Display for Arguments<'a> { /// The origin is: Point { x: 0, y: 0 } /// ``` /// -/// There are a number of `debug_*` methods on `Formatter` to help you with manual +/// There are a number of `debug_*` methods on [`Formatter`] to help you with manual /// implementations, such as [`debug_struct`][debug_struct]. /// /// `Debug` implementations using either `derive` or the debug builder API -/// on `Formatter` support pretty printing using the alternate flag: `{:#?}`. +/// on [`Formatter`] support pretty printing using the alternate flag: `{:#?}`. /// /// [debug_struct]: ../../std/fmt/struct.Formatter.html#method.debug_struct +/// [`Formatter`]: ../../std/fmt/struct.Formatter.html /// /// Pretty printing with `#?`: /// @@ -1321,8 +1322,11 @@ impl<'a> Formatter<'a> { self.flags & (1 << FlagV1::SignAwareZeroPad as u32) != 0 } - /// Creates a `DebugStruct` builder designed to assist with creation of - /// `fmt::Debug` implementations for structs. + /// Creates a [`DebugStruct`] builder designed to assist with creation of + /// [`fmt::Debug`] implementations for structs. + /// + /// [`DebugStruct`]: ../../std/fmt/struct.DebugStruct.html + /// [`fmt::Debug`]: ../../std/fmt/trait.Debug.html /// /// # Examples /// From 3db0094359095aaf2ef3769b9fe2e3b3ff65cf98 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Mon, 25 Sep 2017 11:41:39 -0400 Subject: [PATCH 34/77] Improve wording for StepBy No other iterator makes the distinction between an iterator and an iterator adapter in its summary line, so change it to be consistent with all other adapters. --- src/libcore/iter/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 7907f2fd66126..14b87f42f6a79 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -546,7 +546,7 @@ impl Iterator for Cycle where I: Clone + Iterator { #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for Cycle where I: Clone + Iterator {} -/// An adapter for stepping iterators by a custom amount. +/// An iterator for stepping iterators by a custom amount. /// /// This `struct` is created by the [`step_by`] method on [`Iterator`]. See /// its documentation for more. From 20d4c0fab418edf036b7e0f1910053d3437da269 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 25 Sep 2017 20:06:03 +0200 Subject: [PATCH 35/77] Move src/librustc_mir/transform/nll.rs to a subdirectory --- src/librustc_mir/transform/{nll.rs => nll/mod.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/librustc_mir/transform/{nll.rs => nll/mod.rs} (100%) diff --git a/src/librustc_mir/transform/nll.rs b/src/librustc_mir/transform/nll/mod.rs similarity index 100% rename from src/librustc_mir/transform/nll.rs rename to src/librustc_mir/transform/nll/mod.rs From 9c3fa4d3ef46317dc812dbd43c8c43355dc7c726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 25 Sep 2017 12:01:55 -0700 Subject: [PATCH 36/77] Point at signature on unused lint --- src/librustc/middle/dead.rs | 28 +++++++++---- .../lint-plugin-cmdline-allow.stderr | 2 +- src/test/ui/path-lookahead.stderr | 12 ++---- .../span/unused-warning-point-at-signature.rs | 40 +++++++++++++++++++ .../unused-warning-point-at-signature.stderr | 36 +++++++++++++++++ 5 files changed, 102 insertions(+), 16 deletions(-) create mode 100644 src/test/ui/span/unused-warning-point-at-signature.rs create mode 100644 src/test/ui/span/unused-warning-point-at-signature.stderr diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 66a425a2d476b..a9d9f6f28ec0d 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -553,9 +553,22 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { if self.should_warn_about_item(item) { + // For items that have a definition with a signature followed by a + // block, point only at the signature. + let span = match item.node { + hir::ItemFn(..) | + hir::ItemMod(..) | + hir::ItemEnum(..) | + hir::ItemStruct(..) | + hir::ItemUnion(..) | + hir::ItemTrait(..) | + hir::ItemDefaultImpl(..) | + hir::ItemImpl(..) => self.tcx.sess.codemap().def_span(item.span), + _ => item.span, + }; self.warn_dead_code( item.id, - item.span, + span, item.name, item.node.descriptive_variant() ); @@ -570,8 +583,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { g: &'tcx hir::Generics, id: ast::NodeId) { if self.should_warn_about_variant(&variant.node) { - self.warn_dead_code(variant.node.data.id(), variant.span, - variant.node.name, "variant"); + self.warn_dead_code(variant.node.data.id(), variant.span, variant.node.name, "variant"); } else { intravisit::walk_variant(self, variant, g, id); } @@ -596,15 +608,17 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { match impl_item.node { hir::ImplItemKind::Const(_, body_id) => { if !self.symbol_is_live(impl_item.id, None) { - self.warn_dead_code(impl_item.id, impl_item.span, - impl_item.name, "associated const"); + self.warn_dead_code(impl_item.id, + impl_item.span, + impl_item.name, + "associated const"); } self.visit_nested_body(body_id) } hir::ImplItemKind::Method(_, body_id) => { if !self.symbol_is_live(impl_item.id, None) { - self.warn_dead_code(impl_item.id, impl_item.span, - impl_item.name, "method"); + let span = self.tcx.sess.codemap().def_span(impl_item.span); + self.warn_dead_code(impl_item.id, span, impl_item.name, "method"); } self.visit_nested_body(body_id) } diff --git a/src/test/ui-fulldeps/lint-plugin-cmdline-allow.stderr b/src/test/ui-fulldeps/lint-plugin-cmdline-allow.stderr index 7c9c4e9903908..0cc3a5b6bf31d 100644 --- a/src/test/ui-fulldeps/lint-plugin-cmdline-allow.stderr +++ b/src/test/ui-fulldeps/lint-plugin-cmdline-allow.stderr @@ -2,7 +2,7 @@ warning: function is never used: `lintme` --> $DIR/lint-plugin-cmdline-allow.rs:20:1 | 20 | fn lintme() { } - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | note: lint level defined here --> $DIR/lint-plugin-cmdline-allow.rs:17:9 diff --git a/src/test/ui/path-lookahead.stderr b/src/test/ui/path-lookahead.stderr index 9936a1eb81e2a..1d4ab35046b48 100644 --- a/src/test/ui/path-lookahead.stderr +++ b/src/test/ui/path-lookahead.stderr @@ -9,10 +9,8 @@ warning: unnecessary parentheses around `return` value warning: function is never used: `with_parens` --> $DIR/path-lookahead.rs:17:1 | -17 | / fn with_parens(arg: T) -> String { //~WARN function is never used: `with_parens` -18 | | return (::to_string(&arg)); //~WARN unnecessary parentheses around `return` value -19 | | } - | |_^ +17 | fn with_parens(arg: T) -> String { //~WARN function is never used: `with_parens` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here --> $DIR/path-lookahead.rs:13:9 @@ -24,8 +22,6 @@ note: lint level defined here warning: function is never used: `no_parens` --> $DIR/path-lookahead.rs:21:1 | -21 | / fn no_parens(arg: T) -> String { //~WARN function is never used: `no_parens` -22 | | return ::to_string(&arg); -23 | | } - | |_^ +21 | fn no_parens(arg: T) -> String { //~WARN function is never used: `no_parens` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/span/unused-warning-point-at-signature.rs b/src/test/ui/span/unused-warning-point-at-signature.rs new file mode 100644 index 0000000000000..eb659d08da0c9 --- /dev/null +++ b/src/test/ui/span/unused-warning-point-at-signature.rs @@ -0,0 +1,40 @@ +// Copyright 2017 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. + +// run-pass + +#![warn(unused)] + +enum Enum { + A, + B, + C, + D, +} + +struct Struct { + a: usize, + b: usize, + c: usize, + d: usize, +} + +fn func() -> usize { + 3 +} + +fn +func_complete_span() +-> usize +{ + 3 +} + +fn main() {} diff --git a/src/test/ui/span/unused-warning-point-at-signature.stderr b/src/test/ui/span/unused-warning-point-at-signature.stderr new file mode 100644 index 0000000000000..8e658670e9c0c --- /dev/null +++ b/src/test/ui/span/unused-warning-point-at-signature.stderr @@ -0,0 +1,36 @@ +warning: enum is never used: `Enum` + --> $DIR/unused-warning-point-at-signature.rs:15:1 + | +15 | enum Enum { + | ^^^^^^^^^ + | +note: lint level defined here + --> $DIR/unused-warning-point-at-signature.rs:13:9 + | +13 | #![warn(unused)] + | ^^^^^^ + = note: #[warn(dead_code)] implied by #[warn(unused)] + +warning: struct is never used: `Struct` + --> $DIR/unused-warning-point-at-signature.rs:22:1 + | +22 | struct Struct { + | ^^^^^^^^^^^^^ + +warning: function is never used: `func` + --> $DIR/unused-warning-point-at-signature.rs:29:1 + | +29 | fn func() -> usize { + | ^^^^^^^^^^^^^^^^^^ + +warning: function is never used: `func_complete_span` + --> $DIR/unused-warning-point-at-signature.rs:33:1 + | +33 | / fn +34 | | func_complete_span() +35 | | -> usize +36 | | { +37 | | 3 +38 | | } + | |_^ + From f7fd04ae65d30c3b0af36623bbeb299bbc52d710 Mon Sep 17 00:00:00 2001 From: Lucas Morales Date: Mon, 25 Sep 2017 19:39:52 -0400 Subject: [PATCH 37/77] docs improvement sync::atomic::Atomic* --- src/libcore/sync/atomic.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 3dd08e6971066..bf11e18e4f337 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -926,10 +926,24 @@ macro_rules! atomic_int { $stable_cxchg:meta, $stable_debug:meta, $stable_access:meta, + $s_int_type:expr, $int_ref:expr, $int_type:ident $atomic_type:ident $atomic_init:ident) => { /// An integer type which can be safely shared between threads. /// - /// This type has the same in-memory representation as the underlying integer type. + /// This type has the same in-memory representation as the underlying + /// integer type, [` + #[doc = $s_int_type] + /// `]( + #[doc = $int_ref] + /// ). For more about the differences between atomic types and + /// non-atomic types, please see the [module-level documentation]. + /// + /// Please note that examples are shared between atomic variants of + /// primitive integer types, so it's normal that they are all + /// demonstrating [`AtomicIsize`]. + /// + /// [module-level documentation]: index.html + /// [`AtomicIsize`]: struct.AtomicIsize.html #[$stable] pub struct $atomic_type { v: UnsafeCell<$int_type>, @@ -1339,6 +1353,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + "i8", "../../../std/primitive.i8.html", i8 AtomicI8 ATOMIC_I8_INIT } #[cfg(target_has_atomic = "8")] @@ -1348,6 +1363,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + "u8", "../../../std/primitive.u8.html", u8 AtomicU8 ATOMIC_U8_INIT } #[cfg(target_has_atomic = "16")] @@ -1357,6 +1373,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + "i16", "../../../std/primitive.i16.html", i16 AtomicI16 ATOMIC_I16_INIT } #[cfg(target_has_atomic = "16")] @@ -1366,6 +1383,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + "u16", "../../../std/primitive.u16.html", u16 AtomicU16 ATOMIC_U16_INIT } #[cfg(target_has_atomic = "32")] @@ -1375,6 +1393,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + "i32", "../../../std/primitive.i32.html", i32 AtomicI32 ATOMIC_I32_INIT } #[cfg(target_has_atomic = "32")] @@ -1384,6 +1403,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + "u32", "../../../std/primitive.u32.html", u32 AtomicU32 ATOMIC_U32_INIT } #[cfg(target_has_atomic = "64")] @@ -1393,6 +1413,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + "i64", "../../../std/primitive.i64.html", i64 AtomicI64 ATOMIC_I64_INIT } #[cfg(target_has_atomic = "64")] @@ -1402,6 +1423,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + "u64", "../../../std/primitive.u64.html", u64 AtomicU64 ATOMIC_U64_INIT } #[cfg(target_has_atomic = "ptr")] @@ -1411,6 +1433,7 @@ atomic_int!{ stable(feature = "extended_compare_and_swap", since = "1.10.0"), stable(feature = "atomic_debug", since = "1.3.0"), stable(feature = "atomic_access", since = "1.15.0"), + "isize", "../../../std/primitive.isize.html", isize AtomicIsize ATOMIC_ISIZE_INIT } #[cfg(target_has_atomic = "ptr")] @@ -1420,6 +1443,7 @@ atomic_int!{ stable(feature = "extended_compare_and_swap", since = "1.10.0"), stable(feature = "atomic_debug", since = "1.3.0"), stable(feature = "atomic_access", since = "1.15.0"), + "usize", "../../../std/primitive.usize.html", usize AtomicUsize ATOMIC_USIZE_INIT } From 13724fafdc62e3e7e75822554cadb15ff5ce3035 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 25 Sep 2017 20:53:08 -0700 Subject: [PATCH 38/77] Add more custom folding to `core::iter` adaptors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Many of the iterator adaptors will perform faster folds if they forward to their inner iterator's folds, especially for inner types like `Chain` which are optimized too. The following types are newly specialized: | Type | `fold` | `rfold` | | ----------- | ------ | ------- | | `Enumerate` | ✓ | ✓ | | `Filter` | ✓ | ✓ | | `FilterMap` | ✓ | ✓ | | `FlatMap` | exists | ✓ | | `Fuse` | ✓ | ✓ | | `Inspect` | ✓ | ✓ | | `Peekable` | ✓ | N/A¹ | | `Skip` | ✓ | N/A² | | `SkipWhile` | ✓ | N/A¹ | ¹ not a `DoubleEndedIterator` ² `Skip::next_back` doesn't pull skipped items at all, but this couldn't be avoided if `Skip::rfold` were to call its inner iterator's `rfold`. Benchmarks ---------- In the following results, plain `_sum` computes the sum of a million integers -- note that `sum()` is implemented with `fold()`. The `_ref_sum` variants do the same on a `by_ref()` iterator, which is limited to calling `next()` one by one, without specialized `fold`. The `chain` variants perform the same tests on two iterators chained together, to show a greater benefit of forwarding `fold` internally. test iter::bench_enumerate_chain_ref_sum ... bench: 2,216,264 ns/iter (+/- 29,228) test iter::bench_enumerate_chain_sum ... bench: 922,380 ns/iter (+/- 2,676) test iter::bench_enumerate_ref_sum ... bench: 476,094 ns/iter (+/- 7,110) test iter::bench_enumerate_sum ... bench: 476,438 ns/iter (+/- 3,334) test iter::bench_filter_chain_ref_sum ... bench: 2,266,095 ns/iter (+/- 6,051) test iter::bench_filter_chain_sum ... bench: 745,594 ns/iter (+/- 2,013) test iter::bench_filter_ref_sum ... bench: 889,696 ns/iter (+/- 1,188) test iter::bench_filter_sum ... bench: 667,325 ns/iter (+/- 1,894) test iter::bench_filter_map_chain_ref_sum ... bench: 2,259,195 ns/iter (+/- 353,440) test iter::bench_filter_map_chain_sum ... bench: 1,223,280 ns/iter (+/- 1,972) test iter::bench_filter_map_ref_sum ... bench: 611,607 ns/iter (+/- 2,507) test iter::bench_filter_map_sum ... bench: 611,610 ns/iter (+/- 472) test iter::bench_fuse_chain_ref_sum ... bench: 2,246,106 ns/iter (+/- 22,395) test iter::bench_fuse_chain_sum ... bench: 634,887 ns/iter (+/- 1,341) test iter::bench_fuse_ref_sum ... bench: 444,816 ns/iter (+/- 1,748) test iter::bench_fuse_sum ... bench: 316,954 ns/iter (+/- 2,616) test iter::bench_inspect_chain_ref_sum ... bench: 2,245,431 ns/iter (+/- 21,371) test iter::bench_inspect_chain_sum ... bench: 631,645 ns/iter (+/- 4,928) test iter::bench_inspect_ref_sum ... bench: 317,437 ns/iter (+/- 702) test iter::bench_inspect_sum ... bench: 315,942 ns/iter (+/- 4,320) test iter::bench_peekable_chain_ref_sum ... bench: 2,243,585 ns/iter (+/- 12,186) test iter::bench_peekable_chain_sum ... bench: 634,848 ns/iter (+/- 1,712) test iter::bench_peekable_ref_sum ... bench: 444,808 ns/iter (+/- 480) test iter::bench_peekable_sum ... bench: 317,133 ns/iter (+/- 3,309) test iter::bench_skip_chain_ref_sum ... bench: 1,778,734 ns/iter (+/- 2,198) test iter::bench_skip_chain_sum ... bench: 761,850 ns/iter (+/- 1,645) test iter::bench_skip_ref_sum ... bench: 478,207 ns/iter (+/- 119,252) test iter::bench_skip_sum ... bench: 315,614 ns/iter (+/- 3,054) test iter::bench_skip_while_chain_ref_sum ... bench: 2,486,370 ns/iter (+/- 4,845) test iter::bench_skip_while_chain_sum ... bench: 633,915 ns/iter (+/- 5,892) test iter::bench_skip_while_ref_sum ... bench: 666,926 ns/iter (+/- 804) test iter::bench_skip_while_sum ... bench: 444,405 ns/iter (+/- 571) --- src/libcore/benches/iter.rs | 151 ++++++++++++++++++++++++------ src/libcore/iter/mod.rs | 172 ++++++++++++++++++++++++++++++++++ src/libcore/tests/iter.rs | 180 +++++++++++++++++++++++++++++++++++- src/libcore/tests/lib.rs | 1 + 4 files changed, 471 insertions(+), 33 deletions(-) diff --git a/src/libcore/benches/iter.rs b/src/libcore/benches/iter.rs index 827c6354c60ba..1f16f5b1df3f3 100644 --- a/src/libcore/benches/iter.rs +++ b/src/libcore/benches/iter.rs @@ -147,40 +147,131 @@ fn bench_for_each_chain_ref_fold(b: &mut Bencher) { }); } -#[bench] -fn bench_flat_map_sum(b: &mut Bencher) { - b.iter(|| -> i64 { - (0i64..1000).flat_map(|x| x..x+1000) - .map(black_box) - .sum() - }); + +/// Helper to benchmark `sum` for iterators taken by value which +/// can optimize `fold`, and by reference which cannot. +macro_rules! bench_sums { + ($bench_sum:ident, $bench_ref_sum:ident, $iter:expr) => { + #[bench] + fn $bench_sum(b: &mut Bencher) { + b.iter(|| -> i64 { + $iter.map(black_box).sum() + }); + } + + #[bench] + fn $bench_ref_sum(b: &mut Bencher) { + b.iter(|| -> i64 { + $iter.map(black_box).by_ref().sum() + }); + } + } } -#[bench] -fn bench_flat_map_ref_sum(b: &mut Bencher) { - b.iter(|| -> i64 { - (0i64..1000).flat_map(|x| x..x+1000) - .map(black_box) - .by_ref() - .sum() - }); +bench_sums! { + bench_flat_map_sum, + bench_flat_map_ref_sum, + (0i64..1000).flat_map(|x| x..x+1000) } -#[bench] -fn bench_flat_map_chain_sum(b: &mut Bencher) { - b.iter(|| -> i64 { - (0i64..1000000).flat_map(|x| once(x).chain(once(x))) - .map(black_box) - .sum() - }); +bench_sums! { + bench_flat_map_chain_sum, + bench_flat_map_chain_ref_sum, + (0i64..1000000).flat_map(|x| once(x).chain(once(x))) } -#[bench] -fn bench_flat_map_chain_ref_sum(b: &mut Bencher) { - b.iter(|| -> i64 { - (0i64..1000000).flat_map(|x| once(x).chain(once(x))) - .map(black_box) - .by_ref() - .sum() - }); +bench_sums! { + bench_enumerate_sum, + bench_enumerate_ref_sum, + (0i64..1000000).enumerate().map(|(i, x)| x * i as i64) +} + +bench_sums! { + bench_enumerate_chain_sum, + bench_enumerate_chain_ref_sum, + (0i64..1000000).chain(0..1000000).enumerate().map(|(i, x)| x * i as i64) +} + +bench_sums! { + bench_filter_sum, + bench_filter_ref_sum, + (0i64..1000000).filter(|x| x % 2 == 0) +} + +bench_sums! { + bench_filter_chain_sum, + bench_filter_chain_ref_sum, + (0i64..1000000).chain(0..1000000).filter(|x| x % 2 == 0) +} + +bench_sums! { + bench_filter_map_sum, + bench_filter_map_ref_sum, + (0i64..1000000).filter_map(|x| x.checked_mul(x)) +} + +bench_sums! { + bench_filter_map_chain_sum, + bench_filter_map_chain_ref_sum, + (0i64..1000000).chain(0..1000000).filter_map(|x| x.checked_mul(x)) +} + +bench_sums! { + bench_fuse_sum, + bench_fuse_ref_sum, + (0i64..1000000).fuse() +} + +bench_sums! { + bench_fuse_chain_sum, + bench_fuse_chain_ref_sum, + (0i64..1000000).chain(0..1000000).fuse() +} + +bench_sums! { + bench_inspect_sum, + bench_inspect_ref_sum, + (0i64..1000000).inspect(|_| {}) +} + +bench_sums! { + bench_inspect_chain_sum, + bench_inspect_chain_ref_sum, + (0i64..1000000).chain(0..1000000).inspect(|_| {}) +} + +bench_sums! { + bench_peekable_sum, + bench_peekable_ref_sum, + (0i64..1000000).peekable() +} + +bench_sums! { + bench_peekable_chain_sum, + bench_peekable_chain_ref_sum, + (0i64..1000000).chain(0..1000000).peekable() +} + +bench_sums! { + bench_skip_sum, + bench_skip_ref_sum, + (0i64..1000000).skip(1000) +} + +bench_sums! { + bench_skip_chain_sum, + bench_skip_chain_ref_sum, + (0i64..1000000).chain(0..1000000).skip(1000) +} + +bench_sums! { + bench_skip_while_sum, + bench_skip_while_ref_sum, + (0i64..1000000).skip_while(|&x| x < 1000) +} + +bench_sums! { + bench_skip_while_chain_sum, + bench_skip_while_chain_ref_sum, + (0i64..1000000).chain(0..1000000).skip_while(|&x| x < 1000) } diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 7907f2fd66126..05a5f63680cf9 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -1238,6 +1238,18 @@ impl Iterator for Filter where P: FnMut(&I::Item) -> bool } count } + + #[inline] + fn fold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + let mut predicate = self.predicate; + self.iter.fold(init, move |acc, item| if predicate(&item) { + fold(acc, item) + } else { + acc + }) + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1253,6 +1265,18 @@ impl DoubleEndedIterator for Filter } None } + + #[inline] + fn rfold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + let mut predicate = self.predicate; + self.iter.rfold(init, move |acc, item| if predicate(&item) { + fold(acc, item) + } else { + acc + }) + } } #[unstable(feature = "fused", issue = "35602")] @@ -1304,6 +1328,17 @@ impl Iterator for FilterMap let (_, upper) = self.iter.size_hint(); (0, upper) // can't know a lower bound, due to the predicate } + + #[inline] + fn fold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + let mut f = self.f; + self.iter.fold(init, move |acc, item| match f(item) { + Some(x) => fold(acc, x), + None => acc, + }) + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1319,6 +1354,17 @@ impl DoubleEndedIterator for FilterMap } None } + + #[inline] + fn rfold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + let mut f = self.f; + self.iter.rfold(init, move |acc, item| match f(item) { + Some(x) => fold(acc, x), + None => acc, + }) + } } #[unstable(feature = "fused", issue = "35602")] @@ -1383,6 +1429,19 @@ impl Iterator for Enumerate where I: Iterator { fn count(self) -> usize { self.iter.count() } + + #[inline] + #[rustc_inherit_overflow_checks] + fn fold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + let mut count = self.count; + self.iter.fold(init, move |acc, item| { + let acc = fold(acc, (count, item)); + count += 1; + acc + }) + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1398,6 +1457,19 @@ impl DoubleEndedIterator for Enumerate where (self.count + len, a) }) } + + #[inline] + fn rfold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + // Can safely add and subtract the count, as `ExactSizeIterator` promises + // that the number of elements fits into a `usize`. + let mut count = self.count + self.iter.len(); + self.iter.rfold(init, move |acc, item| { + count -= 1; + fold(acc, (count, item)) + }) + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1509,6 +1581,18 @@ impl Iterator for Peekable { let hi = hi.and_then(|x| x.checked_add(peek_len)); (lo, hi) } + + #[inline] + fn fold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + let acc = match self.peeked { + Some(None) => return init, + Some(Some(v)) => fold(init, v), + None => init, + }; + self.iter.fold(acc, fold) + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1617,6 +1701,19 @@ impl Iterator for SkipWhile let (_, upper) = self.iter.size_hint(); (0, upper) // can't know a lower bound, due to the predicate } + + #[inline] + fn fold(mut self, mut init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + if !self.flag { + match self.next() { + Some(v) => init = fold(init, v), + None => return init, + } + } + self.iter.fold(init, fold) + } } #[unstable(feature = "fused", issue = "35602")] @@ -1757,6 +1854,19 @@ impl Iterator for Skip where I: Iterator { (lower, upper) } + + #[inline] + fn fold(mut self, init: Acc, fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + if self.n > 0 { + // nth(n) skips n+1 + if self.iter.nth(self.n - 1).is_none() { + return init; + } + } + self.iter.fold(init, fold) + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1979,6 +2089,16 @@ impl DoubleEndedIterator for FlatMap wher } } } + + #[inline] + fn rfold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + self.frontiter.into_iter() + .chain(self.iter.map(self.f).map(U::into_iter)) + .chain(self.backiter) + .rfold(init, |acc, iter| iter.rfold(acc, &mut fold)) + } } #[unstable(feature = "fused", issue = "35602")] @@ -2056,6 +2176,17 @@ impl Iterator for Fuse where I: Iterator { self.iter.size_hint() } } + + #[inline] + default fn fold(self, init: Acc, fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + if self.done { + init + } else { + self.iter.fold(init, fold) + } + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -2070,6 +2201,17 @@ impl DoubleEndedIterator for Fuse where I: DoubleEndedIterator { next } } + + #[inline] + default fn rfold(self, init: Acc, fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + if self.done { + init + } else { + self.iter.rfold(init, fold) + } + } } unsafe impl TrustedRandomAccess for Fuse @@ -2110,6 +2252,13 @@ impl Iterator for Fuse where I: FusedIterator { fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } + + #[inline] + fn fold(self, init: Acc, fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + self.iter.fold(init, fold) + } } #[unstable(feature = "fused", reason = "recently added", issue = "35602")] @@ -2120,6 +2269,13 @@ impl DoubleEndedIterator for Fuse fn next_back(&mut self) -> Option<::Item> { self.iter.next_back() } + + #[inline] + fn rfold(self, init: Acc, fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + self.iter.rfold(init, fold) + } } @@ -2184,6 +2340,14 @@ impl Iterator for Inspect where F: FnMut(&I::Item) { fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } + + #[inline] + fn fold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + let mut f = self.f; + self.iter.fold(init, move |acc, item| { f(&item); fold(acc, item) }) + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -2195,6 +2359,14 @@ impl DoubleEndedIterator for Inspect let next = self.iter.next_back(); self.do_inspect(next) } + + #[inline] + fn rfold(self, init: Acc, mut fold: Fold) -> Acc + where Fold: FnMut(Acc, Self::Item) -> Acc, + { + let mut f = self.f; + self.iter.rfold(init, move |acc, item| { f(&item); fold(acc, item) }) + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 59ae30de452c9..89454c52432d4 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -248,6 +248,25 @@ fn test_filter_map() { assert_eq!(it.collect::>(), [0*0, 2*2, 4*4, 6*6, 8*8]); } +#[test] +fn test_filter_map_fold() { + let xs = [0, 1, 2, 3, 4, 5, 6, 7, 8]; + let ys = [0*0, 2*2, 4*4, 6*6, 8*8]; + let it = xs.iter().filter_map(|&x| if x % 2 == 0 { Some(x*x) } else { None }); + let i = it.fold(0, |i, x| { + assert_eq!(x, ys[i]); + i + 1 + }); + assert_eq!(i, ys.len()); + + let it = xs.iter().filter_map(|&x| if x % 2 == 0 { Some(x*x) } else { None }); + let i = it.rfold(ys.len(), |i, x| { + assert_eq!(x, ys[i - 1]); + i - 1 + }); + assert_eq!(i, 0); +} + #[test] fn test_iterator_enumerate() { let xs = [0, 1, 2, 3, 4, 5]; @@ -282,7 +301,31 @@ fn test_iterator_enumerate_nth() { #[test] fn test_iterator_enumerate_count() { let xs = [0, 1, 2, 3, 4, 5]; - assert_eq!(xs.iter().count(), 6); + assert_eq!(xs.iter().enumerate().count(), 6); +} + +#[test] +fn test_iterator_enumerate_fold() { + let xs = [0, 1, 2, 3, 4, 5]; + let mut it = xs.iter().enumerate(); + // steal a couple to get an interesting offset + assert_eq!(it.next(), Some((0, &0))); + assert_eq!(it.next(), Some((1, &1))); + let i = it.fold(2, |i, (j, &x)| { + assert_eq!(i, j); + assert_eq!(x, xs[j]); + i + 1 + }); + assert_eq!(i, xs.len()); + + let mut it = xs.iter().enumerate(); + assert_eq!(it.next(), Some((0, &0))); + let i = it.rfold(xs.len() - 1, |i, (j, &x)| { + assert_eq!(i, j); + assert_eq!(x, xs[j]); + i - 1 + }); + assert_eq!(i, 0); } #[test] @@ -291,6 +334,25 @@ fn test_iterator_filter_count() { assert_eq!(xs.iter().filter(|&&x| x % 2 == 0).count(), 5); } +#[test] +fn test_iterator_filter_fold() { + let xs = [0, 1, 2, 3, 4, 5, 6, 7, 8]; + let ys = [0, 2, 4, 6, 8]; + let it = xs.iter().filter(|&&x| x % 2 == 0); + let i = it.fold(0, |i, &x| { + assert_eq!(x, ys[i]); + i + 1 + }); + assert_eq!(i, ys.len()); + + let it = xs.iter().filter(|&&x| x % 2 == 0); + let i = it.rfold(ys.len(), |i, &x| { + assert_eq!(x, ys[i - 1]); + i - 1 + }); + assert_eq!(i, 0); +} + #[test] fn test_iterator_peekable() { let xs = vec![0, 1, 2, 3, 4, 5]; @@ -381,6 +443,18 @@ fn test_iterator_peekable_last() { assert_eq!(it.last(), None); } +#[test] +fn test_iterator_peekable_fold() { + let xs = [0, 1, 2, 3, 4, 5]; + let mut it = xs.iter().peekable(); + assert_eq!(it.peek(), Some(&&0)); + let i = it.fold(0, |i, &x| { + assert_eq!(x, xs[i]); + i + 1 + }); + assert_eq!(i, xs.len()); +} + /// This is an iterator that follows the Iterator contract, /// but it is not fused. After having returned None once, it will start /// producing elements if .next() is called again. @@ -470,6 +544,26 @@ fn test_iterator_skip_while() { assert_eq!(i, ys.len()); } +#[test] +fn test_iterator_skip_while_fold() { + let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19]; + let ys = [15, 16, 17, 19]; + let it = xs.iter().skip_while(|&x| *x < 15); + let i = it.fold(0, |i, &x| { + assert_eq!(x, ys[i]); + i + 1 + }); + assert_eq!(i, ys.len()); + + let mut it = xs.iter().skip_while(|&x| *x < 15); + assert_eq!(it.next(), Some(&ys[0])); // process skips before folding + let i = it.fold(1, |i, &x| { + assert_eq!(x, ys[i]); + i + 1 + }); + assert_eq!(i, ys.len()); +} + #[test] fn test_iterator_skip() { let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30]; @@ -566,6 +660,26 @@ fn test_iterator_skip_last() { assert_eq!(it.last(), Some(&30)); } +#[test] +fn test_iterator_skip_fold() { + let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30]; + let ys = [13, 15, 16, 17, 19, 20, 30]; + let it = xs.iter().skip(5); + let i = it.fold(0, |i, &x| { + assert_eq!(x, ys[i]); + i + 1 + }); + assert_eq!(i, ys.len()); + + let mut it = xs.iter().skip(5); + assert_eq!(it.next(), Some(&ys[0])); // process skips before folding + let i = it.fold(1, |i, &x| { + assert_eq!(x, ys[i]); + i + 1 + }); + assert_eq!(i, ys.len()); +} + #[test] fn test_iterator_take() { let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19]; @@ -661,13 +775,22 @@ fn test_iterator_flat_map_fold() { let xs = [0, 3, 6]; let ys = [1, 2, 3, 4, 5, 6, 7]; let mut it = xs.iter().flat_map(|&x| x..x+3); - it.next(); - it.next_back(); + assert_eq!(it.next(), Some(0)); + assert_eq!(it.next_back(), Some(8)); let i = it.fold(0, |i, x| { assert_eq!(x, ys[i]); i + 1 }); assert_eq!(i, ys.len()); + + let mut it = xs.iter().flat_map(|&x| x..x+3); + assert_eq!(it.next(), Some(0)); + assert_eq!(it.next_back(), Some(8)); + let i = it.rfold(ys.len(), |i, x| { + assert_eq!(x, ys[i - 1]); + i - 1 + }); + assert_eq!(i, 0); } #[test] @@ -684,6 +807,32 @@ fn test_inspect() { assert_eq!(&xs[..], &ys[..]); } +#[test] +fn test_inspect_fold() { + let xs = [1, 2, 3, 4]; + let mut n = 0; + { + let it = xs.iter().inspect(|_| n += 1); + let i = it.fold(0, |i, &x| { + assert_eq!(x, xs[i]); + i + 1 + }); + assert_eq!(i, xs.len()); + } + assert_eq!(n, xs.len()); + + let mut n = 0; + { + let it = xs.iter().inspect(|_| n += 1); + let i = it.rfold(xs.len(), |i, &x| { + assert_eq!(x, xs[i - 1]); + i - 1 + }); + assert_eq!(i, 0); + } + assert_eq!(n, xs.len()); +} + #[test] fn test_cycle() { let cycle_len = 3; @@ -1241,6 +1390,31 @@ fn test_fuse_count() { // Can't check len now because count consumes. } +#[test] +fn test_fuse_fold() { + let xs = [0, 1, 2]; + let it = xs.iter(); // `FusedIterator` + let i = it.fuse().fold(0, |i, &x| { + assert_eq!(x, xs[i]); + i + 1 + }); + assert_eq!(i, xs.len()); + + let it = xs.iter(); // `FusedIterator` + let i = it.fuse().rfold(xs.len(), |i, &x| { + assert_eq!(x, xs[i - 1]); + i - 1 + }); + assert_eq!(i, 0); + + let it = xs.iter().scan((), |_, &x| Some(x)); // `!FusedIterator` + let i = it.fuse().fold(0, |i, x| { + assert_eq!(x, xs[i]); + i + 1 + }); + assert_eq!(i, xs.len()); +} + #[test] fn test_once() { let mut it = once(42); diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 47995597a0a91..d928276ad2f0d 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -25,6 +25,7 @@ #![feature(inclusive_range)] #![feature(inclusive_range_syntax)] #![feature(iter_rfind)] +#![feature(iter_rfold)] #![feature(nonzero)] #![feature(rand)] #![feature(raw)] From 9e35b797b158d2e437bfee6376f852fd87861286 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 25 Sep 2017 12:26:25 -0700 Subject: [PATCH 39/77] rustc: Default 32 codegen units at O0 This commit changes the default of rustc to use 32 codegen units when compiling in debug mode, typically an opt-level=0 compilation. Since their inception codegen units have matured quite a bit, gaining features such as: * Parallel translation and codegen enabling codegen units to get worked on even more quickly. * Deterministic and reliable partitioning through the same infrastructure as incremental compilation. * Global rate limiting through the `jobserver` crate to avoid overloading the system. The largest benefit of codegen units has forever been faster compilation through parallel processing of modules on the LLVM side of things, using all the cores available on build machines that typically have many available. Some downsides have been fixed through the features above, but the major downside remaining is that using codegen units reduces opportunities for inlining and optimization. This, however, doesn't matter much during debug builds! In this commit the default number of codegen units for debug builds has been raised from 1 to 32. This should enable most `cargo build` compiles that are bottlenecked on translation and/or code generation to immediately see speedups through parallelization on available cores. Work is being done to *always* enable multiple codegen units (and therefore parallel codegen) but it requires #44841 at least to be landed and stabilized, but stay tuned if you're interested in that aspect! --- src/librustc/session/config.rs | 97 +++++++++++++------ src/librustc_trans/back/link.rs | 2 +- src/librustc_trans/back/write.rs | 11 ++- src/librustc_trans/base.rs | 4 +- .../run-make/codegen-options-parsing/Makefile | 30 +++--- src/test/run-make/llvm-phase/test.rs | 1 + 6 files changed, 97 insertions(+), 48 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index d3256357941f3..0390e22234865 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -350,6 +350,9 @@ top_level_options!( // is currently just a hack and will be removed eventually, so please // try to not rely on this too much. actually_rustdoc: bool [TRACKED], + + // Number of object files/codegen units to produce on the backend + codegen_units: usize [UNTRACKED], } ); @@ -512,6 +515,7 @@ pub fn basic_options() -> Options { unstable_features: UnstableFeatures::Disallow, debug_assertions: true, actually_rustdoc: false, + codegen_units: 1, } } @@ -529,11 +533,6 @@ impl Options { (self.debugging_opts.query_dep_graph || self.debugging_opts.incremental_info) } - pub fn single_codegen_unit(&self) -> bool { - self.incremental.is_none() || - self.cg.codegen_units == 1 - } - pub fn file_path_mapping(&self) -> FilePathMapping { FilePathMapping::new( self.debugging_opts.remap_path_prefix_from.iter().zip( @@ -791,7 +790,7 @@ macro_rules! options { fn parse_opt_uint(slot: &mut Option, v: Option<&str>) -> bool { match v { Some(s) => { *slot = s.parse().ok(); slot.is_some() } - None => { *slot = None; true } + None => { *slot = None; false } } } @@ -924,7 +923,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options, "metadata to mangle symbol names with"), extra_filename: String = ("".to_string(), parse_string, [UNTRACKED], "extra data to put in each output filename"), - codegen_units: usize = (1, parse_uint, [UNTRACKED], + codegen_units: Option = (None, parse_opt_uint, [UNTRACKED], "divide crate into N units to optimize in parallel"), remark: Passes = (SomePasses(Vec::new()), parse_passes, [UNTRACKED], "print remarks for these optimization passes (space separated, or \"all\")"), @@ -1521,27 +1520,35 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) } let mut cg = build_codegen_options(matches, error_format); + let mut codegen_units = cg.codegen_units; // Issue #30063: if user requests llvm-related output to one // particular path, disable codegen-units. - if matches.opt_present("o") && cg.codegen_units != 1 { - let incompatible: Vec<_> = output_types.iter() - .map(|ot_path| ot_path.0) - .filter(|ot| { - !ot.is_compatible_with_codegen_units_and_single_output_file() - }).collect(); - if !incompatible.is_empty() { - for ot in &incompatible { - early_warn(error_format, &format!("--emit={} with -o incompatible with \ - -C codegen-units=N for N > 1", - ot.shorthand())); + let incompatible: Vec<_> = output_types.iter() + .map(|ot_path| ot_path.0) + .filter(|ot| { + !ot.is_compatible_with_codegen_units_and_single_output_file() + }) + .map(|ot| ot.shorthand()) + .collect(); + if !incompatible.is_empty() { + match codegen_units { + Some(n) if n > 1 => { + if matches.opt_present("o") { + for ot in &incompatible { + early_warn(error_format, &format!("--emit={} with -o incompatible with \ + -C codegen-units=N for N > 1", + ot)); + } + early_warn(error_format, "resetting to default -C codegen-units=1"); + codegen_units = Some(1); + } } - early_warn(error_format, "resetting to default -C codegen-units=1"); - cg.codegen_units = 1; + _ => codegen_units = Some(1), } } - if cg.codegen_units < 1 { + if codegen_units == Some(0) { early_error(error_format, "Value for codegen units must be a positive nonzero integer"); } @@ -1550,12 +1557,17 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) // case, but it would be confusing to have the validity of // `-Z lto -C codegen-units=2` depend on details of the crate being // compiled, so we complain regardless. - if cg.lto && cg.codegen_units > 1 { - // This case is impossible to handle because LTO expects to be able - // to combine the entire crate and all its dependencies into a - // single compilation unit, but each codegen unit is in a separate - // LLVM context, so they can't easily be combined. - early_error(error_format, "can't perform LTO when using multiple codegen units"); + if cg.lto { + if let Some(n) = codegen_units { + if n > 1 { + // This case is impossible to handle because LTO expects to be able + // to combine the entire crate and all its dependencies into a + // single compilation unit, but each codegen unit is in a separate + // LLVM context, so they can't easily be combined. + early_error(error_format, "can't perform LTO when using multiple codegen units"); + } + } + codegen_units = Some(1); } if cg.lto && debugging_opts.incremental.is_some() { @@ -1720,6 +1732,34 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) let incremental = debugging_opts.incremental.as_ref().map(|m| PathBuf::from(m)); + let codegen_units = codegen_units.unwrap_or_else(|| { + match opt_level { + // If we're compiling at `-O0` then default to 32 codegen units. + // The number here shouldn't matter too too much as debug mode + // builds don't rely on performance at all, meaning that lost + // opportunities for inlining through multiple codegen units is + // a non-issue. + // + // Note that the high number here doesn't mean that we'll be + // spawning a large number of threads in parallel. The backend + // of rustc contains global rate limiting through the + // `jobserver` crate so we'll never overload the system with too + // much work, but rather we'll only be optimizing when we're + // otherwise cooperating with other instances of rustc. + // + // Rather the high number here means that we should be able to + // keep a lot of idle cpus busy. By ensuring that no codegen + // unit takes *too* long to build we'll be guaranteed that all + // cpus will finish pretty closely to one another and we should + // make relatively optimal use of system resources + OptLevel::No => 32, + + // All other optimization levels default use one codegen unit, + // the historical default in Rust for a Long Time. + _ => 1, + } + }); + (Options { crate_types, optimize: opt_level, @@ -1744,6 +1784,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) unstable_features: UnstableFeatures::from_environment(), debug_assertions, actually_rustdoc: false, + codegen_units, }, cfg) } @@ -2447,7 +2488,7 @@ mod tests { opts.cg.extra_filename = String::from("extra-filename"); assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); - opts.cg.codegen_units = 42; + opts.cg.codegen_units = Some(42); assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.cg.remark = super::SomePasses(vec![String::from("pass1"), diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 1630e7759919c..2cf0a32d5afdf 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -509,7 +509,7 @@ fn link_rlib<'a>(sess: &'a Session, // of when we do and don't keep .#module-name#.bc files around. let user_wants_numbered_bitcode = sess.opts.output_types.contains_key(&OutputType::Bitcode) && - sess.opts.cg.codegen_units > 1; + sess.opts.codegen_units > 1; if !sess.opts.cg.save_temps && !user_wants_numbered_bitcode { remove(sess, &bc_filename); } diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index ef6bf2504f312..6b980a37ac778 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -939,10 +939,10 @@ fn produce_final_output_artifacts(sess: &Session, let needs_crate_object = crate_output.outputs.contains_key(&OutputType::Exe); let keep_numbered_bitcode = needs_crate_bitcode || - (user_wants_bitcode && sess.opts.cg.codegen_units > 1); + (user_wants_bitcode && sess.opts.codegen_units > 1); let keep_numbered_objects = needs_crate_object || - (user_wants_objects && sess.opts.cg.codegen_units > 1); + (user_wants_objects && sess.opts.codegen_units > 1); for module in compiled_modules.modules.iter() { let module_name = Some(&module.name[..]); @@ -1520,6 +1520,11 @@ fn start_executing_work(tcx: TyCtxt, total_llvm_time); } + // Regardless of what order these modules completed in, report them to + // the backend in the same order every time to ensure that we're handing + // out deterministic results. + compiled_modules.sort_by(|a, b| a.name.cmp(&b.name)); + let compiled_metadata_module = compiled_metadata_module .expect("Metadata module not compiled?"); @@ -1853,7 +1858,7 @@ impl OngoingCrateTranslation { // FIXME: time_llvm_passes support - does this use a global context or // something? - if sess.opts.cg.codegen_units == 1 && sess.time_llvm_passes() { + if sess.opts.codegen_units == 1 && sess.time_llvm_passes() { unsafe { llvm::LLVMRustPrintPassTimings(); } } diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 2d01d2947d6eb..774acc813438f 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -1162,7 +1162,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>( let strategy = if tcx.sess.opts.debugging_opts.incremental.is_some() { PartitioningStrategy::PerModule } else { - PartitioningStrategy::FixedUnitCount(tcx.sess.opts.cg.codegen_units) + PartitioningStrategy::FixedUnitCount(tcx.sess.opts.codegen_units) }; let codegen_units = time(time_passes, "codegen unit partitioning", || { @@ -1175,7 +1175,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>( .collect::>() }); - assert!(tcx.sess.opts.cg.codegen_units == codegen_units.len() || + assert!(tcx.sess.opts.codegen_units == codegen_units.len() || tcx.sess.opts.debugging_opts.incremental.is_some()); let translation_items: DefIdSet = items.iter().filter_map(|trans_item| { diff --git a/src/test/run-make/codegen-options-parsing/Makefile b/src/test/run-make/codegen-options-parsing/Makefile index dc46a8a04ef8c..755e211a34996 100644 --- a/src/test/run-make/codegen-options-parsing/Makefile +++ b/src/test/run-make/codegen-options-parsing/Makefile @@ -1,26 +1,28 @@ -include ../tools.mk +LOG = $(TMPDIR)/log.txt + all: #Option taking a number - $(RUSTC) -C codegen-units dummy.rs 2>&1 | \ - grep 'codegen option `codegen-units` requires a number' - $(RUSTC) -C codegen-units= dummy.rs 2>&1 | \ - grep 'incorrect value `` for codegen option `codegen-units` - a number was expected' - $(RUSTC) -C codegen-units=foo dummy.rs 2>&1 | \ - grep 'incorrect value `foo` for codegen option `codegen-units` - a number was expected' + $(RUSTC) -C codegen-units dummy.rs 2>&1 | tee $(LOG) + grep 'codegen option `codegen-units` requires a number' $(LOG) + $(RUSTC) -C codegen-units= dummy.rs 2>&1 | tee $(LOG) + grep 'incorrect value `` for codegen option `codegen-units` - a number was expected' $(LOG) + $(RUSTC) -C codegen-units=foo dummy.rs 2>&1 | tee $(LOG) + grep 'incorrect value `foo` for codegen option `codegen-units` - a number was expected' $(LOG) $(RUSTC) -C codegen-units=1 dummy.rs #Option taking a string - $(RUSTC) -C extra-filename dummy.rs 2>&1 | \ - grep 'codegen option `extra-filename` requires a string' + $(RUSTC) -C extra-filename dummy.rs 2>&1 | tee $(LOG) + grep 'codegen option `extra-filename` requires a string' $(LOG) $(RUSTC) -C extra-filename= dummy.rs 2>&1 $(RUSTC) -C extra-filename=foo dummy.rs 2>&1 #Option taking no argument - $(RUSTC) -C lto= dummy.rs 2>&1 | \ - grep 'codegen option `lto` takes no value' - $(RUSTC) -C lto=1 dummy.rs 2>&1 | \ - grep 'codegen option `lto` takes no value' - $(RUSTC) -C lto=foo dummy.rs 2>&1 | \ - grep 'codegen option `lto` takes no value' + $(RUSTC) -C lto= dummy.rs 2>&1 | tee $(LOG) + grep 'codegen option `lto` takes no value' $(LOG) + $(RUSTC) -C lto=1 dummy.rs 2>&1 | tee $(LOG) + grep 'codegen option `lto` takes no value' $(LOG) + $(RUSTC) -C lto=foo dummy.rs 2>&1 | tee $(LOG) + grep 'codegen option `lto` takes no value' $(LOG) $(RUSTC) -C lto dummy.rs # Should not link dead code... diff --git a/src/test/run-make/llvm-phase/test.rs b/src/test/run-make/llvm-phase/test.rs index 7a63871f19e38..2ff4593a801fe 100644 --- a/src/test/run-make/llvm-phase/test.rs +++ b/src/test/run-make/llvm-phase/test.rs @@ -77,6 +77,7 @@ fn main() { .split(' ').map(|s| s.to_string()).collect(); args.push("--out-dir".to_string()); args.push(env::var("TMPDIR").unwrap()); + args.push("-Ccodegen-units=1".to_string()); let (result, _) = rustc_driver::run_compiler( &args, &mut JitCalls, Some(box JitLoader), None); From 3730dfdaf58057466a2c576184c4647840daaeac Mon Sep 17 00:00:00 2001 From: Matthias Devlamynck Date: Tue, 26 Sep 2017 11:43:33 +0200 Subject: [PATCH 40/77] impl Trait in argument position desugaring: Add a flag to hir and ty TypeParameterDef and raise an error when using explicit type parameters when calling a function using impl Trait in argument position. --- src/librustc/hir/lowering.rs | 4 +++ src/librustc/hir/mod.rs | 8 +++++ src/librustc/ich/impls_hir.rs | 7 ++++- src/librustc/ich/impls_ty.rs | 3 +- src/librustc/ty/mod.rs | 2 ++ src/librustc_typeck/check/mod.rs | 31 +++++++++++++++++++ src/librustc_typeck/collect.rs | 3 ++ src/librustc_typeck/diagnostics.rs | 2 ++ src/libsyntax/feature_gate.rs | 6 ++++ src/test/compile-fail/synthetic-param.rs | 38 ++++++++++++++++++++++++ 10 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 src/test/compile-fail/synthetic-param.rs diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 95b8e49d60c6a..769f1cbcb5d0a 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1103,6 +1103,10 @@ impl<'a> LoweringContext<'a> { default: tp.default.as_ref().map(|x| self.lower_ty(x)), span: tp.span, pure_wrt_drop: tp.attrs.iter().any(|attr| attr.check_name("may_dangle")), + synthetic: tp.attrs.iter() + .filter(|attr| attr.check_name("rustc_synthetic")) + .map(|_| hir::SyntheticTyParamKind::ImplTrait) + .nth(0), } } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index bff71155440a3..9bfedd7a381cb 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -351,6 +351,7 @@ pub struct TyParam { pub default: Option>, pub span: Span, pub pure_wrt_drop: bool, + pub synthetic: Option, } /// Represents lifetimes and type parameters attached to a declaration @@ -419,6 +420,13 @@ impl Generics { } } +/// Synthetic Type Parameters are converted to an other form during lowering, this allows +/// to track the original form they had. Usefull for error messages. +#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +pub enum SyntheticTyParamKind { + ImplTrait +} + /// A `where` clause in a definition #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct WhereClause { diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 96d5940caf6a4..776f85cf5da96 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -177,7 +177,8 @@ impl_stable_hash_for!(struct hir::TyParam { bounds, default, span, - pure_wrt_drop + pure_wrt_drop, + synthetic }); impl_stable_hash_for!(struct hir::Generics { @@ -187,6 +188,10 @@ impl_stable_hash_for!(struct hir::Generics { span }); +impl_stable_hash_for!(enum hir::SyntheticTyParamKind { + ImplTrait +}); + impl_stable_hash_for!(struct hir::WhereClause { id, predicates diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 2bbf807807bad..fe060aaf4269e 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -463,7 +463,8 @@ impl_stable_hash_for!(struct ty::TypeParameterDef { index, has_default, object_lifetime_default, - pure_wrt_drop + pure_wrt_drop, + synthetic }); impl<'gcx, T> HashStable> diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 2c1b3e28ffb00..da635ec80fc91 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -675,6 +675,8 @@ pub struct TypeParameterDef { /// on generic parameter `T`, asserts data behind the parameter /// `T` won't be accessed during the parent type's `Drop` impl. pub pure_wrt_drop: bool, + + pub synthetic: Option, } #[derive(Copy, Clone, RustcEncodable, RustcDecodable)] diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6fe49644fe81e..a06f7b7f63b6d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4647,6 +4647,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // a problem. self.check_path_parameter_count(span, &mut type_segment, false); self.check_path_parameter_count(span, &mut fn_segment, false); + self.check_impl_trait(span, &mut fn_segment); let (fn_start, has_self) = match (type_segment, fn_segment) { (_, Some((_, generics))) => { @@ -4871,6 +4872,36 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } + /// Report error if there is an explicit type parameter when using `impl Trait`. + fn check_impl_trait(&self, + span: Span, + segment: &mut Option<(&hir::PathSegment, &ty::Generics)>) { + use hir::SyntheticTyParamKind::*; + + segment.map(|(path_segment, generics)| { + let explicit = !path_segment.infer_types; + let impl_trait = generics.types.iter() + .any(|ty_param| { + match ty_param.synthetic { + Some(ImplTrait) => true, + _ => false, + } + }); + + if explicit && impl_trait { + let mut err = struct_span_err! { + self.tcx.sess, + span, + E0631, + "cannot provide explicit type parameters when `impl Trait` is \ + used in argument position." + }; + + err.emit(); + } + }); + } + fn structurally_resolve_type_or_else(&self, sp: Span, ty: Ty<'tcx>, f: F) -> Ty<'tcx> where F: Fn() -> Ty<'tcx> diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index a36594cb6e557..229a1084b0c1f 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -922,6 +922,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, has_default: false, object_lifetime_default: rl::Set1::Empty, pure_wrt_drop: false, + synthetic: None, }); allow_defaults = true; @@ -993,6 +994,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, object_lifetime_default: object_lifetime_defaults.as_ref().map_or(rl::Set1::Empty, |o| o[i]), pure_wrt_drop: p.pure_wrt_drop, + synthetic: p.synthetic, } }); let mut types: Vec<_> = opt_self.into_iter().chain(types).collect(); @@ -1009,6 +1011,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, has_default: false, object_lifetime_default: rl::Set1::Empty, pure_wrt_drop: false, + synthetic: None, })); }); } diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 6bbe2233ff1fa..4ad1697136a22 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4677,4 +4677,6 @@ register_diagnostics! { E0592, // duplicate definitions with name `{}` // E0613, // Removed (merged with E0609) E0627, // yield statement outside of generator literal + E0631, // cannot provide explicit type parameters when `impl Trait` is used in + // argument position. } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 5c730aaa8d0fa..246300a24a9ab 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -724,6 +724,12 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG is just used for rustc unit tests \ and will never be stable", cfg_fn!(rustc_attrs))), + ("rustc_synthetic", Whitelisted, Gated(Stability::Unstable, + "rustc_attrs", + "this attribute \ + is just used for rustc unit tests \ + and will never be stable", + cfg_fn!(rustc_attrs))), ("rustc_symbol_name", Whitelisted, Gated(Stability::Unstable, "rustc_attrs", "internal rustc attributes will never be stable", diff --git a/src/test/compile-fail/synthetic-param.rs b/src/test/compile-fail/synthetic-param.rs new file mode 100644 index 0000000000000..a9762e383fe4e --- /dev/null +++ b/src/test/compile-fail/synthetic-param.rs @@ -0,0 +1,38 @@ +// Copyright 2015 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. + +#![feature(generic_param_attrs, rustc_attrs)] + +fn func<#[rustc_synthetic] T>(_: T) {} + +struct Foo; + +impl Foo { + pub fn func<#[rustc_synthetic] T>(_: T) {} +} + +struct Bar { + t: S +} + +impl Bar { + pub fn func<#[rustc_synthetic] T>(_: T) {} +} + +fn main() { + func::(42); //~ ERROR cannot provide explicit type parameters + func(42); // Ok + + Foo::func::(42); //~ ERROR cannot provide explicit type parameters + Foo::func(42); // Ok + + Bar::::func::(42); //~ ERROR cannot provide explicit type parameters + Bar::::func(42); // Ok +} From e58f528bb0664c33355ff6b0aa125b8a751fee2a Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Mon, 11 Sep 2017 19:59:57 +0530 Subject: [PATCH 41/77] merge fixes, addressing CR comments --- .../error_reporting/different_lifetimes.rs | 132 +++++++++++------- .../error_reporting/named_anon_conflict.rs | 53 ++++--- src/librustc/infer/error_reporting/util.rs | 11 +- ...e-existing-name-return-type-is-anon.stderr | 26 +--- ...turn-one-existing-name-self-is-anon.stderr | 26 +--- ...th-anon-regions-return-type-is-anon.stderr | 24 +--- .../ex3-both-anon-regions-self-is-anon.stderr | 24 +--- 7 files changed, 138 insertions(+), 158 deletions(-) diff --git a/src/librustc/infer/error_reporting/different_lifetimes.rs b/src/librustc/infer/error_reporting/different_lifetimes.rs index 6c57130a9955f..687b518ef6aff 100644 --- a/src/librustc/infer/error_reporting/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/different_lifetimes.rs @@ -18,6 +18,7 @@ use infer::region_inference::RegionResolutionError; use hir::map as hir_map; use middle::resolve_lifetime as rl; use hir::intravisit::{self, Visitor, NestedVisitorMap}; +use infer::error_reporting::util::AnonymousArgInfo; impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // This method prints the error message for lifetime errors when both the concerned regions @@ -57,6 +58,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let ty_sup = or_false!(self.find_anon_type(sup, &bregion_sup)); let ty_sub = or_false!(self.find_anon_type(sub, &bregion_sub)); + debug!("try_report_anon_anon_conflict: found_arg1={:?} sup={:?} br1={:?}", ty_sub, sup, @@ -66,56 +68,78 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { sub, bregion_sub); - let (main_label, label1, label2) = if let (Some(sup_arg), Some(sub_arg)) = - (self.find_arg_with_region(sup, sup), self.find_arg_with_region(sub, sub)) { + let (ty_sup, ty_fndecl_sup) = ty_sup; + let (ty_sub, ty_fndecl_sub) = ty_sub; - let (anon_arg_sup, is_first_sup, anon_arg_sub, is_first_sub) = - (sup_arg.arg, sup_arg.is_first, sub_arg.arg, sub_arg.is_first); - if self.is_self_anon(is_first_sup, scope_def_id_sup) || - self.is_self_anon(is_first_sub, scope_def_id_sub) { - return false; - } + let AnonymousArgInfo { arg: anon_arg_sup, .. } = + or_false!(self.find_arg_with_region(sup, sup)); + let AnonymousArgInfo { arg: anon_arg_sub, .. } = + or_false!(self.find_arg_with_region(sub, sub)); - if self.is_return_type_anon(scope_def_id_sup, bregion_sup) || - self.is_return_type_anon(scope_def_id_sub, bregion_sub) { - return false; - } + let sup_is_ret_type = + self.is_return_type_anon(scope_def_id_sup, bregion_sup, ty_fndecl_sup); + let sub_is_ret_type = + self.is_return_type_anon(scope_def_id_sub, bregion_sub, ty_fndecl_sub); - if anon_arg_sup == anon_arg_sub { - (format!("this type was declared with multiple lifetimes..."), - format!(" with one lifetime"), - format!(" into the other")) - } else { - let span_label_var1 = if let Some(simple_name) = anon_arg_sup.pat.simple_name() { - format!(" from `{}`", simple_name) - } else { - format!("") - }; + let span_label_var1 = if let Some(simple_name) = anon_arg_sup.pat.simple_name() { + format!(" flows from `{}`", simple_name) + } else { + format!("") + }; + + let span_label_var2 = if let Some(simple_name) = anon_arg_sub.pat.simple_name() { + format!(" into `{}`", simple_name) + } else { + format!("") + }; - let span_label_var2 = if let Some(simple_name) = anon_arg_sub.pat.simple_name() { - format!(" into `{}`", simple_name) - } else { - format!("") - }; - let span_label = - format!("these two types are declared with different lifetimes...",); + let (span_1, span_2, main_label, span_label) = match (sup_is_ret_type, sub_is_ret_type) { + (None, None) => { + let (main_label_1, span_label_1) = if ty_sup == ty_sub { - (span_label, span_label_var1, span_label_var2) + (format!("this type was declared with multiple lifetimes..."), + format!("...but data{} flows{} here", + format!(" with one lifetime"), + format!(" into the other"))) + } else { + (format!("these two types was declared with multiple lifetimes..."), + format!("...but data{} flows{} here", + span_label_var1, + span_label_var2)) + }; + (ty_sup.span, ty_sub.span, main_label_1, span_label_1) + } + (Some(ret_span1), Some(ret_span2)) => { + (ret_span1, + ret_span2, + format!("the return type is declared with different lifetimes..."), + format!("...but data{} flows{} here", + format!(" with one lifetime"), + format!(" into the other"))) + } + + (Some(ret_span), _) => { + (ty_sub.span, + ret_span, + format!("this parameter and the return type are declared + with different lifetimes...",), + format!("...but data{} is returned here", span_label_var1)) + } + (_, Some(ret_span)) => { + (ty_sup.span, + ret_span, + format!("this parameter and the return type are declared + with different lifetimes...",), + format!("...but data{} is returned here", span_label_var1)) } - } else { - debug!("no arg with anon region found"); - debug!("try_report_anon_anon_conflict: is_suitable(sub) = {:?}", - self.is_suitable_region(sub)); - debug!("try_report_anon_anon_conflict: is_suitable(sup) = {:?}", - self.is_suitable_region(sup)); - return false; }; + struct_span_err!(self.tcx.sess, span, E0623, "lifetime mismatch") - .span_label(ty_sup.span, main_label) - .span_label(ty_sub.span, format!("")) - .span_label(span, format!("...but data{} flows{} here", label1, label2)) + .span_label(span_1, main_label) + .span_label(span_2, format!("")) + .span_label(span, span_label) .emit(); return true; } @@ -135,28 +159,32 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { /// ``` /// The function returns the nested type corresponding to the anonymous region /// for e.g. `&u8` and Vec<`&u8`. - pub fn find_anon_type(&self, region: Region<'tcx>, br: &ty::BoundRegion) -> Option<&hir::Ty> { + pub fn find_anon_type(&self, + region: Region<'tcx>, + br: &ty::BoundRegion) + -> Option<(&hir::Ty, &hir::FnDecl)> { if let Some(anon_reg) = self.is_suitable_region(region) { let def_id = anon_reg.def_id; if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { - let inputs: &[_] = match self.tcx.hir.get(node_id) { + let fndecl = match self.tcx.hir.get(node_id) { hir_map::NodeItem(&hir::Item { node: hir::ItemFn(ref fndecl, ..), .. }) => { - &fndecl.inputs + &fndecl } hir_map::NodeTraitItem(&hir::TraitItem { - node: hir::TraitItemKind::Method(ref fndecl, ..), .. - }) => &fndecl.decl.inputs, + node: hir::TraitItemKind::Method(ref m, ..), .. + }) | hir_map::NodeImplItem(&hir::ImplItem { - node: hir::ImplItemKind::Method(ref fndecl, ..), .. - }) => &fndecl.decl.inputs, - - _ => &[], + node: hir::ImplItemKind::Method(ref m, ..), .. + }) => &m.decl, + _ => return None, }; - return inputs + return fndecl + .inputs .iter() - .filter_map(|arg| self.find_component_for_bound_region(&**arg, br)) - .next(); + .filter_map(|arg| self.find_component_for_bound_region(arg, br)) + .next() + .map(|ty| (ty, &**fndecl)); } } None diff --git a/src/librustc/infer/error_reporting/named_anon_conflict.rs b/src/librustc/infer/error_reporting/named_anon_conflict.rs index a3bbdab497a9b..7027c868e6efe 100644 --- a/src/librustc/infer/error_reporting/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/named_anon_conflict.rs @@ -35,15 +35,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // only introduced anonymous regions in parameters) as well as a // version new_ty of its type where the anonymous region is replaced // with the named one.//scope_def_id - let (named, anon_arg_info, region_info) = + let (named, anon, anon_arg_info, region_info) = if self.is_named_region(sub) && self.is_suitable_region(sup).is_some() && self.find_arg_with_region(sup, sub).is_some() { (sub, + sup, self.find_arg_with_region(sup, sub).unwrap(), self.is_suitable_region(sup).unwrap()) } else if self.is_named_region(sup) && self.is_suitable_region(sub).is_some() && self.find_arg_with_region(sub, sup).is_some() { (sup, + sub, self.find_arg_with_region(sub, sup).unwrap(), self.is_suitable_region(sub).unwrap()) } else { @@ -76,33 +78,30 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { return false; } - if self.is_return_type_anon(scope_def_id, br) { - debug!("try_report_named_anon_conflict: is_return_type_anon({:?}, {:?}) = true", - scope_def_id, - br); - return false; - } else if self.is_self_anon(is_first, scope_def_id) { - debug!("try_report_named_anon_conflict: is_self_anon({:?}, {:?}) = true", - is_first, - scope_def_id); - return false; + if let Some(anon_ty) = self.find_anon_type(anon, &br) { + let (_, fndecl) = anon_ty; + if self.is_return_type_anon(scope_def_id, br, fndecl).is_some() || + self.is_self_anon(is_first, scope_def_id) { + return false; + } + } + + let (error_var, span_label_var) = if let Some(simple_name) = arg.pat.simple_name() { + (format!("the type of `{}`", simple_name), format!("the type of `{}`", simple_name)) } else { - let (error_var, span_label_var) = if let Some(simple_name) = arg.pat.simple_name() { - (format!("the type of `{}`", simple_name), format!("the type of `{}`", simple_name)) - } else { - ("parameter type".to_owned(), "type".to_owned()) - }; + ("parameter type".to_owned(), "type".to_owned()) + }; + + struct_span_err!(self.tcx.sess, + span, + E0621, + "explicit lifetime required in {}", + error_var) + .span_label(arg.pat.span, + format!("consider changing {} to `{}`", span_label_var, new_ty)) + .span_label(span, format!("lifetime `{}` required", named)) + .emit(); + return true; - struct_span_err!(self.tcx.sess, - span, - E0621, - "explicit lifetime required in {}", - error_var) - .span_label(arg.pat.span, - format!("consider changing {} to `{}`", span_label_var, new_ty)) - .span_label(span, format!("lifetime `{}` required", named)) - .emit(); - return true; - } } } diff --git a/src/librustc/infer/error_reporting/util.rs b/src/librustc/infer/error_reporting/util.rs index 94faec464b244..47db3f1b7926a 100644 --- a/src/librustc/infer/error_reporting/util.rs +++ b/src/librustc/infer/error_reporting/util.rs @@ -15,6 +15,7 @@ use infer::InferCtxt; use ty::{self, Region, Ty}; use hir::def_id::DefId; use hir::map as hir_map; +use syntax_pos::Span; macro_rules! or_false { ($v:expr) => { @@ -163,7 +164,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // Here, we check for the case where the anonymous region // is in the return type. // FIXME(#42703) - Need to handle certain cases here. - pub fn is_return_type_anon(&self, scope_def_id: DefId, br: ty::BoundRegion) -> bool { + pub fn is_return_type_anon(&self, + scope_def_id: DefId, + br: ty::BoundRegion, + decl: &hir::FnDecl) + -> Option { let ret_ty = self.tcx.type_of(scope_def_id); match ret_ty.sty { ty::TyFnDef(_, _) => { @@ -171,12 +176,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let late_bound_regions = self.tcx .collect_referenced_late_bound_regions(&sig.output()); if late_bound_regions.iter().any(|r| *r == br) { - return true; + return Some(decl.output.span()); } } _ => {} } - false + None } // Here we check for the case where anonymous region // corresponds to self and if yes, we display E0312. diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index e3fd0192053b9..4a1673a531d34 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -1,27 +1,11 @@ -error[E0312]: lifetime of reference outlives lifetime of borrowed content... +error[E0621]: explicit lifetime required in the type of `self` --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:18:5 | +16 | fn foo<'a>(&self, x: &'a i32) -> &i32 { + | ----- consider changing the type of `self` to `&'a Foo` +17 | 18 | x - | ^ - | -note: ...the reference is valid for the anonymous lifetime #1 defined on the method body at 16:3... - --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:16:3 - | -16 | / fn foo<'a>(&self, x: &'a i32) -> &i32 { -17 | | -18 | | x -19 | | -20 | | } - | |___^ -note: ...but the borrowed content is only valid for the lifetime 'a as defined on the method body at 16:3 - --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:16:3 - | -16 | / fn foo<'a>(&self, x: &'a i32) -> &i32 { -17 | | -18 | | x -19 | | -20 | | } - | |___^ + | ^ lifetime `'a` required error: aborting due to previous error diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr index 8551f015db527..973c5ed72f875 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr @@ -1,27 +1,11 @@ -error[E0312]: lifetime of reference outlives lifetime of borrowed content... +error[E0621]: explicit lifetime required in the type of `self` --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:18:30 | +16 | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { + | ----- consider changing the type of `self` to `&'a Foo` +17 | 18 | if true { x } else { self } - | ^^^^ - | -note: ...the reference is valid for the lifetime 'a as defined on the method body at 16:5... - --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:16:5 - | -16 | / fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { -17 | | -18 | | if true { x } else { self } -19 | | -20 | | } - | |_____^ -note: ...but the borrowed content is only valid for the anonymous lifetime #1 defined on the method body at 16:5 - --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:16:5 - | -16 | / fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { -17 | | -18 | | if true { x } else { self } -19 | | -20 | | } - | |_____^ + | ^^^^ lifetime `'a` required error: aborting due to previous error diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr index 890f9b311e7d2..c6b1280ca95aa 100644 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr @@ -1,23 +1,13 @@ -error[E0312]: lifetime of reference outlives lifetime of borrowed content... +error[E0621]: explicit lifetime required in the type of `self` --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:17:5 | +16 | fn foo<'a>(&self, x: &i32) -> &i32 { + | ---- ---- + | | + | this parameter and the return type are + declared with different lifetimes... 17 | x - | ^ - | -note: ...the reference is valid for the anonymous lifetime #1 defined on the method body at 16:3... - --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:16:3 - | -16 | / fn foo<'a>(&self, x: &i32) -> &i32 { -17 | | x -18 | | } - | |___^ -note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined on the method body at 16:3 - --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:16:3 - | -16 | / fn foo<'a>(&self, x: &i32) -> &i32 { -17 | | x -18 | | } - | |___^ + | ^ ...but data from `x` is returned here error: aborting due to previous error diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr index 43f00c32c6285..9b15de1b1738f 100644 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr @@ -1,23 +1,13 @@ -error[E0312]: lifetime of reference outlives lifetime of borrowed content... +error[E0623]: lifetime mismatch --> $DIR/ex3-both-anon-regions-self-is-anon.rs:17:19 | +16 | fn foo<'a>(&self, x: &Foo) -> &Foo { + | ---- ---- + | | + | this parameter and the return type are + declared with different lifetimes... 17 | if true { x } else { self } - | ^ - | -note: ...the reference is valid for the anonymous lifetime #1 defined on the method body at 16:5... - --> $DIR/ex3-both-anon-regions-self-is-anon.rs:16:5 - | -16 | / fn foo<'a>(&self, x: &Foo) -> &Foo { -17 | | if true { x } else { self } -18 | | } - | |_____^ -note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined on the method body at 16:5 - --> $DIR/ex3-both-anon-regions-self-is-anon.rs:16:5 - | -16 | / fn foo<'a>(&self, x: &Foo) -> &Foo { -17 | | if true { x } else { self } -18 | | } - | |_____^ + | ^ ...but data from `x` is returned here error: aborting due to previous error From aa6f0c80507230d864f7af5fe3c4085e28cabfe9 Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Mon, 11 Sep 2017 20:27:26 +0530 Subject: [PATCH 42/77] modify message for return time having multiple lifetimes --- .../error_reporting/different_lifetimes.rs | 12 ++------ ...ne-existing-name-if-else-using-impl.stderr | 29 +++++-------------- ...e-existing-name-return-type-is-anon.stderr | 9 ++++-- ...turn-one-existing-name-self-is-anon.stderr | 9 ++++-- ...th-anon-regions-return-type-is-anon.stderr | 6 ++-- .../ex3-both-anon-regions-self-is-anon.stderr | 4 +-- 6 files changed, 27 insertions(+), 42 deletions(-) diff --git a/src/librustc/infer/error_reporting/different_lifetimes.rs b/src/librustc/infer/error_reporting/different_lifetimes.rs index 687b518ef6aff..e9866545f976a 100644 --- a/src/librustc/infer/error_reporting/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/different_lifetimes.rs @@ -82,7 +82,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.is_return_type_anon(scope_def_id_sub, bregion_sub, ty_fndecl_sub); let span_label_var1 = if let Some(simple_name) = anon_arg_sup.pat.simple_name() { - format!(" flows from `{}`", simple_name) + format!(" from `{}`", simple_name) } else { format!("") }; @@ -103,21 +103,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { format!(" with one lifetime"), format!(" into the other"))) } else { - (format!("these two types was declared with multiple lifetimes..."), + (format!("these two types was declared with different lifetimes..."), format!("...but data{} flows{} here", span_label_var1, span_label_var2)) }; (ty_sup.span, ty_sub.span, main_label_1, span_label_1) } - (Some(ret_span1), Some(ret_span2)) => { - (ret_span1, - ret_span2, - format!("the return type is declared with different lifetimes..."), - format!("...but data{} flows{} here", - format!(" with one lifetime"), - format!(" into the other"))) - } (Some(ret_span), _) => { (ty_sub.span, diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr index 9e4f6c421790f..f383a4dcf673e 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr @@ -1,27 +1,14 @@ -error[E0312]: lifetime of reference outlives lifetime of borrowed content... +error[E0623]: lifetime mismatch --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:21:20 | +19 | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { + | ---- ------- + | | + | this parameter and the return type are declared + with different lifetimes... +20 | 21 | if x > y { x } else { y } - | ^ - | -note: ...the reference is valid for the lifetime 'a as defined on the method body at 19:5... - --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:19:5 - | -19 | / fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { -20 | | -21 | | if x > y { x } else { y } -22 | | -23 | | } - | |_____^ -note: ...but the borrowed content is only valid for the anonymous lifetime #1 defined on the method body at 19:5 - --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:19:5 - | -19 | / fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { -20 | | -21 | | if x > y { x } else { y } -22 | | -23 | | } - | |_____^ + | ^ ...but data flows `x` is returned here error: aborting due to previous error diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index 4a1673a531d34..27a674e5bb7e8 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -1,11 +1,14 @@ -error[E0621]: explicit lifetime required in the type of `self` +error[E0623]: lifetime mismatch --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:18:5 | 16 | fn foo<'a>(&self, x: &'a i32) -> &i32 { - | ----- consider changing the type of `self` to `&'a Foo` + | ------- ---- + | | + | this parameter and the return type are declared + with different lifetimes... 17 | 18 | x - | ^ lifetime `'a` required + | ^ ...but data flows from `x` is returned here error: aborting due to previous error diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr index 973c5ed72f875..8f957d1b009d0 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr @@ -1,11 +1,14 @@ -error[E0621]: explicit lifetime required in the type of `self` +error[E0623]: lifetime mismatch --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:18:30 | 16 | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { - | ----- consider changing the type of `self` to `&'a Foo` + | ----- ------- + | | + | this parameter and the return type are declared + with different lifetimes... 17 | 18 | if true { x } else { self } - | ^^^^ lifetime `'a` required + | ^^^^ ...but data flows from `self` is returned here error: aborting due to previous error diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr index c6b1280ca95aa..1ea2a4ff8ad4d 100644 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr @@ -1,11 +1,11 @@ -error[E0621]: explicit lifetime required in the type of `self` +error[E0623]: lifetime mismatch --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:17:5 | 16 | fn foo<'a>(&self, x: &i32) -> &i32 { | ---- ---- | | - | this parameter and the return type are - declared with different lifetimes... + | this parameter and the return type are declared + with different lifetimes... 17 | x | ^ ...but data from `x` is returned here diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr index 9b15de1b1738f..316b76c64607b 100644 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr @@ -4,8 +4,8 @@ error[E0623]: lifetime mismatch 16 | fn foo<'a>(&self, x: &Foo) -> &Foo { | ---- ---- | | - | this parameter and the return type are - declared with different lifetimes... + | this parameter and the return type are declared + with different lifetimes... 17 | if true { x } else { self } | ^ ...but data from `x` is returned here From bbf82be0766ead2a5e989a9c5bbb507841ebaef4 Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Tue, 12 Sep 2017 00:16:54 +0530 Subject: [PATCH 43/77] tidy fix --- src/librustc/infer/error_reporting/different_lifetimes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/infer/error_reporting/different_lifetimes.rs b/src/librustc/infer/error_reporting/different_lifetimes.rs index e9866545f976a..aca6db1f9a002 100644 --- a/src/librustc/infer/error_reporting/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/different_lifetimes.rs @@ -110,7 +110,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { }; (ty_sup.span, ty_sub.span, main_label_1, span_label_1) } - + (Some(ret_span), _) => { (ty_sub.span, ret_span, From d7bb575b063d10d3dcc4de5facb7453c419d3086 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 12 Sep 2017 10:53:00 -0400 Subject: [PATCH 44/77] use present tense consistently and update references --- src/librustc/infer/error_reporting/different_lifetimes.rs | 4 ++-- .../ex1-return-one-existing-name-if-else-using-impl.stderr | 2 +- .../ex1-return-one-existing-name-return-type-is-anon.stderr | 2 +- .../ex1-return-one-existing-name-self-is-anon.stderr | 2 +- .../ex3-both-anon-regions-both-are-structs-3.stderr | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc/infer/error_reporting/different_lifetimes.rs b/src/librustc/infer/error_reporting/different_lifetimes.rs index aca6db1f9a002..5ae5568ff7114 100644 --- a/src/librustc/infer/error_reporting/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/different_lifetimes.rs @@ -98,12 +98,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { (None, None) => { let (main_label_1, span_label_1) = if ty_sup == ty_sub { - (format!("this type was declared with multiple lifetimes..."), + (format!("this type is declared with multiple lifetimes..."), format!("...but data{} flows{} here", format!(" with one lifetime"), format!(" into the other"))) } else { - (format!("these two types was declared with different lifetimes..."), + (format!("these two types are declared with different lifetimes..."), format!("...but data{} flows{} here", span_label_var1, span_label_var2)) diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr index f383a4dcf673e..311433b828c3e 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr @@ -8,7 +8,7 @@ error[E0623]: lifetime mismatch with different lifetimes... 20 | 21 | if x > y { x } else { y } - | ^ ...but data flows `x` is returned here + | ^ ...but data from `x` is returned here error: aborting due to previous error diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index 27a674e5bb7e8..a187ed3160b2e 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -8,7 +8,7 @@ error[E0623]: lifetime mismatch with different lifetimes... 17 | 18 | x - | ^ ...but data flows from `x` is returned here + | ^ ...but data from `x` is returned here error: aborting due to previous error diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr index 8f957d1b009d0..67574f422a322 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr @@ -8,7 +8,7 @@ error[E0623]: lifetime mismatch with different lifetimes... 17 | 18 | if true { x } else { self } - | ^^^^ ...but data flows from `self` is returned here + | ^^^^ ...but data from `self` is returned here error: aborting due to previous error diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr index 1b5ac7c7b57ee..73460277de44c 100644 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr @@ -4,7 +4,7 @@ error[E0623]: lifetime mismatch 15 | fn foo(mut x: Ref) { | --- | | - | this type was declared with multiple lifetimes... + | this type is declared with multiple lifetimes... 16 | x.a = x.b; | ^^^ ...but data with one lifetime flows into the other here From 9e4649ebf80679090786074c020d3d2e2c0e8a84 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 12 Sep 2017 17:21:53 -0400 Subject: [PATCH 45/77] remove random newlines from error messages, fix compile-fail test That kind of formatting seems like the job of other code. --- src/librustc/infer/error_reporting/different_lifetimes.rs | 8 ++++---- src/test/compile-fail/object-lifetime-default-mybox.rs | 2 +- ...ex1-return-one-existing-name-if-else-using-impl.stderr | 3 +-- ...x1-return-one-existing-name-return-type-is-anon.stderr | 3 +-- .../ex1-return-one-existing-name-self-is-anon.stderr | 3 +-- .../ex3-both-anon-regions-return-type-is-anon.stderr | 3 +-- .../ex3-both-anon-regions-self-is-anon.stderr | 3 +-- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/librustc/infer/error_reporting/different_lifetimes.rs b/src/librustc/infer/error_reporting/different_lifetimes.rs index 5ae5568ff7114..ee30db2625519 100644 --- a/src/librustc/infer/error_reporting/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/different_lifetimes.rs @@ -114,15 +114,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { (Some(ret_span), _) => { (ty_sub.span, ret_span, - format!("this parameter and the return type are declared - with different lifetimes...",), + format!("this parameter and the return type are declared \ + with different lifetimes...",), format!("...but data{} is returned here", span_label_var1)) } (_, Some(ret_span)) => { (ty_sup.span, ret_span, - format!("this parameter and the return type are declared - with different lifetimes...",), + format!("this parameter and the return type are declared \ + with different lifetimes...",), format!("...but data{} is returned here", span_label_var1)) } }; diff --git a/src/test/compile-fail/object-lifetime-default-mybox.rs b/src/test/compile-fail/object-lifetime-default-mybox.rs index 014b0c1e80e71..54657e76e9702 100644 --- a/src/test/compile-fail/object-lifetime-default-mybox.rs +++ b/src/test/compile-fail/object-lifetime-default-mybox.rs @@ -34,7 +34,7 @@ fn load1<'a,'b>(a: &'a MyBox, b: &'b MyBox) -> &'b MyBox { - a //~ ERROR E0312 + a //~ ERROR lifetime mismatch } fn load2<'a>(ss: &MyBox) -> MyBox { diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr index 311433b828c3e..cb9a1edf1ddf9 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr @@ -4,8 +4,7 @@ error[E0623]: lifetime mismatch 19 | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { | ---- ------- | | - | this parameter and the return type are declared - with different lifetimes... + | this parameter and the return type are declared with different lifetimes... 20 | 21 | if x > y { x } else { y } | ^ ...but data from `x` is returned here diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index a187ed3160b2e..8af6acc62c436 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -4,8 +4,7 @@ error[E0623]: lifetime mismatch 16 | fn foo<'a>(&self, x: &'a i32) -> &i32 { | ------- ---- | | - | this parameter and the return type are declared - with different lifetimes... + | this parameter and the return type are declared with different lifetimes... 17 | 18 | x | ^ ...but data from `x` is returned here diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr index 67574f422a322..c09de0c33af7a 100644 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr @@ -4,8 +4,7 @@ error[E0623]: lifetime mismatch 16 | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { | ----- ------- | | - | this parameter and the return type are declared - with different lifetimes... + | this parameter and the return type are declared with different lifetimes... 17 | 18 | if true { x } else { self } | ^^^^ ...but data from `self` is returned here diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr index 1ea2a4ff8ad4d..1409b2161330b 100644 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr @@ -4,8 +4,7 @@ error[E0623]: lifetime mismatch 16 | fn foo<'a>(&self, x: &i32) -> &i32 { | ---- ---- | | - | this parameter and the return type are declared - with different lifetimes... + | this parameter and the return type are declared with different lifetimes... 17 | x | ^ ...but data from `x` is returned here diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr index 316b76c64607b..cae45023e26b2 100644 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr @@ -4,8 +4,7 @@ error[E0623]: lifetime mismatch 16 | fn foo<'a>(&self, x: &Foo) -> &Foo { | ---- ---- | | - | this parameter and the return type are declared - with different lifetimes... + | this parameter and the return type are declared with different lifetimes... 17 | if true { x } else { self } | ^ ...but data from `x` is returned here From 4bbb58d429a56652acfd186295d05de7d84ee74e Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Sun, 24 Sep 2017 03:24:49 +0530 Subject: [PATCH 46/77] remove error code description --- src/librustc/diagnostics.rs | 69 +------------------------------------ 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 76fba1583f3bc..26f56ffacae7f 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -1351,74 +1351,6 @@ struct Foo { ``` "##, -E0312: r##" -A lifetime of reference outlives lifetime of borrowed content. - -Erroneous code example: - -```compile_fail,E0312 -fn make_child<'tree, 'human>( - x: &'human i32, - y: &'tree i32 -) -> &'human i32 { - if x > y - { x } - else - { y } - // error: lifetime of reference outlives lifetime of borrowed content -} -``` - -The function declares that it returns a reference with the `'human` -lifetime, but it may return data with the `'tree` lifetime. As neither -lifetime is declared longer than the other, this results in an -error. Sometimes, this error is because the function *body* is -incorrect -- that is, maybe you did not *mean* to return data from -`y`. In that case, you should fix the function body. - -Often, however, the body is correct. In that case, the function -signature needs to be altered to match the body, so that the caller -understands that data from either `x` or `y` may be returned. The -simplest way to do this is to give both function parameters the *same* -named lifetime: - -``` -fn make_child<'human>( - x: &'human i32, - y: &'human i32 -) -> &'human i32 { - if x > y - { x } - else - { y } // ok! -} -``` - -However, in some cases, you may prefer to explicitly declare that one lifetime -outlives another using a `where` clause: - -``` -fn make_child<'tree, 'human>( - x: &'human i32, - y: &'tree i32 -) -> &'human i32 -where - 'tree: 'human -{ - if x > y - { x } - else - { y } // ok! -} -``` - -Here, the where clause `'tree: 'human` can be read as "the lifetime -'tree outlives the lifetime 'human" -- meaning, references with the -`'tree` lifetime live *at least as long as* references with the -`'human` lifetime. Therefore, it is safe to return data with lifetime -`'tree` when data with the lifetime `'human` is needed. -"##, - E0317: r##" This error occurs when an `if` expression without an `else` block is used in a context where a type other than `()` is expected, for example a `let` @@ -2028,6 +1960,7 @@ register_diagnostics! { // E0304, // expected signed integer constant // E0305, // expected constant E0311, // thing may not live long enough + E0312, // lifetime of reference outlives lifetime of borrowed content E0313, // lifetime of borrowed pointer outlives lifetime of captured variable E0314, // closure outlives stack frame E0315, // cannot invoke closure outside of its lifetime From 5c59bbadb3bebdbeb85556e4974f6b2e640d22de Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Sun, 24 Sep 2017 19:46:29 +0530 Subject: [PATCH 47/77] minor fixes --- src/librustc/infer/error_reporting/named_anon_conflict.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc/infer/error_reporting/named_anon_conflict.rs b/src/librustc/infer/error_reporting/named_anon_conflict.rs index 7027c868e6efe..80fb4ce8e0392 100644 --- a/src/librustc/infer/error_reporting/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/named_anon_conflict.rs @@ -78,8 +78,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { return false; } - if let Some(anon_ty) = self.find_anon_type(anon, &br) { - let (_, fndecl) = anon_ty; + if let Some((_, fndecl)) = self.find_anon_type(anon, &br) { if self.is_return_type_anon(scope_def_id, br, fndecl).is_some() || self.is_self_anon(is_first, scope_def_id) { return false; From 73543d53cd01899df38ce71b883ed820c5822fba Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 26 Sep 2017 11:56:44 -0400 Subject: [PATCH 48/77] fix test reference --- .../ex3-both-anon-regions-both-are-structs-4.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr index 689a1ac292b33..fb524ae62c57a 100644 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr +++ b/src/test/ui/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr @@ -4,7 +4,7 @@ error[E0623]: lifetime mismatch 15 | fn foo(mut x: Ref) { | --- | | - | this type was declared with multiple lifetimes... + | this type is declared with multiple lifetimes... 16 | x.a = x.b; | ^^^ ...but data with one lifetime flows into the other here From 34d36c0168e1604adfe1a512fb9c7817c38d507e Mon Sep 17 00:00:00 2001 From: Basile Desloges Date: Sun, 24 Sep 2017 15:25:49 +0200 Subject: [PATCH 49/77] mir-borrowck: Add borrow data parameter to `report_illegal_mutation_of_borrowed()` --- src/librustc_mir/borrow_check.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/borrow_check.rs b/src/librustc_mir/borrow_check.rs index 9e261d6024891..f324e20b26df3 100644 --- a/src/librustc_mir/borrow_check.rs +++ b/src/librustc_mir/borrow_check.rs @@ -412,7 +412,7 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> WriteKind::StorageDead | WriteKind::Mutate => this.report_illegal_mutation_of_borrowed( - context, lvalue_span), + context, lvalue_span, borrow), WriteKind::Move => this.report_move_out_while_borrowed( context, lvalue_span, borrow), @@ -975,7 +975,10 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> err.emit(); } - fn report_illegal_mutation_of_borrowed(&mut self, _: Context, (lvalue, span): (&Lvalue, Span)) { + fn report_illegal_mutation_of_borrowed(&mut self, + _: Context, + (lvalue, span): (&Lvalue, Span), + loan: &BorrowData) { let mut err = self.tcx.cannot_assign_to_borrowed( span, &self.describe_lvalue(lvalue), Origin::Mir); // FIXME: add span labels for borrow and assignment points From e28c73d71fd9a31de37daf45c086e2a8b05ec05c Mon Sep 17 00:00:00 2001 From: Basile Desloges Date: Sun, 24 Sep 2017 15:37:41 +0200 Subject: [PATCH 50/77] mir-borrowck: Add span labels to `report_illegal_mutation_of_borrowed()` --- src/librustc_mir/borrow_check.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check.rs b/src/librustc_mir/borrow_check.rs index f324e20b26df3..82e125a0dd2f3 100644 --- a/src/librustc_mir/borrow_check.rs +++ b/src/librustc_mir/borrow_check.rs @@ -979,9 +979,15 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> _: Context, (lvalue, span): (&Lvalue, Span), loan: &BorrowData) { + let describe_lvalue = self.describe_lvalue(lvalue); + let borrow_span = self.retrieve_borrow_span(loan); + let mut err = self.tcx.cannot_assign_to_borrowed( span, &self.describe_lvalue(lvalue), Origin::Mir); - // FIXME: add span labels for borrow and assignment points + + err.span_label(borrow_span, format!("borrow of `{}` occurs here", describe_lvalue)); + err.span_label(span, format!("assignment to borrowed `{}` occurs here", describe_lvalue)); + err.emit(); } From 838105f09b407aa6e5239ac1aa68e53846b5b712 Mon Sep 17 00:00:00 2001 From: Matthias Devlamynck Date: Tue, 26 Sep 2017 20:51:22 +0200 Subject: [PATCH 51/77] Use a different error code to avoid conflicts --- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/diagnostics.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index a06f7b7f63b6d..a0099a48c896b 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4892,7 +4892,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut err = struct_span_err! { self.tcx.sess, span, - E0631, + E0632, "cannot provide explicit type parameters when `impl Trait` is \ used in argument position." }; diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 4ad1697136a22..8df973555744b 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4677,6 +4677,6 @@ register_diagnostics! { E0592, // duplicate definitions with name `{}` // E0613, // Removed (merged with E0609) E0627, // yield statement outside of generator literal - E0631, // cannot provide explicit type parameters when `impl Trait` is used in + E0632, // cannot provide explicit type parameters when `impl Trait` is used in // argument position. } From 5102309b1ff63660309dead2e39ff9a9b554799a Mon Sep 17 00:00:00 2001 From: Badel2 <2badel2@gmail.com> Date: Tue, 26 Sep 2017 20:35:27 +0200 Subject: [PATCH 52/77] bump rustfmt --- src/Cargo.lock | 4 ++-- src/tools/rustfmt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 3a9d9ad9c5456..b33719e91141e 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1356,7 +1356,7 @@ dependencies = [ "rls-rustc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfmt-nightly 0.2.5", + "rustfmt-nightly 0.2.7", "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1831,7 +1831,7 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "0.2.5" +version = "0.2.7" dependencies = [ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/tools/rustfmt b/src/tools/rustfmt index a1fd68da464fc..22eb5241c0ee5 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit a1fd68da464fc51585f351c81fc2b867211c197e +Subproject commit 22eb5241c0ee5bb7eaf95e270a2b1500e82bf767 From b683538ef233bf67fec1b8fc48778b13047e536c Mon Sep 17 00:00:00 2001 From: Basile Desloges Date: Tue, 26 Sep 2017 21:56:37 +0200 Subject: [PATCH 53/77] mir-borrowck: Edit compile-fail tests with E0506 error to also test on MIR borrowck --- src/test/compile-fail/E0506.rs | 7 ++- .../borrowck/borrowck-assign-comp.rs | 15 ++++-- .../borrowck/borrowck-closures-mut-and-imm.rs | 36 ++++++++++--- ...k-imm-ref-to-mut-rec-field-issue-3162-c.rs | 7 ++- .../borrowck/borrowck-lend-flow-match.rs | 7 ++- ...k-overloaded-index-and-overloaded-deref.rs | 7 ++- .../borrowck/borrowck-pat-reassign-binding.rs | 7 ++- .../borrowck/borrowck-union-borrow.rs | 50 ++++++++++++++----- .../borrowck-vec-pattern-move-tail.rs | 7 ++- .../coerce-overloaded-autoderef.rs | 19 +++++-- .../compile-fail/hrtb-identity-fn-borrows.rs | 7 ++- .../mut-pattern-internal-mutability.rs | 11 +++- .../regions-pattern-typing-issue-19997.rs | 7 ++- 13 files changed, 150 insertions(+), 37 deletions(-) diff --git a/src/test/compile-fail/E0506.rs b/src/test/compile-fail/E0506.rs index ddaffd4a2736d..b2cf66849c759 100644 --- a/src/test/compile-fail/E0506.rs +++ b/src/test/compile-fail/E0506.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + struct FancyNum { num: u8, } @@ -15,7 +18,9 @@ struct FancyNum { fn main() { let mut fancy_num = FancyNum { num: 5 }; let fancy_ref = &fancy_num; - fancy_num = FancyNum { num: 6 }; //~ ERROR E0506 + fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 + //[mir]~^ ERROR (Mir) [E0506] + //[mir]~| ERROR (Ast) [E0506] println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); } diff --git a/src/test/compile-fail/borrowck/borrowck-assign-comp.rs b/src/test/compile-fail/borrowck/borrowck-assign-comp.rs index 802b83119b7c3..e63de3a3bed79 100644 --- a/src/test/compile-fail/borrowck/borrowck-assign-comp.rs +++ b/src/test/compile-fail/borrowck/borrowck-assign-comp.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + struct point { x: isize, y: isize } fn a() { @@ -17,7 +20,9 @@ fn a() { // This assignment is illegal because the field x is not // inherently mutable; since `p` was made immutable, `p.x` is now // immutable. Otherwise the type of &_q.x (&isize) would be wrong. - p.x = 5; //~ ERROR cannot assign to `p.x` + p.x = 5; //[ast]~ ERROR cannot assign to `p.x` + //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `p.0` because it is borrowed (Mir) q.x; } @@ -27,7 +32,9 @@ fn c() { let mut p = point {x: 3, y: 4}; let q = &p.y; - p = point {x: 5, y: 7};//~ ERROR cannot assign to `p` + p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` + //[mir]~^ ERROR cannot assign to `p` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `p` because it is borrowed (Mir) p.x; // silence warning *q; // stretch loan } @@ -38,7 +45,9 @@ fn d() { let mut p = point {x: 3, y: 4}; let q = &p.y; - p.y = 5; //~ ERROR cannot assign to `p.y` + p.y = 5; //[ast]~ ERROR cannot assign to `p.y` + //[mir]~^ ERROR cannot assign to `p.y` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `p.1` because it is borrowed (Mir) *q; } diff --git a/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs b/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs index aaa0766121543..6c003ec2d48b3 100644 --- a/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs +++ b/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs @@ -11,6 +11,10 @@ // Tests that two closures cannot simultaneously have mutable // and immutable access to the variable. Issue #6801. +// ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + #![feature(box_syntax)] fn get(x: &isize) -> isize { @@ -24,37 +28,49 @@ fn set(x: &mut isize) { fn a() { let mut x = 3; let c1 = || x = 4; - let c2 = || x * 5; //~ ERROR cannot borrow `x` + let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast) + //[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir) } fn b() { let mut x = 3; let c1 = || set(&mut x); - let c2 = || get(&x); //~ ERROR cannot borrow `x` + let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` + //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast) + //[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir) } fn c() { let mut x = 3; let c1 = || set(&mut x); - let c2 = || x * 5; //~ ERROR cannot borrow `x` + let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast) + //[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir) } fn d() { let mut x = 3; let c2 = || x * 5; - x = 5; //~ ERROR cannot assign + x = 5; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir) } fn e() { let mut x = 3; let c1 = || get(&x); - x = 5; //~ ERROR cannot assign + x = 5; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir) } fn f() { let mut x: Box<_> = box 3; let c1 = || get(&*x); - *x = 5; //~ ERROR cannot assign + *x = 5; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `*x` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `(*x)` because it is borrowed (Mir) } fn g() { @@ -64,7 +80,9 @@ fn g() { let mut x: Box<_> = box Foo { f: box 3 }; let c1 = || get(&*x.f); - *x.f = 5; //~ ERROR cannot assign to `*x.f` + *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` + //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `(*(*x).0)` because it is borrowed (Mir) } fn h() { @@ -74,7 +92,9 @@ fn h() { let mut x: Box<_> = box Foo { f: box 3 }; let c1 = || get(&*x.f); - let c2 = || *x.f = 5; //~ ERROR cannot borrow `x` as mutable + let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable + //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable (Ast) + //[mir]~| ERROR cannot borrow `x` as mutable because it is also borrowed as immutable (Mir) } fn main() { diff --git a/src/test/compile-fail/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs b/src/test/compile-fail/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs index 8af10231921aa..03b6b1d732400 100644 --- a/src/test/compile-fail/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs +++ b/src/test/compile-fail/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs @@ -8,11 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + fn main() { let mut _a = 3; let _b = &mut _a; { let _c = &*_b; - _a = 4; //~ ERROR cannot assign to `_a` + _a = 4; //[ast]~ ERROR cannot assign to `_a` + //[mir]~^ ERROR cannot assign to `_a` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `_a` because it is borrowed (Mir) } } diff --git a/src/test/compile-fail/borrowck/borrowck-lend-flow-match.rs b/src/test/compile-fail/borrowck/borrowck-lend-flow-match.rs index f24e82d11c5ed..0e8c003e408f6 100644 --- a/src/test/compile-fail/borrowck/borrowck-lend-flow-match.rs +++ b/src/test/compile-fail/borrowck/borrowck-lend-flow-match.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + #![allow(unused_variables)] #![allow(unused_assignments)] @@ -22,7 +25,9 @@ fn separate_arms() { x = Some(0); } Some(ref __isize) => { - x = Some(1); //~ ERROR cannot assign + x = Some(1); //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir) } } x.clone(); // just to prevent liveness warnings diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs index bee56c9bf390b..9b20cd470f62b 100644 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs +++ b/src/test/compile-fail/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs @@ -13,6 +13,9 @@ // operator. The accounting of the all the implicit things going on // here is rather subtle. Issue #20232. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + use std::ops::{Deref, Index}; struct MyVec { x: T } @@ -39,7 +42,9 @@ fn main() { let mut v = MyVec { x: MyPtr { x: Foo { f: 22 } } }; let i = &v[0].f; v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; - //~^ ERROR cannot assign to `v` + //[ast]~^ ERROR cannot assign to `v` + //[mir]~^^ ERROR cannot assign to `v` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `v` because it is borrowed (Mir) read(*i); } diff --git a/src/test/compile-fail/borrowck/borrowck-pat-reassign-binding.rs b/src/test/compile-fail/borrowck/borrowck-pat-reassign-binding.rs index d176245823ef5..06bb98fa0ec10 100644 --- a/src/test/compile-fail/borrowck/borrowck-pat-reassign-binding.rs +++ b/src/test/compile-fail/borrowck/borrowck-pat-reassign-binding.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + fn main() { let mut x: Option = None; match x { @@ -17,7 +20,9 @@ fn main() { } Some(ref i) => { // But on this branch, `i` is an outstanding borrow - x = Some(*i+1); //~ ERROR cannot assign to `x` + x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` + //[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir) } } x.clone(); // just to prevent liveness warnings diff --git a/src/test/compile-fail/borrowck/borrowck-union-borrow.rs b/src/test/compile-fail/borrowck/borrowck-union-borrow.rs index 20b882e1f807c..73d323ea82cfb 100644 --- a/src/test/compile-fail/borrowck/borrowck-union-borrow.rs +++ b/src/test/compile-fail/borrowck/borrowck-union-borrow.rs @@ -9,6 +9,8 @@ // except according to those terms. // ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir #[derive(Clone, Copy)] union U { @@ -30,11 +32,15 @@ fn main() { } { let ra = &u.a; - let rma = &mut u.a; //~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable + let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable + //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable (Ast) + //[mir]~| ERROR cannot borrow `u.0` as mutable because it is also borrowed as immutable (Mir) } { let ra = &u.a; - u.a = 1; //~ ERROR cannot assign to `u.a` because it is borrowed + u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `u.0` because it is borrowed (Mir) } // Imm borrow, other field { @@ -47,45 +53,65 @@ fn main() { } { let ra = &u.a; - let rmb = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) + let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) + //[mir]~^ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) (Ast) + // FIXME Error for MIR (needs support for union) } { let ra = &u.a; - u.b = 1; //~ ERROR cannot assign to `u.b` because it is borrowed + u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed (Ast) + // FIXME Error for MIR (needs support for union) } // Mut borrow, same field { let rma = &mut u.a; - let ra = &u.a; //~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable + let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable + //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable (Ast) + //[mir]~| ERROR cannot borrow `u.0` as immutable because it is also borrowed as mutable (Mir) } { let ra = &mut u.a; - let a = u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed + let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed (Ast) + //[mir]~| ERROR cannot use `u.0` because it was mutably borrowed (Mir) } { let rma = &mut u.a; - let rma2 = &mut u.a; //~ ERROR cannot borrow `u.a` as mutable more than once at a time + let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time + //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time (Ast) + //[mir]~| ERROR cannot borrow `u.0` as mutable more than once at a time (Mir) } { let rma = &mut u.a; - u.a = 1; //~ ERROR cannot assign to `u.a` because it is borrowed + u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `u.0` because it is borrowed (Mir) } // Mut borrow, other field { let rma = &mut u.a; - let rb = &u.b; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) + let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) + //[mir]~^ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) (Ast) + // FIXME Error for MIR (needs support for union) } { let ra = &mut u.a; - let b = u.b; //~ ERROR cannot use `u.b` because it was mutably borrowed + let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed + //[mir]~^ ERROR cannot use `u.b` because it was mutably borrowed (Ast) + // FIXME Error for MIR (needs support for union) } { let rma = &mut u.a; - let rmb2 = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time + let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time + //[mir]~^ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time (Ast) + // FIXME Error for MIR (needs support for union) } { let rma = &mut u.a; - u.b = 1; //~ ERROR cannot assign to `u.b` because it is borrowed + u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed (Ast) + // FIXME Error for MIR (needs support for union) } } } diff --git a/src/test/compile-fail/borrowck/borrowck-vec-pattern-move-tail.rs b/src/test/compile-fail/borrowck/borrowck-vec-pattern-move-tail.rs index fddb9838c44b5..b5916584930b8 100644 --- a/src/test/compile-fail/borrowck/borrowck-vec-pattern-move-tail.rs +++ b/src/test/compile-fail/borrowck/borrowck-vec-pattern-move-tail.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + #![feature(slice_patterns)] fn main() { @@ -17,7 +20,9 @@ fn main() { _ => unreachable!() }; println!("t[0]: {}", t[0]); - a[2] = 0; //~ ERROR cannot assign to `a[..]` because it is borrowed + a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed + //[mir]~^ ERROR cannot assign to `a[..]` because it is borrowed (Ast) + // FIXME Error for MIR (error missed) println!("t[0]: {}", t[0]); t[0]; } diff --git a/src/test/compile-fail/coerce-overloaded-autoderef.rs b/src/test/compile-fail/coerce-overloaded-autoderef.rs index 14fbc34c43bb4..43b771ce5dbed 100644 --- a/src/test/compile-fail/coerce-overloaded-autoderef.rs +++ b/src/test/compile-fail/coerce-overloaded-autoderef.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + fn borrow_mut(x: &mut T) -> &mut T { x } fn borrow(x: &T) -> &T { x } @@ -17,24 +20,32 @@ fn borrow2(_: &mut T, _: &T) {} fn double_mut_borrow(x: &mut Box) { let y = borrow_mut(x); let z = borrow_mut(x); - //~^ ERROR cannot borrow `*x` as mutable more than once at a time + //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time + //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time (Ast) + //[mir]~| ERROR cannot borrow `(*x)` as mutable more than once at a time (Mir) } fn double_imm_borrow(x: &mut Box) { let y = borrow(x); let z = borrow(x); **x += 1; - //~^ ERROR cannot assign to `**x` because it is borrowed + //[ast]~^ ERROR cannot assign to `**x` because it is borrowed + //[mir]~^^ ERROR cannot assign to `**x` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `(*(*x))` because it is borrowed (Mir) } fn double_mut_borrow2(x: &mut Box) { borrow_mut2(x, x); - //~^ ERROR cannot borrow `*x` as mutable more than once at a time + //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time + //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time (Ast) + //[mir]~| ERROR cannot borrow `(*x)` as mutable more than once at a time (Mir) } fn double_borrow2(x: &mut Box) { borrow2(x, x); - //~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable + //[ast]~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable (Ast) + //[mir]~| ERROR cannot borrow `(*x)` as immutable because it is also borrowed as mutable (Mir) } pub fn main() {} diff --git a/src/test/compile-fail/hrtb-identity-fn-borrows.rs b/src/test/compile-fail/hrtb-identity-fn-borrows.rs index 17939cf9fe026..b6216ce058915 100644 --- a/src/test/compile-fail/hrtb-identity-fn-borrows.rs +++ b/src/test/compile-fail/hrtb-identity-fn-borrows.rs @@ -11,6 +11,9 @@ // Test that the `'a` in the where clause correctly links the region // of the output to the region of the input. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + trait FnLike { fn call(&self, arg: A) -> R; } @@ -21,7 +24,9 @@ fn call_repeatedly(f: F) // Result is stored: cannot re-assign `x` let mut x = 3; let y = f.call(&x); - x = 5; //~ ERROR cannot assign + x = 5; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir) // Result is not stored: can re-assign `x` let mut x = 3; diff --git a/src/test/compile-fail/mut-pattern-internal-mutability.rs b/src/test/compile-fail/mut-pattern-internal-mutability.rs index b0d618328dcca..3a84bd6565e8d 100644 --- a/src/test/compile-fail/mut-pattern-internal-mutability.rs +++ b/src/test/compile-fail/mut-pattern-internal-mutability.rs @@ -8,11 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + fn main() { let foo = &mut 1; let &mut x = foo; - x += 1; //~ ERROR re-assignment of immutable variable + x += 1; //[ast]~ ERROR re-assignment of immutable variable + //[mir]~^ ERROR re-assignment of immutable variable `x` (Ast) + //[mir]~| ERROR re-assignment of immutable variable `x` (Mir) // explicitly mut-ify internals let &mut mut x = foo; @@ -20,5 +25,7 @@ fn main() { // check borrowing is detected successfully let &mut ref x = foo; - *foo += 1; //~ ERROR cannot assign to `*foo` because it is borrowed + *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed + //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `(*foo)` because it is borrowed (Mir) } diff --git a/src/test/compile-fail/regions-pattern-typing-issue-19997.rs b/src/test/compile-fail/regions-pattern-typing-issue-19997.rs index ae9ceb600d45c..91f5f048bc1c0 100644 --- a/src/test/compile-fail/regions-pattern-typing-issue-19997.rs +++ b/src/test/compile-fail/regions-pattern-typing-issue-19997.rs @@ -8,13 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir + fn main() { let a0 = 0; let f = 1; let mut a1 = &a0; match (&a1,) { (&ref b0,) => { - a1 = &f; //~ ERROR cannot assign + a1 = &f; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `a1` because it is borrowed (Ast) + //[mir]~| ERROR cannot assign to `a1` because it is borrowed (Mir) } } } From 6d4989b821632086c7a84c36eedc8f55d1c878a4 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sun, 24 Sep 2017 03:56:57 -0700 Subject: [PATCH 54/77] Add span label to E0384 for MIR borrowck --- src/librustc_mir/borrow_check.rs | 30 +++++++++++++++---- .../borrowck-match-binding-is-assignment.rs | 23 ++++++++++---- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/librustc_mir/borrow_check.rs b/src/librustc_mir/borrow_check.rs index 9e261d6024891..9201e0e2553ef 100644 --- a/src/librustc_mir/borrow_check.rs +++ b/src/librustc_mir/borrow_check.rs @@ -580,7 +580,19 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> if flow_state.inits.curr_state.contains(&mpi) { // may already be assigned before reaching this statement; // report error. - self.report_illegal_reassignment(context, (lvalue, span)); + // FIXME: Not ideal, it only finds the assignment that lexically comes first + let assigned_lvalue = &move_data.move_paths[mpi].lvalue; + let assignment_stmt = self.mir.basic_blocks().iter().filter_map(|bb| { + bb.statements.iter().find(|stmt| { + if let StatementKind::Assign(ref lv, _) = stmt.kind { + *lv == *assigned_lvalue + } else { + false + } + }) + }).next().unwrap(); + self.report_illegal_reassignment( + context, (lvalue, span), assignment_stmt.source_info.span); } } } @@ -982,11 +994,17 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> err.emit(); } - fn report_illegal_reassignment(&mut self, _context: Context, (lvalue, span): (&Lvalue, Span)) { - let mut err = self.tcx.cannot_reassign_immutable( - span, &self.describe_lvalue(lvalue), Origin::Mir); - // FIXME: add span labels for borrow and assignment points - err.emit(); + fn report_illegal_reassignment(&mut self, + _context: Context, + (lvalue, span): (&Lvalue, Span), + assigned_span: Span) { + self.tcx.cannot_reassign_immutable(span, + &self.describe_lvalue(lvalue), + Origin::Mir) + .span_label(span, "re-assignment of immutable variable") + .span_label(assigned_span, format!("first assignment to `{}`", + self.describe_lvalue(lvalue))) + .emit(); } fn report_assignment_to_static(&mut self, _context: Context, (lvalue, span): (&Lvalue, Span)) { diff --git a/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs b/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs index c219b7c5424e9..3639db5cfc4cd 100644 --- a/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs +++ b/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// revisions: ast mir +//[mir]compile-flags: -Zemit-end-regions -Zborrowck-mir + // Test that immutable pattern bindings cannot be reassigned. #![feature(slice_patterns)] @@ -23,31 +26,41 @@ struct S { pub fn main() { match 1 { x => { - x += 1; //~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + //[mir]~^ ERROR (Mir) [E0384] + //[mir]~| ERROR (Ast) [E0384] } } match E::Foo(1) { E::Foo(x) => { - x += 1; //~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + //[mir]~^ ERROR (Mir) [E0384] + //[mir]~| ERROR (Ast) [E0384] } } match (S { bar: 1 }) { S { bar: x } => { - x += 1; //~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + //[mir]~^ ERROR (Mir) [E0384] + //[mir]~| ERROR (Ast) [E0384] } } match (1,) { (x,) => { - x += 1; //~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + //[mir]~^ ERROR (Mir) [E0384] + //[mir]~| ERROR (Ast) [E0384] } } match [1,2,3] { [x,_,_] => { - x += 1; //~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + //[mir]~^ ERROR (Mir) [E0384] + //[mir]~| ERROR (Ast) [E0384] } } } From b53b853129e4a05994e7029e2c45d74141a13961 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Kollasch" Date: Thu, 31 Aug 2017 09:17:50 -0500 Subject: [PATCH 55/77] bootstrap: use shasum(1) on NetBSD build hosts NetBSD doesn't ship with sha256sum. The openssl build will probably try to use perl anyway, so using perl's shasum is reasonable. --- src/bootstrap/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 99077d03dbe03..6e479fe1cb614 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -367,7 +367,7 @@ impl Step for Openssl { if !ok { panic!("failed to download openssl source") } - let mut shasum = if target.contains("apple") { + let mut shasum = if target.contains("apple") || build.build.contains("netbsd") { let mut cmd = Command::new("shasum"); cmd.arg("-a").arg("256"); cmd From 90aa66bfc2e90de39e10ad3ed6d08b534f1efd02 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Kollasch" Date: Thu, 31 Aug 2017 09:22:39 -0500 Subject: [PATCH 56/77] bootstrap: use tar -z on extract MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some tar(1) programs—such as NetBSD's—do not automatically decompress. --- src/bootstrap/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 6e479fe1cb614..9b8857b5749de 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -387,7 +387,7 @@ impl Step for Openssl { let dst = build.openssl_install_dir(target).unwrap(); drop(fs::remove_dir_all(&obj)); drop(fs::remove_dir_all(&dst)); - build.run(Command::new("tar").arg("xf").arg(&tarball).current_dir(&out)); + build.run(Command::new("tar").arg("zxf").arg(&tarball).current_dir(&out)); let mut configure = Command::new("perl"); configure.arg(obj.join("Configure")); From cde47cef0f102933abf0a9143ae916864feb7b6b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 27 Sep 2017 15:11:22 -0300 Subject: [PATCH 57/77] Remove DepNodeIndex::new is already impl for Idx --- src/librustc_incremental/persist/data.rs | 8 -------- src/librustc_incremental/persist/save.rs | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/librustc_incremental/persist/data.rs b/src/librustc_incremental/persist/data.rs index 06acfb5d77807..9050702e3ca71 100644 --- a/src/librustc_incremental/persist/data.rs +++ b/src/librustc_incremental/persist/data.rs @@ -70,14 +70,6 @@ impl SerializedDepGraph { RustcEncodable, RustcDecodable)] pub struct DepNodeIndex(pub u32); -impl DepNodeIndex { - #[inline] - pub fn new(idx: usize) -> DepNodeIndex { - assert!(idx <= ::std::u32::MAX as usize); - DepNodeIndex(idx as u32) - } -} - impl Idx for DepNodeIndex { #[inline] fn new(idx: usize) -> Self { diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index 83a618211dad3..fd699229f1b73 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -19,7 +19,7 @@ use rustc::util::common::time; use rustc::util::nodemap::DefIdMap; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::graph; -use rustc_data_structures::indexed_vec::IndexVec; +use rustc_data_structures::indexed_vec::{IndexVec, Idx}; use rustc_serialize::Encodable as RustcEncodable; use rustc_serialize::opaque::Encoder; use std::io::{self, Cursor, Write}; From 70c3a3da6d6aa9b818c76dc0c3afd31fb2249cfb Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 27 Sep 2017 16:31:31 -0300 Subject: [PATCH 58/77] Remove DepNodeIndexNew::new and ::index, they are already impl for Idx --- src/librustc/dep_graph/graph.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 71a7ee84cd144..d9770db9d69a2 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -569,28 +569,20 @@ pub(super) struct DepNodeIndexNew { } impl Idx for DepNodeIndexNew { - fn new(idx: usize) -> Self { - DepNodeIndexNew::new(idx) + fn new(v: usize) -> DepNodeIndexNew { + assert!((v & 0xFFFF_FFFF) == v); + DepNodeIndexNew { index: v as u32 } } + fn index(self) -> usize { - self.index() + self.index as usize } } impl DepNodeIndexNew { - const INVALID: DepNodeIndexNew = DepNodeIndexNew { index: ::std::u32::MAX, }; - - fn new(v: usize) -> DepNodeIndexNew { - assert!((v & 0xFFFF_FFFF) == v); - DepNodeIndexNew { index: v as u32 } - } - - fn index(self) -> usize { - self.index as usize - } } #[derive(Clone, Debug, PartialEq)] From e0e14c9a5b141cb86c1b2cde85c35388ba63ad23 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 27 Sep 2017 16:41:35 -0300 Subject: [PATCH 59/77] Remove SerializedDepNodeIndex::new it is already impl for Idx --- src/librustc/dep_graph/serialized.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/librustc/dep_graph/serialized.rs b/src/librustc/dep_graph/serialized.rs index 21beac9214eef..6110c270086fe 100644 --- a/src/librustc/dep_graph/serialized.rs +++ b/src/librustc/dep_graph/serialized.rs @@ -19,14 +19,6 @@ use rustc_data_structures::indexed_vec::{IndexVec, Idx}; RustcEncodable, RustcDecodable)] pub struct SerializedDepNodeIndex(pub u32); -impl SerializedDepNodeIndex { - #[inline] - pub fn new(idx: usize) -> SerializedDepNodeIndex { - assert!(idx <= ::std::u32::MAX as usize); - SerializedDepNodeIndex(idx as u32) - } -} - impl Idx for SerializedDepNodeIndex { #[inline] fn new(idx: usize) -> Self { From 0f97b6b73c647604ad08e475b68058f52c4951c4 Mon Sep 17 00:00:00 2001 From: Tomas Nilsson Date: Tue, 12 Sep 2017 21:55:41 +0200 Subject: [PATCH 60/77] Apply attr proc macros before cfg processing Now items are not fully configured until right before expanding derives. --- src/libsyntax/ext/expand.rs | 39 ++++++++++++------- .../run-pass-fulldeps/proc-macro/attr-cfg.rs | 39 +++++++++++++++++++ .../proc-macro/auxiliary/attr-cfg.rs | 32 +++++++++++++++ .../proc-macro/auxiliary/derive-attr-cfg.rs | 23 +++++++++++ .../proc-macro/derive-attr-cfg.rs | 27 +++++++++++++ 5 files changed, 146 insertions(+), 14 deletions(-) create mode 100644 src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs create mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs create mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs create mode 100644 src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 68ddfdc404a8b..6e7a8203b61ca 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -308,7 +308,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { err.emit(); } - let item = item + let item = self.fully_configure(item) .map_attrs(|mut attrs| { attrs.retain(|a| a.path != "derive"); attrs }); let item_with_markers = add_derived_markers(&mut self.cx, item.span(), &traits, item.clone()); @@ -400,6 +400,27 @@ impl<'a, 'b> MacroExpander<'a, 'b> { result } + fn fully_configure(&mut self, item: Annotatable) -> Annotatable { + let mut cfg = StripUnconfigured { + should_test: self.cx.ecfg.should_test, + sess: self.cx.parse_sess, + features: self.cx.ecfg.features, + }; + // Since the item itself has already been configured by the InvocationCollector, + // we know that fold result vector will contain exactly one element + match item { + Annotatable::Item(item) => { + Annotatable::Item(cfg.fold_item(item).pop().unwrap()) + } + Annotatable::TraitItem(item) => { + Annotatable::TraitItem(item.map(|item| cfg.fold_trait_item(item).pop().unwrap())) + } + Annotatable::ImplItem(item) => { + Annotatable::ImplItem(item.map(|item| cfg.fold_impl_item(item).pop().unwrap())) + } + } + } + fn expand_invoc(&mut self, invoc: Invocation, ext: Rc) -> Expansion { let result = match invoc.kind { InvocationKind::Bang { .. } => self.expand_bang_invoc(invoc, ext), @@ -740,15 +761,6 @@ struct InvocationCollector<'a, 'b: 'a> { monotonic: bool, } -macro_rules! fully_configure { - ($this:ident, $node:ident, $noop_fold:ident) => { - match $noop_fold($node, &mut $this.cfg).pop() { - Some(node) => node, - None => return SmallVector::new(), - } - } -} - impl<'a, 'b> InvocationCollector<'a, 'b> { fn collect(&mut self, expansion_kind: ExpansionKind, kind: InvocationKind) -> Expansion { let mark = Mark::fresh(self.cx.current_expansion.mark); @@ -900,7 +912,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { let (attr, traits, mut item) = self.classify_item(item); if attr.is_some() || !traits.is_empty() { - let item = Annotatable::Item(fully_configure!(self, item, noop_fold_item)); + let item = Annotatable::Item(item); return self.collect_attr(attr, traits, item, ExpansionKind::Items).make_items(); } @@ -974,8 +986,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { let (attr, traits, item) = self.classify_item(item); if attr.is_some() || !traits.is_empty() { - let item = - Annotatable::TraitItem(P(fully_configure!(self, item, noop_fold_trait_item))); + let item = Annotatable::TraitItem(P(item)); return self.collect_attr(attr, traits, item, ExpansionKind::TraitItems) .make_trait_items() } @@ -995,7 +1006,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { let (attr, traits, item) = self.classify_item(item); if attr.is_some() || !traits.is_empty() { - let item = Annotatable::ImplItem(P(fully_configure!(self, item, noop_fold_impl_item))); + let item = Annotatable::ImplItem(P(item)); return self.collect_attr(attr, traits, item, ExpansionKind::ImplItems) .make_impl_items(); } diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs b/src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs new file mode 100644 index 0000000000000..5a28d756df5a5 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs @@ -0,0 +1,39 @@ +// Copyright 2016 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. + +// aux-build:attr-cfg.rs +// ignore-stage1 +// revisions: foo bar + +#![feature(proc_macro)] + +extern crate attr_cfg; +use attr_cfg::attr_cfg; + +#[attr_cfg] +fn outer() -> u8 { + #[cfg(foo)] + fn inner() -> u8 { 1 } + + #[cfg(bar)] + fn inner() -> u8 { 2 } + + inner() +} + +#[cfg(foo)] +fn main() { + assert_eq!(outer(), 1); +} + +#[cfg(bar)] +fn main() { + assert_eq!(outer(), 2); +} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs new file mode 100644 index 0000000000000..9145c46cfc7c9 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs @@ -0,0 +1,32 @@ +// Copyright 2016 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. + +// no-prefer-dynamic +#![feature(proc_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn attr_cfg(args: TokenStream, input: TokenStream) -> TokenStream { + let input_str = input.to_string(); + + assert_eq!(input_str, "fn outer() -> u8 { + #[cfg(foo)] + fn inner() -> u8 { 1 } + #[cfg(bar)] + fn inner() -> u8 { 2 } + inner() +}"); + + input +} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs new file mode 100644 index 0000000000000..787a4a470e257 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs @@ -0,0 +1,23 @@ +// Copyright 2016 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. + +// no-prefer-dynamic +#![feature(proc_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Foo, attributes(foo))] +pub fn derive(input: TokenStream) -> TokenStream { + assert!(!input.to_string().contains("#[cfg(any())]")); + "".parse().unwrap() +} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs b/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs new file mode 100644 index 0000000000000..b94c45248dae5 --- /dev/null +++ b/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs @@ -0,0 +1,27 @@ +// Copyright 2016 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. + +// aux-build:derive-attr-cfg.rs +// ignore-stage1 + +#![feature(proc_macro)] + +extern crate derive_attr_cfg; +use derive_attr_cfg::Foo; + +#[derive(Foo)] +#[foo] +struct S { + #[cfg(any())] + x: i32 +} + +fn main() { +} From 2bd104fd4ffaf2a72799b5d49fcea3931e6a9e15 Mon Sep 17 00:00:00 2001 From: Hunter Praska Date: Wed, 7 Jun 2017 22:51:45 -0500 Subject: [PATCH 61/77] Impl Try for Option --- src/libcore/option.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 138e04c7737e0..fa6e309547915 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -146,7 +146,7 @@ #![stable(feature = "rust1", since = "1.0.0")] use iter::{FromIterator, FusedIterator, TrustedLen}; -use mem; +use {mem, ops}; // Note that this is not a lang item per se, but it has a hidden dependency on // `Iterator`, which is one. The compiler assumes that the `next` method of @@ -1123,3 +1123,26 @@ impl> FromIterator> for Option { } } } + +/// The `Option` type. See [the module level documentation](index.html) for more. +#[unstable(feature = "try_trait", issue = "42327")] +#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] +pub struct Missing; + +#[unstable(feature = "try_trait", issue = "42327")] +impl ops::Try for Option { + type Ok = T; + type Error = Missing; + + fn into_result(self) -> Result { + self.ok_or(Missing) + } + + fn from_ok(v: T) -> Self { + Some(v) + } + + fn from_error(_: Missing) -> Self { + None + } +} From f098d7be2978d8df3d180b6afae435468fc050de Mon Sep 17 00:00:00 2001 From: Hunter Praska Date: Wed, 7 Jun 2017 22:52:13 -0500 Subject: [PATCH 62/77] Add tests for Option and Result Try impl --- src/libcore/tests/lib.rs | 1 + src/libcore/tests/option.rs | 27 +++++++++++++++++++++++++++ src/libcore/tests/result.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 47995597a0a91..938bc3556654e 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -38,6 +38,7 @@ #![feature(test)] #![feature(trusted_len)] #![feature(try_from)] +#![feature(try_trait)] #![feature(unique)] #![feature(const_atomic_bool_new)] diff --git a/src/libcore/tests/option.rs b/src/libcore/tests/option.rs index 6bac55575fb18..00700b36b6982 100644 --- a/src/libcore/tests/option.rs +++ b/src/libcore/tests/option.rs @@ -270,3 +270,30 @@ fn test_cloned() { assert_eq!(opt_ref_ref.clone().cloned(), Some(&val)); assert_eq!(opt_ref_ref.cloned().cloned(), Some(1)); } + +#[test] +fn test_try() { + fn try_option_some() -> Option { + let val = Some(1)?; + Some(val) + } + assert_eq!(try_option_some(), Some(1)); + + fn try_option_none() -> Option { + let val = None?; + Some(val) + } + assert_eq!(try_option_none(), None); + + fn try_option_ok() -> Result { + let val = Ok(1)?; + Ok(val) + } + assert_eq!(try_option_ok(), Ok(1)); + + fn try_option_err() -> Result { + let val = Err(Missing)?; + Ok(val) + } + assert_eq!(try_option_err(), Err(Missing)); +} diff --git a/src/libcore/tests/result.rs b/src/libcore/tests/result.rs index 4c5f19dee1293..37264980dc703 100644 --- a/src/libcore/tests/result.rs +++ b/src/libcore/tests/result.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use core::option::*; + fn op1() -> Result { Ok(666) } fn op2() -> Result { Err("sadface") } @@ -202,3 +204,30 @@ pub fn test_unwrap_or_default() { assert_eq!(op1().unwrap_or_default(), 666); assert_eq!(op2().unwrap_or_default(), 0); } + +#[test] +fn test_try() { + fn try_result_some() -> Option { + let val = Ok(1)?; + Some(val) + } + assert_eq!(try_result_some(), Some(1)); + + fn try_result_none() -> Option { + let val = Err(Missing)?; + Some(val) + } + assert_eq!(try_result_none(), None); + + fn try_result_ok() -> Result { + let val = Ok(1)?; + Ok(val) + } + assert_eq!(try_result_ok(), Ok(1)); + + fn try_result_err() -> Result { + let val = Err(1)?; + Ok(val) + } + assert_eq!(try_result_err(), Err(1)); +} From 8f63e8de464155e570ed81905ff203557dd02ac9 Mon Sep 17 00:00:00 2001 From: Hunter Praska Date: Thu, 8 Jun 2017 14:02:04 -0500 Subject: [PATCH 63/77] Add docs for Missing, correct Option's Try test --- src/libcore/option.rs | 2 +- src/libcore/tests/option.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index fa6e309547915..0c3339590dbeb 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1124,7 +1124,7 @@ impl> FromIterator> for Option { } } -/// The `Option` type. See [the module level documentation](index.html) for more. +/// The equivalent of `Option::None` for a `Result::Err`. #[unstable(feature = "try_trait", issue = "42327")] #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] pub struct Missing; diff --git a/src/libcore/tests/option.rs b/src/libcore/tests/option.rs index 00700b36b6982..e2907e1dd896f 100644 --- a/src/libcore/tests/option.rs +++ b/src/libcore/tests/option.rs @@ -286,13 +286,13 @@ fn test_try() { assert_eq!(try_option_none(), None); fn try_option_ok() -> Result { - let val = Ok(1)?; + let val = Some(1)?; Ok(val) } assert_eq!(try_option_ok(), Ok(1)); fn try_option_err() -> Result { - let val = Err(Missing)?; + let val = None?; Ok(val) } assert_eq!(try_option_err(), Err(Missing)); From 28996db803b958b235f5f3e95bc1762955de8a05 Mon Sep 17 00:00:00 2001 From: Hunter Praska Date: Sun, 18 Jun 2017 13:07:09 -0500 Subject: [PATCH 64/77] Rename option::Missing to NoneError --- src/libcore/option.rs | 15 +++++++++------ src/libcore/tests/option.rs | 6 +++--- src/libcore/tests/result.rs | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 0c3339590dbeb..980ea551f0806 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1124,25 +1124,28 @@ impl> FromIterator> for Option { } } -/// The equivalent of `Option::None` for a `Result::Err`. +/// The error type that results from applying the try operator (`?`) to a `None` value. If you wish +/// to allow `x?` (where `x` is an `Option`) to be converted into your error type, you can +/// implement `impl From` for `YourErrorType`. In that case, `x?` within a function that +/// returns `Result<_, YourErrorType>` will translate a `None` value into an `Err` result. #[unstable(feature = "try_trait", issue = "42327")] #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] -pub struct Missing; +pub struct NoneError; #[unstable(feature = "try_trait", issue = "42327")] impl ops::Try for Option { type Ok = T; - type Error = Missing; + type Error = NoneError; - fn into_result(self) -> Result { - self.ok_or(Missing) + fn into_result(self) -> Result { + self.ok_or(NoneError) } fn from_ok(v: T) -> Self { Some(v) } - fn from_error(_: Missing) -> Self { + fn from_error(_: NoneError) -> Self { None } } diff --git a/src/libcore/tests/option.rs b/src/libcore/tests/option.rs index e2907e1dd896f..22109e28edd9b 100644 --- a/src/libcore/tests/option.rs +++ b/src/libcore/tests/option.rs @@ -285,15 +285,15 @@ fn test_try() { } assert_eq!(try_option_none(), None); - fn try_option_ok() -> Result { + fn try_option_ok() -> Result { let val = Some(1)?; Ok(val) } assert_eq!(try_option_ok(), Ok(1)); - fn try_option_err() -> Result { + fn try_option_err() -> Result { let val = None?; Ok(val) } - assert_eq!(try_option_err(), Err(Missing)); + assert_eq!(try_option_err(), Err(NoneError)); } diff --git a/src/libcore/tests/result.rs b/src/libcore/tests/result.rs index 37264980dc703..ce41bde8342ed 100644 --- a/src/libcore/tests/result.rs +++ b/src/libcore/tests/result.rs @@ -214,7 +214,7 @@ fn test_try() { assert_eq!(try_result_some(), Some(1)); fn try_result_none() -> Option { - let val = Err(Missing)?; + let val = Err(NoneError)?; Some(val) } assert_eq!(try_result_none(), None); From e30d92bb2d885629b51a5511b58109c94a1c56da Mon Sep 17 00:00:00 2001 From: Hunter Praska Date: Fri, 22 Sep 2017 10:24:06 -0500 Subject: [PATCH 65/77] Add UI tests --- src/test/ui/suggestions/try-on-option.rs | 25 ++++++++++++++++++++ src/test/ui/suggestions/try-on-option.stderr | 22 +++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/test/ui/suggestions/try-on-option.rs create mode 100644 src/test/ui/suggestions/try-on-option.stderr diff --git a/src/test/ui/suggestions/try-on-option.rs b/src/test/ui/suggestions/try-on-option.rs new file mode 100644 index 0000000000000..4cd8cd81151cc --- /dev/null +++ b/src/test/ui/suggestions/try-on-option.rs @@ -0,0 +1,25 @@ +// Copyright 2017 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. + +#![feature(try_trait)] + +fn main() {} + +fn foo() -> Result { + let x: Option = None; + x?; + Ok(22) +} + +fn bar() -> u32 { + let x: Option = None; + x?; + 22 +} diff --git a/src/test/ui/suggestions/try-on-option.stderr b/src/test/ui/suggestions/try-on-option.stderr new file mode 100644 index 0000000000000..86d4510cad3c2 --- /dev/null +++ b/src/test/ui/suggestions/try-on-option.stderr @@ -0,0 +1,22 @@ +error[E0277]: the trait bound `(): std::convert::From` is not satisfied + --> $DIR/try-on-option.rs:17:5 + | +17 | x?; + | ^^ the trait `std::convert::From` is not implemented for `()` + | + = note: required by `std::convert::From::from` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`) + --> $DIR/try-on-option.rs:23:5 + | +23 | x?; + | -- + | | + | cannot use the `?` operator in a function that returns `u32` + | in this macro invocation + | + = help: the trait `std::ops::Try` is not implemented for `u32` + = note: required by `std::ops::Try::from_error` + +error: aborting due to 2 previous errors + From c5cad5a78dd32846b3353a25f707dd2fcfd7bc63 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 22 Sep 2017 13:58:35 +1200 Subject: [PATCH 66/77] Update RLS and Rustfmt --- src/Cargo.lock | 387 +++++++++++++++++++++++++------------------------ src/Cargo.toml | 5 - src/tools/rls | 2 +- 3 files changed, 201 insertions(+), 193 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index c930c2073eb88..2de8cc0f0fe91 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -80,31 +80,31 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -140,16 +140,16 @@ name = "bootstrap" version = "0.0.0" dependencies = [ "build_helper 0.1.0", - "cmake 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -166,8 +166,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "build-manifest" version = "0.1.0" dependencies = [ - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -175,7 +175,7 @@ dependencies = [ name = "build_helper" version = "0.1.0" dependencies = [ - "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -193,8 +193,8 @@ dependencies = [ "docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -205,20 +205,20 @@ dependencies = [ "ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -233,13 +233,13 @@ name = "cargotest" version = "0.1.0" dependencies = [ "cargo 0.23.0", - "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -248,6 +248,11 @@ dependencies = [ name = "cargotest2" version = "0.1.0" +[[package]] +name = "cc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "cfg-if" version = "0.1.2" @@ -255,7 +260,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" -version = "2.26.0" +version = "2.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -263,8 +268,7 @@ dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -272,10 +276,10 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -300,9 +304,9 @@ version = "0.0.0" dependencies = [ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -332,7 +336,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -340,7 +344,7 @@ name = "core-foundation-sys" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -349,9 +353,9 @@ version = "0.12.0" dependencies = [ "curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -394,23 +398,23 @@ name = "curl" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl-sys 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "socket2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "curl-sys" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -459,8 +463,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -500,7 +504,7 @@ name = "error-chain" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -508,7 +512,7 @@ name = "error-chain" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -520,10 +524,11 @@ dependencies = [ [[package]] name = "filetime" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -540,11 +545,11 @@ version = "0.1.0" [[package]] name = "flate2" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -567,7 +572,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -582,7 +587,7 @@ dependencies = [ [[package]] name = "futures" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -592,7 +597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getopts" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -601,10 +606,10 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -661,10 +666,10 @@ dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -753,9 +758,9 @@ version = "0.1.0" name = "installer" version = "0.0.0" dependencies = [ - "clap 2.26.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -766,7 +771,7 @@ dependencies = [ [[package]] name = "itoa" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -774,20 +779,20 @@ name = "jobserver" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-core" -version = "7.1.0" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -816,9 +821,9 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -837,21 +842,21 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.30" +version = "0.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cmake 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "curl-sys 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -860,20 +865,20 @@ name = "libssh2-sys" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cmake 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libz-sys" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -889,12 +894,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lzma-sys" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -942,7 +948,7 @@ name = "mdbook" version = "0.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "clap 2.26.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "handlebars 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -951,9 +957,9 @@ dependencies = [ "open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -963,7 +969,7 @@ name = "memchr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -971,16 +977,16 @@ name = "memchr" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "miniz-sys" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1005,7 +1011,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1081,7 +1087,7 @@ name = "num_cpus" version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1095,14 +1101,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl" -version = "0.9.17" +version = "0.9.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1112,11 +1118,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl-sys" -version = "0.9.17" +version = "0.9.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1238,12 +1244,12 @@ version = "0.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quick-error" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1261,7 +1267,7 @@ name = "racer" version = "2.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "clap 2.26.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_errors 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1282,10 +1288,15 @@ name = "rand" version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "redox_syscall" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "reformat" version = "0.1.0" @@ -1346,7 +1357,7 @@ version = "0.122.0" dependencies = [ "cargo 0.23.0", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 7.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 7.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "languageserver-types 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1357,9 +1368,9 @@ dependencies = [ "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustfmt-nightly 0.2.7", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1382,8 +1393,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1397,8 +1408,8 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1414,7 +1425,7 @@ dependencies = [ name = "rustbook" version = "0.1.0" dependencies = [ - "clap 2.26.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", "mdbook 0.0.25 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1424,7 +1435,7 @@ version = "0.0.0" dependencies = [ "arena 0.0.0", "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "fmt_macros 0.0.0", "graphviz 0.0.0", "jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1482,7 +1493,7 @@ dependencies = [ "alloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", - "cmake 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -1632,7 +1643,7 @@ dependencies = [ "alloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", - "cmake 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -1640,7 +1651,7 @@ dependencies = [ name = "rustc_metadata" version = "0.0.0" dependencies = [ - "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "proc_macro 0.0.0", @@ -1677,7 +1688,7 @@ dependencies = [ "alloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", - "cmake 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -1752,7 +1763,7 @@ name = "rustc_trans" version = "0.0.0" dependencies = [ "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1795,7 +1806,7 @@ dependencies = [ "alloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", - "cmake 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -1841,14 +1852,14 @@ version = "0.2.7" dependencies = [ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "strings 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1896,7 +1907,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1906,22 +1917,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.11" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_derive" -version = "1.0.11" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive_internals 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive_internals" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1933,18 +1944,18 @@ name = "serde_ignored" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1973,7 +1984,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2024,7 +2035,7 @@ dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_codegen 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2122,7 +2133,7 @@ name = "syntex_errors" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2144,7 +2155,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_errors 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2158,8 +2169,8 @@ name = "tar" version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "xattr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2200,7 +2211,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2216,13 +2227,13 @@ dependencies = [ name = "test" version = "0.0.0" dependencies = [ - "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.0.0", ] [[package]] name = "textwrap" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2235,7 +2246,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2272,7 +2283,7 @@ name = "toml" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2351,7 +2362,7 @@ name = "url_serde" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2440,7 +2451,7 @@ name = "xattr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2448,7 +2459,7 @@ name = "xz2" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lzma-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lzma-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2463,16 +2474,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" "checksum ar 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b24e4eef8e3fa7e2ca75b157e6039cdf8d9d3a68213ddc19d0fd9d576b9717c9" "checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159" -"checksum backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72f9b4182546f4b04ebc4ab7f84948953a118bd6021a1b6a6c909e3e94f6be76" -"checksum backtrace-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "afccc5772ba333abccdf60d55200fa3406f8c59dcf54d5f7998c9107d3799c7c" +"checksum backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99f2ce94e22b8e664d95c57fff45b98a966c2252b60691d0b7aeeccd88d70983" +"checksum backtrace-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "c63ea141ef8fdb10409d0f5daf30ac51f84ef43bff66f16627773d2a292cd189" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5cde24d1b2e2216a726368b2363a273739c91f4e3eb4e0dd12d672d396ad989" "checksum bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32" +"checksum cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7db2f146208d7e0fbee761b09cd65a7f51ccc38705d4e7262dad4d73b12a76b1" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum clap 2.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2267a8fdd4dce6956ba6649e130f62fb279026e5e84b92aa939ac8f85ce3f9f0" -"checksum cmake 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "0c8a6541a55bcd72d3de4faee2d101a5a66df29790282c7f797082a7228a9b3d" +"checksum clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3451e409013178663435d6f15fdb212f14ee4424a3d74f979d081d0a66b6f1f2" +"checksum cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "357c07e7a1fc95732793c1edb5901e1a1f305cfcf63a90eb12dbd22bdb6b789d" "checksum conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299" "checksum core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5909502e547762013619f4c4e01cc7393c20fe2d52d7fa471c1210adb2320dc7" "checksum core-foundation-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bc9fb3d6cb663e6fd7cf1c63f9b144ee2b1e4a78595a0451dd34bff85b9a3387" @@ -2481,7 +2493,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cssparser 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef6124306e5ebc5ab11891d063aeafdd0cdc308079b708c8b566125f3680292b" "checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df" "checksum curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7034c534a1d7d22f7971d6088aa9d281d219ef724026c3428092500f41ae9c2c" -"checksum curl-sys 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d5481162dc4f424d088581db2f979fa7d4c238fe9794595de61d8d7522e277de" +"checksum curl-sys 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "4bee31aa3a079d5f3ff9579ea4dcfb1b1a17a40886f5f467436d383e78134b55" "checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" "checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3" @@ -2494,15 +2506,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" -"checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" -"checksum flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "36df0166e856739905cd3d7e0b210fe818592211a008862599845e012d8d304c" +"checksum filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "6ab199bf38537c6f38792669e081e0bb278b9b7405bba2642e4e5d15bf732c0e" +"checksum flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423" "checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344" "checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d" "checksum fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ab76cfd2aaa59b7bf6688ad9ba15bbae64bff97f04ea02144cfd3443e5c2866" "checksum futf 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "51f93f3de6ba1794dcd5810b3546d004600a59a98266487c8407bc4b24e398f3" -"checksum futures 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a82bdc62350ca9d7974c760e9665102fc9d740992a528c2254aa930e53b783c4" +"checksum futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "05a23db7bd162d4e8265968602930c476f688f0c180b44bdaf55e0cb2c687558" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" -"checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" +"checksum getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "65922871abd2f101a2eb0eaebadc66668e54a87ad9c3dd82520b5f86ede5eff9" "checksum git2 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0c1c0203d653f4140241da0c1375a404f0a397249ec818cd2076c6280c50f6fa" "checksum git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68676bc784bf0bef83278898929bf64a251e87c0340723d0b93fa096c9c5bf8e" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" @@ -2515,19 +2527,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum html5ever 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a49d5001dd1bddf042ea41ed4e0a671d50b1bf187e66b349d7ec613bdce4ad90" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b3fcaf2365eb14b28ec7603c98c06cc531f19de9eb283d89a3dff8417c8c99f5" -"checksum itoa 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ac17257442c2ed77dbc9fd555cf83c58b0c7f7d0e8f2ae08c0ac05c72842e1f6" +"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" "checksum jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "443ae8bc0af6c106e6e8b77e04684faecc1a5ce94e058f4c2b0a037b0ea1b133" -"checksum jsonrpc-core 7.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "903e5eee845f3d83c1436d12848d97b1247cf850ff06a8e1db2f1ce3543af2cf" +"checksum jsonrpc-core 7.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1acd0f9934da94466d2370f36832b9b19271b4abdfdb5e69f0bcd991ebcd515" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kuchiki 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ef2ea4f2f7883cd7c6772b06c14abca01a2cc1f75c426cebffcf6b3b925ef9fc" "checksum languageserver-types 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d52e477b23bf52cd3ca0f9fc6c5d14be954eec97e3b9cdfbd962d911bd533caf" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" -"checksum libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)" = "2370ca07ec338939e356443dac2296f581453c35fe1e3a3ed06023c49435f915" -"checksum libgit2-sys 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "c00f6e5bc3fb2b5f87e75e8d0fd4ae6720d55f3ee23d389b7c6cae30f8db8db1" +"checksum libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d1419b2939a0bc44b77feb34661583c7546b532b192feab36249ab584b86856c" +"checksum libgit2-sys 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)" = "205fc37e829c5b36de63d14c8dc8b62c5a6a2519b16318ed0977079ca97256a9" "checksum libssh2-sys 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0db4ec23611747ef772db1c4d650f8bd762f07b461727ec998f953c614024b75" -"checksum libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "3fdd64ef8ee652185674455c1d450b83cbc8ad895625d543b5324d923f82e4d8" +"checksum libz-sys 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "44ebbc760fd2d2f4d93de09a0e13d97e057612052e871da9985cedcb451e6bd5" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" -"checksum lzma-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "66b2e318eb97ab84f05725471f90c52a09c964053a5899a13fd0165acc26d00b" +"checksum lzma-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c1b93b78f89e8737dac81837fc8f5521ac162abcba902e1a3db949d55346d1da" "checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" "checksum magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf0336886480e671965f794bc9b6fce88503563013d1bfb7a502c81fe3ac527" "checksum magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40d014c7011ac470ae28e2f76a02bfea4a8480f73e701353b49ad7a8d75f4699" @@ -2536,7 +2548,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mdbook 0.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "146eadfc6d141452a364c351f07bb19208d1401e931f40b8532f87bba3ecc40f" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" -"checksum miniz-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "28eaee17666671fa872e567547e8428e83308ebe5808cdf6a0e28397dbe2c726" +"checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" "checksum num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "a311b77ebdc5dd4cf6449d81e4135d9f0e3b153839ac90e648a8ef538f923525" @@ -2548,9 +2560,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0" "checksum num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aec53c34f2d0247c5ca5d32cca1478762f301740468ee9ee6dcb7a0dd7a0c584" "checksum open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3478ed1686bd1300c8a981a940abc92b06fac9cbef747f4c668d4e032ff7b842" -"checksum openssl 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)" = "085aaedcc89a2fac1eb2bc19cd66f29d4ea99fec60f82a5f3a88a6be7dbd90b5" +"checksum openssl 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "816914b22eb15671d62c73442a51978f311e911d6a6f6cbdafa6abce1b5038fc" "checksum openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d98df0270d404ccd3c050a41d579c52d1db15375168bb3471e04ec0f5f378daf" -"checksum openssl-sys 0.9.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7e3a9845a4c9fdb321931868aae5549e96bb7b979bf9af7de03603d74691b5f3" +"checksum openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4c63a7d559c1e5afa6d6a9e6fa34bbc5f800ffc9ae08b72c605420b0c4f5e8" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356" "checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8" @@ -2563,11 +2575,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c93cdc1fb30af9ddf3debc4afbdb0f35126cbd99daa229dd76cdd5349b41d989" "checksum psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abcd5d1a07d360e29727f757a9decb3ce8bc6e0efa8969cfaad669a8317a2478" "checksum pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9ab1e588ef8efd702c7ed9d2bd774db5e6f4d878bb5a1a9f371828fbdff6973" -"checksum quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c36987d4978eb1be2e422b1e0423a557923a5c3e7e6f31d5699e9aafaefa469" +"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" "checksum quote 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c5cf478fe1006dbcc72567121d23dbdae5f1632386068c5c86ff4f645628504" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum racer 2.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "f120c7510ef7aff254aeb06067fb6fac573ec96a1660e194787cf9dced412bf0" "checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf" +"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" @@ -2585,11 +2598,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum selectors 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3c89b1c6a3c029c82263f7dd2d44d0005ee7374eb09e254ab59dede4353a8c0" "checksum semver 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bee2bc909ab2d8d60dab26e8cad85b25d795b14603a0dcb627b78b9d30b6454b" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f7726f29ddf9731b17ff113c461e362c381d9d69433f79de4f3dd572488823e9" -"checksum serde_derive 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cf823e706be268e73e7747b147aa31c8f633ab4ba31f115efb57e5047c3a76dd" -"checksum serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37aee4e0da52d801acfbc0cc219eb1eda7142112339726e427926a6f6ee65d3a" +"checksum serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "6a7046c9d4c6c522d10b2d098f9bebe2bef227e0e74044d8c1bfcf6b476af799" +"checksum serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "1afcaae083fd1c46952a315062326bc9957f182358eb7da03b57ef1c688f7aa9" +"checksum serde_derive_internals 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd381f6d01a6616cdba8530492d453b7761b456ba974e98768a18cad2cd76f58" "checksum serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "190e9765dcedb56be63b6e0993a006c7e3b071a016a304736e4a315dc01fb142" -"checksum serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "48b04779552e92037212c3615370f6bd57a40ebba7f20e554ff9f55e41a69a7b" +"checksum serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d243424e06f9f9c39e3cd36147470fd340db785825e367625f79298a6ac6b7ac" "checksum shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5cc96481d54583947bfe88bf30c23d53f883c6cd0145368b69989d97b84ef8" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum smallvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f8266519bc1d17d0b5b16f6c21295625d562841c708f6376f49028a43e9c11e" @@ -2612,7 +2625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209" "checksum termcolor 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9065bced9c3e43453aa3d56f1e98590b8455b341d2fa191a1090c0dd0b242c75" -"checksum textwrap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f728584ea33b0ad19318e20557cb0a39097751dbb07171419673502f848c7af6" +"checksum textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8e08afc40ae3459e4838f303e465aa50d823df8d7f83ca88108f6d3afe7edd" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" "checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14" diff --git a/src/Cargo.toml b/src/Cargo.toml index 12c074b6a4162..cdb72a042634e 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -60,10 +60,5 @@ debug-assertions = false [patch."https://github.com/rust-lang/cargo"] cargo = { path = "tools/cargo" } -# Override rustfmt dependencies both on the repo and the crate (the RLS -# sometimes uses either). -# FIXME should only need the crates.io patch, long term. -[patch."https://github.com/rust-lang-nursery/rustfmt"] -rustfmt-nightly = { path = "tools/rustfmt" } [patch.crates-io] rustfmt-nightly = { path = "tools/rustfmt" } diff --git a/src/tools/rls b/src/tools/rls index 7221e38023c41..65e6eb6fdd89b 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 7221e38023c41ff2532ebbf54a7da296fd488b50 +Subproject commit 65e6eb6fdd89bcd5857890477dd7a412f4d78e22 From c0ea270f701bd857cc0bd20db1707810fb4b7493 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 22 Sep 2017 13:59:04 +1200 Subject: [PATCH 67/77] Rename rls component to rls-preview on nightly --- src/bootstrap/dist.rs | 17 ++++------------- src/tools/build-manifest/src/main.rs | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 5188604b0a69a..3d4aa0413db61 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1098,13 +1098,8 @@ impl Step for Rls { .arg("--output-dir").arg(&distdir(build)) .arg("--non-installed-overlay").arg(&overlay) .arg(format!("--package-name={}-{}", name, target)) - .arg("--legacy-manifest-dirs=rustlib,cargo"); - - if build.config.channel == "nightly" { - cmd.arg("--component-name=rls"); - } else { - cmd.arg("--component-name=rls-preview"); - } + .arg("--legacy-manifest-dirs=rustlib,cargo") + .arg("--component-name=rls-preview"); build.run(&mut cmd); distdir(build).join(format!("{}-{}.tar.gz", name, target)) @@ -1333,12 +1328,8 @@ impl Step for Extended { cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-std"), target)) .join(format!("rust-std-{}", target)), &exe.join("rust-std")); - let rls_path = if build.config.channel == "nightly" { - work.join(&format!("{}-{}", pkgname(build, "rls"), target)).join("rls") - } else { - work.join(&format!("{}-{}", pkgname(build, "rls"), target)).join("rls-preview") - }; - cp_r(&rls_path, &exe.join("rls")); + cp_r(&work.join(&format!("{}-{}", pkgname(build, "rls"), target)).join("rls-preview"), + &exe.join("rls")); cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-analysis"), target)) .join(format!("rust-analysis-{}", target)), &exe.join("rust-analysis")); diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 028ef729960e3..190fe78c658fe 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -108,6 +108,7 @@ struct Manifest { manifest_version: String, date: String, pkg: BTreeMap, + renames: BTreeMap } #[derive(Serialize)] @@ -117,6 +118,11 @@ struct Package { target: BTreeMap, } +#[derive(Serialize)] +struct Rename { + to: String, +} + #[derive(Serialize)] struct Target { available: bool, @@ -236,6 +242,7 @@ impl Builder { manifest_version: "2".to_string(), date: self.date.to_string(), pkg: BTreeMap::new(), + renames: BTreeMap::new(), }; self.package("rustc", &mut manifest.pkg, HOSTS); @@ -244,14 +251,11 @@ impl Builder { self.package("rust-std", &mut manifest.pkg, TARGETS); self.package("rust-docs", &mut manifest.pkg, TARGETS); self.package("rust-src", &mut manifest.pkg, &["*"]); - let rls_package_name = if self.rust_release == "nightly" { - "rls" - } else { - "rls-preview" - }; - self.package(rls_package_name, &mut manifest.pkg, HOSTS); + self.package("rls-preview", &mut manifest.pkg, HOSTS); self.package("rust-analysis", &mut manifest.pkg, TARGETS); + manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() }); + let mut pkg = Package { version: self.cached_version("rust").to_string(), git_commit_hash: self.cached_git_commit_hash("rust").clone(), @@ -287,7 +291,7 @@ impl Builder { } extensions.push(Component { - pkg: rls_package_name.to_string(), + pkg: "rls-preview".to_string(), target: host.to_string(), }); extensions.push(Component { @@ -319,7 +323,7 @@ impl Builder { } manifest.pkg.insert("rust".to_string(), pkg); - return manifest + return manifest; } fn package(&mut self, From bfcb2909372d4bd1dbd718dbcf3a5eec96a10c62 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 22 Sep 2017 14:41:22 +1200 Subject: [PATCH 68/77] Add RLS and Rustfmt to the toolstate mechanism --- src/bootstrap/check.rs | 12 ++++++++++-- src/bootstrap/tool.rs | 4 ++-- src/bootstrap/toolstate.rs | 2 ++ src/tools/toolstate.toml | 7 +++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 21e7a05236266..6e276f44668f7 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -254,7 +254,11 @@ impl Step for Rls { builder.add_rustc_lib_path(compiler, &mut cargo); - try_run(build, &mut cargo); + try_run_expecting( + build, + &mut cargo, + builder.build.config.toolstate.rls.passes(ToolState::Testing), + ); } } @@ -295,7 +299,11 @@ impl Step for Rustfmt { builder.add_rustc_lib_path(compiler, &mut cargo); - try_run(build, &mut cargo); + try_run_expecting( + build, + &mut cargo, + builder.build.config.toolstate.rustfmt.passes(ToolState::Testing), + ); } } diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index e07ffea2a2ee2..19879ab2ade37 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -454,7 +454,7 @@ impl Step for Rls { tool: "rls", mode: Mode::Librustc, path: "src/tools/rls", - expectation: BuildExpectation::None, + expectation: builder.build.config.toolstate.rls.passes(ToolState::Compiling), }) } } @@ -489,7 +489,7 @@ impl Step for Rustfmt { tool: "rustfmt", mode: Mode::Librustc, path: "src/tools/rustfmt", - expectation: BuildExpectation::None, + expectation: builder.build.config.toolstate.rustfmt.passes(ToolState::Compiling), }) } } diff --git a/src/bootstrap/toolstate.rs b/src/bootstrap/toolstate.rs index 0711c034602b5..8a113f6b4d2df 100644 --- a/src/bootstrap/toolstate.rs +++ b/src/bootstrap/toolstate.rs @@ -46,4 +46,6 @@ impl Default for ToolState { pub struct ToolStates { pub miri: ToolState, pub clippy: ToolState, + pub rls: ToolState, + pub rustfmt: ToolState, } diff --git a/src/tools/toolstate.toml b/src/tools/toolstate.toml index 3cc815ef34edd..1700daa0aff14 100644 --- a/src/tools/toolstate.toml +++ b/src/tools/toolstate.toml @@ -27,3 +27,10 @@ miri = "Broken" # ping @Manishearth @llogiq @mcarton @oli-obk clippy = "Broken" + +# ping @nrc +rls = "Testing" + +# ping @nrc +rustfmt = "Testing" + From 71a0be0792fb3ea29e685ef4ebb6cbc688dbb313 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 25 Sep 2017 17:13:29 +1300 Subject: [PATCH 69/77] Update the RLS again --- src/Cargo.lock | 22 +++++++++++++--------- src/Cargo.toml | 1 + src/tools/rls | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 2de8cc0f0fe91..0bbc2314d10b7 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1,10 +1,6 @@ [root] -name = "unwind" -version = "0.0.0" -dependencies = [ - "core 0.0.0", - "libc 0.0.0", -] +name = "workspace_symbol" +version = "0.1.0" [[package]] name = "advapi32-sys" @@ -1362,7 +1358,7 @@ dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "racer 2.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-analysis 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-analysis 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-rustc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1376,7 +1372,7 @@ dependencies = [ [[package]] name = "rls-analysis" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "derive-new 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2347,6 +2343,14 @@ dependencies = [ "tidy 0.1.0", ] +[[package]] +name = "unwind" +version = "0.0.0" +dependencies = [ + "core 0.0.0", + "libc 0.0.0", +] + [[package]] name = "url" version = "1.5.1" @@ -2585,7 +2589,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" -"checksum rls-analysis 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4302cc8291570d7f817945845d8c01756e833dbc93c0a87d4f6c9a0b0b7992f1" +"checksum rls-analysis 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fa390bdc70b0a90d07d9cd5c6989ba5fca2d59728903919ebda1a1b2037b18d7" "checksum rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11d339f1888e33e74d8032de0f83c40b2bdaaaf04a8cfc03b32186c3481fb534" "checksum rls-rustc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b21ea952e9bf1569929abf1bb920262cde04b7b1b26d8e0260286302807299d2" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" diff --git a/src/Cargo.toml b/src/Cargo.toml index cdb72a042634e..2208f38963852 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -38,6 +38,7 @@ members = [ "tools/rls/test_data/infer_custom_bin", "tools/rls/test_data/infer_lib", "tools/rls/test_data/omit_init_build", + "tools/rls/test_data/workspace_symbol", ] # Curiously, compiletest will segfault if compiled with opt-level=3 on 64-bit diff --git a/src/tools/rls b/src/tools/rls index 65e6eb6fdd89b..93b47d14cef57 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 65e6eb6fdd89bcd5857890477dd7a412f4d78e22 +Subproject commit 93b47d14cef5720bba7cfb4dcb8078fbf1f706c1 From 9b91b877ad333af04886b9d9bd73b45c8cf8b88f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 27 Sep 2017 15:36:38 -0700 Subject: [PATCH 70/77] Update the Cargo submodule --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 8118b02ac5ce4..e447ac7e94b7f 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 8118b02ac5ce49b22e049ff03316d5e1574852cf +Subproject commit e447ac7e94b7f56ab13e361f9e324dafe3eb0a34 From 041d3550f6d963144722094edfccb3e4e3b74114 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 27 Sep 2017 15:37:02 -0700 Subject: [PATCH 71/77] Update some minor dependencies --- src/Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 0bbc2314d10b7..a8def85baebe6 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -398,7 +398,7 @@ dependencies = [ "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -950,7 +950,7 @@ dependencies = [ "handlebars 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1092,7 +1092,7 @@ version = "0.1.0" [[package]] name = "open" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1975,7 +1975,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "socket2" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2563,7 +2563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum num-rational 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "288629c76fac4b33556f4b7ab57ba21ae202da65ba8b77466e6d598e31990790" "checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0" "checksum num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aec53c34f2d0247c5ca5d32cca1478762f301740468ee9ee6dcb7a0dd7a0c584" -"checksum open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3478ed1686bd1300c8a981a940abc92b06fac9cbef747f4c668d4e032ff7b842" +"checksum open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c281318d992e4432cfa799969467003d05921582a7489a8325e37f8a450d5113" "checksum openssl 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "816914b22eb15671d62c73442a51978f311e911d6a6f6cbdafa6abce1b5038fc" "checksum openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d98df0270d404ccd3c050a41d579c52d1db15375168bb3471e04ec0f5f378daf" "checksum openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4c63a7d559c1e5afa6d6a9e6fa34bbc5f800ffc9ae08b72c605420b0c4f5e8" @@ -2610,7 +2610,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5cc96481d54583947bfe88bf30c23d53f883c6cd0145368b69989d97b84ef8" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum smallvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f8266519bc1d17d0b5b16f6c21295625d562841c708f6376f49028a43e9c11e" -"checksum socket2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4daf80fcf54186fac4fe049e0b39d36a5cfde69a11a06413e61e77f553cccf9a" +"checksum socket2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9e76b159741052c7deaa9fd0b5ca6b5f79cecf525ed665abfe5002086c6b2791" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum string_cache 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "413fc7852aeeb5472f1986ef755f561ddf0c789d3d796e65f0b6fe293ecd4ef8" "checksum string_cache_codegen 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "479cde50c3539481f33906a387f2bd17c8e87cb848c35b6021d41fb81ff9b4d7" From 20fc2153239ef0dd2eeb23a8ee30d0c9843000b3 Mon Sep 17 00:00:00 2001 From: Havvy Date: Thu, 28 Sep 2017 01:30:25 -0700 Subject: [PATCH 72/77] Normalize spaces in lang attributes. --- src/libcore/marker.rs | 2 +- src/libcore/ops/unsize.rs | 2 +- src/libcore/ptr.rs | 2 +- src/rtstartup/rsbegin.rs | 2 +- src/rtstartup/rsend.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index e8fd729b638be..f56a9a4033298 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -122,7 +122,7 @@ pub trait Sized { /// [RFC982]: https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md /// [nomicon-coerce]: ../../nomicon/coercions.html #[unstable(feature = "unsize", issue = "27732")] -#[lang="unsize"] +#[lang = "unsize"] pub trait Unsize { // Empty. } diff --git a/src/libcore/ops/unsize.rs b/src/libcore/ops/unsize.rs index 58da290cfb694..cd896859b16bc 100644 --- a/src/libcore/ops/unsize.rs +++ b/src/libcore/ops/unsize.rs @@ -42,7 +42,7 @@ use marker::Unsize; /// [unsize]: ../marker/trait.Unsize.html /// [nomicon-coerce]: ../../nomicon/coercions.html #[unstable(feature = "coerce_unsized", issue = "27732")] -#[lang="coerce_unsized"] +#[lang = "coerce_unsized"] pub trait CoerceUnsized { // Empty. } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 4041a3760e5ca..34d310446536d 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -56,7 +56,7 @@ pub use intrinsics::write_bytes; /// This has all the same safety problems as `ptr::read` with respect to /// invalid pointers, types, and double drops. #[stable(feature = "drop_in_place", since = "1.8.0")] -#[lang="drop_in_place"] +#[lang = "drop_in_place"] #[allow(unconditional_recursion)] pub unsafe fn drop_in_place(to_drop: *mut T) { // Code here does not matter - this is replaced by the diff --git a/src/rtstartup/rsbegin.rs b/src/rtstartup/rsbegin.rs index 335817fddbbe2..8733c7436d5bd 100644 --- a/src/rtstartup/rsbegin.rs +++ b/src/rtstartup/rsbegin.rs @@ -38,7 +38,7 @@ trait Copy {} trait Freeze {} impl Freeze for .. {} -#[lang="drop_in_place"] +#[lang = "drop_in_place"] #[inline] #[allow(unconditional_recursion)] pub unsafe fn drop_in_place(to_drop: *mut T) { diff --git a/src/rtstartup/rsend.rs b/src/rtstartup/rsend.rs index 9229b4e31289f..a6aed3540ddbb 100644 --- a/src/rtstartup/rsend.rs +++ b/src/rtstartup/rsend.rs @@ -25,7 +25,7 @@ trait Copy {} trait Freeze {} impl Freeze for .. {} -#[lang="drop_in_place"] +#[lang = "drop_in_place"] #[inline] #[allow(unconditional_recursion)] pub unsafe fn drop_in_place(to_drop: *mut T) { From 7694ca419b3ade48e22982b69dec90eb45d8da73 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 22 Sep 2017 21:34:27 -0700 Subject: [PATCH 73/77] Update to the `cc` crate This is the name the `gcc` crate has moved to --- src/Cargo.lock | 20 +++++++++++-------- src/Cargo.toml | 1 + src/bootstrap/Cargo.toml | 2 +- src/bootstrap/bin/sccache-plus-cl.rs | 4 ++-- src/bootstrap/{cc.rs => cc_detect.rs} | 10 +++++----- src/bootstrap/lib.rs | 12 ++++++------ src/bootstrap/native.rs | 4 ++-- src/bootstrap/tool.rs | 4 ++++ src/liballoc_jemalloc/Cargo.toml | 2 +- src/liballoc_jemalloc/build.rs | 6 +++--- src/libprofiler_builtins/Cargo.toml | 2 +- src/libprofiler_builtins/build.rs | 4 ++-- src/librustc/session/config.rs | 28 +++++++++++++-------------- src/librustc_llvm/Cargo.toml | 2 +- src/librustc_llvm/build.rs | 4 ++-- src/librustc_trans/Cargo.toml | 2 +- src/librustc_trans/back/link.rs | 2 +- src/librustc_trans/lib.rs | 2 +- src/librustdoc/Cargo.toml | 2 +- src/librustdoc/build.rs | 4 ++-- src/libstd/Cargo.toml | 2 +- src/libstd/build.rs | 4 ++-- 22 files changed, 66 insertions(+), 57 deletions(-) rename src/bootstrap/{cc.rs => cc_detect.rs} (96%) diff --git a/src/Cargo.lock b/src/Cargo.lock index a8def85baebe6..c77be5154d3db 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -42,8 +42,8 @@ dependencies = [ "alloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.0.0", ] @@ -136,9 +136,9 @@ name = "bootstrap" version = "0.0.0" dependencies = [ "build_helper 0.1.0", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1221,8 +1221,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "profiler_builtins" version = "0.0.0" dependencies = [ + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1628,7 +1628,7 @@ version = "0.0.0" dependencies = [ "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "build_helper 0.1.0", - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_cratesio_shim 0.0.0", ] @@ -1759,8 +1759,8 @@ name = "rustc_trans" version = "0.0.0" dependencies = [ "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1786,7 +1786,7 @@ name = "rustc_trans_utils" version = "0.0.0" dependencies = [ "ar 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", @@ -1828,8 +1828,8 @@ name = "rustdoc" version = "0.0.0" dependencies = [ "build_helper 0.1.0", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "html-diff 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1998,10 +1998,10 @@ dependencies = [ "alloc_jemalloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", + "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "collections 0.0.0", "compiler_builtins 0.0.0", "core 0.0.0", - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.0.0", "panic_abort 0.0.0", "panic_unwind 0.0.0", @@ -2320,6 +2320,10 @@ name = "unicode-xid" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicødë" +version = "0.1.0" + [[package]] name = "unreachable" version = "0.1.1" diff --git a/src/Cargo.toml b/src/Cargo.toml index 2208f38963852..f4b4189e01f06 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -38,6 +38,7 @@ members = [ "tools/rls/test_data/infer_custom_bin", "tools/rls/test_data/infer_lib", "tools/rls/test_data/omit_init_build", + "tools/rls/test_data/unicødë", "tools/rls/test_data/workspace_symbol", ] diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 85e3b65c1953c..3f1d03b187203 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -34,7 +34,7 @@ cmake = "0.1.23" filetime = "0.1" num_cpus = "1.0" getopts = "0.2" -gcc = "0.3.54" +cc = "1.0" libc = "0.2" serde = "1.0.8" serde_derive = "1.0.8" diff --git a/src/bootstrap/bin/sccache-plus-cl.rs b/src/bootstrap/bin/sccache-plus-cl.rs index 266dffa5c92c7..8584014d48d5f 100644 --- a/src/bootstrap/bin/sccache-plus-cl.rs +++ b/src/bootstrap/bin/sccache-plus-cl.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate gcc; +extern crate cc; use std::env; use std::process::{self, Command}; @@ -18,7 +18,7 @@ fn main() { // Locate the actual compiler that we're invoking env::remove_var("CC"); env::remove_var("CXX"); - let mut cfg = gcc::Build::new(); + let mut cfg = cc::Build::new(); cfg.cargo_metadata(false) .out_dir("/") .target(&target) diff --git a/src/bootstrap/cc.rs b/src/bootstrap/cc_detect.rs similarity index 96% rename from src/bootstrap/cc.rs rename to src/bootstrap/cc_detect.rs index c77e609d70be0..08df65c761182 100644 --- a/src/bootstrap/cc.rs +++ b/src/bootstrap/cc_detect.rs @@ -23,7 +23,7 @@ //! 6. "cc" //! //! Some of this logic is implemented here, but much of it is farmed out to the -//! `gcc` crate itself, so we end up having the same fallbacks as there. +//! `cc` crate itself, so we end up having the same fallbacks as there. //! Similar logic is then used to find a C++ compiler, just some s/cc/c++/ is //! used. //! @@ -35,7 +35,7 @@ use std::process::Command; use std::iter; use build_helper::{cc2ar, output}; -use gcc; +use cc; use Build; use config::Target; @@ -45,7 +45,7 @@ pub fn find(build: &mut Build) { // For all targets we're going to need a C compiler for building some shims // and such as well as for being a linker for Rust code. for target in build.targets.iter().chain(&build.hosts).cloned().chain(iter::once(build.build)) { - let mut cfg = gcc::Build::new(); + let mut cfg = cc::Build::new(); cfg.cargo_metadata(false).opt_level(0).warnings(false).debug(false) .target(&target).host(&build.build); @@ -67,7 +67,7 @@ pub fn find(build: &mut Build) { // For all host triples we need to find a C++ compiler as well for host in build.hosts.iter().cloned().chain(iter::once(build.build)) { - let mut cfg = gcc::Build::new(); + let mut cfg = cc::Build::new(); cfg.cargo_metadata(false).opt_level(0).warnings(false).debug(false).cpp(true) .target(&host).host(&build.build); let config = build.config.target_config.get(&host); @@ -82,7 +82,7 @@ pub fn find(build: &mut Build) { } } -fn set_compiler(cfg: &mut gcc::Build, +fn set_compiler(cfg: &mut cc::Build, gnu_compiler: &str, target: Interned, config: Option<&Target>, diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 06c7c4c2faffc..83aa08366df7d 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -126,7 +126,7 @@ extern crate lazy_static; extern crate serde_json; extern crate cmake; extern crate filetime; -extern crate gcc; +extern crate cc; extern crate getopts; extern crate num_cpus; extern crate toml; @@ -148,7 +148,7 @@ use build_helper::{run_silent, run_suppressed, try_run_silent, try_run_suppresse use util::{exe, libdir, OutputFolder, CiEnv}; -mod cc; +mod cc_detect; mod channel; mod check; mod clean; @@ -241,9 +241,9 @@ pub struct Build { // Runtime state filled in later on // target -> (cc, ar) - cc: HashMap, (gcc::Tool, Option)>, + cc: HashMap, (cc::Tool, Option)>, // host -> (cc, ar) - cxx: HashMap, gcc::Tool>, + cxx: HashMap, cc::Tool>, crates: HashMap, Crate>, is_sudo: bool, ci_env: CiEnv, @@ -350,7 +350,7 @@ impl Build { } self.verbose("finding compilers"); - cc::find(self); + cc_detect::find(self); self.verbose("running sanity check"); sanity::check(self); // If local-rust is the same major.minor as the current version, then force a local-rebuild @@ -619,7 +619,7 @@ impl Build { /// specified. fn cflags(&self, target: Interned) -> Vec { // Filter out -O and /O (the optimization flags) that we picked up from - // gcc-rs because the build scripts will determine that for themselves. + // cc-rs because the build scripts will determine that for themselves. let mut base = self.cc[&target].0.args().iter() .map(|s| s.to_string_lossy().into_owned()) .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 99077d03dbe03..29376ff25e4af 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -27,7 +27,7 @@ use std::process::Command; use build_helper::output; use cmake; -use gcc; +use cc; use Build; use util; @@ -289,7 +289,7 @@ impl Step for TestHelpers { let _folder = build.fold_output(|| "build_test_helpers"); println!("Building test helpers"); t!(fs::create_dir_all(&dst)); - let mut cfg = gcc::Build::new(); + let mut cfg = cc::Build::new(); // We may have found various cross-compilers a little differently due to our // extra configuration, so inform gcc of these compilers. Note, though, that diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 19879ab2ade37..a05e58e6a2270 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -126,6 +126,10 @@ pub fn prepare_tool_cargo( cargo.env("LIBZ_SYS_STATIC", "1"); } + // if tools are using lzma we want to force the build script to build its + // own copy + cargo.env("LZMA_API_STATIC", "1"); + cargo.env("CFG_RELEASE_CHANNEL", &build.config.channel); cargo.env("CFG_VERSION", build.rust_version()); diff --git a/src/liballoc_jemalloc/Cargo.toml b/src/liballoc_jemalloc/Cargo.toml index 94700cf447535..4042c4d2d4e02 100644 --- a/src/liballoc_jemalloc/Cargo.toml +++ b/src/liballoc_jemalloc/Cargo.toml @@ -19,7 +19,7 @@ libc = { path = "../rustc/libc_shim" } [build-dependencies] build_helper = { path = "../build_helper" } -gcc = "0.3.50" +cc = "1.0" [features] debug = [] diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs index d89d3bcdb62a5..7dd85ddcc7965 100644 --- a/src/liballoc_jemalloc/build.rs +++ b/src/liballoc_jemalloc/build.rs @@ -11,7 +11,7 @@ #![deny(warnings)] extern crate build_helper; -extern crate gcc; +extern crate cc; use std::env; use std::path::PathBuf; @@ -63,7 +63,7 @@ fn main() { _ => return, }; - let compiler = gcc::Build::new().get_compiler(); + let compiler = cc::Build::new().get_compiler(); // only msvc returns None for ar so unwrap is okay let ar = build_helper::cc2ar(compiler.path(), &target).unwrap(); let cflags = compiler.args() @@ -150,7 +150,7 @@ fn main() { // sure the symbols are available. if target.contains("androideabi") { println!("cargo:rerun-if-changed=pthread_atfork_dummy.c"); - gcc::Build::new() + cc::Build::new() .flag("-fvisibility=hidden") .file("pthread_atfork_dummy.c") .compile("libpthread_atfork_dummy.a"); diff --git a/src/libprofiler_builtins/Cargo.toml b/src/libprofiler_builtins/Cargo.toml index a60db3136797a..eb31f5730d191 100644 --- a/src/libprofiler_builtins/Cargo.toml +++ b/src/libprofiler_builtins/Cargo.toml @@ -15,4 +15,4 @@ doc = false core = { path = "../libcore" } [build-dependencies] -gcc = "0.3.50" +cc = "1.0" diff --git a/src/libprofiler_builtins/build.rs b/src/libprofiler_builtins/build.rs index 41e92b33475da..8508b2dae2c56 100644 --- a/src/libprofiler_builtins/build.rs +++ b/src/libprofiler_builtins/build.rs @@ -12,14 +12,14 @@ //! //! See the build.rs for libcompiler_builtins crate for details. -extern crate gcc; +extern crate cc; use std::env; use std::path::Path; fn main() { let target = env::var("TARGET").expect("TARGET was not set"); - let cfg = &mut gcc::Build::new(); + let cfg = &mut cc::Build::new(); let mut profile_sources = vec!["GCDAProfiling.c", "InstrProfiling.c", diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index d3256357941f3..b1bf893cfd8be 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1373,20 +1373,20 @@ pub fn rustc_optgroups() -> Vec { always = always colorize output; never = never colorize output", "auto|always|never"), - opt::flagopt("", "pretty", - "Pretty-print the input instead of compiling; - valid types are: `normal` (un-annotated source), - `expanded` (crates expanded), or - `expanded,identified` (fully parenthesized, AST nodes with IDs).", - "TYPE"), - opt::flagopt("", "unpretty", - "Present the input source, unstable (and less-pretty) variants; - valid types are any of the types for `--pretty`, as well as: - `flowgraph=` (graphviz formatted flowgraph for node), - `everybody_loops` (all function bodies replaced with `loop {}`), - `hir` (the HIR), `hir,identified`, or - `hir,typed` (HIR with types for each node).", - "TYPE"), + opt::opt("", "pretty", + "Pretty-print the input instead of compiling; + valid types are: `normal` (un-annotated source), + `expanded` (crates expanded), or + `expanded,identified` (fully parenthesized, AST nodes with IDs).", + "TYPE"), + opt::opt("", "unpretty", + "Present the input source, unstable (and less-pretty) variants; + valid types are any of the types for `--pretty`, as well as: + `flowgraph=` (graphviz formatted flowgraph for node), + `everybody_loops` (all function bodies replaced with `loop {}`), + `hir` (the HIR), `hir,identified`, or + `hir,typed` (HIR with types for each node).", + "TYPE"), ]); opts } diff --git a/src/librustc_llvm/Cargo.toml b/src/librustc_llvm/Cargo.toml index 1ed2cbab65fc4..de5add56b761d 100644 --- a/src/librustc_llvm/Cargo.toml +++ b/src/librustc_llvm/Cargo.toml @@ -18,4 +18,4 @@ rustc_cratesio_shim = { path = "../librustc_cratesio_shim" } [build-dependencies] build_helper = { path = "../build_helper" } -gcc = "0.3.50" +cc = "1.0" diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 393aa7fa43bab..dde7a38efc796 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate gcc; +extern crate cc; extern crate build_helper; use std::process::Command; @@ -136,7 +136,7 @@ fn main() { let mut cmd = Command::new(&llvm_config); cmd.arg("--cxxflags"); let cxxflags = output(&mut cmd); - let mut cfg = gcc::Build::new(); + let mut cfg = cc::Build::new(); cfg.warnings(false); for flag in cxxflags.split_whitespace() { // Ignore flags like `-m64` when we're doing a cross build diff --git a/src/librustc_trans/Cargo.toml b/src/librustc_trans/Cargo.toml index 6f1f5b4a123d8..482350d04b5a7 100644 --- a/src/librustc_trans/Cargo.toml +++ b/src/librustc_trans/Cargo.toml @@ -32,4 +32,4 @@ syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } [target."cfg(windows)".dependencies] -gcc = "0.3.50" +cc = "1.0" diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 1630e7759919c..39a9ccd8eb9b7 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -125,7 +125,7 @@ pub fn get_linker(sess: &Session) -> (String, Command, Vec<(OsString, OsString)> #[cfg(windows)] pub fn msvc_link_exe_cmd(sess: &Session) -> (Command, Vec<(OsString, OsString)>) { - use gcc::windows_registry; + use cc::windows_registry; let target = &sess.opts.target_triple; let tool = windows_registry::find_tool(target, "link.exe"); diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 8a2c478cea061..796dfd4417c6a 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -61,7 +61,7 @@ extern crate syntax_pos; extern crate rustc_errors as errors; extern crate serialize; #[cfg(windows)] -extern crate gcc; // Used to locate MSVC, not gcc :) +extern crate cc; // Used to locate MSVC pub use base::trans_crate; diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 61ac541e2c139..b295b414a035b 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -18,4 +18,4 @@ html-diff = "0.0.4" [build-dependencies] build_helper = { path = "../build_helper" } -gcc = "0.3.50" +cc = "1.0" diff --git a/src/librustdoc/build.rs b/src/librustdoc/build.rs index 830492dec9482..97c9ca1e2d27c 100644 --- a/src/librustdoc/build.rs +++ b/src/librustdoc/build.rs @@ -9,12 +9,12 @@ // except according to those terms. extern crate build_helper; -extern crate gcc; +extern crate cc; fn main() { let src_dir = std::path::Path::new("../rt/hoedown/src"); build_helper::rerun_if_changed_anything_in_dir(src_dir); - let mut cfg = gcc::Build::new(); + let mut cfg = cc::Build::new(); cfg.file("../rt/hoedown/src/autolink.c") .file("../rt/hoedown/src/buffer.c") .file("../rt/hoedown/src/document.c") diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 09c168169348b..fb276448ffac4 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -36,7 +36,7 @@ rustc_tsan = { path = "../librustc_tsan" } [build-dependencies] build_helper = { path = "../build_helper" } -gcc = "0.3.50" +cc = "1.0" [features] backtrace = [] diff --git a/src/libstd/build.rs b/src/libstd/build.rs index b8061665aa164..7ca762c801a81 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -11,7 +11,7 @@ #![deny(warnings)] extern crate build_helper; -extern crate gcc; +extern crate cc; use std::env; use std::process::Command; @@ -77,7 +77,7 @@ fn main() { fn build_libbacktrace(host: &str, target: &str) -> Result<(), ()> { let native = native_lib_boilerplate("libbacktrace", "libbacktrace", "backtrace", ".libs")?; - let compiler = gcc::Build::new().get_compiler(); + let compiler = cc::Build::new().get_compiler(); // only msvc returns None for ar so unwrap is okay let ar = build_helper::cc2ar(compiler.path(), target).unwrap(); let mut cflags = compiler.args().iter().map(|s| s.to_str().unwrap()) From 3457a22d9151806d2af401a94076cb55d88ac8c8 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Tue, 5 Sep 2017 13:08:02 -0500 Subject: [PATCH 74/77] ci: Fix building disabled containers * Change the context into the disabled directory. Now you can test containers which are disabled. --- src/ci/docker/disabled/aarch64-gnu/Dockerfile | 2 +- src/ci/docker/disabled/wasm32-exp/Dockerfile | 2 +- src/ci/docker/run.sh | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ci/docker/disabled/aarch64-gnu/Dockerfile b/src/ci/docker/disabled/aarch64-gnu/Dockerfile index 9a0e45312235e..fedb4094c8aaa 100644 --- a/src/ci/docker/disabled/aarch64-gnu/Dockerfile +++ b/src/ci/docker/disabled/aarch64-gnu/Dockerfile @@ -31,7 +31,7 @@ WORKDIR /build # The `config` config file was a previously generated config file for # the kernel. This file was generated by running `make defconfig` # followed by `make menuconfig` and then enabling the IPv6 protocol page. -COPY disabled/aarch64-gnu/config /build/.config +COPY aarch64-gnu/config /build/.config RUN curl https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.42.tar.xz | \ tar xJf - && \ cd /build/linux-4.4.42 && \ diff --git a/src/ci/docker/disabled/wasm32-exp/Dockerfile b/src/ci/docker/disabled/wasm32-exp/Dockerfile index 6323369421bb4..8653b0e8b465e 100644 --- a/src/ci/docker/disabled/wasm32-exp/Dockerfile +++ b/src/ci/docker/disabled/wasm32-exp/Dockerfile @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # emscripten COPY scripts/emscripten-wasm.sh /scripts/ -COPY disabled/wasm32-exp/node.sh /usr/local/bin/node +COPY wasm32-exp/node.sh /usr/local/bin/node RUN bash /scripts/emscripten-wasm.sh # cache diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 5eba81ff60a22..e4f63149278b1 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -36,12 +36,14 @@ elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then echo Cannot run disabled images on travis! exit 1 fi - retry docker \ + # retry messes with the pipe from tar to docker. Not needed on non-travis + # Transform changes the context of disabled Dockerfiles to match the enabled ones + tar --transform 's#^./disabled/#./#' -C $docker_dir -c . | docker \ build \ --rm \ -t rust-ci \ - -f "$docker_dir/disabled/$image/Dockerfile" \ - "$docker_dir" + -f "$image/Dockerfile" \ + - else echo Invalid image: $image exit 1 From 1a29e822274c69efbf2b8177e7702a4136897050 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Thu, 28 Sep 2017 23:46:19 -0700 Subject: [PATCH 75/77] Remove conflicting TryFrom impls on 32-bit targets. --- src/libcore/num/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index cfa22360e9e17..6489d0d192a2e 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2664,12 +2664,12 @@ mod ptr_try_from_impls { try_from_both_bounded!(isize, i8, i16); try_from_unbounded!(isize, i32, i64, i128); - rev!(try_from_unbounded, usize, u8, u16, u32); + rev!(try_from_unbounded, usize, u16, u32); rev!(try_from_upper_bounded, usize, u64, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32); rev!(try_from_both_bounded, usize, i64, i128); - rev!(try_from_unbounded, isize, u8, u16); + rev!(try_from_unbounded, isize, u16); rev!(try_from_upper_bounded, isize, u32, u64, u128); rev!(try_from_unbounded, isize, i8, i16, i32); rev!(try_from_both_bounded, isize, i64, i128); From 966cf339cbf83500775e195c23d420582c9d0f48 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Fri, 29 Sep 2017 14:04:28 -0700 Subject: [PATCH 76/77] Simplify implementation of From for TryFromIntError. --- src/libcore/num/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 6489d0d192a2e..0b226f84eabfb 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2505,8 +2505,9 @@ impl fmt::Display for TryFromIntError { #[unstable(feature = "try_from", issue = "33417")] impl From for TryFromIntError { - fn from(_: Infallible) -> TryFromIntError { - TryFromIntError(()) + fn from(infallible: Infallible) -> TryFromIntError { + match infallible { + } } } From 27d95d3645761252caf42c77fc53b76b4278520a Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Fri, 29 Sep 2017 14:10:26 -0700 Subject: [PATCH 77/77] Fix more TryFrom impls for integers. --- src/libcore/num/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 0b226f84eabfb..23538ecab4fa3 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2639,14 +2639,14 @@ mod ptr_try_from_impls { try_from_both_bounded!(isize, i8); try_from_unbounded!(isize, i16, i32, i64, i128); - rev!(try_from_unbounded, usize, u8, u16); + rev!(try_from_unbounded, usize, u16); rev!(try_from_upper_bounded, usize, u32, u64, u128); rev!(try_from_lower_bounded, usize, i8, i16); rev!(try_from_both_bounded, usize, i32, i64, i128); rev!(try_from_unbounded, isize, u8); rev!(try_from_upper_bounded, isize, u16, u32, u64, u128); - rev!(try_from_unbounded, isize, i8, i16); + rev!(try_from_unbounded, isize, i16); rev!(try_from_both_bounded, isize, i32, i64, i128); } @@ -2670,9 +2670,9 @@ mod ptr_try_from_impls { rev!(try_from_lower_bounded, usize, i8, i16, i32); rev!(try_from_both_bounded, usize, i64, i128); - rev!(try_from_unbounded, isize, u16); + rev!(try_from_unbounded, isize, u8, u16); rev!(try_from_upper_bounded, isize, u32, u64, u128); - rev!(try_from_unbounded, isize, i8, i16, i32); + rev!(try_from_unbounded, isize, i16, i32); rev!(try_from_both_bounded, isize, i64, i128); }