From a35cdd4e41a2bec5d8896653f898aaff61cb0106 Mon Sep 17 00:00:00 2001 From: John Downey Date: Wed, 6 Mar 2019 12:17:26 -0600 Subject: [PATCH 01/65] Implement `iter::Sum` and `iter::Product` for `Option` This is similar to the existing implementation for `Result`. It will take each item into the accumulator unless a `None` is returned. --- src/libcore/iter/traits/accum.rs | 113 +++++++++++++++++++++++++++++++ src/libcore/tests/iter.rs | 16 +++++ 2 files changed, 129 insertions(+) diff --git a/src/libcore/iter/traits/accum.rs b/src/libcore/iter/traits/accum.rs index dfe1d2a1006..b67714ca779 100644 --- a/src/libcore/iter/traits/accum.rs +++ b/src/libcore/iter/traits/accum.rs @@ -223,3 +223,116 @@ impl Product> for Result ResultShunt::process(iter, |i| i.product()) } } + +/// An iterator adapter that produces output as long as the underlying +/// iterator produces `Option::Some` values. +struct OptionShunt { + iter: I, + exited_early: bool, +} + +impl OptionShunt +where + I: Iterator>, +{ + /// Process the given iterator as if it yielded a `T` instead of a + /// `Option`. Any `None` value will stop the inner iterator and + /// the overall result will be a `None`. + pub fn process(iter: I, mut f: F) -> Option + where + F: FnMut(&mut Self) -> U, + { + let mut shunt = OptionShunt::new(iter); + let value = f(shunt.by_ref()); + shunt.reconstruct(value) + } + + fn new(iter: I) -> Self { + OptionShunt { + iter, + exited_early: false, + } + } + + /// Consume the adapter and rebuild a `Option` value. + fn reconstruct(self, val: U) -> Option { + if self.exited_early { + None + } else { + Some(val) + } + } +} + +impl Iterator for OptionShunt +where + I: Iterator>, +{ + type Item = T; + + fn next(&mut self) -> Option { + match self.iter.next() { + Some(Some(v)) => Some(v), + Some(None) => { + self.exited_early = true; + None + } + None => None, + } + } + + fn size_hint(&self) -> (usize, Option) { + if self.exited_early { + (0, Some(0)) + } else { + let (_, upper) = self.iter.size_hint(); + (0, upper) + } + } +} + +#[stable(feature = "iter_arith_traits_option", since = "1.34.0")] +impl Sum> for Option +where + T: Sum, +{ + /// Takes each element in the `Iterator`: if it is a `None`, no further + /// elements are taken, and the `None` is returned. Should no `None` occur, + /// the sum of all elements is returned. + /// + /// # Examples + /// + /// This sums up every integer in a vector, rejecting the sum if a negative + /// element is encountered: + /// + /// ``` + /// let v = vec![1, 2]; + /// let res: Option = v.iter().map(|&x: &i32| + /// if x < 0 { None } + /// else { Some(x) } + /// ).sum(); + /// assert_eq!(res, Some(3)); + /// ``` + fn sum(iter: I) -> Option + where + I: Iterator>, + { + OptionShunt::process(iter, |i| i.sum()) + } +} + +#[stable(feature = "iter_arith_traits_option", since = "1.34.0")] +impl Product> for Option +where + T: Product, +{ + /// Takes each element in the `Iterator`: if it is a `None`, no further + /// elements are taken, and the `None` is returned. Should no `None` occur, + /// the product of all elements is returned. + fn product(iter: I) -> Option + where + I: Iterator>, + { + OptionShunt::process(iter, |i| i.product()) + } +} diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index d880abb181c..814f4ec4ca5 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -1066,6 +1066,14 @@ fn test_iterator_sum_result() { assert_eq!(v.iter().cloned().sum::>(), Err(())); } +#[test] +fn test_iterator_sum_option() { + let v: &[Option] = &[Some(1), Some(2), Some(3), Some(4)]; + assert_eq!(v.iter().cloned().sum::>(), Some(10)); + let v: &[Option] = &[Some(1), None, Some(3), Some(4)]; + assert_eq!(v.iter().cloned().sum::>(), None); +} + #[test] fn test_iterator_product() { let v: &[i32] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; @@ -1082,6 +1090,14 @@ fn test_iterator_product_result() { assert_eq!(v.iter().cloned().product::>(), Err(())); } +#[test] +fn test_iterator_product_option() { + let v: &[Option] = &[Some(1), Some(2), Some(3), Some(4)]; + assert_eq!(v.iter().cloned().product::>(), Some(24)); + let v: &[Option] = &[Some(1), None, Some(3), Some(4)]; + assert_eq!(v.iter().cloned().product::>(), None); +} + #[test] fn test_iterator_max() { let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; From 8c698763579d5cf78094d2d4495c3d801ed0d2e7 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 19 Mar 2019 17:17:18 -0500 Subject: [PATCH 02/65] Update stable attribute to be since 1.35.0 Co-Authored-By: jtdowney --- src/libcore/iter/traits/accum.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/iter/traits/accum.rs b/src/libcore/iter/traits/accum.rs index b67714ca779..ae51e1bddac 100644 --- a/src/libcore/iter/traits/accum.rs +++ b/src/libcore/iter/traits/accum.rs @@ -291,7 +291,7 @@ where } } -#[stable(feature = "iter_arith_traits_option", since = "1.34.0")] +#[stable(feature = "iter_arith_traits_option", since = "1.35.0")] impl Sum> for Option where T: Sum, @@ -321,7 +321,7 @@ where } } -#[stable(feature = "iter_arith_traits_option", since = "1.34.0")] +#[stable(feature = "iter_arith_traits_option", since = "1.35.0")] impl Product> for Option where T: Product, From 422a4c07c826fb007f5199031482d5b40d255899 Mon Sep 17 00:00:00 2001 From: John Downey Date: Wed, 20 Mar 2019 20:14:46 -0500 Subject: [PATCH 03/65] Add improved doc example for Sum> --- src/libcore/iter/traits/accum.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/libcore/iter/traits/accum.rs b/src/libcore/iter/traits/accum.rs index ae51e1bddac..88c4820d583 100644 --- a/src/libcore/iter/traits/accum.rs +++ b/src/libcore/iter/traits/accum.rs @@ -302,16 +302,13 @@ where /// /// # Examples /// - /// This sums up every integer in a vector, rejecting the sum if a negative - /// element is encountered: + /// This sums up the position of the character 'a' in a vector of strings, + /// if a word did not have the character 'a' the operation returns `None`: /// /// ``` - /// let v = vec![1, 2]; - /// let res: Option = v.iter().map(|&x: &i32| - /// if x < 0 { None } - /// else { Some(x) } - /// ).sum(); - /// assert_eq!(res, Some(3)); + /// let words = vec!["have", "a", "great", "day"]; + /// let total: Option = words.iter().map(|w| w.find('a')).sum(); + /// assert_eq!(total, Some(5)); /// ``` fn sum(iter: I) -> Option where From 4d9b9e9038102ada95d1898d303038803d752f62 Mon Sep 17 00:00:00 2001 From: "@amit.chandra" <@amit.chandra> Date: Fri, 26 Apr 2019 19:53:18 +0530 Subject: [PATCH 04/65] wip nth_back on chunks Signed-off-by: wizAmit --- src/libcore/slice/mod.rs | 16 ++++++++++++++++ src/libcore/tests/slice.rs | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 8731f486753..049d38c158c 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4152,6 +4152,22 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { Some(snd) } } + + #[inline] + fn nth_back(&mut self, n: usize) { + let (end, overflow) = self.v.len().overflowing_sub(n); + if end < self.v.len() || overflow { + self.v = &[]; + None + } else { + let start = match end.checked_sub(self.chunk_size) { + Some(sum) => cmp::min(self.v.len(), sum), + None => self.v.len(), + }; + let nth = &self.v[start..end]; + self.v = &self.v[end..]; + } + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index acf6b03791f..0233b96d3a7 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -134,6 +134,19 @@ fn test_chunks_nth() { assert_eq!(c2.next(), None); } +#[test] +fn test_chunks_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.chunks(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[4, 5]); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.chunks(3); + assert_eq!(c2.nth_back(1).unwrap(), &[0, 1]); + assert_eq!(c2.next(), None); +} + #[test] fn test_chunks_last() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; From 73ca8bc140d4b0935ecb0199ea65723ec6a6791f Mon Sep 17 00:00:00 2001 From: "@amit.chandra" <@amit.chandra> Date: Wed, 1 May 2019 23:34:07 +0530 Subject: [PATCH 05/65] hopefully working nth_back on chunks Signed-off-by: wizAmit --- src/libcore/slice/mod.rs | 17 +++++++++-------- src/libcore/tests/slice.rs | 9 ++++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 049d38c158c..00dbe7104d1 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4154,18 +4154,19 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { } #[inline] - fn nth_back(&mut self, n: usize) { - let (end, overflow) = self.v.len().overflowing_sub(n); - if end < self.v.len() || overflow { - self.v = &[]; + fn nth_back(&mut self, n: usize) -> Option { + let (end, overflow) = self.v.len().overflowing_sub(n * self.chunk_size); + if overflow { + self.v = &mut []; None } else { let start = match end.checked_sub(self.chunk_size) { - Some(sum) => cmp::min(self.v.len(), sum), - None => self.v.len(), + Some(res) => cmp::min(self.v.len(), res), + None => 0, }; - let nth = &self.v[start..end]; - self.v = &self.v[end..]; + let nth_back = &self.v[start..end]; + self.v = &self.v[..start]; + Some(nth_back) } } } diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 0233b96d3a7..edea405fad7 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -139,12 +139,19 @@ fn test_chunks_nth_back() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; let mut c = v.chunks(2); assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); - assert_eq!(c.next().unwrap(), &[4, 5]); + assert_eq!(c.next().unwrap(), &[0, 1]); + assert_eq!(c.next(), None); let v2: &[i32] = &[0, 1, 2, 3, 4]; let mut c2 = v2.chunks(3); assert_eq!(c2.nth_back(1).unwrap(), &[0, 1]); assert_eq!(c2.next(), None); + assert_eq!(c2.next_back(), None); + + let v3: &[i32] = &[0, 1, 2, 3, 4]; + let mut c3 = v3.chunks(10); + assert_eq!(c3.nth_back(0).unwrap(), &[0, 1, 2, 3, 4]); + assert_eq!(c3.next(), None); } #[test] From 5eb0e08d0feab69f9e5f3b6881bde328a9105c96 Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Sun, 5 May 2019 11:21:30 +0200 Subject: [PATCH 06/65] Implement nth_back for RChunks(Exact)(Mut) --- src/libcore/slice/mod.rs | 72 ++++++++++++++++++++++++++++++++++++++ src/libcore/tests/slice.rs | 52 +++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 8731f486753..f7a7976faec 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4643,6 +4643,23 @@ impl<'a, T> DoubleEndedIterator for RChunks<'a, T> { Some(fst) } } + + #[inline] + fn nth_back(&mut self, n: usize) -> Option { + let len = self.len(); + if n >= len { + self.v = &[]; + None + } else { + // can't underflow because `n < len` + let offset_from_end = (len - 1 - n) * self.chunk_size; + let end = self.v.len() - offset_from_end; + let start = end.saturating_sub(self.chunk_size); + let nth_back = &self.v[start..end]; + self.v = &self.v[end..]; + Some(nth_back) + } + } } #[stable(feature = "rchunks", since = "1.31.0")] @@ -4768,6 +4785,24 @@ impl<'a, T> DoubleEndedIterator for RChunksMut<'a, T> { Some(head) } } + + #[inline] + fn nth_back(&mut self, n: usize) -> Option { + let len = self.len(); + if n >= len { + self.v = &mut []; + None + } else { + // can't underflow because `n < len` + let offset_from_end = (len - 1 - n) * self.chunk_size; + let end = self.v.len() - offset_from_end; + let start = end.saturating_sub(self.chunk_size); + let (tmp, tail) = mem::replace(&mut self.v, &mut []).split_at_mut(end); + let (_, nth_back) = tmp.split_at_mut(start); + self.v = tail; + Some(nth_back) + } + } } #[stable(feature = "rchunks", since = "1.31.0")] @@ -4892,6 +4927,24 @@ impl<'a, T> DoubleEndedIterator for RChunksExact<'a, T> { Some(fst) } } + + #[inline] + fn nth_back(&mut self, n: usize) -> Option { + let len = self.len(); + if n >= len { + self.v = &[]; + None + } else { + // now that we know that `n` corresponds to a chunk, + // none of these operations can underflow/overflow + let offset = (len - n) * self.chunk_size; + let start = self.v.len() - offset; + let end = start + self.chunk_size; + let nth_back = &self.v[start..end]; + self.v = &self.v[end..]; + Some(nth_back) + } + } } #[stable(feature = "rchunks", since = "1.31.0")] @@ -5010,6 +5063,25 @@ impl<'a, T> DoubleEndedIterator for RChunksExactMut<'a, T> { Some(head) } } + + #[inline] + fn nth_back(&mut self, n: usize) -> Option { + let len = self.len(); + if n >= len { + self.v = &mut []; + None + } else { + // now that we know that `n` corresponds to a chunk, + // none of these operations can underflow/overflow + let offset = (len - n) * self.chunk_size; + let start = self.v.len() - offset; + let end = start + self.chunk_size; + let (tmp, tail) = mem::replace(&mut self.v, &mut []).split_at_mut(end); + let (_, nth_back) = tmp.split_at_mut(start); + self.v = tail; + Some(nth_back) + } + } } #[stable(feature = "rchunks", since = "1.31.0")] diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index acf6b03791f..cd520a052a0 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -356,6 +356,19 @@ fn test_rchunks_nth() { assert_eq!(c2.next(), None); } +#[test] +fn test_rchunks_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.rchunks(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next_back().unwrap(), &[4, 5]); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.rchunks(3); + assert_eq!(c2.nth_back(1).unwrap(), &[2, 3, 4]); + assert_eq!(c2.next_back(), None); +} + #[test] fn test_rchunks_last() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; @@ -407,6 +420,19 @@ fn test_rchunks_mut_nth() { assert_eq!(c2.next(), None); } +#[test] +fn test_rchunks_mut_nth_back() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let mut c = v.rchunks_mut(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next_back().unwrap(), &[4, 5]); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let mut c2 = v2.rchunks_mut(3); + assert_eq!(c2.nth_back(1).unwrap(), &[2, 3, 4]); + assert_eq!(c2.next_back(), None); +} + #[test] fn test_rchunks_mut_last() { let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; @@ -460,6 +486,19 @@ fn test_rchunks_exact_nth() { assert_eq!(c2.next(), None); } +#[test] +fn test_rchunks_exact_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.rchunks_exact(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next_back().unwrap(), &[4, 5]); + + let v2: &[i32] = &[0, 1, 2, 3, 4, 5, 6]; + let mut c2 = v2.rchunks_exact(3); + assert_eq!(c2.nth_back(1).unwrap(), &[4, 5, 6]); + assert_eq!(c2.next(), None); +} + #[test] fn test_rchunks_exact_last() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; @@ -518,6 +557,19 @@ fn test_rchunks_exact_mut_nth() { assert_eq!(c2.next(), None); } +#[test] +fn test_rchunks_exact_mut_nth_back() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let mut c = v.rchunks_exact_mut(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next_back().unwrap(), &[4, 5]); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4, 5, 6]; + let mut c2 = v2.rchunks_exact_mut(3); + assert_eq!(c2.nth_back(1).unwrap(), &[4, 5, 6]); + assert_eq!(c2.next(), None); +} + #[test] fn test_rchunks_exact_mut_last() { let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; From 02a148dba261439626c5020a7cbb15e690521e87 Mon Sep 17 00:00:00 2001 From: "@amit.chandra" <@amit.chandra> Date: Fri, 26 Apr 2019 19:53:18 +0530 Subject: [PATCH 07/65] wip nth_back on chunks Signed-off-by: wizAmit --- src/libcore/slice/mod.rs | 16 ++++++++++++++++ src/libcore/tests/slice.rs | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 8731f486753..049d38c158c 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4152,6 +4152,22 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { Some(snd) } } + + #[inline] + fn nth_back(&mut self, n: usize) { + let (end, overflow) = self.v.len().overflowing_sub(n); + if end < self.v.len() || overflow { + self.v = &[]; + None + } else { + let start = match end.checked_sub(self.chunk_size) { + Some(sum) => cmp::min(self.v.len(), sum), + None => self.v.len(), + }; + let nth = &self.v[start..end]; + self.v = &self.v[end..]; + } + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index acf6b03791f..0233b96d3a7 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -134,6 +134,19 @@ fn test_chunks_nth() { assert_eq!(c2.next(), None); } +#[test] +fn test_chunks_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.chunks(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[4, 5]); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.chunks(3); + assert_eq!(c2.nth_back(1).unwrap(), &[0, 1]); + assert_eq!(c2.next(), None); +} + #[test] fn test_chunks_last() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; From aff83c80dd162b43a301e2bea73762cc4560f0f3 Mon Sep 17 00:00:00 2001 From: "@amit.chandra" <@amit.chandra> Date: Wed, 1 May 2019 23:34:07 +0530 Subject: [PATCH 08/65] hopefully working nth_back on chunks Signed-off-by: wizAmit --- src/libcore/slice/mod.rs | 17 +++++++++-------- src/libcore/tests/slice.rs | 9 ++++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 049d38c158c..00dbe7104d1 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4154,18 +4154,19 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { } #[inline] - fn nth_back(&mut self, n: usize) { - let (end, overflow) = self.v.len().overflowing_sub(n); - if end < self.v.len() || overflow { - self.v = &[]; + fn nth_back(&mut self, n: usize) -> Option { + let (end, overflow) = self.v.len().overflowing_sub(n * self.chunk_size); + if overflow { + self.v = &mut []; None } else { let start = match end.checked_sub(self.chunk_size) { - Some(sum) => cmp::min(self.v.len(), sum), - None => self.v.len(), + Some(res) => cmp::min(self.v.len(), res), + None => 0, }; - let nth = &self.v[start..end]; - self.v = &self.v[end..]; + let nth_back = &self.v[start..end]; + self.v = &self.v[..start]; + Some(nth_back) } } } diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 0233b96d3a7..edea405fad7 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -139,12 +139,19 @@ fn test_chunks_nth_back() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; let mut c = v.chunks(2); assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); - assert_eq!(c.next().unwrap(), &[4, 5]); + assert_eq!(c.next().unwrap(), &[0, 1]); + assert_eq!(c.next(), None); let v2: &[i32] = &[0, 1, 2, 3, 4]; let mut c2 = v2.chunks(3); assert_eq!(c2.nth_back(1).unwrap(), &[0, 1]); assert_eq!(c2.next(), None); + assert_eq!(c2.next_back(), None); + + let v3: &[i32] = &[0, 1, 2, 3, 4]; + let mut c3 = v3.chunks(10); + assert_eq!(c3.nth_back(0).unwrap(), &[0, 1, 2, 3, 4]); + assert_eq!(c3.next(), None); } #[test] From 16223e4bea1ecb087c60d2ac1aeb16c7b7033d52 Mon Sep 17 00:00:00 2001 From: wizAmit Date: Tue, 14 May 2019 13:28:43 +0530 Subject: [PATCH 09/65] new implementation for nth_back for chunks --- src/libcore/slice/mod.rs | 27 ++++++++++++++++++++++----- src/libcore/tests/slice.rs | 6 +++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 00dbe7104d1..72a54c5ce82 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4155,15 +4155,32 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { #[inline] fn nth_back(&mut self, n: usize) -> Option { - let (end, overflow) = self.v.len().overflowing_sub(n * self.chunk_size); + let remainder = match self.v.len().checked_rem(self.chunk_size) { + Some(res) => res, + None => 0, + }; + + let sub_chunk_size = if remainder != 0 { remainder } else { self.chunk_size }; + + let safe_sub = match n.checked_mul(sub_chunk_size) { + Some(res) => res, + None => 0, + }; + + let (end, overflow) = self.v.len().overflowing_sub(safe_sub); if overflow { - self.v = &mut []; + self.v= &[]; None } else { - let start = match end.checked_sub(self.chunk_size) { - Some(res) => cmp::min(self.v.len(), res), - None => 0, + let start = if n == 0 { + self.v.len() - sub_chunk_size + } else { + match end.checked_sub(self.chunk_size) { + Some(res) => res, + None => 0, + } }; + let nth_back = &self.v[start..end]; self.v = &self.v[..start]; Some(nth_back) diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index edea405fad7..cf2602f3210 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -144,7 +144,7 @@ fn test_chunks_nth_back() { let v2: &[i32] = &[0, 1, 2, 3, 4]; let mut c2 = v2.chunks(3); - assert_eq!(c2.nth_back(1).unwrap(), &[0, 1]); + assert_eq!(c2.nth_back(1).unwrap(), &[0, 1, 2]); assert_eq!(c2.next(), None); assert_eq!(c2.next_back(), None); @@ -152,6 +152,10 @@ fn test_chunks_nth_back() { let mut c3 = v3.chunks(10); assert_eq!(c3.nth_back(0).unwrap(), &[0, 1, 2, 3, 4]); assert_eq!(c3.next(), None); + + let v4: &[i32] = &[0, 1, 2]; + let mut c4 = v4.chunks(10); + assert_eq!(c4.nth_back(1_000_000_000usize), None); } #[test] From 9fd4d48b5e12494926041bb1a053d5891e661bc4 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 15 May 2019 11:54:16 +0200 Subject: [PATCH 10/65] Stabilize RefCell::try_borrow_unguarded Servo has been using this since https://github.com/servo/servo/pull/23196 to add a runtime check to some unsafe code, as discussed in PR https://github.com/rust-lang/rust/pull/59211. Stabilizing would help do more of the same in libraries that also have users on Stable. --- src/doc/unstable-book/src/library-features/borrow-state.md | 7 ------- src/libcore/cell.rs | 3 +-- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 src/doc/unstable-book/src/library-features/borrow-state.md diff --git a/src/doc/unstable-book/src/library-features/borrow-state.md b/src/doc/unstable-book/src/library-features/borrow-state.md deleted file mode 100644 index 304b8dffe98..00000000000 --- a/src/doc/unstable-book/src/library-features/borrow-state.md +++ /dev/null @@ -1,7 +0,0 @@ -# `borrow_state` - -The tracking issue for this feature is: [#27733] - -[#27733]: https://github.com/rust-lang/rust/issues/27733 - ------------------------- diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index fcfd80d9266..5fc819f8efc 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -969,7 +969,6 @@ impl RefCell { /// # Examples /// /// ``` - /// #![feature(borrow_state)] /// use std::cell::RefCell; /// /// let c = RefCell::new(5); @@ -984,7 +983,7 @@ impl RefCell { /// assert!(unsafe { c.try_borrow_unguarded() }.is_ok()); /// } /// ``` - #[unstable(feature = "borrow_state", issue = "27733")] + #[stable(feature = "borrow_state", since = "1.37.0")] #[inline] pub unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError> { if !is_writing(self.borrow.get()) { From c95be3d033a72880749813ae0bfc7067437f9c19 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Thu, 16 May 2019 14:32:28 -0400 Subject: [PATCH 11/65] strip synstructure consts from compiler docs --- Cargo.lock | 8 ++++---- src/bootstrap/doc.rs | 2 +- src/librustc_macros/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4417c25abcb..6efce4297dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -835,7 +835,7 @@ dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2849,7 +2849,7 @@ dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3385,7 +3385,7 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4306,7 +4306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" +"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "a303ba60a099fcd2aaa646b14d2724591a96a75283e4b7ed3d1a1658909d9ae2" "checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" "checksum tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9de21546595a0873061940d994bbbc5c35f024ae4fd61ec5c5b159115684f508" diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 9c3a17bff6b..5605ec34083 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -728,7 +728,7 @@ impl Step for Rustc { // Build cargo command. let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc"); - cargo.env("RUSTDOCFLAGS", "--document-private-items"); + cargo.env("RUSTDOCFLAGS", "--document-private-items --passes strip-hidden"); compile::rustc_cargo(builder, &mut cargo); // Only include compiler crates, no dependencies of those, such as `libc`. diff --git a/src/librustc_macros/Cargo.toml b/src/librustc_macros/Cargo.toml index 6e32a53c364..f989ebc6dfd 100644 --- a/src/librustc_macros/Cargo.toml +++ b/src/librustc_macros/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" proc-macro = true [dependencies] -synstructure = "0.10.1" +synstructure = "0.10.2" syn = { version = "0.15.22", features = ["full"] } proc-macro2 = "0.4.24" quote = "0.6.10" From dc82626262605665bbcea8f24925442e48dc897c Mon Sep 17 00:00:00 2001 From: "@amit.chandra" <@amit.chandra> Date: Fri, 26 Apr 2019 19:53:18 +0530 Subject: [PATCH 12/65] wip nth_back on chunks Signed-off-by: wizAmit --- src/libcore/slice/mod.rs | 16 ++++++++++++++++ src/libcore/tests/slice.rs | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index d06d107d32a..54c5285bc49 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4178,6 +4178,22 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { Some(snd) } } + + #[inline] + fn nth_back(&mut self, n: usize) { + let (end, overflow) = self.v.len().overflowing_sub(n); + if end < self.v.len() || overflow { + self.v = &[]; + None + } else { + let start = match end.checked_sub(self.chunk_size) { + Some(sum) => cmp::min(self.v.len(), sum), + None => self.v.len(), + }; + let nth = &self.v[start..end]; + self.v = &self.v[end..]; + } + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index acf6b03791f..0233b96d3a7 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -134,6 +134,19 @@ fn test_chunks_nth() { assert_eq!(c2.next(), None); } +#[test] +fn test_chunks_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.chunks(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[4, 5]); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.chunks(3); + assert_eq!(c2.nth_back(1).unwrap(), &[0, 1]); + assert_eq!(c2.next(), None); +} + #[test] fn test_chunks_last() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; From 2080b86566358dad8cb8c967e321a172a69c49f7 Mon Sep 17 00:00:00 2001 From: "@amit.chandra" <@amit.chandra> Date: Wed, 1 May 2019 23:34:07 +0530 Subject: [PATCH 13/65] hopefully working nth_back on chunks Signed-off-by: wizAmit --- src/libcore/slice/mod.rs | 17 +++++++++-------- src/libcore/tests/slice.rs | 9 ++++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 54c5285bc49..b138ae3449f 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4180,18 +4180,19 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { } #[inline] - fn nth_back(&mut self, n: usize) { - let (end, overflow) = self.v.len().overflowing_sub(n); - if end < self.v.len() || overflow { - self.v = &[]; + fn nth_back(&mut self, n: usize) -> Option { + let (end, overflow) = self.v.len().overflowing_sub(n * self.chunk_size); + if overflow { + self.v = &mut []; None } else { let start = match end.checked_sub(self.chunk_size) { - Some(sum) => cmp::min(self.v.len(), sum), - None => self.v.len(), + Some(res) => cmp::min(self.v.len(), res), + None => 0, }; - let nth = &self.v[start..end]; - self.v = &self.v[end..]; + let nth_back = &self.v[start..end]; + self.v = &self.v[..start]; + Some(nth_back) } } } diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 0233b96d3a7..edea405fad7 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -139,12 +139,19 @@ fn test_chunks_nth_back() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; let mut c = v.chunks(2); assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); - assert_eq!(c.next().unwrap(), &[4, 5]); + assert_eq!(c.next().unwrap(), &[0, 1]); + assert_eq!(c.next(), None); let v2: &[i32] = &[0, 1, 2, 3, 4]; let mut c2 = v2.chunks(3); assert_eq!(c2.nth_back(1).unwrap(), &[0, 1]); assert_eq!(c2.next(), None); + assert_eq!(c2.next_back(), None); + + let v3: &[i32] = &[0, 1, 2, 3, 4]; + let mut c3 = v3.chunks(10); + assert_eq!(c3.nth_back(0).unwrap(), &[0, 1, 2, 3, 4]); + assert_eq!(c3.next(), None); } #[test] From 29a103daa92bb3607fd4cd34169d4ff6170987fa Mon Sep 17 00:00:00 2001 From: "@amit.chandra" <@amit.chandra> Date: Fri, 26 Apr 2019 19:53:18 +0530 Subject: [PATCH 14/65] wip nth_back on chunks Signed-off-by: wizAmit --- src/libcore/slice/mod.rs | 17 ----------------- src/libcore/tests/slice.rs | 19 ------------------- 2 files changed, 36 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index b138ae3449f..d06d107d32a 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4178,23 +4178,6 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { Some(snd) } } - - #[inline] - fn nth_back(&mut self, n: usize) -> Option { - let (end, overflow) = self.v.len().overflowing_sub(n * self.chunk_size); - if overflow { - self.v = &mut []; - None - } else { - let start = match end.checked_sub(self.chunk_size) { - Some(res) => cmp::min(self.v.len(), res), - None => 0, - }; - let nth_back = &self.v[start..end]; - self.v = &self.v[..start]; - Some(nth_back) - } - } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index edea405fad7..1cba4b38382 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -134,25 +134,6 @@ fn test_chunks_nth() { assert_eq!(c2.next(), None); } -#[test] -fn test_chunks_nth_back() { - let v: &[i32] = &[0, 1, 2, 3, 4, 5]; - let mut c = v.chunks(2); - assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); - assert_eq!(c.next().unwrap(), &[0, 1]); - assert_eq!(c.next(), None); - - let v2: &[i32] = &[0, 1, 2, 3, 4]; - let mut c2 = v2.chunks(3); - assert_eq!(c2.nth_back(1).unwrap(), &[0, 1]); - assert_eq!(c2.next(), None); - assert_eq!(c2.next_back(), None); - - let v3: &[i32] = &[0, 1, 2, 3, 4]; - let mut c3 = v3.chunks(10); - assert_eq!(c3.nth_back(0).unwrap(), &[0, 1, 2, 3, 4]); - assert_eq!(c3.next(), None); -} #[test] fn test_chunks_last() { From 9309447397ffcc2f427f850c1a7df8af2c682169 Mon Sep 17 00:00:00 2001 From: wizAmit Date: Wed, 22 May 2019 22:27:30 +0530 Subject: [PATCH 15/65] succint implementation --- src/libcore/slice/mod.rs | 18 ++++++++++++++++++ src/libcore/tests/slice.rs | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index d06d107d32a..8862c0c1cef 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -4178,6 +4178,24 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { Some(snd) } } + + #[inline] + fn nth_back(&mut self, n: usize) -> Option { + let len = self.len(); + if n >= len { + self.v = &[]; + None + } else { + let start = (len - 1 - n) * self.chunk_size; + let end = match start.checked_add(self.chunk_size) { + Some(res) => cmp::min(res, self.v.len()), + None => self.v.len(), + }; + let nth_back = &self.v[start..end]; + self.v = &self.v[..start]; + Some(nth_back) + } + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 1cba4b38382..a4cb0c42044 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -134,6 +134,30 @@ fn test_chunks_nth() { assert_eq!(c2.next(), None); } +#[test] +fn test_chunks_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.chunks(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + assert_eq!(c.next(), None); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.chunks(3); + assert_eq!(c2.nth_back(1).unwrap(), &[0, 1, 2]); + assert_eq!(c2.next(), None); + assert_eq!(c2.next_back(), None); + + let v3: &[i32] = &[0, 1, 2, 3, 4]; + let mut c3 = v3.chunks(10); + assert_eq!(c3.nth_back(0).unwrap(), &[0, 1, 2, 3, 4]); + assert_eq!(c3.next(), None); + + let v4: &[i32] = &[0, 1, 2]; + let mut c4 = v4.chunks(10); + assert_eq!(c4.nth_back(1_000_000_000usize), None); +} + #[test] fn test_chunks_last() { From 89d437ec76cab8153ada936c5d67ef2deb901eb4 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Sat, 4 May 2019 15:37:12 -0400 Subject: [PATCH 16/65] do not print panic message on doctest failures --- src/librustdoc/test.rs | 139 ++++++++++++++---- .../rustdoc-ui/failed-doctest-compile-fail.rs | 11 ++ .../failed-doctest-compile-fail.stdout | 14 ++ .../failed-doctest-missing-codes.rs | 11 ++ .../failed-doctest-missing-codes.stdout | 26 ++++ src/test/rustdoc-ui/failed-doctest-output.rs | 5 +- .../rustdoc-ui/failed-doctest-output.stdout | 32 ++-- .../rustdoc-ui/failed-doctest-should-panic.rs | 11 ++ .../failed-doctest-should-panic.stdout | 14 ++ .../rustdoc-ui/unparseable-doc-test.stdout | 4 +- 10 files changed, 224 insertions(+), 43 deletions(-) create mode 100644 src/test/rustdoc-ui/failed-doctest-compile-fail.rs create mode 100644 src/test/rustdoc-ui/failed-doctest-compile-fail.stdout create mode 100644 src/test/rustdoc-ui/failed-doctest-missing-codes.rs create mode 100644 src/test/rustdoc-ui/failed-doctest-missing-codes.stdout create mode 100644 src/test/rustdoc-ui/failed-doctest-should-panic.rs create mode 100644 src/test/rustdoc-ui/failed-doctest-should-panic.stdout diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index d76d4380755..9d1a0cc074c 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -17,7 +17,7 @@ use std::io::prelude::*; use std::io; use std::panic::{self, AssertUnwindSafe}; use std::path::PathBuf; -use std::process::Command; +use std::process::{self, Command}; use std::str; use std::sync::{Arc, Mutex}; use syntax::symbol::sym; @@ -160,13 +160,45 @@ fn scrape_test_config(krate: &::rustc::hir::Crate) -> TestOptions { opts } -fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, - cfgs: Vec, libs: Vec, - cg: CodegenOptions, externs: Externs, - should_panic: bool, no_run: bool, as_test_harness: bool, - compile_fail: bool, mut error_codes: Vec, opts: &TestOptions, - maybe_sysroot: Option, linker: Option, edition: Edition, - persist_doctests: Option) { +/// Documentation test failure modes. +enum TestFailure { + /// The test failed to compile. + CompileError, + /// The test is marked `compile_fail` but compiled successfully. + UnexpectedCompilePass, + /// The test failed to compile (as expected) but the compiler output did not contain all + /// expected error codes. + MissingErrorCodes(Vec), + /// The test binary was unable to be executed. + ExecutionError(io::Error), + /// The test binary exited with a non-zero exit code. + /// + /// This typically means an assertion in the test failed or another form of panic occurred. + ExecutionFailure(process::Output), + /// The test is marked `should_panic` but the test binary executed successfully. + UnexpectedRunPass, +} + +fn run_test( + test: &str, + cratename: &str, + filename: &FileName, + line: usize, + cfgs: Vec, + libs: Vec, + cg: CodegenOptions, + externs: Externs, + should_panic: bool, + no_run: bool, + as_test_harness: bool, + compile_fail: bool, + mut error_codes: Vec, + opts: &TestOptions, + maybe_sysroot: Option, + linker: Option, + edition: Edition, + persist_doctests: Option, +) -> Result<(), TestFailure> { let (test, line_offset) = match panic::catch_unwind(|| { make_test(test, Some(cratename), as_test_harness, opts, edition) }) { @@ -307,44 +339,43 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, match (compile_result, compile_fail) { (Ok(()), true) => { - panic!("test compiled while it wasn't supposed to") + return Err(TestFailure::UnexpectedCompilePass); } (Ok(()), false) => {} (Err(_), true) => { - if error_codes.len() > 0 { + if !error_codes.is_empty() { let out = String::from_utf8(data.lock().unwrap().to_vec()).unwrap(); error_codes.retain(|err| !out.contains(err)); + + if !error_codes.is_empty() { + return Err(TestFailure::MissingErrorCodes(error_codes)); + } } } (Err(_), false) => { - panic!("couldn't compile the test") + return Err(TestFailure::CompileError); } } - if error_codes.len() > 0 { - panic!("Some expected error codes were not found: {:?}", error_codes); + if no_run { + return Ok(()); } - if no_run { return } - // Run the code! let mut cmd = Command::new(output_file); match cmd.output() { - Err(e) => panic!("couldn't run the test: {}{}", e, - if e.kind() == io::ErrorKind::PermissionDenied { - " - maybe your tempdir is mounted with noexec?" - } else { "" }), + Err(e) => return Err(TestFailure::ExecutionError(e)), Ok(out) => { if should_panic && out.status.success() { - panic!("test executable succeeded when it should have failed"); + return Err(TestFailure::UnexpectedRunPass); } else if !should_panic && !out.status.success() { - panic!("test executable failed:\n{}\n{}\n", - str::from_utf8(&out.stdout).unwrap_or(""), - str::from_utf8(&out.stderr).unwrap_or("")); + return Err(TestFailure::ExecutionFailure(out)); } } } + + Ok(()) } /// Transforms a test into code that can be compiled into a Rust binary, and returns the number of @@ -711,7 +742,7 @@ impl Tester for Collector { allow_fail: config.allow_fail, }, testfn: testing::DynTestFn(box move || { - run_test( + let res = run_test( &test, &cratename, &filename, @@ -730,7 +761,65 @@ impl Tester for Collector { linker, edition, persist_doctests - ) + ); + + if let Err(err) = res { + match err { + TestFailure::CompileError => { + eprint!("Couldn't compile the test."); + } + TestFailure::UnexpectedCompilePass => { + eprint!("Test compiled successfully, but it's marked `compile_fail`."); + } + TestFailure::UnexpectedRunPass => { + eprint!("Test executable succeeded, but it's marked `should_panic`."); + } + TestFailure::MissingErrorCodes(codes) => { + eprint!("Some expected error codes were not found: {:?}", codes); + } + TestFailure::ExecutionError(err) => { + eprint!("Couldn't run the test: {}", err); + if err.kind() == io::ErrorKind::PermissionDenied { + eprint!(" - maybe your tempdir is mounted with noexec?"); + } + } + TestFailure::ExecutionFailure(out) => { + let reason = if let Some(code) = out.status.code() { + format!("exit code {}", code) + } else { + String::from("terminated by signal") + }; + + eprintln!("Test executable failed ({}).", reason); + + // FIXME(#12309): An unfortunate side-effect of capturing the test + // executable's output is that the relative ordering between the test's + // stdout and stderr is lost. However, this is better than the + // alternative: if the test executable inherited the parent's I/O + // handles the output wouldn't be captured at all, even on success. + // + // The ordering could be preserved if the test process' stderr was + // redirected to stdout, but that functionality does not exist in the + // standard library, so it may not be portable enough. + let stdout = str::from_utf8(&out.stdout).unwrap_or_default(); + let stderr = str::from_utf8(&out.stderr).unwrap_or_default(); + + if !stdout.is_empty() || !stderr.is_empty() { + eprintln!(); + + if !stdout.is_empty() { + eprintln!("stdout:\n{}", stdout); + } + + if !stderr.is_empty() { + eprintln!("stderr:\n{}", stderr); + } + } + } + } + + panic::resume_unwind(box ()); + } }), }); } diff --git a/src/test/rustdoc-ui/failed-doctest-compile-fail.rs b/src/test/rustdoc-ui/failed-doctest-compile-fail.rs new file mode 100644 index 00000000000..297d6efd45f --- /dev/null +++ b/src/test/rustdoc-ui/failed-doctest-compile-fail.rs @@ -0,0 +1,11 @@ +// FIXME: if/when the output of the test harness can be tested on its own, this test should be +// adapted to use that, and that normalize line can go away + +// compile-flags:--test +// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" +// failure-status: 101 + +/// ```compile_fail +/// println!("Hello"); +/// ``` +pub struct Foo; diff --git a/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout b/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout new file mode 100644 index 00000000000..74e33d7beeb --- /dev/null +++ b/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout @@ -0,0 +1,14 @@ + +running 1 test +test $DIR/failed-doctest-compile-fail.rs - Foo (line 8) ... FAILED + +failures: + +---- $DIR/failed-doctest-compile-fail.rs - Foo (line 8) stdout ---- +Test compiled successfully, but it's marked `compile_fail`. + +failures: + $DIR/failed-doctest-compile-fail.rs - Foo (line 8) + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out + diff --git a/src/test/rustdoc-ui/failed-doctest-missing-codes.rs b/src/test/rustdoc-ui/failed-doctest-missing-codes.rs new file mode 100644 index 00000000000..62102062d49 --- /dev/null +++ b/src/test/rustdoc-ui/failed-doctest-missing-codes.rs @@ -0,0 +1,11 @@ +// FIXME: if/when the output of the test harness can be tested on its own, this test should be +// adapted to use that, and that normalize line can go away + +// compile-flags:--test +// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" +// failure-status: 101 + +/// ```compile_fail,E0004 +/// let x: () = 5i32; +/// ``` +pub struct Foo; diff --git a/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout b/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout new file mode 100644 index 00000000000..d206b721765 --- /dev/null +++ b/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout @@ -0,0 +1,26 @@ + +running 1 test +test $DIR/failed-doctest-missing-codes.rs - Foo (line 8) ... FAILED + +failures: + +---- $DIR/failed-doctest-missing-codes.rs - Foo (line 8) stdout ---- +error[E0308]: mismatched types + --> $DIR/failed-doctest-missing-codes.rs:9:13 + | +3 | let x: () = 5i32; + | ^^^^ expected (), found i32 + | + = note: expected type `()` + found type `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. +Some expected error codes were not found: ["E0004"] + +failures: + $DIR/failed-doctest-missing-codes.rs - Foo (line 8) + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out + diff --git a/src/test/rustdoc-ui/failed-doctest-output.rs b/src/test/rustdoc-ui/failed-doctest-output.rs index 48f1424e6b2..d2cdeb8f8f5 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.rs +++ b/src/test/rustdoc-ui/failed-doctest-output.rs @@ -5,10 +5,13 @@ // compile-flags:--test // normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" // failure-status: 101 -// rustc-env:RUST_BACKTRACE=0 // doctest fails at runtime /// ``` +/// println!("stdout 1"); +/// eprintln!("stderr 1"); +/// println!("stdout 2"); +/// eprintln!("stderr 2"); /// panic!("oh no"); /// ``` pub struct SomeStruct; diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 45efa30d991..0c42c652d78 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -1,13 +1,13 @@ running 2 tests -test $DIR/failed-doctest-output.rs - OtherStruct (line 17) ... FAILED -test $DIR/failed-doctest-output.rs - SomeStruct (line 11) ... FAILED +test $DIR/failed-doctest-output.rs - OtherStruct (line 20) ... FAILED +test $DIR/failed-doctest-output.rs - SomeStruct (line 10) ... FAILED failures: ----- $DIR/failed-doctest-output.rs - OtherStruct (line 17) stdout ---- +---- $DIR/failed-doctest-output.rs - OtherStruct (line 20) stdout ---- error[E0425]: cannot find value `no` in this scope - --> $DIR/failed-doctest-output.rs:18:1 + --> $DIR/failed-doctest-output.rs:21:1 | 3 | no | ^^ not found in this scope @@ -15,21 +15,25 @@ error[E0425]: cannot find value `no` in this scope error: aborting due to previous error For more information about this error, try `rustc --explain E0425`. -thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:320:13 +Couldn't compile the test. +---- $DIR/failed-doctest-output.rs - SomeStruct (line 10) stdout ---- +Test executable failed (exit code 101). + +stdout: +stdout 1 +stdout 2 + +stderr: +stderr 1 +stderr 2 +thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:7:1 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. ----- $DIR/failed-doctest-output.rs - SomeStruct (line 11) stdout ---- -thread '$DIR/failed-doctest-output.rs - SomeStruct (line 11)' panicked at 'test executable failed: - -thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1 -note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. - -', src/librustdoc/test.rs:342:17 failures: - $DIR/failed-doctest-output.rs - OtherStruct (line 17) - $DIR/failed-doctest-output.rs - SomeStruct (line 11) + $DIR/failed-doctest-output.rs - OtherStruct (line 20) + $DIR/failed-doctest-output.rs - SomeStruct (line 10) test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out diff --git a/src/test/rustdoc-ui/failed-doctest-should-panic.rs b/src/test/rustdoc-ui/failed-doctest-should-panic.rs new file mode 100644 index 00000000000..400fb97804a --- /dev/null +++ b/src/test/rustdoc-ui/failed-doctest-should-panic.rs @@ -0,0 +1,11 @@ +// FIXME: if/when the output of the test harness can be tested on its own, this test should be +// adapted to use that, and that normalize line can go away + +// compile-flags:--test +// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" +// failure-status: 101 + +/// ```should_panic +/// println!("Hello, world!"); +/// ``` +pub struct Foo; diff --git a/src/test/rustdoc-ui/failed-doctest-should-panic.stdout b/src/test/rustdoc-ui/failed-doctest-should-panic.stdout new file mode 100644 index 00000000000..081b64b50af --- /dev/null +++ b/src/test/rustdoc-ui/failed-doctest-should-panic.stdout @@ -0,0 +1,14 @@ + +running 1 test +test $DIR/failed-doctest-should-panic.rs - Foo (line 8) ... FAILED + +failures: + +---- $DIR/failed-doctest-should-panic.rs - Foo (line 8) stdout ---- +Test executable succeeded, but it's marked `should_panic`. + +failures: + $DIR/failed-doctest-should-panic.rs - Foo (line 8) + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out + diff --git a/src/test/rustdoc-ui/unparseable-doc-test.stdout b/src/test/rustdoc-ui/unparseable-doc-test.stdout index f31b64fbce3..0350c016436 100644 --- a/src/test/rustdoc-ui/unparseable-doc-test.stdout +++ b/src/test/rustdoc-ui/unparseable-doc-test.stdout @@ -13,9 +13,7 @@ error: unterminated double quote string error: aborting due to previous error -thread '$DIR/unparseable-doc-test.rs - foo (line 6)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:320:13 -note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. - +Couldn't compile the test. failures: $DIR/unparseable-doc-test.rs - foo (line 6) From f1d0829e20e3ff3ff78a09136968612887544af2 Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Sat, 4 May 2019 12:04:52 +0200 Subject: [PATCH 17/65] Add Step::sub_usize --- src/libcore/iter/range.rs | 35 +++++++++++++++++++ src/librustc_data_structures/indexed_vec.rs | 5 +++ .../run-pass/impl-trait/example-calendar.rs | 4 +++ 3 files changed, 44 insertions(+) diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index f8a975cc8d4..6bbf776fb8f 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -34,6 +34,13 @@ pub trait Step: Clone + PartialOrd + Sized { /// Adds a `usize`, returning `None` on overflow. fn add_usize(&self, n: usize) -> Option; + + /// Subtracts a `usize`, returning `None` on underflow. + fn sub_usize(&self, n: usize) -> Option { + // this default implementation makes the addition of `sub_usize` a non-breaking change + let _ = n; + unimplemented!() + } } // These are still macro-generated because the integer literals resolve to different types. @@ -85,6 +92,15 @@ macro_rules! step_impl_unsigned { } } + #[inline] + #[allow(unreachable_patterns)] + fn sub_usize(&self, n: usize) -> Option { + match <$t>::try_from(n) { + Ok(n_as_t) => self.checked_sub(n_as_t), + Err(_) => None, + } + } + step_identical_methods!(); } )*) @@ -125,6 +141,25 @@ macro_rules! step_impl_signed { } } + #[inline] + #[allow(unreachable_patterns)] + fn sub_usize(&self, n: usize) -> Option { + match <$unsigned>::try_from(n) { + Ok(n_as_unsigned) => { + // Wrapping in unsigned space handles cases like + // `80_i8.sub_usize(200) == Some(-120_i8)`, + // even though 200_usize is out of range for i8. + let wrapped = (*self as $unsigned).wrapping_sub(n_as_unsigned) as $t; + if wrapped <= *self { + Some(wrapped) + } else { + None // Subtraction underflowed + } + } + Err(_) => None, + } + } + step_identical_methods!(); } )*) diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index 359b89f683d..c7f6e54c3d5 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -212,6 +212,11 @@ macro_rules! newtype_index { fn add_usize(&self, u: usize) -> Option { Idx::index(*self).checked_add(u).map(Self::new) } + + #[inline] + fn sub_usize(&self, u: usize) -> Option { + Idx::index(*self).checked_sub(u).map(Self::new) + } } impl From<$type> for u32 { diff --git a/src/test/run-pass/impl-trait/example-calendar.rs b/src/test/run-pass/impl-trait/example-calendar.rs index 968e9b7d34a..f1b1656745e 100644 --- a/src/test/run-pass/impl-trait/example-calendar.rs +++ b/src/test/run-pass/impl-trait/example-calendar.rs @@ -180,6 +180,10 @@ impl std::iter::Step for NaiveDate { fn add_usize(&self, _: usize) -> Option { unimplemented!() } + + fn sub_usize(&self, _: usize) -> Option { + unimplemented!() + } } #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] From f9d328d7ffa17ab78eaa62a2976033a7176886d9 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Sun, 12 May 2019 14:53:01 +0200 Subject: [PATCH 18/65] sync::Weak::{as,from,into}_raw Methods on the Weak to access it as raw pointer to the data. --- src/liballoc/sync.rs | 164 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 158 insertions(+), 6 deletions(-) diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 90c7859b3db..70865656c51 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -13,7 +13,7 @@ use core::borrow; use core::fmt; use core::cmp::{self, Ordering}; use core::intrinsics::abort; -use core::mem::{self, align_of_val, size_of_val}; +use core::mem::{self, align_of, align_of_val, size_of_val}; use core::ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn}; use core::pin::Pin; use core::ptr::{self, NonNull}; @@ -397,11 +397,7 @@ impl Arc { /// ``` #[stable(feature = "rc_raw", since = "1.17.0")] pub unsafe fn from_raw(ptr: *const T) -> Self { - // Align the unsized value to the end of the ArcInner. - // Because it is ?Sized, it will always be the last field in memory. - let align = align_of_val(&*ptr); - let layout = Layout::new::>(); - let offset = (layout.size() + layout.padding_needed_for(align)) as isize; + let offset = data_offset(ptr); // Reverse the offset to find the original ArcInner. let fake_ptr = ptr as *mut ArcInner; @@ -1071,6 +1067,144 @@ impl Weak { ptr: NonNull::new(usize::MAX as *mut ArcInner).expect("MAX is not 0"), } } + + /// Returns a raw pointer to the object `T` pointed to by this `Weak`. + /// + /// It is up to the caller to ensure that the object is still alive when accessing it through + /// the pointer. + /// + /// The pointer may be [`null`] or be dangling in case the object has already been destroyed. + /// + /// # Examples + /// + /// ``` + /// #![feature(weak_into_raw)] + /// + /// use std::sync::{Arc, Weak}; + /// use std::ptr; + /// + /// let strong = Arc::new(42); + /// let weak = Arc::downgrade(&strong); + /// // Both point to the same object + /// assert!(ptr::eq(&*strong, Weak::as_raw(&weak))); + /// // The strong here keeps it alive, so we can still access the object. + /// assert_eq!(42, unsafe { *Weak::as_raw(&weak) }); + /// + /// drop(strong); + /// // But not any more. We can do Weak::as_raw(&weak), but accessing the pointer would lead to + /// // undefined behaviour. + /// // assert_eq!(42, unsafe { *Weak::as_raw(&weak) }); + /// ``` + /// + /// [`null`]: ../../std/ptr/fn.null.html + #[unstable(feature = "weak_into_raw", issue = "60728")] + pub fn as_raw(this: &Self) -> *const T { + match this.inner() { + None => ptr::null(), + Some(inner) => { + let offset = data_offset_sized::(); + let ptr = inner as *const ArcInner; + // Note: while the pointer we create may already point to dropped value, the + // allocation still lives (it must hold the weak point as long as we are alive). + // Therefore, the offset is OK to do, it won't get out of the allocation. + let ptr = unsafe { (ptr as *const u8).offset(offset) }; + ptr as *const T + } + } + } + + /// Consumes the `Weak` and turns it into a raw pointer. + /// + /// This converts the weak pointer into a raw pointer, preserving the original weak count. It + /// can be turned back into the `Weak` with [`from_raw`]. + /// + /// The same restrictions of accessing the target of the pointer as with + /// [`as_raw`] apply. + /// + /// # Examples + /// + /// ``` + /// #![feature(weak_into_raw)] + /// + /// use std::sync::{Arc, Weak}; + /// + /// let strong = Arc::new(42); + /// let weak = Arc::downgrade(&strong); + /// let raw = Weak::into_raw(weak); + /// + /// assert_eq!(1, Arc::weak_count(&strong)); + /// assert_eq!(42, unsafe { *raw }); + /// + /// drop(unsafe { Weak::from_raw(raw) }); + /// assert_eq!(0, Arc::weak_count(&strong)); + /// ``` + /// + /// [`from_raw`]: struct.Weak.html#method.from_raw + /// [`as_raw`]: struct.Weak.html#method.as_raw + #[unstable(feature = "weak_into_raw", issue = "60728")] + pub fn into_raw(this: Self) -> *const T { + let result = Self::as_raw(&this); + mem::forget(this); + result + } + + /// Converts a raw pointer previously created by [`into_raw`] back into + /// `Weak`. + /// + /// This can be used to safely get a strong reference (by calling [`upgrade`] + /// later) or to deallocate the weak count by dropping the `Weak`. + /// + /// It takes ownership of one weak count. In case a [`null`] is passed, a dangling [`Weak`] is + /// returned. + /// + /// # Safety + /// + /// The pointer must represent one valid weak count. In other words, it must point to `T` which + /// is or *was* managed by an [`Arc`] and the weak count of that [`Arc`] must not have reached + /// 0. It is allowed for the strong count to be 0. + /// + /// # Examples + /// + /// ``` + /// #![feature(weak_into_raw)] + /// + /// use std::sync::{Arc, Weak}; + /// + /// let strong = Arc::new(42); + /// + /// let raw_1 = Weak::into_raw(Arc::downgrade(&strong)); + /// let raw_2 = Weak::into_raw(Arc::downgrade(&strong)); + /// + /// assert_eq!(2, Arc::weak_count(&strong)); + /// + /// assert_eq!(42, *Weak::upgrade(&unsafe { Weak::from_raw(raw_1) }).unwrap()); + /// assert_eq!(1, Arc::weak_count(&strong)); + /// + /// drop(strong); + /// + /// // Decrement the last weak count. + /// assert!(Weak::upgrade(&unsafe { Weak::from_raw(raw_2) }).is_none()); + /// ``` + /// + /// [`null`]: ../../std/ptr/fn.null.html + /// [`into_raw`]: struct.Weak.html#method.into_raw + /// [`upgrade`]: struct.Weak.html#method.upgrade + /// [`Weak`]: struct.Weak.html + /// [`Arc`]: struct.Arc.html + #[unstable(feature = "weak_into_raw", issue = "60728")] + pub unsafe fn from_raw(ptr: *const T) -> Self { + if ptr.is_null() { + Self::new() + } else { + // See Arc::from_raw for details + let offset = data_offset(ptr); + let fake_ptr = ptr as *mut ArcInner; + let ptr = set_data_ptr(fake_ptr, (ptr as *mut u8).offset(-offset)); + Weak { + ptr: NonNull::new(ptr).expect("Invalid pointer passed to from_raw"), + } + } + } } impl Weak { @@ -2150,3 +2284,21 @@ impl AsRef for Arc { #[stable(feature = "pin", since = "1.33.0")] impl Unpin for Arc { } + +/// Computes the offset of the data field within ArcInner. +unsafe fn data_offset(ptr: *const T) -> isize { + // Align the unsized value to the end of the ArcInner. + // Because it is ?Sized, it will always be the last field in memory. + let align = align_of_val(&*ptr); + let layout = Layout::new::>(); + (layout.size() + layout.padding_needed_for(align)) as isize +} + +/// Computes the offset of the data field within ArcInner. +/// +/// Unlike [`data_offset`], this doesn't need the pointer, but it works only on `T: Sized`. +fn data_offset_sized() -> isize { + let align = align_of::(); + let layout = Layout::new::>(); + (layout.size() + layout.padding_needed_for(align)) as isize +} From 4f1dcb34dffc26a23fa8c2cac69a31d7557fd173 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Sun, 19 May 2019 12:46:37 +0200 Subject: [PATCH 19/65] rc::Weak::{as,from,into}_raw Methods on the Weak to access it as a raw pointer to the data. --- src/liballoc/rc.rs | 162 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 156 insertions(+), 6 deletions(-) diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 0dffb19476f..1f357a719bb 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -239,7 +239,7 @@ use core::fmt; use core::hash::{Hash, Hasher}; use core::intrinsics::abort; use core::marker::{self, Unpin, Unsize, PhantomData}; -use core::mem::{self, align_of_val, forget, size_of_val}; +use core::mem::{self, align_of, align_of_val, forget, size_of_val}; use core::ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn}; use core::pin::Pin; use core::ptr::{self, NonNull}; @@ -416,11 +416,7 @@ impl Rc { /// ``` #[stable(feature = "rc_raw", since = "1.17.0")] pub unsafe fn from_raw(ptr: *const T) -> Self { - // Align the unsized value to the end of the RcBox. - // Because it is ?Sized, it will always be the last field in memory. - let align = align_of_val(&*ptr); - let layout = Layout::new::>(); - let offset = (layout.size() + layout.padding_needed_for(align)) as isize; + let offset = data_offset(ptr); // Reverse the offset to find the original RcBox. let fake_ptr = ptr as *mut RcBox; @@ -1262,6 +1258,143 @@ impl Weak { ptr: NonNull::new(usize::MAX as *mut RcBox).expect("MAX is not 0"), } } + + /// Returns a raw pointer to the object `T` pointed to by this `Weak`. + /// + /// It is up to the caller to ensure that the object is still alive when accessing it through + /// the pointer. + /// + /// The pointer may be [`null`] or be dangling in case the object has already been destroyed. + /// + /// # Examples + /// + /// ``` + /// #![feature(weak_into_raw)] + /// + /// use std::rc::{Rc, Weak}; + /// use std::ptr; + /// + /// let strong = Rc::new(42); + /// let weak = Rc::downgrade(&strong); + /// // Both point to the same object + /// assert!(ptr::eq(&*strong, Weak::as_raw(&weak))); + /// // The strong here keeps it alive, so we can still access the object. + /// assert_eq!(42, unsafe { *Weak::as_raw(&weak) }); + /// + /// drop(strong); + /// // But not any more. We can do Weak::as_raw(&weak), but accessing the pointer would lead to + /// // undefined behaviour. + /// // assert_eq!(42, unsafe { *Weak::as_raw(&weak) }); + /// ``` + /// + /// [`null`]: ../../std/ptr/fn.null.html + #[unstable(feature = "weak_into_raw", issue = "60728")] + pub fn as_raw(this: &Self) -> *const T { + match this.inner() { + None => ptr::null(), + Some(inner) => { + let offset = data_offset_sized::(); + let ptr = inner as *const RcBox; + // Note: while the pointer we create may already point to dropped value, the + // allocation still lives (it must hold the weak point as long as we are alive). + // Therefore, the offset is OK to do, it won't get out of the allocation. + let ptr = unsafe { (ptr as *const u8).offset(offset) }; + ptr as *const T + } + } + } + + /// Consumes the `Weak` and turns it into a raw pointer. + /// + /// This converts the weak pointer into a raw pointer, preserving the original weak count. It + /// can be turned back into the `Weak` with [`from_raw`]. + /// + /// The same restrictions of accessing the target of the pointer as with + /// [`as_raw`] apply. + /// + /// # Examples + /// + /// ``` + /// #![feature(weak_into_raw)] + /// + /// use std::rc::{Rc, Weak}; + /// + /// let strong = Rc::new(42); + /// let weak = Rc::downgrade(&strong); + /// let raw = Weak::into_raw(weak); + /// + /// assert_eq!(1, Rc::weak_count(&strong)); + /// assert_eq!(42, unsafe { *raw }); + /// + /// drop(unsafe { Weak::from_raw(raw) }); + /// assert_eq!(0, Rc::weak_count(&strong)); + /// ``` + /// + /// [`from_raw`]: struct.Weak.html#method.from_raw + /// [`as_raw`]: struct.Weak.html#method.as_raw + #[unstable(feature = "weak_into_raw", issue = "60728")] + pub fn into_raw(this: Self) -> *const T { + let result = Self::as_raw(&this); + mem::forget(this); + result + } + + /// Converts a raw pointer previously created by [`into_raw`] back into `Weak`. + /// + /// This can be used to safely get a strong reference (by calling [`upgrade`] + /// later) or to deallocate the weak count by dropping the `Weak`. + /// + /// It takes ownership of one weak count. In case a [`null`] is passed, a dangling [`Weak`] is + /// returned. + /// + /// # Safety + /// + /// The pointer must represent one valid weak count. In other words, it must point to `T` which + /// is or *was* managed by an [`Rc`] and the weak count of that [`Rc`] must not have reached + /// 0. It is allowed for the strong count to be 0. + /// + /// # Examples + /// + /// ``` + /// #![feature(weak_into_raw)] + /// + /// use std::rc::{Rc, Weak}; + /// + /// let strong = Rc::new(42); + /// + /// let raw_1 = Weak::into_raw(Rc::downgrade(&strong)); + /// let raw_2 = Weak::into_raw(Rc::downgrade(&strong)); + /// + /// assert_eq!(2, Rc::weak_count(&strong)); + /// + /// assert_eq!(42, *Weak::upgrade(&unsafe { Weak::from_raw(raw_1) }).unwrap()); + /// assert_eq!(1, Rc::weak_count(&strong)); + /// + /// drop(strong); + /// + /// // Decrement the last weak count. + /// assert!(Weak::upgrade(&unsafe { Weak::from_raw(raw_2) }).is_none()); + /// ``` + /// + /// [`null`]: ../../std/ptr/fn.null.html + /// [`into_raw`]: struct.Weak.html#method.into_raw + /// [`upgrade`]: struct.Weak.html#method.upgrade + /// [`Rc`]: struct.Rc.html + /// [`Weak`]: struct.Weak.html + #[unstable(feature = "weak_into_raw", issue = "60728")] + pub unsafe fn from_raw(ptr: *const T) -> Self { + if ptr.is_null() { + Self::new() + } else { + // See Rc::from_raw for details + let offset = data_offset(ptr); + let fake_ptr = ptr as *mut RcBox; + let ptr = set_data_ptr(fake_ptr, (ptr as *mut u8).offset(-offset)); + Weak { + ptr: NonNull::new(ptr).expect("Invalid pointer passed to from_raw"), + } + } + } } pub(crate) fn is_dangling(ptr: NonNull) -> bool { @@ -2007,3 +2140,20 @@ impl AsRef for Rc { #[stable(feature = "pin", since = "1.33.0")] impl Unpin for Rc { } + +unsafe fn data_offset(ptr: *const T) -> isize { + // Align the unsized value to the end of the RcBox. + // Because it is ?Sized, it will always be the last field in memory. + let align = align_of_val(&*ptr); + let layout = Layout::new::>(); + (layout.size() + layout.padding_needed_for(align)) as isize +} + +/// Computes the offset of the data field within ArcInner. +/// +/// Unlike [`data_offset`], this doesn't need the pointer, but it works only on `T: Sized`. +fn data_offset_sized() -> isize { + let align = align_of::(); + let layout = Layout::new::>(); + (layout.size() + layout.padding_needed_for(align)) as isize +} From ad52c77a46593f2ebd4ae5a291f1a698527bb123 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 26 May 2019 07:39:14 -0700 Subject: [PATCH 20/65] ci: Attempt to skip a full rustc compile on dist* Currently when we're preparing cross-compiled compilers it can take quite some time because we have to build the compiler itself three different times. The first is the normal bootstrap, the second is a second build for the build platform, and the third is the actual target architecture compiler. The second compiler was historically built exclusively for procedural macros, and long ago we didn't actually need it. This commit tries out avoiding that second compiled compiler, meaning we only compile rustc for the build platform only once. Some local testing shows that this is promising, but bors is of course the ultimate test! --- src/bootstrap/tool.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index edcd68d010e..804fb68c88a 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -539,9 +539,9 @@ impl Step for Cargo { } fn run(self, builder: &Builder<'_>) -> PathBuf { - // Cargo depends on procedural macros, which requires a full host - // compiler to be available, so we need to depend on that. - builder.ensure(compile::Rustc { + // Cargo depends on procedural macros, so make sure the host + // libstd/libproc_macro is available. + builder.ensure(compile::Test { compiler: self.compiler, target: builder.config.build, }); @@ -613,26 +613,26 @@ macro_rules! tool_extended { tool_extended!((self, builder), Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", {}; CargoClippy, clippy, "src/tools/clippy", "cargo-clippy", { - // Clippy depends on procedural macros (serde), which requires a full host - // compiler to be available, so we need to depend on that. - builder.ensure(compile::Rustc { + // Clippy depends on procedural macros, so make sure that's built for + // the compiler itself. + builder.ensure(compile::Test { compiler: self.compiler, target: builder.config.build, }); }; Clippy, clippy, "src/tools/clippy", "clippy-driver", { - // Clippy depends on procedural macros (serde), which requires a full host - // compiler to be available, so we need to depend on that. - builder.ensure(compile::Rustc { + // Clippy depends on procedural macros, so make sure that's built for + // the compiler itself. + builder.ensure(compile::Test { compiler: self.compiler, target: builder.config.build, }); }; Miri, miri, "src/tools/miri", "miri", {}; CargoMiri, miri, "src/tools/miri", "cargo-miri", { - // Miri depends on procedural macros (serde), which requires a full host - // compiler to be available, so we need to depend on that. - builder.ensure(compile::Rustc { + // Miri depends on procedural macros, so make sure that's built for + // the compiler itself. + builder.ensure(compile::Test { compiler: self.compiler, target: builder.config.build, }); @@ -646,9 +646,9 @@ tool_extended!((self, builder), if clippy.is_some() { self.extra_features.push("clippy".to_owned()); } - // RLS depends on procedural macros, which requires a full host - // compiler to be available, so we need to depend on that. - builder.ensure(compile::Rustc { + // RLS depends on procedural macros, so make sure that's built for + // the compiler itself. + builder.ensure(compile::Test { compiler: self.compiler, target: builder.config.build, }); From 24b2e20b3127b5a8da20c4910080bf9756dd2a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 26 May 2019 11:39:48 -0700 Subject: [PATCH 21/65] Account for short-hand init structs when suggesting conversion --- src/librustc_typeck/check/demand.rs | 6 ++++- src/librustc_typeck/check/mod.rs | 20 +++++++++++----- src/test/ui/suggestions/issue-52820.rs | 12 ++++++++++ src/test/ui/suggestions/issue-52820.stderr | 27 ++++++++++++++++++++++ 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 src/test/ui/suggestions/issue-52820.rs create mode 100644 src/test/ui/suggestions/issue-52820.stderr diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index a4e687b8f90..bc872f8c03c 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -270,7 +270,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None } - fn is_hir_id_from_struct_pattern_shorthand_field(&self, hir_id: hir::HirId, sp: Span) -> bool { + crate fn is_hir_id_from_struct_pattern_shorthand_field( + &self, + hir_id: hir::HirId, + sp: Span, + ) -> bool { let cm = self.sess().source_map(); let parent_id = self.tcx.hir().get_parent_node_by_hir_id(hir_id); if let Some(parent) = self.tcx.hir().find_by_hir_id(parent_id) { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 655bf5722ae..e6c9448a605 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -5014,6 +5014,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Applicability::MachineApplicable, ); } else if !self.check_for_cast(err, expr, found, expected) { + let is_struct_pat_shorthand_field = self.is_hir_id_from_struct_pattern_shorthand_field( + expr.hir_id, + expr.span, + ); let methods = self.get_conversion_methods(expr.span, expected, found); if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) { let mut suggestions = iter::repeat(&expr_text).zip(methods.iter()) @@ -5023,14 +5027,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None // do not suggest code that is already there (#53348) } else { let method_call_list = [".to_vec()", ".to_string()"]; - if receiver.ends_with(".clone()") + let sugg = if receiver.ends_with(".clone()") && method_call_list.contains(&method_call.as_str()) { let max_len = receiver.rfind(".").unwrap(); - Some(format!("{}{}", &receiver[..max_len], method_call)) - } - else { - Some(format!("{}{}", receiver, method_call)) - } + format!("{}{}", &receiver[..max_len], method_call) + } else { + format!("{}{}", receiver, method_call) + }; + Some(if is_struct_pat_shorthand_field { + format!("{}: {}", receiver, sugg) + } else { + sugg + }) } }).peekable(); if suggestions.peek().is_some() { diff --git a/src/test/ui/suggestions/issue-52820.rs b/src/test/ui/suggestions/issue-52820.rs new file mode 100644 index 00000000000..075b07f5652 --- /dev/null +++ b/src/test/ui/suggestions/issue-52820.rs @@ -0,0 +1,12 @@ +struct Bravery { + guts: String, + brains: String, +} + +fn main() { + let guts = "mettle"; + let _ = Bravery { + guts, //~ ERROR mismatched types + brains: guts.clone(), //~ ERROR mismatched types + }; +} diff --git a/src/test/ui/suggestions/issue-52820.stderr b/src/test/ui/suggestions/issue-52820.stderr new file mode 100644 index 00000000000..fb568aca250 --- /dev/null +++ b/src/test/ui/suggestions/issue-52820.stderr @@ -0,0 +1,27 @@ +error[E0308]: mismatched types + --> $DIR/issue-52820.rs:9:9 + | +LL | guts, + | ^^^^ + | | + | expected struct `std::string::String`, found &str + | help: try using a conversion method: `guts: guts.to_string()` + | + = note: expected type `std::string::String` + found type `&str` + +error[E0308]: mismatched types + --> $DIR/issue-52820.rs:10:17 + | +LL | brains: guts.clone(), + | ^^^^^^^^^^^^ + | | + | expected struct `std::string::String`, found &str + | help: try using a conversion method: `guts.to_string()` + | + = note: expected type `std::string::String` + found type `&str` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. From 21aa149b0bc7f6321bf03f5f5df75b4d16bdb406 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 24 May 2019 14:59:19 +0200 Subject: [PATCH 22/65] Move existing `#[linkage]` tests to a subdirectory where I can add more tests. --- src/test/ui/{ => linkage-attr}/linkage2.rs | 0 src/test/ui/{ => linkage-attr}/linkage2.stderr | 0 src/test/ui/{ => linkage-attr}/linkage3.rs | 0 src/test/ui/{ => linkage-attr}/linkage3.stderr | 0 src/test/ui/{ => linkage-attr}/linkage4.rs | 0 src/test/ui/{ => linkage-attr}/linkage4.stderr | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename src/test/ui/{ => linkage-attr}/linkage2.rs (100%) rename src/test/ui/{ => linkage-attr}/linkage2.stderr (100%) rename src/test/ui/{ => linkage-attr}/linkage3.rs (100%) rename src/test/ui/{ => linkage-attr}/linkage3.stderr (100%) rename src/test/ui/{ => linkage-attr}/linkage4.rs (100%) rename src/test/ui/{ => linkage-attr}/linkage4.stderr (100%) diff --git a/src/test/ui/linkage2.rs b/src/test/ui/linkage-attr/linkage2.rs similarity index 100% rename from src/test/ui/linkage2.rs rename to src/test/ui/linkage-attr/linkage2.rs diff --git a/src/test/ui/linkage2.stderr b/src/test/ui/linkage-attr/linkage2.stderr similarity index 100% rename from src/test/ui/linkage2.stderr rename to src/test/ui/linkage-attr/linkage2.stderr diff --git a/src/test/ui/linkage3.rs b/src/test/ui/linkage-attr/linkage3.rs similarity index 100% rename from src/test/ui/linkage3.rs rename to src/test/ui/linkage-attr/linkage3.rs diff --git a/src/test/ui/linkage3.stderr b/src/test/ui/linkage-attr/linkage3.stderr similarity index 100% rename from src/test/ui/linkage3.stderr rename to src/test/ui/linkage-attr/linkage3.stderr diff --git a/src/test/ui/linkage4.rs b/src/test/ui/linkage-attr/linkage4.rs similarity index 100% rename from src/test/ui/linkage4.rs rename to src/test/ui/linkage-attr/linkage4.rs diff --git a/src/test/ui/linkage4.stderr b/src/test/ui/linkage-attr/linkage4.stderr similarity index 100% rename from src/test/ui/linkage4.stderr rename to src/test/ui/linkage-attr/linkage4.stderr From 64edaec6b35ea32e8dffbe27ff123c4a090869a8 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 24 May 2019 14:11:39 +0200 Subject: [PATCH 23/65] Always supply span to check_and_apply_linkage, sidestepping need to add `bug!`s to rustc. --- src/librustc_codegen_llvm/consts.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 5f47108309f..23e2bfe1ad1 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -102,7 +102,7 @@ fn check_and_apply_linkage( attrs: &CodegenFnAttrs, ty: Ty<'tcx>, sym: LocalInternedString, - span: Option + span: Span ) -> &'ll Value { let llty = cx.layout_of(ty).llvm_type(cx); if let Some(linkage) = attrs.linkage { @@ -116,11 +116,7 @@ fn check_and_apply_linkage( let llty2 = if let ty::RawPtr(ref mt) = ty.sty { cx.layout_of(mt.ty).llvm_type(cx) } else { - if let Some(span) = span { - cx.sess().span_fatal(span, "must have type `*const T` or `*mut T`") - } else { - bug!("must have type `*const T` or `*mut T`") - } + cx.sess().span_fatal(span, "must have type `*const T` or `*mut T`") }; unsafe { // Declare a symbol `foo` with the desired linkage. @@ -136,14 +132,7 @@ fn check_and_apply_linkage( let mut real_name = "_rust_extern_with_linkage_".to_string(); real_name.push_str(&sym); let g2 = cx.define_global(&real_name, llty).unwrap_or_else(||{ - if let Some(span) = span { - cx.sess().span_fatal( - span, - &format!("symbol `{}` is already defined", &sym) - ) - } else { - bug!("symbol `{}` is already defined", &sym) - } + cx.sess().span_fatal(span, &format!("symbol `{}` is already defined", &sym)) }); llvm::LLVMRustSetLinkage(g2, llvm::Linkage::InternalLinkage); llvm::LLVMSetInitializer(g2, g1); @@ -240,7 +229,7 @@ impl CodegenCx<'ll, 'tcx> { ref attrs, span, node: hir::ForeignItemKind::Static(..), .. }) => { let fn_attrs = self.tcx.codegen_fn_attrs(def_id); - (check_and_apply_linkage(&self, &fn_attrs, ty, sym, Some(span)), attrs) + (check_and_apply_linkage(&self, &fn_attrs, ty, sym, span), attrs) } item => bug!("get_static: expected static, found {:?}", item) @@ -260,7 +249,8 @@ impl CodegenCx<'ll, 'tcx> { debug!("get_static: sym={} item_attr={:?}", sym, self.tcx.item_attrs(def_id)); let attrs = self.tcx.codegen_fn_attrs(def_id); - let g = check_and_apply_linkage(&self, &attrs, ty, sym, None); + let span = self.tcx.def_span(def_id); + let g = check_and_apply_linkage(&self, &attrs, ty, sym, span); // Thread-local statics in some other crate need to *always* be linked // against in a thread-local fashion, so we need to be sure to apply the From 444f2bae5920a93677a9de6063897e5ce00491e7 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 24 May 2019 14:55:15 +0200 Subject: [PATCH 24/65] Refine the message to at least *mention* the attribute itself. Update pre-existing test's diagnostic output accordingly. --- src/librustc_codegen_llvm/consts.rs | 3 ++- src/test/ui/linkage-attr/linkage2.rs | 2 +- src/test/ui/linkage-attr/linkage2.stderr | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 23e2bfe1ad1..99b5cf42551 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -116,7 +116,8 @@ fn check_and_apply_linkage( let llty2 = if let ty::RawPtr(ref mt) = ty.sty { cx.layout_of(mt.ty).llvm_type(cx) } else { - cx.sess().span_fatal(span, "must have type `*const T` or `*mut T`") + cx.sess().span_fatal( + span, "must have type `*const T` or `*mut T` due to `#[linkage]` attribute") }; unsafe { // Declare a symbol `foo` with the desired linkage. diff --git a/src/test/ui/linkage-attr/linkage2.rs b/src/test/ui/linkage-attr/linkage2.rs index f9ea5319d54..c8af1a69979 100644 --- a/src/test/ui/linkage-attr/linkage2.rs +++ b/src/test/ui/linkage-attr/linkage2.rs @@ -7,7 +7,7 @@ extern { #[linkage = "extern_weak"] static foo: i32; - //~^ ERROR: must have type `*const T` or `*mut T` + //~^ ERROR: must have type `*const T` or `*mut T` due to `#[linkage]` attribute } fn main() { diff --git a/src/test/ui/linkage-attr/linkage2.stderr b/src/test/ui/linkage-attr/linkage2.stderr index 8326c0baccc..2654ffd67b6 100644 --- a/src/test/ui/linkage-attr/linkage2.stderr +++ b/src/test/ui/linkage-attr/linkage2.stderr @@ -1,4 +1,4 @@ -error: must have type `*const T` or `*mut T` +error: must have type `*const T` or `*mut T` due to `#[linkage]` attribute --> $DIR/linkage2.rs:9:32 | LL | #[linkage = "extern_weak"] static foo: i32; From 4e60f53280c34d35c29b007b28e32b9a6f695d1b Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 24 May 2019 15:13:16 +0200 Subject: [PATCH 25/65] Regression test for issue #59548. --- .../ui/linkage-attr/auxiliary/def_illtyped_external.rs | 5 +++++ src/test/ui/linkage-attr/linkage-requires-raw-ptr.rs | 10 ++++++++++ .../ui/linkage-attr/linkage-requires-raw-ptr.stderr | 8 ++++++++ 3 files changed, 23 insertions(+) create mode 100644 src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs create mode 100644 src/test/ui/linkage-attr/linkage-requires-raw-ptr.rs create mode 100644 src/test/ui/linkage-attr/linkage-requires-raw-ptr.stderr diff --git a/src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs b/src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs new file mode 100644 index 00000000000..2300930e513 --- /dev/null +++ b/src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs @@ -0,0 +1,5 @@ +#![feature(linkage)] +#![crate_type = "lib"] + +#[linkage="external"] +pub static EXTERN: u32 = 0; diff --git a/src/test/ui/linkage-attr/linkage-requires-raw-ptr.rs b/src/test/ui/linkage-attr/linkage-requires-raw-ptr.rs new file mode 100644 index 00000000000..014c715be0d --- /dev/null +++ b/src/test/ui/linkage-attr/linkage-requires-raw-ptr.rs @@ -0,0 +1,10 @@ +// rust-lang/rust#59548: We used to ICE when trying to use a static +// with a type that violated its own `#[linkage]`. + +// aux-build:def_illtyped_external.rs + +extern crate def_illtyped_external as dep; + +fn main() { + println!("{:p}", &dep::EXTERN); +} diff --git a/src/test/ui/linkage-attr/linkage-requires-raw-ptr.stderr b/src/test/ui/linkage-attr/linkage-requires-raw-ptr.stderr new file mode 100644 index 00000000000..a80b495f97f --- /dev/null +++ b/src/test/ui/linkage-attr/linkage-requires-raw-ptr.stderr @@ -0,0 +1,8 @@ +error: must have type `*const T` or `*mut T` due to `#[linkage]` attribute + --> $DIR/auxiliary/def_illtyped_external.rs:5:1 + | +LL | pub static EXTERN: u32 = 0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + From c8887abf20f72631eeeb72eaf14fa27fc4e550fa Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 27 May 2019 12:08:10 +0200 Subject: [PATCH 26/65] Tests for external linkage symbol collision check. Fix #61232 --- .../auxiliary/def_colliding_external.rs | 7 ++++++ ...-detect-extern-generated-name-collision.rs | 21 +++++++++++++++++ ...ect-extern-generated-name-collision.stderr | 8 +++++++ ...e-detect-local-generated-name-collision.rs | 23 +++++++++++++++++++ ...tect-local-generated-name-collision.stderr | 8 +++++++ 5 files changed, 67 insertions(+) create mode 100644 src/test/ui/linkage-attr/auxiliary/def_colliding_external.rs create mode 100644 src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.rs create mode 100644 src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.stderr create mode 100644 src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.rs create mode 100644 src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.stderr diff --git a/src/test/ui/linkage-attr/auxiliary/def_colliding_external.rs b/src/test/ui/linkage-attr/auxiliary/def_colliding_external.rs new file mode 100644 index 00000000000..bbbfc485791 --- /dev/null +++ b/src/test/ui/linkage-attr/auxiliary/def_colliding_external.rs @@ -0,0 +1,7 @@ +#![feature(linkage)] +#![crate_type = "lib"] + +extern { + #[linkage="external"] + pub static collision: *const i32; +} diff --git a/src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.rs b/src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.rs new file mode 100644 index 00000000000..85a9a336b0d --- /dev/null +++ b/src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.rs @@ -0,0 +1,21 @@ +// rust-lang/rust#61232: We used to ICE when trying to detect a +// collision on the symbol generated for the external linkage item in +// an extern crate. + +// aux-build:def_colliding_external.rs + +extern crate def_colliding_external as dep1; + +#[no_mangle] +pub static _rust_extern_with_linkage_collision: i32 = 0; + +mod dep2 { + #[no_mangle] + pub static collision: usize = 0; +} + +fn main() { + unsafe { + println!("{:p}", &dep1::collision); + } +} diff --git a/src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.stderr b/src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.stderr new file mode 100644 index 00000000000..dcb954a4bc0 --- /dev/null +++ b/src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.stderr @@ -0,0 +1,8 @@ +error: symbol `collision` is already defined + --> $DIR/auxiliary/def_colliding_external.rs:6:5 + | +LL | pub static collision: *const i32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.rs b/src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.rs new file mode 100644 index 00000000000..dc15798e16a --- /dev/null +++ b/src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.rs @@ -0,0 +1,23 @@ +#![feature(linkage)] + +mod dep1 { + extern { + #[linkage="external"] + #[no_mangle] + pub static collision: *const i32; //~ ERROR symbol `collision` is already defined + } +} + +#[no_mangle] +pub static _rust_extern_with_linkage_collision: i32 = 0; + +mod dep2 { + #[no_mangle] + pub static collision: usize = 0; +} + +fn main() { + unsafe { + println!("{:p}", &dep1::collision); + } +} diff --git a/src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.stderr b/src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.stderr new file mode 100644 index 00000000000..117c76f7f26 --- /dev/null +++ b/src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.stderr @@ -0,0 +1,8 @@ +error: symbol `collision` is already defined + --> $DIR/linkage-detect-local-generated-name-collision.rs:7:9 + | +LL | pub static collision: *const i32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + From 06eb412741894f3efe4298f9c7993d0cd49bf577 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 27 May 2019 13:42:21 +0000 Subject: [PATCH 27/65] Stabilize bufreader_buffer feature --- src/libstd/io/buffered.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index e309f81192c..88186c50097 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -158,7 +158,6 @@ impl BufReader { /// # Examples /// /// ```no_run - /// # #![feature(bufreader_buffer)] /// use std::io::{BufReader, BufRead}; /// use std::fs::File; /// @@ -173,7 +172,7 @@ impl BufReader { /// Ok(()) /// } /// ``` - #[unstable(feature = "bufreader_buffer", issue = "45323")] + #[stable(feature = "bufreader_buffer", since = "1.37.0")] pub fn buffer(&self) -> &[u8] { &self.buf[self.pos..self.cap] } @@ -552,7 +551,6 @@ impl BufWriter { /// # Examples /// /// ```no_run - /// # #![feature(bufreader_buffer)] /// use std::io::BufWriter; /// use std::net::TcpStream; /// @@ -561,7 +559,7 @@ impl BufWriter { /// // See how many bytes are currently buffered /// let bytes_buffered = buf_writer.buffer().len(); /// ``` - #[unstable(feature = "bufreader_buffer", issue = "45323")] + #[stable(feature = "bufreader_buffer", since = "1.37.0")] pub fn buffer(&self) -> &[u8] { &self.buf } From 645f685e1b05f3f62de26ea1579861e83cbd0d74 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 27 May 2019 22:40:13 +0200 Subject: [PATCH 28/65] Box::into_vec: use Box::into_raw instead of mem::forget --- src/liballoc/slice.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 8768f1ff081..aeb7f90d3e6 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -137,17 +137,16 @@ pub use hack::to_vec; // `core::slice::SliceExt` - we need to supply these functions for the // `test_permutations` test mod hack { - use core::mem; - use crate::boxed::Box; use crate::vec::Vec; #[cfg(test)] use crate::string::ToString; - pub fn into_vec(mut b: Box<[T]>) -> Vec { + pub fn into_vec(b: Box<[T]>) -> Vec { unsafe { - let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len()); - mem::forget(b); + let len = b.len(); + let b = Box::into_raw(b); + let xs = Vec::from_raw_parts(b as *mut T, len, len); xs } } From 96e3fb255bfcae8ce7210985bf75e77335d22580 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Sat, 25 May 2019 21:45:51 +0200 Subject: [PATCH 29/65] librustc_errors: Move annotation collection to own impl Extracted from work on #59346. This moves the annotation collection to the `FileWithAnnotatedLines` impl to allow re-use in a separate EmitterWriter. --- src/librustc_errors/emitter.rs | 341 +++++++++++++++++---------------- 1 file changed, 174 insertions(+), 167 deletions(-) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 890d2c5ce0b..e1112a15577 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -162,6 +162,7 @@ impl ColorConfig { } } +/// Handles the writing of `HumanReadableErrorType::Default` and `HumanReadableErrorType::Short` pub struct EmitterWriter { dst: Destination, sm: Option>, @@ -170,7 +171,8 @@ pub struct EmitterWriter { ui_testing: bool, } -struct FileWithAnnotatedLines { +#[derive(Debug)] +pub struct FileWithAnnotatedLines { file: Lrc, lines: Vec, multiline_depth: usize, @@ -221,169 +223,6 @@ impl EmitterWriter { } } - fn preprocess_annotations(&mut self, msp: &MultiSpan) -> Vec { - fn add_annotation_to_file(file_vec: &mut Vec, - file: Lrc, - line_index: usize, - ann: Annotation) { - - for slot in file_vec.iter_mut() { - // Look through each of our files for the one we're adding to - if slot.file.name == file.name { - // See if we already have a line for it - for line_slot in &mut slot.lines { - if line_slot.line_index == line_index { - line_slot.annotations.push(ann); - return; - } - } - // We don't have a line yet, create one - slot.lines.push(Line { - line_index, - annotations: vec![ann], - }); - slot.lines.sort(); - return; - } - } - // This is the first time we're seeing the file - file_vec.push(FileWithAnnotatedLines { - file, - lines: vec![Line { - line_index, - annotations: vec![ann], - }], - multiline_depth: 0, - }); - } - - let mut output = vec![]; - let mut multiline_annotations = vec![]; - - if let Some(ref sm) = self.sm { - for span_label in msp.span_labels() { - if span_label.span.is_dummy() { - continue; - } - - let lo = sm.lookup_char_pos(span_label.span.lo()); - let mut hi = sm.lookup_char_pos(span_label.span.hi()); - - // Watch out for "empty spans". If we get a span like 6..6, we - // want to just display a `^` at 6, so convert that to - // 6..7. This is degenerate input, but it's best to degrade - // gracefully -- and the parser likes to supply a span like - // that for EOF, in particular. - - if lo.col_display == hi.col_display && lo.line == hi.line { - hi.col_display += 1; - } - - let ann_type = if lo.line != hi.line { - let ml = MultilineAnnotation { - depth: 1, - line_start: lo.line, - line_end: hi.line, - start_col: lo.col_display, - end_col: hi.col_display, - is_primary: span_label.is_primary, - label: span_label.label.clone(), - overlaps_exactly: false, - }; - multiline_annotations.push((lo.file.clone(), ml.clone())); - AnnotationType::Multiline(ml) - } else { - AnnotationType::Singleline - }; - let ann = Annotation { - start_col: lo.col_display, - end_col: hi.col_display, - is_primary: span_label.is_primary, - label: span_label.label.clone(), - annotation_type: ann_type, - }; - - if !ann.is_multiline() { - add_annotation_to_file(&mut output, lo.file, lo.line, ann); - } - } - } - - // Find overlapping multiline annotations, put them at different depths - multiline_annotations.sort_by_key(|&(_, ref ml)| (ml.line_start, ml.line_end)); - for item in multiline_annotations.clone() { - let ann = item.1; - for item in multiline_annotations.iter_mut() { - let ref mut a = item.1; - // Move all other multiline annotations overlapping with this one - // one level to the right. - if !(ann.same_span(a)) && - num_overlap(ann.line_start, ann.line_end, a.line_start, a.line_end, true) - { - a.increase_depth(); - } else if ann.same_span(a) && &ann != a { - a.overlaps_exactly = true; - } else { - break; - } - } - } - - let mut max_depth = 0; // max overlapping multiline spans - for (file, ann) in multiline_annotations { - if ann.depth > max_depth { - max_depth = ann.depth; - } - let mut end_ann = ann.as_end(); - if !ann.overlaps_exactly { - // avoid output like - // - // | foo( - // | _____^ - // | |_____| - // | || bar, - // | || ); - // | || ^ - // | ||______| - // | |______foo - // | baz - // - // and instead get - // - // | foo( - // | _____^ - // | | bar, - // | | ); - // | | ^ - // | | | - // | |______foo - // | baz - add_annotation_to_file(&mut output, file.clone(), ann.line_start, ann.as_start()); - // 4 is the minimum vertical length of a multiline span when presented: two lines - // of code and two lines of underline. This is not true for the special case where - // the beginning doesn't have an underline, but the current logic seems to be - // working correctly. - let middle = min(ann.line_start + 4, ann.line_end); - for line in ann.line_start + 1..middle { - // Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`). - add_annotation_to_file(&mut output, file.clone(), line, ann.as_line()); - } - if middle < ann.line_end - 1 { - for line in ann.line_end - 1..ann.line_end { - add_annotation_to_file(&mut output, file.clone(), line, ann.as_line()); - } - } - } else { - end_ann.annotation_type = AnnotationType::Singleline; - } - add_annotation_to_file(&mut output, file, ann.line_end, end_ann); - } - for file_vec in output.iter_mut() { - file_vec.multiline_depth = max_depth; - } - output - } - fn render_source_line(&self, buffer: &mut StyledBuffer, file: Lrc, @@ -1093,9 +932,7 @@ impl EmitterWriter { } } - // Preprocess all the annotations so that they are grouped by file and by line number - // This helps us quickly iterate over the whole message (including secondary file spans) - let mut annotated_files = self.preprocess_annotations(msp); + let mut annotated_files = FileWithAnnotatedLines::collect_annotations(msp, &self.sm); // Make sure our primary file comes first let (primary_lo, sm) = if let (Some(sm), Some(ref primary_span)) = @@ -1503,6 +1340,176 @@ impl EmitterWriter { } } +impl FileWithAnnotatedLines { + /// Preprocess all the annotations so that they are grouped by file and by line number + /// This helps us quickly iterate over the whole message (including secondary file spans) + pub fn collect_annotations( + msp: &MultiSpan, + source_map: &Option> + ) -> Vec { + fn add_annotation_to_file(file_vec: &mut Vec, + file: Lrc, + line_index: usize, + ann: Annotation) { + + for slot in file_vec.iter_mut() { + // Look through each of our files for the one we're adding to + if slot.file.name == file.name { + // See if we already have a line for it + for line_slot in &mut slot.lines { + if line_slot.line_index == line_index { + line_slot.annotations.push(ann); + return; + } + } + // We don't have a line yet, create one + slot.lines.push(Line { + line_index, + annotations: vec![ann], + }); + slot.lines.sort(); + return; + } + } + // This is the first time we're seeing the file + file_vec.push(FileWithAnnotatedLines { + file, + lines: vec![Line { + line_index, + annotations: vec![ann], + }], + multiline_depth: 0, + }); + } + + let mut output = vec![]; + let mut multiline_annotations = vec![]; + + if let Some(ref sm) = source_map { + for span_label in msp.span_labels() { + if span_label.span.is_dummy() { + continue; + } + + let lo = sm.lookup_char_pos(span_label.span.lo()); + let mut hi = sm.lookup_char_pos(span_label.span.hi()); + + // Watch out for "empty spans". If we get a span like 6..6, we + // want to just display a `^` at 6, so convert that to + // 6..7. This is degenerate input, but it's best to degrade + // gracefully -- and the parser likes to supply a span like + // that for EOF, in particular. + + if lo.col_display == hi.col_display && lo.line == hi.line { + hi.col_display += 1; + } + + let ann_type = if lo.line != hi.line { + let ml = MultilineAnnotation { + depth: 1, + line_start: lo.line, + line_end: hi.line, + start_col: lo.col_display, + end_col: hi.col_display, + is_primary: span_label.is_primary, + label: span_label.label.clone(), + overlaps_exactly: false, + }; + multiline_annotations.push((lo.file.clone(), ml.clone())); + AnnotationType::Multiline(ml) + } else { + AnnotationType::Singleline + }; + let ann = Annotation { + start_col: lo.col_display, + end_col: hi.col_display, + is_primary: span_label.is_primary, + label: span_label.label.clone(), + annotation_type: ann_type, + }; + + if !ann.is_multiline() { + add_annotation_to_file(&mut output, lo.file, lo.line, ann); + } + } + } + + // Find overlapping multiline annotations, put them at different depths + multiline_annotations.sort_by_key(|&(_, ref ml)| (ml.line_start, ml.line_end)); + for item in multiline_annotations.clone() { + let ann = item.1; + for item in multiline_annotations.iter_mut() { + let ref mut a = item.1; + // Move all other multiline annotations overlapping with this one + // one level to the right. + if !(ann.same_span(a)) && + num_overlap(ann.line_start, ann.line_end, a.line_start, a.line_end, true) + { + a.increase_depth(); + } else if ann.same_span(a) && &ann != a { + a.overlaps_exactly = true; + } else { + break; + } + } + } + + let mut max_depth = 0; // max overlapping multiline spans + for (file, ann) in multiline_annotations { + if ann.depth > max_depth { + max_depth = ann.depth; + } + let mut end_ann = ann.as_end(); + if !ann.overlaps_exactly { + // avoid output like + // + // | foo( + // | _____^ + // | |_____| + // | || bar, + // | || ); + // | || ^ + // | ||______| + // | |______foo + // | baz + // + // and instead get + // + // | foo( + // | _____^ + // | | bar, + // | | ); + // | | ^ + // | | | + // | |______foo + // | baz + add_annotation_to_file(&mut output, file.clone(), ann.line_start, ann.as_start()); + // 4 is the minimum vertical length of a multiline span when presented: two lines + // of code and two lines of underline. This is not true for the special case where + // the beginning doesn't have an underline, but the current logic seems to be + // working correctly. + let middle = min(ann.line_start + 4, ann.line_end); + for line in ann.line_start + 1..middle { + // Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`). + add_annotation_to_file(&mut output, file.clone(), line, ann.as_line()); + } + if middle < ann.line_end - 1 { + for line in ann.line_end - 1..ann.line_end { + add_annotation_to_file(&mut output, file.clone(), line, ann.as_line()); + } + } + } else { + end_ann.annotation_type = AnnotationType::Singleline; + } + add_annotation_to_file(&mut output, file, ann.line_end, end_ann); + } + for file_vec in output.iter_mut() { + file_vec.multiline_depth = max_depth; + } + output + } +} + fn draw_col_separator(buffer: &mut StyledBuffer, line: usize, col: usize) { buffer.puts(line, col, "| ", Style::LineNumber); } From 9f92668ce1ae2d4634a0a04024b316ba8b6939a2 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 21 May 2019 12:11:23 +0200 Subject: [PATCH 30/65] Emit error when trying to use PGO in conjunction with unwinding on Windows. --- src/librustc/session/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 3d8092f6e00..275df6d9f82 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1281,6 +1281,18 @@ fn validate_commandline_args_with_session_available(sess: &Session) { path.display())); } } + + // PGO does not work reliably with panic=unwind on Windows. Let's make it + // an error to combine the two for now. It always runs into an assertions + // if LLVM is built with assertions, but without assertions it sometimes + // does not crash and will probably generate a corrupted binary. + if sess.opts.debugging_opts.pgo_gen.enabled() && + sess.target.target.options.is_like_msvc && + sess.panic_strategy() == PanicStrategy::Unwind { + sess.err("Profile-guided optimization does not yet work in conjunction \ + with `-Cpanic=unwind` on Windows when targeting MSVC. \ + See https://github.com/rust-lang/rust/issues/61002 for details."); + } } /// Hash value constructed out of all the `-C metadata` arguments passed to the From ebabcf710515fb2b24907cf90fe02410ad675829 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 22 May 2019 10:35:14 +0200 Subject: [PATCH 31/65] Make test/codegen/pgo-instrumentation.rs work reliably on Windows. --- src/test/codegen/pgo-instrumentation.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/test/codegen/pgo-instrumentation.rs b/src/test/codegen/pgo-instrumentation.rs index 8493ef565d8..e9436505886 100644 --- a/src/test/codegen/pgo-instrumentation.rs +++ b/src/test/codegen/pgo-instrumentation.rs @@ -1,20 +1,23 @@ // Test that `-Zpgo-gen` creates expected instrumentation artifacts in LLVM IR. +// Compiling with `-Cpanic=abort` because PGO+unwinding isn't supported on all platforms. // needs-profiler-support -// compile-flags: -Z pgo-gen -Ccodegen-units=1 +// compile-flags: -Z pgo-gen -Ccodegen-units=1 -Cpanic=abort // CHECK: @__llvm_profile_raw_version = // CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global // CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global -// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}main{{.*}} = private global -// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}main{{.*}} = private global +// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}some_other_function{{.*}} = private global +// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}some_other_function{{.*}} = private global // CHECK: @__llvm_profile_filename = {{.*}}"default_%m.profraw\00"{{.*}} +#![crate_type="lib"] + #[inline(never)] fn some_function() { } -fn main() { +pub fn some_other_function() { some_function(); } From 1b86bd73cd5e8e463f50e5c53968125d0ab4e1f0 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 28 May 2019 15:18:37 +0200 Subject: [PATCH 32/65] is_union returns ty to avoid computing it twice --- .../borrow_check/conflict_errors.rs | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index 8022d1f0c73..58adc24b809 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -595,11 +595,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { ) -> (String, String, String, String) { // Define a small closure that we can use to check if the type of a place // is a union. - let is_union = |place: &Place<'tcx>| -> bool { - place.ty(self.mir, self.infcx.tcx).ty - .ty_adt_def() - .map(|adt| adt.is_union()) - .unwrap_or(false) + let union_ty = |place: &Place<'tcx>| -> Option> { + let ty = place.ty(self.mir, self.infcx.tcx).ty; + ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty) }; // Start with an empty tuple, so we can use the functions on `Option` to reduce some @@ -619,7 +617,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let mut current = first_borrowed_place; while let Place::Projection(box Projection { base, elem }) = current { match elem { - ProjectionElem::Field(field, _) if is_union(base) => { + ProjectionElem::Field(field, _) if union_ty(base).is_some() => { return Some((base, field)); }, _ => current = base, @@ -632,25 +630,29 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // borrowed place and look for a access to a different field of the same union. let mut current = second_borrowed_place; while let Place::Projection(box Projection { base, elem }) = current { - match elem { - ProjectionElem::Field(field, _) if { - is_union(base) && field != target_field && base == target_base - } => { - let desc_base = self.describe_place(base) - .unwrap_or_else(|| "_".to_owned()); - let desc_first = self.describe_place(first_borrowed_place) - .unwrap_or_else(|| "_".to_owned()); - let desc_second = self.describe_place(second_borrowed_place) - .unwrap_or_else(|| "_".to_owned()); + if let ProjectionElem::Field(field, _) = elem { + if let Some(union_ty) = union_ty(base) { + if field != target_field && base == target_base { + let desc_base = + self.describe_place(base).unwrap_or_else(|| "_".to_owned()); + let desc_first = self + .describe_place(first_borrowed_place) + .unwrap_or_else(|| "_".to_owned()); + let desc_second = self + .describe_place(second_borrowed_place) + .unwrap_or_else(|| "_".to_owned()); - // Also compute the name of the union type, eg. `Foo` so we - // can add a helpful note with it. - let ty = base.ty(self.mir, self.infcx.tcx).ty; - - return Some((desc_base, desc_first, desc_second, ty.to_string())); - }, - _ => current = base, + return Some(( + desc_base, + desc_first, + desc_second, + union_ty.to_string(), + )); + } + } } + + current = base; } None }) From bb94fc00695be648f62751e8f393e11644d938ae Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 28 May 2019 16:47:59 +0200 Subject: [PATCH 33/65] Use closure to avoid self.describe_place(...).unwrap_or_else(...) repetition --- .../borrow_check/conflict_errors.rs | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index 58adc24b809..5c5d495466c 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -599,6 +599,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let ty = place.ty(self.mir, self.infcx.tcx).ty; ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty) }; + let describe_place = |place| self.describe_place(place).unwrap_or_else(|| "_".to_owned()); // Start with an empty tuple, so we can use the functions on `Option` to reduce some // code duplication (particularly around returning an empty description in the failure @@ -633,19 +634,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { if let ProjectionElem::Field(field, _) = elem { if let Some(union_ty) = union_ty(base) { if field != target_field && base == target_base { - let desc_base = - self.describe_place(base).unwrap_or_else(|| "_".to_owned()); - let desc_first = self - .describe_place(first_borrowed_place) - .unwrap_or_else(|| "_".to_owned()); - let desc_second = self - .describe_place(second_borrowed_place) - .unwrap_or_else(|| "_".to_owned()); - return Some(( - desc_base, - desc_first, - desc_second, + describe_place(base), + describe_place(first_borrowed_place), + describe_place(second_borrowed_place), union_ty.to_string(), )); } @@ -659,9 +651,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { .unwrap_or_else(|| { // If we didn't find a field access into a union, or both places match, then // only return the description of the first place. - let desc_place = self.describe_place(first_borrowed_place) - .unwrap_or_else(|| "_".to_owned()); - (desc_place, "".to_string(), "".to_string(), "".to_string()) + ( + describe_place(first_borrowed_place), + "".to_string(), + "".to_string(), + "".to_string(), + ) }) } From 5e4d83e9720191dde99e9d54d09df09aa835a176 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 27 May 2019 23:37:18 +0200 Subject: [PATCH 34/65] Rename Place::local to Place::local_or_deref_local --- src/librustc/mir/mod.rs | 2 +- src/librustc_mir/borrow_check/conflict_errors.rs | 6 +++--- src/librustc_mir/borrow_check/error_reporting.rs | 10 +++++----- src/librustc_mir/build/expr/as_rvalue.rs | 2 +- src/librustc_mir/dataflow/impls/storage_liveness.rs | 6 ++++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 84aff8101a0..d70470fe261 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2040,7 +2040,7 @@ impl<'tcx> Place<'tcx> { /// a single deref of a local. // // FIXME: can we safely swap the semantics of `fn base_local` below in here instead? - pub fn local(&self) -> Option { + pub fn local_or_deref_local(&self) -> Option { match self { Place::Base(PlaceBase::Local(local)) | Place::Projection(box Projection { diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index 8022d1f0c73..f464e58e36b 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -1616,7 +1616,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { ); // Find the local from the operand. - let assigned_from_local = match assigned_from.local() { + let assigned_from_local = match assigned_from.local_or_deref_local() { Some(local) => local, None => continue, }; @@ -1672,7 +1672,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { ); // Find the local from the rvalue. - let assigned_from_local = match assigned_from.local() { + let assigned_from_local = match assigned_from.local_or_deref_local() { Some(local) => local, None => continue, }; @@ -1735,7 +1735,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { assigned_from, ); - if let Some(assigned_from_local) = assigned_from.local() { + if let Some(assigned_from_local) = assigned_from.local_or_deref_local() { debug!( "annotate_argument_and_return_for_borrow: assigned_from_local={:?}", assigned_from_local, diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index ec0359794e7..5a22c81a5d0 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -37,15 +37,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { diag: &mut DiagnosticBuilder<'_>, ) { debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place); - let mut target = place.local(); + let mut target = place.local_or_deref_local(); for stmt in &self.mir[location.block].statements[location.statement_index..] { debug!("add_moved_or_invoked_closure_note: stmt={:?} target={:?}", stmt, target); if let StatementKind::Assign(into, box Rvalue::Use(from)) = &stmt.kind { debug!("add_fnonce_closure_note: into={:?} from={:?}", into, from); match from { Operand::Copy(ref place) | - Operand::Move(ref place) if target == place.local() => - target = into.local(), + Operand::Move(ref place) if target == place.local_or_deref_local() => + target = into.local_or_deref_local(), _ => {}, } } @@ -69,8 +69,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { if self.infcx.tcx.parent(id) == self.infcx.tcx.lang_items().fn_once_trait() { let closure = match args.first() { Some(Operand::Copy(ref place)) | - Some(Operand::Move(ref place)) if target == place.local() => - place.local().unwrap(), + Some(Operand::Move(ref place)) if target == place.local_or_deref_local() => + place.local_or_deref_local().unwrap(), _ => return, }; diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index 07a9f294fb6..685db7713ca 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -528,7 +528,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { }) => { // Not projected from the implicit `self` in a closure. debug_assert!( - match base.local() { + match base.local_or_deref_local() { Some(local) => local == Local::new(1), None => false, }, diff --git a/src/librustc_mir/dataflow/impls/storage_liveness.rs b/src/librustc_mir/dataflow/impls/storage_liveness.rs index 3bf11c57379..5dde9812d60 100644 --- a/src/librustc_mir/dataflow/impls/storage_liveness.rs +++ b/src/librustc_mir/dataflow/impls/storage_liveness.rs @@ -46,8 +46,10 @@ impl<'a, 'tcx> BitDenotation<'tcx> for MaybeStorageLive<'a, 'tcx> { sets: &mut BlockSets<'_, Local>, loc: Location) { match &self.mir[loc.block].terminator().kind { - TerminatorKind::Drop { location, .. } => if let Some(l) = location.local() { - sets.kill(l); + TerminatorKind::Drop { location, .. } => { + if let Some(l) = location.local_or_deref_local() { + sets.kill(l); + } } _ => (), } From 6bb6c001be34d0932a014df981ee18f165c43374 Mon Sep 17 00:00:00 2001 From: Andre Bogus Date: Tue, 28 May 2019 19:10:39 +0200 Subject: [PATCH 35/65] implicit `Option`-returning doctests This distinguishes `Option` and `Result`-returning doctests with implicit `main` method, where the former tests must end with `Some(())`. --- src/doc/rustdoc/src/documentation-tests.md | 13 +++++++++++++ src/librustdoc/test.rs | 7 ++++++- src/test/rustdoc/process-termination.rs | 12 ++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/doc/rustdoc/src/documentation-tests.md b/src/doc/rustdoc/src/documentation-tests.md index c9acd3c307b..a896ce819ae 100644 --- a/src/doc/rustdoc/src/documentation-tests.md +++ b/src/doc/rustdoc/src/documentation-tests.md @@ -253,6 +253,19 @@ conversion, so type inference fails because the type is not unique. Please note that you must write the `(())` in one sequence without intermediate whitespace so that rustdoc understands you want an implicit `Result`-returning function. +As of version 1.37.0, this simplification also works with `Option`s, which can +be handy to test e.g. iterators or checked arithmetic, for example: + +```ignore +/// ``` +/// let _ = &[].iter().next()?; +///# Some(()) +/// ``` +``` + +Note that the result must be a `Some(())` and this has to be written in one go. +In this case disambiguating the result isn't required. + ## Documenting macros Here’s an example of documenting a macro: diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index d76d4380755..1b6460f5251 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -499,8 +499,13 @@ pub fn make_test(s: &str, prog.push_str(everything_else); } else { let returns_result = everything_else.trim_end().ends_with("(())"); + let returns_option = everything_else.trim_end().ends_with("Some(())"); let (main_pre, main_post) = if returns_result { - ("fn main() { fn _inner() -> Result<(), impl core::fmt::Debug> {", + (if returns_option { + "fn main() { fn _inner() -> Option<()> {" + } else { + "fn main() { fn _inner() -> Result<(), impl core::fmt::Debug> {" + }, "}\n_inner().unwrap() }") } else { ("fn main() {\n", "\n}") diff --git a/src/test/rustdoc/process-termination.rs b/src/test/rustdoc/process-termination.rs index 32258792b6e..31ae0143d47 100644 --- a/src/test/rustdoc/process-termination.rs +++ b/src/test/rustdoc/process-termination.rs @@ -21,4 +21,16 @@ /// Err("This is returned from `main`, leading to panic")?; /// Ok::<(), &'static str>(()) /// ``` +/// +/// This also works with `Option<()>`s now: +/// +/// ```rust +/// Some(()) +/// ``` +/// +/// ```rust,should_panic +/// let x: &[u32] = &[]; +/// let _ = x.iter().next()?; +/// Some(()) +/// ``` pub fn check_process_termination() {} From a552e7a85f65075b148a7d5cf039fbae5846fa1b Mon Sep 17 00:00:00 2001 From: Bastian Germann Date: Tue, 28 May 2019 19:30:46 +0200 Subject: [PATCH 36/65] Revert "Disable solaris target since toolchain no longer builds" This reverts commit e764f475ca7fffd6167ea991afc7d1b2b3f642dc. Fixes #61174. --- src/ci/docker/dist-various-2/Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ci/docker/dist-various-2/Dockerfile b/src/ci/docker/dist-various-2/Dockerfile index bf449c83f12..53523d41a55 100644 --- a/src/ci/docker/dist-various-2/Dockerfile +++ b/src/ci/docker/dist-various-2/Dockerfile @@ -32,10 +32,9 @@ COPY dist-various-2/build-cloudabi-toolchain.sh /tmp/ RUN /tmp/build-cloudabi-toolchain.sh x86_64-unknown-cloudabi COPY dist-various-2/build-fuchsia-toolchain.sh /tmp/ RUN /tmp/build-fuchsia-toolchain.sh -# FIXME(#61022) - reenable solaris -# COPY dist-various-2/build-solaris-toolchain.sh /tmp/ -# RUN /tmp/build-solaris-toolchain.sh x86_64 amd64 solaris-i386 -# RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc +COPY dist-various-2/build-solaris-toolchain.sh /tmp/ +RUN /tmp/build-solaris-toolchain.sh x86_64 amd64 solaris-i386 +RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc COPY dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/ # We pass the commit id of the port of LLVM's libunwind to the build script. # Any update to the commit id here, should cause the container image to be re-built from this point on. @@ -76,9 +75,8 @@ ENV TARGETS=x86_64-fuchsia ENV TARGETS=$TARGETS,aarch64-fuchsia ENV TARGETS=$TARGETS,wasm32-unknown-unknown ENV TARGETS=$TARGETS,wasm32-wasi -# FIXME(#61022) - reenable solaris -# ENV TARGETS=$TARGETS,sparcv9-sun-solaris -# ENV TARGETS=$TARGETS,x86_64-sun-solaris +ENV TARGETS=$TARGETS,sparcv9-sun-solaris +ENV TARGETS=$TARGETS,x86_64-sun-solaris ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32 ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx From f7cc467b59474dcbe9dcaf3c22dab3e663937de5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 28 May 2019 10:00:53 -0700 Subject: [PATCH 37/65] rustbuild: Tweak how stage1 compilers are selected This commit furthers the previous one to ensure that we don't build an extra stage of the compiler in CI. A test has been added to rustbuild to ensure that this doesn't regress, and then in debugging this test it was hunted down that the `dist::Std` target was the one erroneously pulling in the wrong compiler. The `dist::Std` step was updated to instead account for the "full bootstrap" or not flag, ensuring that the correct compiler for compiling the final standard library was used. This was another use of the `force_use_stage1` function which was in theory supposed to be pretty central, so existing users were all evaluated and a new function, `Builder::compiler_for`, was introduced. All existing users of `force_use_stage1` have been updated to use `compiler_for`, where the semantics of `compiler_for` are similar to that of `compiler` except that it doesn't guarantee the presence of a sysroot for the arguments passed (as they may be modified). Perhaps one day we can unify `compiler` and `compiler_for`, but the usage of `Builder::compiler` is so ubiquitous it would take quite some time to evaluate whether each one needs the sysroot or not, so it's hoped that can be done in parallel. --- src/bootstrap/builder.rs | 101 ++++++++++++++++++++++++--------------- src/bootstrap/compile.rs | 29 ++++++----- src/bootstrap/dist.rs | 17 +++---- src/bootstrap/doc.rs | 35 ++------------ src/bootstrap/test.rs | 14 ++---- 5 files changed, 98 insertions(+), 98 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 51663e93169..4369b64b739 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -577,6 +577,25 @@ impl<'a> Builder<'a> { }) } + /// Similar to `compiler`, except handles the full-bootstrap option to + /// silently use the stage1 compiler instead of a stage2 compiler if one is + /// requested. + /// + /// Note that this does *not* have the side effect of creating + /// `compiler(stage, host)`, unlike `compiler` above which does have such + /// a side effect. The returned compiler here can only be used to compile + /// new artifacts, it can't be used to rely on the presence of a particular + /// sysroot. + /// + /// See `force_use_stage1` for documentation on what each argument is. + pub fn compiler_for(&self, stage: u32, host: Interned, target: Interned) -> Compiler { + if self.build.force_use_stage1(Compiler { stage, host }, target) { + self.compiler(1, self.config.build) + } else { + self.compiler(stage, host) + } + } + pub fn sysroot(&self, compiler: Compiler) -> Interned { self.ensure(compile::Sysroot { compiler }) } @@ -750,11 +769,7 @@ impl<'a> Builder<'a> { // This is for the original compiler, but if we're forced to use stage 1, then // std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since // we copy the libs forward. - let cmp = if self.force_use_stage1(compiler, target) { - self.compiler(1, compiler.host) - } else { - compiler - }; + let cmp = self.compiler_for(compiler.stage, compiler.host, target); let libstd_stamp = match cmd { "check" => check::libstd_stamp(self, cmp, target), @@ -1371,7 +1386,7 @@ mod __test { assert_eq!( first(builder.cache.all::()), &[dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: a, },] ); @@ -1408,7 +1423,7 @@ mod __test { first(builder.cache.all::()), &[ dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: a, }, dist::Std { @@ -1455,11 +1470,11 @@ mod __test { first(builder.cache.all::()), &[ dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: a, }, dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: b, }, ] @@ -1467,6 +1482,39 @@ mod __test { assert_eq!(first(builder.cache.all::()), &[dist::Src]); } + #[test] + fn dist_only_cross_host() { + let a = INTERNER.intern_str("A"); + let b = INTERNER.intern_str("B"); + let mut build = Build::new(configure(&["B"], &[])); + build.config.docs = false; + build.hosts = vec![b]; + let mut builder = Builder::new(&build); + builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]); + + assert_eq!( + first(builder.cache.all::()), + &[ + dist::Rustc { + compiler: Compiler { host: b, stage: 2 } + }, + ] + ); + assert_eq!( + first(builder.cache.all::()), + &[ + compile::Rustc { + compiler: Compiler { host: a, stage: 0 }, + target: a, + }, + compile::Rustc { + compiler: Compiler { host: a, stage: 1 }, + target: b, + }, + ] + ); + } + #[test] fn dist_with_targets_and_hosts() { let build = Build::new(configure(&["B"], &["C"])); @@ -1508,11 +1556,11 @@ mod __test { first(builder.cache.all::()), &[ dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: a, }, dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: b, }, dist::Std { @@ -1557,11 +1605,11 @@ mod __test { first(builder.cache.all::()), &[ dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: a, }, dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: b, }, dist::Std { @@ -1608,11 +1656,11 @@ mod __test { first(builder.cache.all::()), &[ dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: a, }, dist::Std { - compiler: Compiler { host: a, stage: 2 }, + compiler: Compiler { host: a, stage: 1 }, target: b, }, ] @@ -1662,10 +1710,6 @@ mod __test { compiler: Compiler { host: a, stage: 1 }, target: b, }, - compile::Test { - compiler: Compiler { host: a, stage: 2 }, - target: b, - }, ] ); assert_eq!( @@ -1718,10 +1762,6 @@ mod __test { compiler: Compiler { host: b, stage: 2 }, target: a, }, - compile::Rustc { - compiler: Compiler { host: a, stage: 0 }, - target: b, - }, compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b, @@ -1756,10 +1796,6 @@ mod __test { compiler: Compiler { host: b, stage: 2 }, target: a, }, - compile::Test { - compiler: Compiler { host: a, stage: 0 }, - target: b, - }, compile::Test { compiler: Compiler { host: a, stage: 1 }, target: b, @@ -1806,9 +1842,6 @@ mod __test { compile::Assemble { target_compiler: Compiler { host: a, stage: 1 }, }, - compile::Assemble { - target_compiler: Compiler { host: b, stage: 1 }, - }, compile::Assemble { target_compiler: Compiler { host: a, stage: 2 }, }, @@ -1828,10 +1861,6 @@ mod __test { compiler: Compiler { host: a, stage: 1 }, target: a, }, - compile::Rustc { - compiler: Compiler { host: a, stage: 0 }, - target: b, - }, compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b, @@ -1858,10 +1887,6 @@ mod __test { compiler: Compiler { host: b, stage: 2 }, target: a, }, - compile::Test { - compiler: Compiler { host: a, stage: 0 }, - target: b, - }, compile::Test { compiler: Compiler { host: a, stage: 1 }, target: b, diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 2da5e1c5902..057dcea7f24 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -70,20 +70,20 @@ impl Step for Std { builder.ensure(StartupObjects { compiler, target }); - if builder.force_use_stage1(compiler, target) { - let from = builder.compiler(1, builder.config.build); + let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); + if compiler_to_use != compiler { builder.ensure(Std { - compiler: from, + compiler: compiler_to_use, target, }); - builder.info(&format!("Uplifting stage1 std ({} -> {})", from.host, target)); + builder.info(&format!("Uplifting stage1 std ({} -> {})", compiler_to_use.host, target)); // Even if we're not building std this stage, the new sysroot must // still contain the third party objects needed by various targets. copy_third_party_objects(builder, &compiler, target); builder.ensure(StdLink { - compiler: from, + compiler: compiler_to_use, target_compiler: compiler, target, }); @@ -402,15 +402,16 @@ impl Step for Test { return; } - if builder.force_use_stage1(compiler, target) { + let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); + if compiler_to_use != compiler { builder.ensure(Test { - compiler: builder.compiler(1, builder.config.build), + compiler: compiler_to_use, target, }); builder.info( &format!("Uplifting stage1 test ({} -> {})", builder.config.build, target)); builder.ensure(TestLink { - compiler: builder.compiler(1, builder.config.build), + compiler: compiler_to_use, target_compiler: compiler, target, }); @@ -527,15 +528,16 @@ impl Step for Rustc { return; } - if builder.force_use_stage1(compiler, target) { + let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); + if compiler_to_use != compiler { builder.ensure(Rustc { - compiler: builder.compiler(1, builder.config.build), + compiler: compiler_to_use, target, }); builder.info(&format!("Uplifting stage1 rustc ({} -> {})", builder.config.build, target)); builder.ensure(RustcLink { - compiler: builder.compiler(1, builder.config.build), + compiler: compiler_to_use, target_compiler: compiler, target, }); @@ -691,9 +693,10 @@ impl Step for CodegenBackend { return; } - if builder.force_use_stage1(compiler, target) { + let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); + if compiler_to_use != compiler { builder.ensure(CodegenBackend { - compiler: builder.compiler(1, builder.config.build), + compiler: compiler_to_use, target, backend, }); diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index b0616ff6691..8a96e9a27d8 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -647,7 +647,11 @@ impl Step for Std { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Std { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), + compiler: run.builder.compiler_for( + run.builder.top_stage, + run.builder.config.build, + run.target, + ), target: run.target, }); } @@ -757,13 +761,10 @@ impl Step for Analysis { builder.ensure(Std { compiler, target }); - // Package save-analysis from stage1 if not doing a full bootstrap, as the - // stage2 artifacts is simply copied from stage1 in that case. - let compiler = if builder.force_use_stage1(compiler, target) { - builder.compiler(1, compiler.host) - } else { - compiler.clone() - }; + // Find the actual compiler (handling the full bootstrap option) which + // produced the save-analysis data because that data isn't copied + // through the sysroot uplifting. + let compiler = builder.compiler_for(compiler.stage, compiler.host, target); let image = tmpdir(builder).join(format!("{}-{}-image", name, target)); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 9c3a17bff6b..7985abf1eb1 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -475,12 +475,7 @@ impl Step for Std { builder.info(&format!("Documenting stage{} std ({})", stage, target)); let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); - let compiler = builder.compiler(stage, builder.config.build); - let compiler = if builder.force_use_stage1(compiler, target) { - builder.compiler(1, compiler.host) - } else { - compiler - }; + let compiler = builder.compiler_for(stage, builder.config.build, target); builder.ensure(compile::Std { compiler, target }); let out_dir = builder.stage_out(compiler, Mode::Std) @@ -563,12 +558,7 @@ impl Step for Test { builder.info(&format!("Documenting stage{} test ({})", stage, target)); let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); - let compiler = builder.compiler(stage, builder.config.build); - let compiler = if builder.force_use_stage1(compiler, target) { - builder.compiler(1, compiler.host) - } else { - compiler - }; + let compiler = builder.compiler_for(stage, builder.config.build, target); // Build libstd docs so that we generate relative links builder.ensure(Std { stage, target }); @@ -632,12 +622,7 @@ impl Step for WhitelistedRustc { builder.info(&format!("Documenting stage{} whitelisted compiler ({})", stage, target)); let out = builder.doc_out(target); t!(fs::create_dir_all(&out)); - let compiler = builder.compiler(stage, builder.config.build); - let compiler = if builder.force_use_stage1(compiler, target) { - builder.compiler(1, compiler.host) - } else { - compiler - }; + let compiler = builder.compiler_for(stage, builder.config.build, target); // Build libstd docs so that we generate relative links builder.ensure(Std { stage, target }); @@ -706,12 +691,7 @@ impl Step for Rustc { t!(fs::create_dir_all(&out)); // Get the correct compiler for this stage. - let compiler = builder.compiler(stage, builder.config.build); - let compiler = if builder.force_use_stage1(compiler, target) { - builder.compiler(1, compiler.host) - } else { - compiler - }; + let compiler = builder.compiler_for(stage, builder.config.build, target); if !builder.config.compiler_docs { builder.info("\tskipping - compiler/librustdoc docs disabled"); @@ -807,12 +787,7 @@ impl Step for Rustdoc { t!(fs::create_dir_all(&out)); // Get the correct compiler for this stage. - let compiler = builder.compiler(stage, builder.config.build); - let compiler = if builder.force_use_stage1(compiler, target) { - builder.compiler(1, compiler.host) - } else { - compiler - }; + let compiler = builder.compiler_for(stage, builder.config.build, target); if !builder.config.compiler_docs { builder.info("\tskipping - compiler/librustdoc docs disabled"); diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 25d45fa5f40..51b23e5801a 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1707,15 +1707,11 @@ impl Step for Crate { builder.ensure(compile::Test { compiler, target }); builder.ensure(RemoteCopyLibs { compiler, target }); - // If we're not doing a full bootstrap but we're testing a stage2 version of - // libstd, then what we're actually testing is the libstd produced in - // stage1. Reflect that here by updating the compiler that we're working - // with automatically. - let compiler = if builder.force_use_stage1(compiler, target) { - builder.compiler(1, compiler.host) - } else { - compiler.clone() - }; + // If we're not doing a full bootstrap but we're testing a stage2 + // version of libstd, then what we're actually testing is the libstd + // produced in stage1. Reflect that here by updating the compiler that + // we're working with automatically. + let compiler = builder.compiler_for(compiler.stage, compiler.host, target); let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand()); match mode { From 54e10558b4c28fd2a861e34ec5daf53b287a4198 Mon Sep 17 00:00:00 2001 From: memoryruins Date: Tue, 28 May 2019 14:42:14 -0400 Subject: [PATCH 38/65] Set bare_trait_objects lint to warn --- src/librustc/lint/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 69d865f53d4..f7af51e4752 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -255,7 +255,7 @@ declare_lint! { declare_lint! { pub BARE_TRAIT_OBJECTS, - Allow, + Warn, "suggest using `dyn Trait` for trait objects" } From a1d1d7a2c696c2afeff2ea206621a32d77fa49dc Mon Sep 17 00:00:00 2001 From: memoryruins Date: Tue, 28 May 2019 14:45:27 -0400 Subject: [PATCH 39/65] Update test/ui/parser for bare_trait_object warnings --- src/test/ui/parser/bounds-obj-parens.rs | 2 ++ src/test/ui/parser/trailing-plus-in-bounds.rs | 1 + src/test/ui/parser/trait-object-bad-parens.rs | 1 + .../ui/parser/trait-object-bad-parens.stderr | 8 +++---- .../ui/parser/trait-object-lifetime-parens.rs | 2 ++ .../trait-object-lifetime-parens.stderr | 10 ++++---- .../parser/trait-object-polytrait-priority.rs | 2 ++ .../trait-object-polytrait-priority.stderr | 2 +- .../ui/parser/trait-object-trait-parens.rs | 3 +++ .../parser/trait-object-trait-parens.stderr | 24 +++++++++++++++++-- 10 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/test/ui/parser/bounds-obj-parens.rs b/src/test/ui/parser/bounds-obj-parens.rs index cc86879bf46..1e0f9e40cdc 100644 --- a/src/test/ui/parser/bounds-obj-parens.rs +++ b/src/test/ui/parser/bounds-obj-parens.rs @@ -1,5 +1,7 @@ // compile-pass +#![allow(bare_trait_objects)] + type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318) fn main() {} diff --git a/src/test/ui/parser/trailing-plus-in-bounds.rs b/src/test/ui/parser/trailing-plus-in-bounds.rs index 153f942b978..89a2953ad0f 100644 --- a/src/test/ui/parser/trailing-plus-in-bounds.rs +++ b/src/test/ui/parser/trailing-plus-in-bounds.rs @@ -2,6 +2,7 @@ // compile-flags: -Z continue-parse-after-error #![feature(box_syntax)] +#![allow(bare_trait_objects)] use std::fmt::Debug; diff --git a/src/test/ui/parser/trait-object-bad-parens.rs b/src/test/ui/parser/trait-object-bad-parens.rs index 0f1f49a521b..e81b019b646 100644 --- a/src/test/ui/parser/trait-object-bad-parens.rs +++ b/src/test/ui/parser/trait-object-bad-parens.rs @@ -1,6 +1,7 @@ // compile-flags: -Z continue-parse-after-error #![feature(optin_builtin_traits)] +#![allow(bare_trait_objects)] auto trait Auto {} diff --git a/src/test/ui/parser/trait-object-bad-parens.stderr b/src/test/ui/parser/trait-object-bad-parens.stderr index 74e484eebee..a36727ffeaf 100644 --- a/src/test/ui/parser/trait-object-bad-parens.stderr +++ b/src/test/ui/parser/trait-object-bad-parens.stderr @@ -1,23 +1,23 @@ error[E0178]: expected a path on the left-hand side of `+`, not `((Auto))` - --> $DIR/trait-object-bad-parens.rs:8:16 + --> $DIR/trait-object-bad-parens.rs:9:16 | LL | let _: Box<((Auto)) + Auto>; | ^^^^^^^^^^^^^^^ expected a path error[E0178]: expected a path on the left-hand side of `+`, not `(Auto + Auto)` - --> $DIR/trait-object-bad-parens.rs:10:16 + --> $DIR/trait-object-bad-parens.rs:11:16 | LL | let _: Box<(Auto + Auto) + Auto>; | ^^^^^^^^^^^^^^^^^^^^ expected a path error[E0178]: expected a path on the left-hand side of `+`, not `(Auto)` - --> $DIR/trait-object-bad-parens.rs:12:16 + --> $DIR/trait-object-bad-parens.rs:13:16 | LL | let _: Box<(Auto +) + Auto>; | ^^^^^^^^^^^^^^^ expected a path error[E0178]: expected a path on the left-hand side of `+`, not `(dyn Auto)` - --> $DIR/trait-object-bad-parens.rs:14:16 + --> $DIR/trait-object-bad-parens.rs:15:16 | LL | let _: Box<(dyn Auto) + Auto>; | ^^^^^^^^^^^^^^^^^ expected a path diff --git a/src/test/ui/parser/trait-object-lifetime-parens.rs b/src/test/ui/parser/trait-object-lifetime-parens.rs index 43f6497f7e7..d5598afd6f4 100644 --- a/src/test/ui/parser/trait-object-lifetime-parens.rs +++ b/src/test/ui/parser/trait-object-lifetime-parens.rs @@ -1,5 +1,7 @@ // compile-flags: -Z continue-parse-after-error +#![allow(bare_trait_objects)] + trait Trait {} fn f<'a, T: Trait + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported diff --git a/src/test/ui/parser/trait-object-lifetime-parens.stderr b/src/test/ui/parser/trait-object-lifetime-parens.stderr index a31b7aea8fe..55f14c97876 100644 --- a/src/test/ui/parser/trait-object-lifetime-parens.stderr +++ b/src/test/ui/parser/trait-object-lifetime-parens.stderr @@ -1,23 +1,23 @@ error: parenthesized lifetime bounds are not supported - --> $DIR/trait-object-lifetime-parens.rs:5:21 + --> $DIR/trait-object-lifetime-parens.rs:7:21 | LL | fn f<'a, T: Trait + ('a)>() {} | ^^^^ help: remove the parentheses error: parenthesized lifetime bounds are not supported - --> $DIR/trait-object-lifetime-parens.rs:8:24 + --> $DIR/trait-object-lifetime-parens.rs:10:24 | LL | let _: Box; | ^^^^ help: remove the parentheses error: expected `:`, found `)` - --> $DIR/trait-object-lifetime-parens.rs:9:19 + --> $DIR/trait-object-lifetime-parens.rs:11:19 | LL | let _: Box<('a) + Trait>; | ^ expected `:` error: chained comparison operators require parentheses - --> $DIR/trait-object-lifetime-parens.rs:9:15 + --> $DIR/trait-object-lifetime-parens.rs:11:15 | LL | let _: Box<('a) + Trait>; | ^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _: Box<('a) + Trait>; = help: or use `(...)` if you meant to specify fn arguments error: expected type, found `'a` - --> $DIR/trait-object-lifetime-parens.rs:9:17 + --> $DIR/trait-object-lifetime-parens.rs:11:17 | LL | let _: Box<('a) + Trait>; | - ^^ diff --git a/src/test/ui/parser/trait-object-polytrait-priority.rs b/src/test/ui/parser/trait-object-polytrait-priority.rs index 40d2ad52c35..63425f3e201 100644 --- a/src/test/ui/parser/trait-object-polytrait-priority.rs +++ b/src/test/ui/parser/trait-object-polytrait-priority.rs @@ -1,3 +1,5 @@ +#![allow(bare_trait_objects)] + trait Trait<'a> {} fn main() { diff --git a/src/test/ui/parser/trait-object-polytrait-priority.stderr b/src/test/ui/parser/trait-object-polytrait-priority.stderr index 5e2a35ea60c..a6add6079ce 100644 --- a/src/test/ui/parser/trait-object-polytrait-priority.stderr +++ b/src/test/ui/parser/trait-object-polytrait-priority.stderr @@ -1,5 +1,5 @@ error[E0178]: expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>` - --> $DIR/trait-object-polytrait-priority.rs:4:12 + --> $DIR/trait-object-polytrait-priority.rs:6:12 | LL | let _: &for<'a> Trait<'a> + 'static; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding parentheses: `&(for<'a> Trait<'a> + 'static)` diff --git a/src/test/ui/parser/trait-object-trait-parens.rs b/src/test/ui/parser/trait-object-trait-parens.rs index 9ac10cd1327..a113de14b6f 100644 --- a/src/test/ui/parser/trait-object-trait-parens.rs +++ b/src/test/ui/parser/trait-object-trait-parens.rs @@ -5,8 +5,11 @@ fn f Trait<'a>)>() {} fn main() { let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>; //~^ ERROR `?Trait` is not permitted in trait object types + //~| WARN trait objects without an explicit `dyn` are deprecated let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>; + //~^ WARN trait objects without an explicit `dyn` are deprecated let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>; //~^ ERROR use of undeclared lifetime name `'a` //~| ERROR `?Trait` is not permitted in trait object types + //~| WARN trait objects without an explicit `dyn` are deprecated } diff --git a/src/test/ui/parser/trait-object-trait-parens.stderr b/src/test/ui/parser/trait-object-trait-parens.stderr index 36494b76539..e3fb8a0113a 100644 --- a/src/test/ui/parser/trait-object-trait-parens.stderr +++ b/src/test/ui/parser/trait-object-trait-parens.stderr @@ -5,13 +5,33 @@ LL | let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>; | ^^^^^^^^ error: `?Trait` is not permitted in trait object types - --> $DIR/trait-object-trait-parens.rs:9:47 + --> $DIR/trait-object-trait-parens.rs:11:47 | LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>; | ^^^^^^^^ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/trait-object-trait-parens.rs:6:16 + | +LL | let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (Copy) + (?Sized) + (for<'a> Trait<'a>)` + | + = note: #[warn(bare_trait_objects)] on by default + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/trait-object-trait-parens.rs:9:16 + | +LL | let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (?Sized) + (for<'a> Trait<'a>) + (Copy)` + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/trait-object-trait-parens.rs:11:16 + | +LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (for<'a> Trait<'a>) + (Copy) + (?Sized)` + error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/trait-object-trait-parens.rs:9:31 + --> $DIR/trait-object-trait-parens.rs:11:31 | LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>; | ^^ undeclared lifetime From 59291dc788d4b14f5c154ab30ccf87d85a472978 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 28 May 2019 11:50:05 -0700 Subject: [PATCH 40/65] rustbuild: Assert extended builds don't dist too much This extends a test in the previous commit to assert that we don't build extra rustc compilers even when the "extended" option is set to true. This involved some internal refactoring to have more judicious usage of `compiler_for`, added in the previous commit, as well. Various `dist::*` targets were refactored to be parameterized with a `Compiler` instead of a `stage`/`host`, and then the various parameters within the `Extended` target were tweaked to ensure that we don't ever accidentally ask for a stage2 build compiler when we're distributing something. --- src/bootstrap/builder.rs | 27 +++---- src/bootstrap/dist.rs | 150 ++++++++++++++++++++++----------------- src/bootstrap/install.rs | 62 ++++++++-------- 3 files changed, 126 insertions(+), 113 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 4369b64b739..56fba94d4c9 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1371,7 +1371,7 @@ mod __test { assert_eq!( first(builder.cache.all::()), - &[dist::Docs { stage: 2, host: a },] + &[dist::Docs { host: a },] ); assert_eq!( first(builder.cache.all::()), @@ -1405,8 +1405,8 @@ mod __test { assert_eq!( first(builder.cache.all::()), &[ - dist::Docs { stage: 2, host: a }, - dist::Docs { stage: 2, host: b }, + dist::Docs { host: a }, + dist::Docs { host: b }, ] ); assert_eq!( @@ -1447,8 +1447,8 @@ mod __test { assert_eq!( first(builder.cache.all::()), &[ - dist::Docs { stage: 2, host: a }, - dist::Docs { stage: 2, host: b }, + dist::Docs { host: a }, + dist::Docs { host: b }, ] ); assert_eq!( @@ -1488,6 +1488,7 @@ mod __test { let b = INTERNER.intern_str("B"); let mut build = Build::new(configure(&["B"], &[])); build.config.docs = false; + build.config.extended = true; build.hosts = vec![b]; let mut builder = Builder::new(&build); builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]); @@ -1528,9 +1529,9 @@ mod __test { assert_eq!( first(builder.cache.all::()), &[ - dist::Docs { stage: 2, host: a }, - dist::Docs { stage: 2, host: b }, - dist::Docs { stage: 2, host: c }, + dist::Docs { host: a }, + dist::Docs { host: b }, + dist::Docs { host: c }, ] ); assert_eq!( @@ -1587,9 +1588,9 @@ mod __test { assert_eq!( first(builder.cache.all::()), &[ - dist::Docs { stage: 2, host: a }, - dist::Docs { stage: 2, host: b }, - dist::Docs { stage: 2, host: c }, + dist::Docs { host: a }, + dist::Docs { host: b }, + dist::Docs { host: c }, ] ); assert_eq!( @@ -1633,8 +1634,8 @@ mod __test { assert_eq!( first(builder.cache.all::()), &[ - dist::Docs { stage: 2, host: a }, - dist::Docs { stage: 2, host: b }, + dist::Docs { host: a }, + dist::Docs { host: b }, ] ); assert_eq!( diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 8a96e9a27d8..27496191618 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -68,7 +68,6 @@ fn missing_tool(tool_name: &str, skip: bool) { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Docs { - pub stage: u32, pub host: Interned, } @@ -82,7 +81,6 @@ impl Step for Docs { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Docs { - stage: run.builder.top_stage, host: run.target, }); } @@ -130,7 +128,6 @@ impl Step for Docs { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustcDocs { - pub stage: u32, pub host: Interned, } @@ -144,7 +141,6 @@ impl Step for RustcDocs { fn make_run(run: RunConfig<'_>) { run.builder.ensure(RustcDocs { - stage: run.builder.top_stage, host: run.target, }); } @@ -741,7 +737,14 @@ impl Step for Analysis { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Analysis { - compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), + // Find the actual compiler (handling the full bootstrap option) which + // produced the save-analysis data because that data isn't copied + // through the sysroot uplifting. + compiler: run.builder.compiler_for( + run.builder.top_stage, + run.builder.config.build, + run.target, + ), target: run.target, }); } @@ -761,11 +764,6 @@ impl Step for Analysis { builder.ensure(Std { compiler, target }); - // Find the actual compiler (handling the full bootstrap option) which - // produced the save-analysis data because that data isn't copied - // through the sysroot uplifting. - let compiler = builder.compiler_for(compiler.stage, compiler.host, target); - let image = tmpdir(builder).join(format!("{}-{}-image", name, target)); let src = builder.stage_out(compiler, Mode::Std) @@ -1067,7 +1065,7 @@ pub fn sanitize_sh(path: &Path) -> String { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Cargo { - pub stage: u32, + pub compiler: Compiler, pub target: Interned, } @@ -1081,16 +1079,20 @@ impl Step for Cargo { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Cargo { - stage: run.builder.top_stage, + compiler: run.builder.compiler_for( + run.builder.top_stage, + run.builder.config.build, + run.target, + ), target: run.target, }); } fn run(self, builder: &Builder<'_>) -> PathBuf { - let stage = self.stage; + let compiler = self.compiler; let target = self.target; - builder.info(&format!("Dist cargo stage{} ({})", stage, target)); + builder.info(&format!("Dist cargo stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/cargo"); let etc = src.join("src/etc"); let release_num = builder.release_num("cargo"); @@ -1105,10 +1107,7 @@ impl Step for Cargo { // Prepare the image directory builder.create_dir(&image.join("share/zsh/site-functions")); builder.create_dir(&image.join("etc/bash_completion.d")); - let cargo = builder.ensure(tool::Cargo { - compiler: builder.compiler(stage, builder.config.build), - target - }); + let cargo = builder.ensure(tool::Cargo { compiler, target }); builder.install(&cargo, &image.join("bin"), 0o755); for man in t!(etc.join("man").read_dir()) { let man = t!(man); @@ -1153,7 +1152,7 @@ impl Step for Cargo { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rls { - pub stage: u32, + pub compiler: Compiler, pub target: Interned, } @@ -1167,17 +1166,21 @@ impl Step for Rls { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rls { - stage: run.builder.top_stage, + compiler: run.builder.compiler_for( + run.builder.top_stage, + run.builder.config.build, + run.target, + ), target: run.target, }); } fn run(self, builder: &Builder<'_>) -> Option { - let stage = self.stage; + let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); - builder.info(&format!("Dist RLS stage{} ({})", stage, target)); + builder.info(&format!("Dist RLS stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/rls"); let release_num = builder.release_num("rls"); let name = pkgname(builder, "rls"); @@ -1192,8 +1195,9 @@ impl Step for Rls { // We expect RLS to build, because we've exited this step above if tool // state for RLS isn't testing. let rls = builder.ensure(tool::Rls { - compiler: builder.compiler(stage, builder.config.build), - target, extra_features: Vec::new() + compiler, + target, + extra_features: Vec::new(), }).or_else(|| { missing_tool("RLS", builder.build.config.missing_tools); None })?; builder.install(&rls, &image.join("bin"), 0o755); @@ -1232,7 +1236,7 @@ impl Step for Rls { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Clippy { - pub stage: u32, + pub compiler: Compiler, pub target: Interned, } @@ -1246,17 +1250,21 @@ impl Step for Clippy { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Clippy { - stage: run.builder.top_stage, + compiler: run.builder.compiler_for( + run.builder.top_stage, + run.builder.config.build, + run.target, + ), target: run.target, }); } fn run(self, builder: &Builder<'_>) -> Option { - let stage = self.stage; + let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); - builder.info(&format!("Dist clippy stage{} ({})", stage, target)); + builder.info(&format!("Dist clippy stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/clippy"); let release_num = builder.release_num("clippy"); let name = pkgname(builder, "clippy"); @@ -1271,11 +1279,12 @@ impl Step for Clippy { // We expect clippy to build, because we've exited this step above if tool // state for clippy isn't testing. let clippy = builder.ensure(tool::Clippy { - compiler: builder.compiler(stage, builder.config.build), - target, extra_features: Vec::new() + compiler, + target, + extra_features: Vec::new(), }).or_else(|| { missing_tool("clippy", builder.build.config.missing_tools); None })?; let cargoclippy = builder.ensure(tool::CargoClippy { - compiler: builder.compiler(stage, builder.config.build), + compiler, target, extra_features: Vec::new() }).or_else(|| { missing_tool("cargo clippy", builder.build.config.missing_tools); None })?; @@ -1316,7 +1325,7 @@ impl Step for Clippy { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Miri { - pub stage: u32, + pub compiler: Compiler, pub target: Interned, } @@ -1330,17 +1339,21 @@ impl Step for Miri { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Miri { - stage: run.builder.top_stage, + compiler: run.builder.compiler_for( + run.builder.top_stage, + run.builder.config.build, + run.target, + ), target: run.target, }); } fn run(self, builder: &Builder<'_>) -> Option { - let stage = self.stage; + let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); - builder.info(&format!("Dist miri stage{} ({})", stage, target)); + builder.info(&format!("Dist miri stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/miri"); let release_num = builder.release_num("miri"); let name = pkgname(builder, "miri"); @@ -1355,12 +1368,14 @@ impl Step for Miri { // We expect miri to build, because we've exited this step above if tool // state for miri isn't testing. let miri = builder.ensure(tool::Miri { - compiler: builder.compiler(stage, builder.config.build), - target, extra_features: Vec::new() + compiler, + target, + extra_features: Vec::new(), }).or_else(|| { missing_tool("miri", builder.build.config.missing_tools); None })?; let cargomiri = builder.ensure(tool::CargoMiri { - compiler: builder.compiler(stage, builder.config.build), - target, extra_features: Vec::new() + compiler, + target, + extra_features: Vec::new() }).or_else(|| { missing_tool("cargo miri", builder.build.config.missing_tools); None })?; builder.install(&miri, &image.join("bin"), 0o755); @@ -1400,7 +1415,7 @@ impl Step for Miri { #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Rustfmt { - pub stage: u32, + pub compiler: Compiler, pub target: Interned, } @@ -1414,16 +1429,20 @@ impl Step for Rustfmt { fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustfmt { - stage: run.builder.top_stage, + compiler: run.builder.compiler_for( + run.builder.top_stage, + run.builder.config.build, + run.target, + ), target: run.target, }); } fn run(self, builder: &Builder<'_>) -> Option { - let stage = self.stage; + let compiler = self.compiler; let target = self.target; - builder.info(&format!("Dist Rustfmt stage{} ({})", stage, target)); + builder.info(&format!("Dist Rustfmt stage{} ({})", compiler.stage, target)); let src = builder.src.join("src/tools/rustfmt"); let release_num = builder.release_num("rustfmt"); let name = pkgname(builder, "rustfmt"); @@ -1436,12 +1455,14 @@ impl Step for Rustfmt { // Prepare the image directory let rustfmt = builder.ensure(tool::Rustfmt { - compiler: builder.compiler(stage, builder.config.build), - target, extra_features: Vec::new() + compiler, + target, + extra_features: Vec::new(), }).or_else(|| { missing_tool("Rustfmt", builder.build.config.missing_tools); None })?; let cargofmt = builder.ensure(tool::Cargofmt { - compiler: builder.compiler(stage, builder.config.build), - target, extra_features: Vec::new() + compiler, + target, + extra_features: Vec::new(), }).or_else(|| { missing_tool("Cargofmt", builder.build.config.missing_tools); None })?; builder.install(&rustfmt, &image.join("bin"), 0o755); @@ -1506,30 +1527,28 @@ impl Step for Extended { /// Creates a combined installer for the specified target in the provided stage. fn run(self, builder: &Builder<'_>) { - let stage = self.stage; let target = self.target; + let stage = self.stage; + let compiler = builder.compiler_for(self.stage, self.host, self.target); - builder.info(&format!("Dist extended stage{} ({})", stage, target)); + builder.info(&format!("Dist extended stage{} ({})", compiler.stage, target)); let rustc_installer = builder.ensure(Rustc { compiler: builder.compiler(stage, target), }); - let cargo_installer = builder.ensure(Cargo { stage, target }); - let rustfmt_installer = builder.ensure(Rustfmt { stage, target }); - let rls_installer = builder.ensure(Rls { stage, target }); - let llvm_tools_installer = builder.ensure(LlvmTools { stage, target }); - let clippy_installer = builder.ensure(Clippy { stage, target }); - let miri_installer = builder.ensure(Miri { stage, target }); + let cargo_installer = builder.ensure(Cargo { compiler, target }); + let rustfmt_installer = builder.ensure(Rustfmt { compiler, target }); + let rls_installer = builder.ensure(Rls { compiler, target }); + let llvm_tools_installer = builder.ensure(LlvmTools { target }); + let clippy_installer = builder.ensure(Clippy { compiler, target }); + let miri_installer = builder.ensure(Miri { compiler, target }); let lldb_installer = builder.ensure(Lldb { target }); let mingw_installer = builder.ensure(Mingw { host: target }); - let analysis_installer = builder.ensure(Analysis { - compiler: builder.compiler(stage, self.host), - target - }); + let analysis_installer = builder.ensure(Analysis { compiler, target }); - let docs_installer = builder.ensure(Docs { stage, host: target, }); + let docs_installer = builder.ensure(Docs { host: target, }); let std_installer = builder.ensure(Std { - compiler: builder.compiler(stage, self.host), + compiler: builder.compiler(stage, target), target, }); @@ -2077,7 +2096,6 @@ pub fn maybe_install_llvm_dylib(builder: &Builder<'_>, #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct LlvmTools { - pub stage: u32, pub target: Interned, } @@ -2091,26 +2109,24 @@ impl Step for LlvmTools { fn make_run(run: RunConfig<'_>) { run.builder.ensure(LlvmTools { - stage: run.builder.top_stage, target: run.target, }); } fn run(self, builder: &Builder<'_>) -> Option { - let stage = self.stage; let target = self.target; assert!(builder.config.extended); /* run only if llvm-config isn't used */ if let Some(config) = builder.config.target_config.get(&target) { if let Some(ref _s) = config.llvm_config { - builder.info(&format!("Skipping LlvmTools stage{} ({}): external LLVM", - stage, target)); + builder.info(&format!("Skipping LlvmTools ({}): external LLVM", + target)); return None; } } - builder.info(&format!("Dist LlvmTools stage{} ({})", stage, target)); + builder.info(&format!("Dist LlvmTools ({})", target)); let src = builder.src.join("src/llvm-project/llvm"); let name = pkgname(builder, "llvm-tools"); diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index deda30b6bbd..f4da02c007f 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -5,12 +5,13 @@ use std::env; use std::fs; -use std::path::{Path, PathBuf, Component}; +use std::path::{Component, Path, PathBuf}; use std::process::Command; use build_helper::t; use crate::dist::{self, pkgname, sanitize_sh, tmpdir}; +use crate::Compiler; use crate::builder::{Builder, RunConfig, ShouldRun, Step}; use crate::cache::Interned; @@ -58,7 +59,7 @@ fn install_sh( package: &str, name: &str, stage: u32, - host: Option> + host: Option>, ) { builder.info(&format!("Install {} stage{} ({:?})", package, stage, host)); @@ -144,9 +145,8 @@ macro_rules! install { $( #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct $name { - pub stage: u32, + pub compiler: Compiler, pub target: Interned, - pub host: Interned, } impl $name { @@ -175,9 +175,8 @@ macro_rules! install { fn make_run(run: RunConfig<'_>) { run.builder.ensure($name { - stage: run.builder.top_stage, + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, - host: run.builder.config.build, }); } @@ -190,67 +189,67 @@ macro_rules! install { install!((self, builder, _config), Docs, "src/doc", _config.docs, only_hosts: false, { - builder.ensure(dist::Docs { stage: self.stage, host: self.target }); - install_docs(builder, self.stage, self.target); + builder.ensure(dist::Docs { host: self.target }); + install_docs(builder, self.compiler.stage, self.target); }; Std, "src/libstd", true, only_hosts: true, { for target in &builder.targets { builder.ensure(dist::Std { - compiler: builder.compiler(self.stage, self.host), + compiler: self.compiler, target: *target }); - install_std(builder, self.stage, *target); + install_std(builder, self.compiler.stage, *target); } }; Cargo, "cargo", Self::should_build(_config), only_hosts: true, { - builder.ensure(dist::Cargo { stage: self.stage, target: self.target }); - install_cargo(builder, self.stage, self.target); + builder.ensure(dist::Cargo { compiler: self.compiler, target: self.target }); + install_cargo(builder, self.compiler.stage, self.target); }; Rls, "rls", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() || + if builder.ensure(dist::Rls { compiler: self.compiler, target: self.target }).is_some() || Self::should_install(builder) { - install_rls(builder, self.stage, self.target); + install_rls(builder, self.compiler.stage, self.target); } else { - builder.info(&format!("skipping Install RLS stage{} ({})", self.stage, self.target)); + builder.info(&format!("skipping Install RLS stage{} ({})", self.compiler.stage, self.target)); } }; Clippy, "clippy", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Clippy { stage: self.stage, target: self.target }).is_some() || + if builder.ensure(dist::Clippy { compiler: self.compiler, target: self.target }).is_some() || Self::should_install(builder) { - install_clippy(builder, self.stage, self.target); + install_clippy(builder, self.compiler.stage, self.target); } else { - builder.info(&format!("skipping Install clippy stage{} ({})", self.stage, self.target)); + builder.info(&format!("skipping Install clippy stage{} ({})", self.compiler.stage, self.target)); } }; Miri, "miri", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Miri { stage: self.stage, target: self.target }).is_some() || + if builder.ensure(dist::Miri { compiler: self.compiler, target: self.target }).is_some() || Self::should_install(builder) { - install_miri(builder, self.stage, self.target); + install_miri(builder, self.compiler.stage, self.target); } else { - builder.info(&format!("skipping Install miri stage{} ({})", self.stage, self.target)); + builder.info(&format!("skipping Install miri stage{} ({})", self.compiler.stage, self.target)); } }; Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() || + if builder.ensure(dist::Rustfmt { compiler: self.compiler, target: self.target }).is_some() || Self::should_install(builder) { - install_rustfmt(builder, self.stage, self.target); + install_rustfmt(builder, self.compiler.stage, self.target); } else { builder.info( - &format!("skipping Install Rustfmt stage{} ({})", self.stage, self.target)); + &format!("skipping Install Rustfmt stage{} ({})", self.compiler.stage, self.target)); } }; Analysis, "analysis", Self::should_build(_config), only_hosts: false, { builder.ensure(dist::Analysis { - compiler: builder.compiler(self.stage, self.host), + compiler: self.compiler, target: self.target }); - install_analysis(builder, self.stage, self.target); + install_analysis(builder, self.compiler.stage, self.target); }; Rustc, "src/librustc", true, only_hosts: true, { builder.ensure(dist::Rustc { - compiler: builder.compiler(self.stage, self.target), + compiler: self.compiler, }); - install_rustc(builder, self.stage, self.target); + install_rustc(builder, self.compiler.stage, self.target); }; ); @@ -266,15 +265,12 @@ impl Step for Src { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let config = &run.builder.config; - let cond = config.extended && - config.tools.as_ref().map_or(true, |t| t.contains("src")); + let cond = config.extended && config.tools.as_ref().map_or(true, |t| t.contains("src")); run.path("src").default_condition(cond) } fn make_run(run: RunConfig<'_>) { - run.builder.ensure(Src { - stage: run.builder.top_stage, - }); + run.builder.ensure(Src { stage: run.builder.top_stage }); } fn run(self, builder: &Builder<'_>) { From 7b362bb84178b9c87b2b9246b7d3d107820e932a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 28 May 2019 11:56:05 -0700 Subject: [PATCH 41/65] Fixup style --- src/bootstrap/builder.rs | 7 ++++++- src/bootstrap/install.rs | 27 +++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 56fba94d4c9..a007cbff064 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -588,7 +588,12 @@ impl<'a> Builder<'a> { /// sysroot. /// /// See `force_use_stage1` for documentation on what each argument is. - pub fn compiler_for(&self, stage: u32, host: Interned, target: Interned) -> Compiler { + pub fn compiler_for( + &self, + stage: u32, + host: Interned, + target: Interned, + ) -> Compiler { if self.build.force_use_stage1(Compiler { stage, host }, target) { self.compiler(1, self.config.build) } else { diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index f4da02c007f..0047be4d595 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -210,15 +210,21 @@ install!((self, builder, _config), Self::should_install(builder) { install_rls(builder, self.compiler.stage, self.target); } else { - builder.info(&format!("skipping Install RLS stage{} ({})", self.compiler.stage, self.target)); + builder.info( + &format!("skipping Install RLS stage{} ({})", self.compiler.stage, self.target), + ); } }; Clippy, "clippy", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Clippy { compiler: self.compiler, target: self.target }).is_some() || - Self::should_install(builder) { + if builder.ensure(dist::Clippy { + compiler: self.compiler, + target: self.target, + }).is_some() || Self::should_install(builder) { install_clippy(builder, self.compiler.stage, self.target); } else { - builder.info(&format!("skipping Install clippy stage{} ({})", self.compiler.stage, self.target)); + builder.info( + &format!("skipping Install clippy stage{} ({})", self.compiler.stage, self.target), + ); } }; Miri, "miri", Self::should_build(_config), only_hosts: true, { @@ -226,16 +232,21 @@ install!((self, builder, _config), Self::should_install(builder) { install_miri(builder, self.compiler.stage, self.target); } else { - builder.info(&format!("skipping Install miri stage{} ({})", self.compiler.stage, self.target)); + builder.info( + &format!("skipping Install miri stage{} ({})", self.compiler.stage, self.target), + ); } }; Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Rustfmt { compiler: self.compiler, target: self.target }).is_some() || - Self::should_install(builder) { + if builder.ensure(dist::Rustfmt { + compiler: self.compiler, + target: self.target + }).is_some() || Self::should_install(builder) { install_rustfmt(builder, self.compiler.stage, self.target); } else { builder.info( - &format!("skipping Install Rustfmt stage{} ({})", self.compiler.stage, self.target)); + &format!("skipping Install Rustfmt stage{} ({})", self.compiler.stage, self.target), + ); } }; Analysis, "analysis", Self::should_build(_config), only_hosts: false, { From 0631d19c9a8d4b31828f0c980bec3d1699e5c10b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 28 May 2019 22:46:48 +0200 Subject: [PATCH 42/65] Avoid unneeded bug!() call --- src/librustc_codegen_ssa/mir/place.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index 670b6c47269..cd32d6f484d 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -396,22 +396,20 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let cx = self.cx; let tcx = self.cx.tcx(); - if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place { - match self.locals[index] { - LocalRef::Place(place) => { - return place; - } - LocalRef::UnsizedPlace(place) => { - return bx.load_operand(place).deref(cx); - } - LocalRef::Operand(..) => { - bug!("using operand local {:?} as place", place); + let result = match *place { + mir::Place::Base(mir::PlaceBase::Local(index)) => { + match self.locals[index] { + LocalRef::Place(place) => { + return place; + } + LocalRef::UnsizedPlace(place) => { + return bx.load_operand(place).deref(cx); + } + LocalRef::Operand(..) => { + bug!("using operand local {:?} as place", place); + } } } - } - - let result = match *place { - mir::Place::Base(mir::PlaceBase::Local(_)) => bug!(), // handled above mir::Place::Base( mir::PlaceBase::Static( box mir::Static { ty, kind: mir::StaticKind::Promoted(promoted) } From 120ce12016005e73dfe01a67aa34c02f0eb432e2 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Wed, 29 May 2019 00:35:14 +0300 Subject: [PATCH 43/65] Rename `TraitOrImpl` to `Assoc` and `trait_or_impl` to `assoc`. --- src/librustc_privacy/lib.rs | 25 +++++++++++++++++++------ src/librustc_resolve/lib.rs | 12 ++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 68930533a28..a08c028390b 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1703,8 +1703,13 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { } } - fn check_trait_or_impl_item(&self, hir_id: hir::HirId, assoc_item_kind: AssocItemKind, - defaultness: hir::Defaultness, vis: ty::Visibility) { + fn check_assoc_item( + &self, + hir_id: hir::HirId, + assoc_item_kind: AssocItemKind, + defaultness: hir::Defaultness, + vis: ty::Visibility, + ) { let mut check = self.check(hir_id, vis); let (check_ty, is_assoc_ty) = match assoc_item_kind { @@ -1754,8 +1759,12 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> self.check(item.hir_id, item_visibility).generics().predicates(); for trait_item_ref in trait_item_refs { - self.check_trait_or_impl_item(trait_item_ref.id.hir_id, trait_item_ref.kind, - trait_item_ref.defaultness, item_visibility); + self.check_assoc_item( + trait_item_ref.id.hir_id, + trait_item_ref.kind, + trait_item_ref.defaultness, + item_visibility, + ); } } hir::ItemKind::TraitAlias(..) => { @@ -1803,8 +1812,12 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> } else { impl_vis }; - self.check_trait_or_impl_item(impl_item_ref.id.hir_id, impl_item_ref.kind, - impl_item_ref.defaultness, impl_item_vis); + self.check_assoc_item( + impl_item_ref.id.hir_id, + impl_item_ref.kind, + impl_item_ref.defaultness, + impl_item_vis, + ); } } } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c05b69ab44f..9b7b44025c1 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -860,7 +860,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { FnKind::ItemFn(_, ref header, ..) => (FnItemRibKind, &header.asyncness.node), FnKind::Method(_, ref sig, _, _) => - (TraitOrImplItemRibKind, &sig.header.asyncness.node), + (AssocItemRibKind, &sig.header.asyncness.node), FnKind::Closure(_) => // Async closures aren't resolved through `visit_fn`-- they're // processed separately @@ -1033,7 +1033,7 @@ enum RibKind<'a> { /// methods or associated types. Allow references to ty params that impl or trait /// binds. Disallow any other upvars (including other ty params that are /// upvars). - TraitOrImplItemRibKind, + AssocItemRibKind, /// We passed through a function definition. Disallow upvars. /// Permit only those const parameters that are specified in the function's generics. @@ -2612,7 +2612,7 @@ impl<'a> Resolver<'a> { for trait_item in trait_items { let generic_params = HasGenericParams(&trait_item.generics, - TraitOrImplItemRibKind); + AssocItemRibKind); this.with_generic_param_rib(generic_params, |this| { match trait_item.node { TraitItemKind::Const(ref ty, ref default) => { @@ -2899,7 +2899,7 @@ impl<'a> Resolver<'a> { // We also need a new scope for the impl item type parameters. let generic_params = HasGenericParams(&impl_item.generics, - TraitOrImplItemRibKind); + AssocItemRibKind); this.with_generic_param_rib(generic_params, |this| { use self::ResolutionError::*; match impl_item.node { @@ -4074,7 +4074,7 @@ impl<'a> Resolver<'a> { seen.insert(node_id, depth); } } - ItemRibKind | FnItemRibKind | TraitOrImplItemRibKind => { + ItemRibKind | FnItemRibKind | AssocItemRibKind => { // This was an attempt to access an upvar inside a // named function item. This is not allowed, so we // report an error. @@ -4103,7 +4103,7 @@ impl<'a> Resolver<'a> { Res::Def(DefKind::TyParam, _) | Res::SelfTy(..) => { for rib in ribs { match rib.kind { - NormalRibKind | TraitOrImplItemRibKind | ClosureRibKind(..) | + NormalRibKind | AssocItemRibKind | ClosureRibKind(..) | ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind | ConstantItemRibKind | TyParamAsConstParamTy => { // Nothing to do. Continue. From 35ce2abf2142f5f5e96222fd4dd6b9472f59a6ca Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 28 May 2019 22:53:16 +0100 Subject: [PATCH 44/65] Use proper const printing in rustdoc --- src/librustdoc/clean/mod.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 4ee63a4c970..e68ad6a7c3b 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3145,10 +3145,7 @@ impl<'tcx> Clean for ty::Const<'tcx> { fn clean(&self, cx: &DocContext<'_>) -> Constant { Constant { type_: self.ty.clean(cx), - expr: match self.val { - ConstValue::Param(ty::ParamConst { name, .. }) => format!("{}", name), - e => format!("{:?}", e), // FIXME generic consts with expressions - }, + expr: format!("{}", self), } } } From 7f9dc73a31b94b76a87151467d0dd6dfc186a573 Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 28 May 2019 22:53:36 +0100 Subject: [PATCH 45/65] Add a const-generics folder to rustdoc tests --- .../{generic-const.rs => const-generics/const-impl.rs} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename src/test/rustdoc/{generic-const.rs => const-generics/const-impl.rs} (99%) diff --git a/src/test/rustdoc/generic-const.rs b/src/test/rustdoc/const-generics/const-impl.rs similarity index 99% rename from src/test/rustdoc/generic-const.rs rename to src/test/rustdoc/const-generics/const-impl.rs index d6794ac8f1d..85ee6d3376b 100644 --- a/src/test/rustdoc/generic-const.rs +++ b/src/test/rustdoc/const-generics/const-impl.rs @@ -1,8 +1,9 @@ -#![feature(const_generics)] -#![crate_name = "foo"] - // ignore-tidy-linelength +#![feature(const_generics)] + +#![crate_name = "foo"] + pub enum Order { Sorted, Unsorted, From 9c9b7b4eaceefe88bafc3b4e3529635973320253 Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 28 May 2019 22:53:48 +0100 Subject: [PATCH 46/65] Add a regression test for unevaluated const in rustdoc --- src/test/rustdoc/const-generics/add-impl.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/rustdoc/const-generics/add-impl.rs diff --git a/src/test/rustdoc/const-generics/add-impl.rs b/src/test/rustdoc/const-generics/add-impl.rs new file mode 100644 index 00000000000..ed45d339728 --- /dev/null +++ b/src/test/rustdoc/const-generics/add-impl.rs @@ -0,0 +1,21 @@ +// ignore-tidy-linelength + +#![feature(const_generics)] + +#![crate_name = "foo"] + +use std::ops::Add; + +// @has foo/struct.Simd.html '//pre[@class="rust struct"]' 'pub struct Simd' +pub struct Simd { + inner: T, +} + +// @has foo/struct.Simd.html '//div[@id="implementations-list"]/h3/code' 'impl Add> for Simd' +impl Add for Simd { + type Output = Self; + + fn add(self, rhs: Self) -> Self::Output { + Self { inner: 0 } + } +} From 03d32905e7312b0179103e8cc338876c81098da4 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Wed, 29 May 2019 01:01:32 +0300 Subject: [PATCH 47/65] rustc_codegen_ssa: remove obsolete codegen stats. --- src/librustc/mir/mono.rs | 18 ------------------ src/librustc_codegen_ssa/base.rs | 10 ---------- 2 files changed, 28 deletions(-) diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index a26468b0fb6..eeefaa4dd49 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -190,12 +190,6 @@ impl<'a, 'tcx> HashStable> for CodegenUnit<'tcx> { #[derive(Clone, Default)] pub struct Stats { - pub n_glues_created: usize, - pub n_null_glues: usize, - pub n_real_glues: usize, - pub n_fns: usize, - pub n_inlines: usize, - pub n_closures: usize, pub n_llvm_insns: usize, pub llvm_insns: FxHashMap, // (ident, llvm-instructions) @@ -203,12 +197,6 @@ pub struct Stats { } impl_stable_hash_for!(struct self::Stats { - n_glues_created, - n_null_glues, - n_real_glues, - n_fns, - n_inlines, - n_closures, n_llvm_insns, llvm_insns, fn_stats @@ -216,12 +204,6 @@ impl_stable_hash_for!(struct self::Stats { impl Stats { pub fn extend(&mut self, stats: Stats) { - self.n_glues_created += stats.n_glues_created; - self.n_null_glues += stats.n_null_glues; - self.n_real_glues += stats.n_real_glues; - self.n_fns += stats.n_fns; - self.n_inlines += stats.n_inlines; - self.n_closures += stats.n_closures; self.n_llvm_insns += stats.n_llvm_insns; for (k, v) in stats.llvm_insns { diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 0b037f87247..67d3a211306 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -85,7 +85,6 @@ impl<'a, 'tcx, Cx: CodegenMethods<'tcx>> Drop for StatRecorder<'a, 'tcx, Cx> { let mut stats = self.cx.stats().borrow_mut(); let iend = stats.n_llvm_insns; stats.fn_stats.push((self.name.take().unwrap(), iend - self.istart)); - stats.n_fns += 1; // Reset LLVM insn count to avoid compound costs. stats.n_llvm_insns = self.istart; } @@ -428,8 +427,6 @@ pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( let lldecl = cx.instances().borrow().get(&instance).cloned().unwrap_or_else(|| bug!("Instance `{:?}` not already declared", instance)); - cx.stats().borrow_mut().n_closures += 1; - let mir = cx.tcx().instance_mir(instance.def); mir::codegen_mir::(cx, lldecl, &mir, instance, sig); } @@ -703,13 +700,6 @@ pub fn codegen_crate( if tcx.sess.codegen_stats() { println!("--- codegen stats ---"); - println!("n_glues_created: {}", all_stats.n_glues_created); - println!("n_null_glues: {}", all_stats.n_null_glues); - println!("n_real_glues: {}", all_stats.n_real_glues); - - println!("n_fns: {}", all_stats.n_fns); - println!("n_inlines: {}", all_stats.n_inlines); - println!("n_closures: {}", all_stats.n_closures); println!("fn stats:"); all_stats.fn_stats.sort_by_key(|&(_, insns)| insns); for &(ref name, insns) in all_stats.fn_stats.iter() { From 29b7c0687e4408fcd94bad8bf7c25142573c5065 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Wed, 29 May 2019 01:21:27 +0300 Subject: [PATCH 48/65] rustc_codegen_llvm: remove LLVM instruction count stats. --- src/librustc/mir/mono.rs | 25 ----- src/librustc/session/config.rs | 13 --- src/librustc/session/mod.rs | 6 -- src/librustc_codegen_llvm/base.rs | 34 +++---- src/librustc_codegen_llvm/builder.rs | 107 --------------------- src/librustc_codegen_llvm/context.rs | 11 --- src/librustc_codegen_llvm/lib.rs | 5 +- src/librustc_codegen_ssa/base.rs | 64 +----------- src/librustc_codegen_ssa/traits/backend.rs | 3 +- src/librustc_codegen_ssa/traits/misc.rs | 3 - 10 files changed, 20 insertions(+), 251 deletions(-) diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index eeefaa4dd49..ca79bc15358 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -188,31 +188,6 @@ impl<'a, 'tcx> HashStable> for CodegenUnit<'tcx> { } } -#[derive(Clone, Default)] -pub struct Stats { - pub n_llvm_insns: usize, - pub llvm_insns: FxHashMap, - // (ident, llvm-instructions) - pub fn_stats: Vec<(String, usize)>, -} - -impl_stable_hash_for!(struct self::Stats { - n_llvm_insns, - llvm_insns, - fn_stats -}); - -impl Stats { - pub fn extend(&mut self, stats: Stats) { - self.n_llvm_insns += stats.n_llvm_insns; - - for (k, v) in stats.llvm_insns { - *self.llvm_insns.entry(k).or_insert(0) += v; - } - self.fn_stats.extend(stats.fn_stats); - } -} - pub struct CodegenUnitNameBuilder<'a, 'gcx: 'tcx, 'tcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'tcx>, cache: FxHashMap, diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index f4ee39d6988..300d0cbfba5 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1216,21 +1216,12 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "measure time of each rustc pass"), time: bool = (false, parse_bool, [UNTRACKED], "measure time of rustc processes"), - count_llvm_insns: bool = (false, parse_bool, - [UNTRACKED_WITH_WARNING(true, - "The output generated by `-Z count_llvm_insns` might not be reliable \ - when used with incremental compilation")], - "count where LLVM instrs originate"), time_llvm_passes: bool = (false, parse_bool, [UNTRACKED_WITH_WARNING(true, "The output of `-Z time-llvm-passes` will only reflect timings of \ re-codegened modules when used with incremental compilation" )], "measure time of each LLVM pass"), input_stats: bool = (false, parse_bool, [UNTRACKED], "gather statistics about the input"), - codegen_stats: bool = (false, parse_bool, [UNTRACKED_WITH_WARNING(true, - "The output of `-Z codegen-stats` might not be accurate when incremental \ - compilation is enabled")], - "gather codegen statistics"), asm_comments: bool = (false, parse_bool, [TRACKED], "generate comments into the assembly (may change behavior)"), verify_llvm_ir: bool = (false, parse_bool, [TRACKED], @@ -3259,14 +3250,10 @@ mod tests { assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.time_passes = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); - opts.debugging_opts.count_llvm_insns = true; - assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.time_llvm_passes = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.input_stats = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); - opts.debugging_opts.codegen_stats = true; - assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.borrowck_stats = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.meta_stats = true; diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 974a5bb70e6..2726a4770c8 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -519,15 +519,9 @@ impl Session { pub fn instrument_mcount(&self) -> bool { self.opts.debugging_opts.instrument_mcount } - pub fn count_llvm_insns(&self) -> bool { - self.opts.debugging_opts.count_llvm_insns - } pub fn time_llvm_passes(&self) -> bool { self.opts.debugging_opts.time_llvm_passes } - pub fn codegen_stats(&self) -> bool { - self.opts.debugging_opts.codegen_stats - } pub fn meta_stats(&self) -> bool { self.opts.debugging_opts.meta_stats } diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 9077e89a402..f8c6087373f 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -24,7 +24,7 @@ use crate::common; use crate::context::CodegenCx; use crate::monomorphize::partitioning::CodegenUnitExt; use rustc::dep_graph; -use rustc::mir::mono::{Linkage, Visibility, Stats}; +use rustc::mir::mono::{Linkage, Visibility}; use rustc::middle::cstore::{EncodedMetadata}; use rustc::ty::TyCtxt; use rustc::middle::exported_symbols; @@ -104,17 +104,17 @@ pub fn iter_globals(llmod: &'ll llvm::Module) -> ValueIter<'ll> { } } -pub fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - cgu_name: InternedString) - -> Stats { +pub fn compile_codegen_unit(tcx: TyCtxt<'a, 'tcx, 'tcx>, cgu_name: InternedString) { let start_time = Instant::now(); let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx); - let ((stats, module), _) = tcx.dep_graph.with_task(dep_node, - tcx, - cgu_name, - module_codegen, - dep_graph::hash_result); + let (module, _) = tcx.dep_graph.with_task( + dep_node, + tcx, + cgu_name, + module_codegen, + dep_graph::hash_result, + ); let time_to_codegen = start_time.elapsed(); // We assume that the cost to run LLVM on a CGU is proportional to @@ -123,17 +123,15 @@ pub fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, time_to_codegen.subsec_nanos() as u64; submit_codegened_module_to_llvm(&LlvmCodegenBackend(()), tcx, module, cost); - return stats; fn module_codegen<'ll, 'tcx>( tcx: TyCtxt<'ll, 'tcx, 'tcx>, - cgu_name: InternedString) - -> (Stats, ModuleCodegen) - { + cgu_name: InternedString, + ) -> ModuleCodegen { let cgu = tcx.codegen_unit(cgu_name); // Instantiate monomorphizations without filling out definitions yet... let llvm_module = ModuleLlvm::new(tcx, &cgu_name.as_str()); - let stats = { + { let cx = CodegenCx::new(tcx, cgu, &llvm_module); let mono_items = cx.codegen_unit .items_in_deterministic_order(cx.tcx); @@ -169,15 +167,13 @@ pub fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if cx.sess().opts.debuginfo != DebugInfo::None { cx.debuginfo_finalize(); } + } - cx.consume_stats().into_inner() - }; - - (stats, ModuleCodegen { + ModuleCodegen { name: cgu_name.to_string(), module_llvm: llvm_module, kind: ModuleKind::Regular, - }) + } } } diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 48808eea304..79c58fbf6e4 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -147,21 +147,18 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn ret_void(&mut self) { - self.count_insn("retvoid"); unsafe { llvm::LLVMBuildRetVoid(self.llbuilder); } } fn ret(&mut self, v: &'ll Value) { - self.count_insn("ret"); unsafe { llvm::LLVMBuildRet(self.llbuilder, v); } } fn br(&mut self, dest: &'ll BasicBlock) { - self.count_insn("br"); unsafe { llvm::LLVMBuildBr(self.llbuilder, dest); } @@ -173,7 +170,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { then_llbb: &'ll BasicBlock, else_llbb: &'ll BasicBlock, ) { - self.count_insn("condbr"); unsafe { llvm::LLVMBuildCondBr(self.llbuilder, cond, then_llbb, else_llbb); } @@ -204,7 +200,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { catch: &'ll BasicBlock, funclet: Option<&Funclet<'ll>>, ) -> &'ll Value { - self.count_insn("invoke"); debug!("Invoke {:?} with args ({:?})", llfn, @@ -227,7 +222,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn unreachable(&mut self) { - self.count_insn("unreachable"); unsafe { llvm::LLVMBuildUnreachable(self.llbuilder); } @@ -235,21 +229,18 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { /* Arithmetic */ fn add(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("add"); unsafe { llvm::LLVMBuildAdd(self.llbuilder, lhs, rhs, noname()) } } fn fadd(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("fadd"); unsafe { llvm::LLVMBuildFAdd(self.llbuilder, lhs, rhs, noname()) } } fn fadd_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("fadd"); unsafe { let instr = llvm::LLVMBuildFAdd(self.llbuilder, lhs, rhs, noname()); llvm::LLVMRustSetHasUnsafeAlgebra(instr); @@ -258,21 +249,18 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn sub(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("sub"); unsafe { llvm::LLVMBuildSub(self.llbuilder, lhs, rhs, noname()) } } fn fsub(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("fsub"); unsafe { llvm::LLVMBuildFSub(self.llbuilder, lhs, rhs, noname()) } } fn fsub_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("fsub"); unsafe { let instr = llvm::LLVMBuildFSub(self.llbuilder, lhs, rhs, noname()); llvm::LLVMRustSetHasUnsafeAlgebra(instr); @@ -281,21 +269,18 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn mul(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("mul"); unsafe { llvm::LLVMBuildMul(self.llbuilder, lhs, rhs, noname()) } } fn fmul(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("fmul"); unsafe { llvm::LLVMBuildFMul(self.llbuilder, lhs, rhs, noname()) } } fn fmul_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("fmul"); unsafe { let instr = llvm::LLVMBuildFMul(self.llbuilder, lhs, rhs, noname()); llvm::LLVMRustSetHasUnsafeAlgebra(instr); @@ -305,42 +290,36 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn udiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("udiv"); unsafe { llvm::LLVMBuildUDiv(self.llbuilder, lhs, rhs, noname()) } } fn exactudiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("exactudiv"); unsafe { llvm::LLVMBuildExactUDiv(self.llbuilder, lhs, rhs, noname()) } } fn sdiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("sdiv"); unsafe { llvm::LLVMBuildSDiv(self.llbuilder, lhs, rhs, noname()) } } fn exactsdiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("exactsdiv"); unsafe { llvm::LLVMBuildExactSDiv(self.llbuilder, lhs, rhs, noname()) } } fn fdiv(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("fdiv"); unsafe { llvm::LLVMBuildFDiv(self.llbuilder, lhs, rhs, noname()) } } fn fdiv_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("fdiv"); unsafe { let instr = llvm::LLVMBuildFDiv(self.llbuilder, lhs, rhs, noname()); llvm::LLVMRustSetHasUnsafeAlgebra(instr); @@ -349,28 +328,24 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn urem(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("urem"); unsafe { llvm::LLVMBuildURem(self.llbuilder, lhs, rhs, noname()) } } fn srem(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("srem"); unsafe { llvm::LLVMBuildSRem(self.llbuilder, lhs, rhs, noname()) } } fn frem(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("frem"); unsafe { llvm::LLVMBuildFRem(self.llbuilder, lhs, rhs, noname()) } } fn frem_fast(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("frem"); unsafe { let instr = llvm::LLVMBuildFRem(self.llbuilder, lhs, rhs, noname()); llvm::LLVMRustSetHasUnsafeAlgebra(instr); @@ -379,63 +354,54 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn shl(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("shl"); unsafe { llvm::LLVMBuildShl(self.llbuilder, lhs, rhs, noname()) } } fn lshr(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("lshr"); unsafe { llvm::LLVMBuildLShr(self.llbuilder, lhs, rhs, noname()) } } fn ashr(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("ashr"); unsafe { llvm::LLVMBuildAShr(self.llbuilder, lhs, rhs, noname()) } } fn and(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("and"); unsafe { llvm::LLVMBuildAnd(self.llbuilder, lhs, rhs, noname()) } } fn or(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("or"); unsafe { llvm::LLVMBuildOr(self.llbuilder, lhs, rhs, noname()) } } fn xor(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("xor"); unsafe { llvm::LLVMBuildXor(self.llbuilder, lhs, rhs, noname()) } } fn neg(&mut self, v: &'ll Value) -> &'ll Value { - self.count_insn("neg"); unsafe { llvm::LLVMBuildNeg(self.llbuilder, v, noname()) } } fn fneg(&mut self, v: &'ll Value) -> &'ll Value { - self.count_insn("fneg"); unsafe { llvm::LLVMBuildFNeg(self.llbuilder, v, noname()) } } fn not(&mut self, v: &'ll Value) -> &'ll Value { - self.count_insn("not"); unsafe { llvm::LLVMBuildNot(self.llbuilder, v, noname()) } @@ -524,7 +490,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn dynamic_alloca(&mut self, ty: &'ll Type, name: &str, align: Align) -> &'ll Value { - self.count_insn("alloca"); unsafe { let alloca = if name.is_empty() { llvm::LLVMBuildAlloca(self.llbuilder, ty, noname()) @@ -543,7 +508,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { len: &'ll Value, name: &str, align: Align) -> &'ll Value { - self.count_insn("alloca"); unsafe { let alloca = if name.is_empty() { llvm::LLVMBuildArrayAlloca(self.llbuilder, ty, len, noname()) @@ -558,7 +522,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn load(&mut self, ptr: &'ll Value, align: Align) -> &'ll Value { - self.count_insn("load"); unsafe { let load = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname()); llvm::LLVMSetAlignment(load, align.bytes() as c_uint); @@ -567,7 +530,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn volatile_load(&mut self, ptr: &'ll Value) -> &'ll Value { - self.count_insn("load.volatile"); unsafe { let insn = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname()); llvm::LLVMSetVolatile(insn, llvm::True); @@ -581,7 +543,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { order: rustc_codegen_ssa::common::AtomicOrdering, size: Size, ) -> &'ll Value { - self.count_insn("load.atomic"); unsafe { let load = llvm::LLVMRustBuildAtomicLoad( self.llbuilder, @@ -745,7 +706,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { flags: MemFlags, ) -> &'ll Value { debug!("Store {:?} -> {:?} ({:?})", val, ptr, flags); - self.count_insn("store"); let ptr = self.check_store(val, ptr); unsafe { let store = llvm::LLVMBuildStore(self.llbuilder, val, ptr); @@ -774,7 +734,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn atomic_store(&mut self, val: &'ll Value, ptr: &'ll Value, order: rustc_codegen_ssa::common::AtomicOrdering, size: Size) { debug!("Store {:?} -> {:?}", val, ptr); - self.count_insn("store.atomic"); let ptr = self.check_store(val, ptr); unsafe { let store = llvm::LLVMRustBuildAtomicStore( @@ -789,7 +748,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn gep(&mut self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value { - self.count_insn("gep"); unsafe { llvm::LLVMBuildGEP(self.llbuilder, ptr, indices.as_ptr(), indices.len() as c_uint, noname()) @@ -797,7 +755,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn inbounds_gep(&mut self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value { - self.count_insn("inboundsgep"); unsafe { llvm::LLVMBuildInBoundsGEP( self.llbuilder, ptr, indices.as_ptr(), indices.len() as c_uint, noname()) @@ -805,7 +762,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn struct_gep(&mut self, ptr: &'ll Value, idx: u64) -> &'ll Value { - self.count_insn("structgep"); assert_eq!(idx as c_uint as u64, idx); unsafe { llvm::LLVMBuildStructGEP(self.llbuilder, ptr, idx as c_uint, noname()) @@ -814,77 +770,66 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { /* Casts */ fn trunc(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("trunc"); unsafe { llvm::LLVMBuildTrunc(self.llbuilder, val, dest_ty, noname()) } } fn sext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("sext"); unsafe { llvm::LLVMBuildSExt(self.llbuilder, val, dest_ty, noname()) } } fn fptoui(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("fptoui"); unsafe { llvm::LLVMBuildFPToUI(self.llbuilder, val, dest_ty, noname()) } } fn fptosi(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("fptosi"); unsafe { llvm::LLVMBuildFPToSI(self.llbuilder, val, dest_ty,noname()) } } fn uitofp(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("uitofp"); unsafe { llvm::LLVMBuildUIToFP(self.llbuilder, val, dest_ty, noname()) } } fn sitofp(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("sitofp"); unsafe { llvm::LLVMBuildSIToFP(self.llbuilder, val, dest_ty, noname()) } } fn fptrunc(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("fptrunc"); unsafe { llvm::LLVMBuildFPTrunc(self.llbuilder, val, dest_ty, noname()) } } fn fpext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("fpext"); unsafe { llvm::LLVMBuildFPExt(self.llbuilder, val, dest_ty, noname()) } } fn ptrtoint(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("ptrtoint"); unsafe { llvm::LLVMBuildPtrToInt(self.llbuilder, val, dest_ty, noname()) } } fn inttoptr(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("inttoptr"); unsafe { llvm::LLVMBuildIntToPtr(self.llbuilder, val, dest_ty, noname()) } } fn bitcast(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("bitcast"); unsafe { llvm::LLVMBuildBitCast(self.llbuilder, val, dest_ty, noname()) } @@ -892,14 +837,12 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn intcast(&mut self, val: &'ll Value, dest_ty: &'ll Type, is_signed: bool) -> &'ll Value { - self.count_insn("intcast"); unsafe { llvm::LLVMRustBuildIntCast(self.llbuilder, val, dest_ty, is_signed) } } fn pointercast(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("pointercast"); unsafe { llvm::LLVMBuildPointerCast(self.llbuilder, val, dest_ty, noname()) } @@ -907,7 +850,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { /* Comparisons */ fn icmp(&mut self, op: IntPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("icmp"); let op = llvm::IntPredicate::from_generic(op); unsafe { llvm::LLVMBuildICmp(self.llbuilder, op as c_uint, lhs, rhs, noname()) @@ -915,7 +857,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn fcmp(&mut self, op: RealPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("fcmp"); unsafe { llvm::LLVMBuildFCmp(self.llbuilder, op as c_uint, lhs, rhs, noname()) } @@ -984,7 +925,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { then_val: &'ll Value, else_val: &'ll Value, ) -> &'ll Value { - self.count_insn("select"); unsafe { llvm::LLVMBuildSelect(self.llbuilder, cond, then_val, else_val, noname()) } @@ -992,14 +932,12 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { #[allow(dead_code)] fn va_arg(&mut self, list: &'ll Value, ty: &'ll Type) -> &'ll Value { - self.count_insn("vaarg"); unsafe { llvm::LLVMBuildVAArg(self.llbuilder, list, ty, noname()) } } fn extract_element(&mut self, vec: &'ll Value, idx: &'ll Value) -> &'ll Value { - self.count_insn("extractelement"); unsafe { llvm::LLVMBuildExtractElement(self.llbuilder, vec, idx, noname()) } @@ -1016,7 +954,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn extract_value(&mut self, agg_val: &'ll Value, idx: u64) -> &'ll Value { - self.count_insn("extractvalue"); assert_eq!(idx as c_uint as u64, idx); unsafe { llvm::LLVMBuildExtractValue(self.llbuilder, agg_val, idx as c_uint, noname()) @@ -1025,7 +962,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn insert_value(&mut self, agg_val: &'ll Value, elt: &'ll Value, idx: u64) -> &'ll Value { - self.count_insn("insertvalue"); assert_eq!(idx as c_uint as u64, idx); unsafe { llvm::LLVMBuildInsertValue(self.llbuilder, agg_val, elt, idx as c_uint, @@ -1035,7 +971,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn landing_pad(&mut self, ty: &'ll Type, pers_fn: &'ll Value, num_clauses: usize) -> &'ll Value { - self.count_insn("landingpad"); unsafe { llvm::LLVMBuildLandingPad(self.llbuilder, ty, pers_fn, num_clauses as c_uint, noname()) @@ -1043,14 +978,12 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn set_cleanup(&mut self, landing_pad: &'ll Value) { - self.count_insn("setcleanup"); unsafe { llvm::LLVMSetCleanup(landing_pad, llvm::True); } } fn resume(&mut self, exn: &'ll Value) -> &'ll Value { - self.count_insn("resume"); unsafe { llvm::LLVMBuildResume(self.llbuilder, exn) } @@ -1059,7 +992,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn cleanup_pad(&mut self, parent: Option<&'ll Value>, args: &[&'ll Value]) -> Funclet<'ll> { - self.count_insn("cleanuppad"); let name = const_cstr!("cleanuppad"); let ret = unsafe { llvm::LLVMRustBuildCleanupPad(self.llbuilder, @@ -1075,7 +1007,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { &mut self, funclet: &Funclet<'ll>, unwind: Option<&'ll BasicBlock>, ) -> &'ll Value { - self.count_insn("cleanupret"); let ret = unsafe { llvm::LLVMRustBuildCleanupRet(self.llbuilder, funclet.cleanuppad(), unwind) }; @@ -1085,7 +1016,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn catch_pad(&mut self, parent: &'ll Value, args: &[&'ll Value]) -> Funclet<'ll> { - self.count_insn("catchpad"); let name = const_cstr!("catchpad"); let ret = unsafe { llvm::LLVMRustBuildCatchPad(self.llbuilder, parent, @@ -1101,7 +1031,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { unwind: Option<&'ll BasicBlock>, num_handlers: usize, ) -> &'ll Value { - self.count_insn("catchswitch"); let name = const_cstr!("catchswitch"); let ret = unsafe { llvm::LLVMRustBuildCatchSwitch(self.llbuilder, parent, unwind, @@ -1199,7 +1128,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { args: &[&'ll Value], funclet: Option<&Funclet<'ll>>, ) -> &'ll Value { - self.count_insn("call"); debug!("Call {:?} with args ({:?})", llfn, @@ -1221,7 +1149,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } fn zext(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { - self.count_insn("zext"); unsafe { llvm::LLVMBuildZExt(self.llbuilder, val, dest_ty, noname()) } @@ -1285,19 +1212,6 @@ impl Builder<'a, 'll, 'tcx> { } } - fn count_insn(&self, category: &str) { - if self.sess().codegen_stats() { - self.stats.borrow_mut().n_llvm_insns += 1; - } - if self.sess().count_llvm_insns() { - *self.stats - .borrow_mut() - .llvm_insns - .entry(category.to_string()) - .or_insert(0) += 1; - } - } - fn position_at_start(&mut self, llbb: &'ll BasicBlock) { unsafe { llvm::LLVMRustPositionBuilderAtStart(self.llbuilder, llbb); @@ -1305,12 +1219,10 @@ impl Builder<'a, 'll, 'tcx> { } pub fn minnum(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("minnum"); unsafe { llvm::LLVMRustBuildMinNum(self.llbuilder, lhs, rhs) } } pub fn maxnum(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { - self.count_insn("maxnum"); unsafe { llvm::LLVMRustBuildMaxNum(self.llbuilder, lhs, rhs) } } @@ -1319,7 +1231,6 @@ impl Builder<'a, 'll, 'tcx> { elt: &'ll Value, idx: &'ll Value, ) -> &'ll Value { - self.count_insn("insertelement"); unsafe { llvm::LLVMBuildInsertElement(self.llbuilder, vec, elt, idx, noname()) } @@ -1331,14 +1242,12 @@ impl Builder<'a, 'll, 'tcx> { v2: &'ll Value, mask: &'ll Value, ) -> &'ll Value { - self.count_insn("shufflevector"); unsafe { llvm::LLVMBuildShuffleVector(self.llbuilder, v1, v2, mask, noname()) } } pub fn vector_reduce_fadd_fast(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.fadd_fast"); unsafe { // FIXME: add a non-fast math version once // https://bugs.llvm.org/show_bug.cgi?id=36732 @@ -1349,7 +1258,6 @@ impl Builder<'a, 'll, 'tcx> { } } pub fn vector_reduce_fmul_fast(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.fmul_fast"); unsafe { // FIXME: add a non-fast math version once // https://bugs.llvm.org/show_bug.cgi?id=36732 @@ -1360,35 +1268,27 @@ impl Builder<'a, 'll, 'tcx> { } } pub fn vector_reduce_add(&mut self, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.add"); unsafe { llvm::LLVMRustBuildVectorReduceAdd(self.llbuilder, src) } } pub fn vector_reduce_mul(&mut self, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.mul"); unsafe { llvm::LLVMRustBuildVectorReduceMul(self.llbuilder, src) } } pub fn vector_reduce_and(&mut self, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.and"); unsafe { llvm::LLVMRustBuildVectorReduceAnd(self.llbuilder, src) } } pub fn vector_reduce_or(&mut self, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.or"); unsafe { llvm::LLVMRustBuildVectorReduceOr(self.llbuilder, src) } } pub fn vector_reduce_xor(&mut self, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.xor"); unsafe { llvm::LLVMRustBuildVectorReduceXor(self.llbuilder, src) } } pub fn vector_reduce_fmin(&mut self, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.fmin"); unsafe { llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ false) } } pub fn vector_reduce_fmax(&mut self, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.fmax"); unsafe { llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ false) } } pub fn vector_reduce_fmin_fast(&mut self, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.fmin_fast"); unsafe { let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ true); llvm::LLVMRustSetHasUnsafeAlgebra(instr); @@ -1396,7 +1296,6 @@ impl Builder<'a, 'll, 'tcx> { } } pub fn vector_reduce_fmax_fast(&mut self, src: &'ll Value) -> &'ll Value { - self.count_insn("vector.reduce.fmax_fast"); unsafe { let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ true); llvm::LLVMRustSetHasUnsafeAlgebra(instr); @@ -1404,11 +1303,9 @@ impl Builder<'a, 'll, 'tcx> { } } pub fn vector_reduce_min(&mut self, src: &'ll Value, is_signed: bool) -> &'ll Value { - self.count_insn("vector.reduce.min"); unsafe { llvm::LLVMRustBuildVectorReduceMin(self.llbuilder, src, is_signed) } } pub fn vector_reduce_max(&mut self, src: &'ll Value, is_signed: bool) -> &'ll Value { - self.count_insn("vector.reduce.max"); unsafe { llvm::LLVMRustBuildVectorReduceMax(self.llbuilder, src, is_signed) } } @@ -1419,7 +1316,6 @@ impl Builder<'a, 'll, 'tcx> { } pub fn catch_ret(&mut self, funclet: &Funclet<'ll>, unwind: &'ll BasicBlock) -> &'ll Value { - self.count_insn("catchret"); let ret = unsafe { llvm::LLVMRustBuildCatchRet(self.llbuilder, funclet.cleanuppad(), unwind) }; @@ -1488,7 +1384,6 @@ impl Builder<'a, 'll, 'tcx> { } pub fn va_arg(&mut self, list: &'ll Value, ty: &'ll Type) -> &'ll Value { - self.count_insn("vaarg"); unsafe { llvm::LLVMBuildVAArg(self.llbuilder, list, ty, noname()) } @@ -1511,7 +1406,6 @@ impl Builder<'a, 'll, 'tcx> { } fn phi(&mut self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[&'ll BasicBlock]) -> &'ll Value { - self.count_insn("addincoming"); assert_eq!(vals.len(), bbs.len()); let phi = unsafe { llvm::LLVMBuildPhi(self.llbuilder, ty, noname()) @@ -1525,7 +1419,6 @@ impl Builder<'a, 'll, 'tcx> { } fn add_incoming_to_phi(&mut self, phi: &'ll Value, val: &'ll Value, bb: &'ll BasicBlock) { - self.count_insn("addincoming"); unsafe { llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint); } diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 7bf8f705ea8..b6b47d047c8 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -12,7 +12,6 @@ use rustc_codegen_ssa::traits::*; use rustc_data_structures::base_n; use rustc_data_structures::small_c_str::SmallCStr; -use rustc::mir::mono::Stats; use rustc::session::config::{self, DebugInfo}; use rustc::session::Session; use rustc::ty::layout::{ @@ -44,7 +43,6 @@ pub struct CodegenCx<'ll, 'tcx: 'll> { pub llmod: &'ll llvm::Module, pub llcx: &'ll llvm::Context, - pub stats: RefCell, pub codegen_unit: Arc>, /// Cache instances of monomorphic and polymorphic items @@ -284,7 +282,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { tls_model, llmod, llcx, - stats: RefCell::new(Stats::default()), codegen_unit, instances: Default::default(), vtables: Default::default(), @@ -408,14 +405,6 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { self.check_overflow } - fn stats(&self) -> &RefCell { - &self.stats - } - - fn consume_stats(self) -> RefCell { - self.stats - } - fn codegen_unit(&self) -> &Arc> { &self.codegen_unit } diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 09b284052b3..57cffa48163 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -52,7 +52,6 @@ use rustc_codegen_ssa::CompiledModule; use errors::{FatalError, Handler}; use rustc::dep_graph::WorkProduct; use syntax_pos::symbol::InternedString; -use rustc::mir::mono::Stats; pub use llvm_util::target_features; use std::any::Any; use std::sync::{mpsc, Arc}; @@ -130,8 +129,8 @@ impl ExtraBackendMethods for LlvmCodegenBackend { &self, tcx: TyCtxt<'a, 'tcx, 'tcx>, cgu_name: InternedString, - ) -> Stats { - base::compile_codegen_unit(tcx, cgu_name) + ) { + base::compile_codegen_unit(tcx, cgu_name); } fn target_machine_factory( &self, diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 67d3a211306..172b5b39987 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -20,7 +20,7 @@ use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::middle::cstore::EncodedMetadata; use rustc::middle::lang_items::StartFnLangItem; use rustc::middle::weak_lang_items; -use rustc::mir::mono::{Stats, CodegenUnitNameBuilder}; +use rustc::mir::mono::CodegenUnitNameBuilder; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::layout::{self, Align, TyLayout, LayoutOf, VariantIdx, HasTyCtxt}; use rustc::ty::query::Providers; @@ -28,7 +28,6 @@ use rustc::middle::cstore::{self, LinkagePreference}; use rustc::util::common::{time, print_time_passes_entry}; use rustc::session::config::{self, EntryFnType, Lto}; use rustc::session::Session; -use rustc_mir::monomorphize::item::DefPathBasedNames; use rustc_mir::monomorphize::Instance; use rustc_mir::monomorphize::partitioning::{CodegenUnit, CodegenUnitExt}; use rustc::util::nodemap::FxHashMap; @@ -58,39 +57,6 @@ use rustc::hir; use crate::mir::operand::OperandValue; -use std::marker::PhantomData; - -pub struct StatRecorder<'a, 'tcx, Cx: 'a + CodegenMethods<'tcx>> { - cx: &'a Cx, - name: Option, - istart: usize, - _marker: PhantomData<&'tcx ()>, -} - -impl<'a, 'tcx, Cx: CodegenMethods<'tcx>> StatRecorder<'a, 'tcx, Cx> { - pub fn new(cx: &'a Cx, name: String) -> Self { - let istart = cx.stats().borrow().n_llvm_insns; - StatRecorder { - cx, - name: Some(name), - istart, - _marker: PhantomData, - } - } -} - -impl<'a, 'tcx, Cx: CodegenMethods<'tcx>> Drop for StatRecorder<'a, 'tcx, Cx> { - fn drop(&mut self) { - if self.cx.sess().codegen_stats() { - let mut stats = self.cx.stats().borrow_mut(); - let iend = stats.n_llvm_insns; - stats.fn_stats.push((self.name.take().unwrap(), iend - self.istart)); - // Reset LLVM insn count to avoid compound costs. - stats.n_llvm_insns = self.istart; - } - } -} - pub fn bin_op_to_icmp_predicate(op: hir::BinOpKind, signed: bool) -> IntPredicate { @@ -407,15 +373,6 @@ pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( cx: &'a Bx::CodegenCx, instance: Instance<'tcx>, ) { - let _s = if cx.sess().codegen_stats() { - let mut instance_name = String::new(); - DefPathBasedNames::new(cx.tcx(), true, true) - .push_def_path(instance.def_id(), &mut instance_name); - Some(StatRecorder::new(cx, instance_name)) - } else { - None - }; - // this is an info! to allow collecting monomorphization statistics // and to allow finding the last function before LLVM aborts from // release builds. @@ -650,7 +607,6 @@ pub fn codegen_crate( }; let mut total_codegen_time = Duration::new(0, 0); - let mut all_stats = Stats::default(); for cgu in codegen_units.into_iter() { ongoing_codegen.wait_for_signal_to_codegen_item(); @@ -663,8 +619,7 @@ pub fn codegen_crate( CguReuse::No => { tcx.sess.profiler(|p| p.start_activity(format!("codegen {}", cgu.name()))); let start_time = Instant::now(); - let stats = backend.compile_codegen_unit(tcx, *cgu.name()); - all_stats.extend(stats); + backend.compile_codegen_unit(tcx, *cgu.name()); total_codegen_time += start_time.elapsed(); tcx.sess.profiler(|p| p.end_activity(format!("codegen {}", cgu.name()))); false @@ -698,21 +653,6 @@ pub fn codegen_crate( symbol_names_test::report_symbol_names(tcx); - if tcx.sess.codegen_stats() { - println!("--- codegen stats ---"); - println!("fn stats:"); - all_stats.fn_stats.sort_by_key(|&(_, insns)| insns); - for &(ref name, insns) in all_stats.fn_stats.iter() { - println!("{} insns, {}", insns, *name); - } - } - - if tcx.sess.count_llvm_insns() { - for (k, v) in all_stats.llvm_insns.iter() { - println!("{:7} {}", *v, *k); - } - } - ongoing_codegen.check_for_errors(tcx.sess); assert_and_save_dep_graph(tcx); diff --git a/src/librustc_codegen_ssa/traits/backend.rs b/src/librustc_codegen_ssa/traits/backend.rs index 530eba516a6..0466b47cf14 100644 --- a/src/librustc_codegen_ssa/traits/backend.rs +++ b/src/librustc_codegen_ssa/traits/backend.rs @@ -5,7 +5,6 @@ use super::write::WriteBackendMethods; use super::CodegenObject; use rustc::middle::allocator::AllocatorKind; use rustc::middle::cstore::EncodedMetadata; -use rustc::mir::mono::Stats; use rustc::session::{Session, config}; use rustc::ty::TyCtxt; use rustc_codegen_utils::codegen_backend::CodegenBackend; @@ -49,7 +48,7 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se &self, tcx: TyCtxt<'a, 'tcx, 'tcx>, cgu_name: InternedString, - ) -> Stats; + ); // If find_features is true this won't access `sess.crate_types` by assuming // that `is_pie_binary` is false. When we discover LLVM target features // `sess.crate_types` is uninitialized so we cannot access it. diff --git a/src/librustc_codegen_ssa/traits/misc.rs b/src/librustc_codegen_ssa/traits/misc.rs index 2797dd89f5b..5ea86df6e94 100644 --- a/src/librustc_codegen_ssa/traits/misc.rs +++ b/src/librustc_codegen_ssa/traits/misc.rs @@ -1,5 +1,4 @@ use super::BackendTypes; -use rustc::mir::mono::Stats; use rustc::session::Session; use rustc::ty::{self, Instance, Ty}; use rustc::util::nodemap::FxHashMap; @@ -17,8 +16,6 @@ pub trait MiscMethods<'tcx>: BackendTypes { fn eh_personality(&self) -> Self::Value; fn eh_unwind_resume(&self) -> Self::Value; fn sess(&self) -> &Session; - fn stats(&self) -> &RefCell; - fn consume_stats(self) -> RefCell; fn codegen_unit(&self) -> &Arc>; fn used_statics(&self) -> &RefCell>; fn set_frame_pointer_elimination(&self, llfn: Self::Value); From 7fa97c08508057b29142211fc45b3e282f194a7b Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Wed, 29 May 2019 01:22:37 +0300 Subject: [PATCH 49/65] rustc_codegen_llvm: rename away the last occurrence of `insn`. --- src/librustc_codegen_llvm/builder.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 79c58fbf6e4..42e7a72c43b 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -531,9 +531,9 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn volatile_load(&mut self, ptr: &'ll Value) -> &'ll Value { unsafe { - let insn = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname()); - llvm::LLVMSetVolatile(insn, llvm::True); - insn + let load = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname()); + llvm::LLVMSetVolatile(load, llvm::True); + load } } From 9f8d934f271fcaf9c34aefa8062b7563cfd34721 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 28 May 2019 16:00:39 -0700 Subject: [PATCH 50/65] Bump Sum and Product for Option to 1.37 --- src/libcore/iter/traits/accum.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/iter/traits/accum.rs b/src/libcore/iter/traits/accum.rs index 88c4820d583..f9e86be3721 100644 --- a/src/libcore/iter/traits/accum.rs +++ b/src/libcore/iter/traits/accum.rs @@ -291,7 +291,7 @@ where } } -#[stable(feature = "iter_arith_traits_option", since = "1.35.0")] +#[stable(feature = "iter_arith_traits_option", since = "1.37.0")] impl Sum> for Option where T: Sum, @@ -318,7 +318,7 @@ where } } -#[stable(feature = "iter_arith_traits_option", since = "1.35.0")] +#[stable(feature = "iter_arith_traits_option", since = "1.37.0")] impl Product> for Option where T: Product, From eb4580a570069175e1290b294d91042a09f9fde3 Mon Sep 17 00:00:00 2001 From: memoryruins Date: Tue, 28 May 2019 14:46:13 -0400 Subject: [PATCH 51/65] Update ui test suite to use dyn --- .../ui/anonymous-higher-ranked-lifetime.rs | 8 +- .../anonymous-higher-ranked-lifetime.stderr | 32 ++-- .../associated-const-in-trait.rs | 2 +- .../associated-const-in-trait.stderr | 4 +- ...pe-projection-from-multiple-supertraits.rs | 2 +- ...rojection-from-multiple-supertraits.stderr | 10 +- .../associated-types/associated-types-eq-3.rs | 2 +- .../associated-types-incomplete-object.rs | 8 +- .../associated-types-incomplete-object.stderr | 12 +- .../associated-types-overridden-binding-2.rs | 2 +- ...sociated-types-overridden-binding-2.stderr | 6 +- .../associated-types-overridden-binding.rs | 2 +- .../bound-lifetime-constrained.object.stderr | 12 +- .../bound-lifetime-constrained.rs | 4 +- ...ound-lifetime-in-binding-only.angle.stderr | 6 +- ...ound-lifetime-in-binding-only.paren.stderr | 6 +- .../bound-lifetime-in-binding-only.rs | 4 +- .../bound-lifetime-in-return-only.rs | 4 +- src/test/ui/async-await/async-with-closure.rs | 2 +- src/test/ui/async-await/issues/issue-53249.rs | 2 +- src/test/ui/async-await/issues/issue-54974.rs | 2 +- src/test/ui/bad/bad-sized.rs | 2 +- src/test/ui/bad/bad-sized.stderr | 26 +-- .../borrowck-borrow-mut-object-twice.rs | 2 +- .../borrowck/borrowck-consume-upcast-box.rs | 4 +- .../borrowck-consume-upcast-box.stderr | 2 +- .../borrowck-escaping-closure-error-2.rs | 2 +- src/test/ui/borrowck/borrowck-in-static.rs | 2 +- .../ui/borrowck/borrowck-object-lifetime.rs | 8 +- ...orrowck-use-uninitialized-in-cast-trait.rs | 2 +- ...wck-use-uninitialized-in-cast-trait.stderr | 2 +- .../regions-escape-unboxed-closure.rs | 2 +- .../two-phase-nonrecv-autoref.nll.stderr | 2 +- .../ui/borrowck/two-phase-nonrecv-autoref.rs | 6 +- src/test/ui/bounds-lifetime.rs | 2 +- src/test/ui/bounds-lifetime.stderr | 6 +- ...cast-to-unsized-trait-object-suggestion.rs | 4 +- ...-to-unsized-trait-object-suggestion.stderr | 12 +- src/test/ui/casts-differing-anon.rs | 2 +- src/test/ui/class-cast-to-trait.rs | 2 +- .../ui/closure_context/issue-26046-fn-mut.rs | 2 +- .../ui/closure_context/issue-26046-fn-once.rs | 2 +- .../closure-immutable-outer-variable.fixed | 2 +- .../closure-immutable-outer-variable.rs | 2 +- ...herence-overlapping-inherent-impl-trait.rs | 4 +- ...nce-overlapping-inherent-impl-trait.stderr | 10 +- src/test/ui/codemap_tests/two_files_data.rs | 2 +- .../coerce-expect-unsized-ascribed.rs | 16 +- .../coerce-expect-unsized-ascribed.stderr | 14 +- ...mpl-trait-for-trait-object-safe.old.stderr | 2 +- ...impl-trait-for-trait-object-safe.re.stderr | 2 +- ...erence-impl-trait-for-trait-object-safe.rs | 2 +- .../coherence-impl-trait-for-trait.old.stderr | 12 +- .../coherence-impl-trait-for-trait.re.stderr | 12 +- .../coherence-impl-trait-for-trait.rs | 8 +- .../ui/confuse-field-and-method/issue-2392.rs | 8 +- .../confuse-field-and-method/issue-32128.rs | 2 +- .../ui/consts/const-eval/const_transmute.rs | 2 +- src/test/ui/consts/const-eval/issue-53401.rs | 2 +- src/test/ui/consts/const-eval/ub-upvars.rs | 2 +- .../ui/consts/const-eval/ub-upvars.stderr | 2 +- .../ui/consts/const-eval/union-ub-fat-ptr.rs | 10 +- .../consts/const-eval/union-ub-fat-ptr.stderr | 16 +- src/test/ui/consts/const-unsized.rs | 4 +- src/test/ui/consts/const-unsized.stderr | 8 +- .../min_const_fn/min_const_fn.nll.stderr | 4 +- .../ui/consts/min_const_fn/min_const_fn.rs | 2 +- .../consts/min_const_fn/min_const_fn.stderr | 4 +- src/test/ui/cross/cross-borrow-trait.rs | 8 +- src/test/ui/cross/cross-borrow-trait.stderr | 12 +- src/test/ui/custom-test-frameworks-simple.rs | 2 +- .../cycle-trait-default-type-trait.rs | 2 +- .../cycle-trait-default-type-trait.stderr | 10 +- src/test/ui/destructure-trait-ref.rs | 19 ++- src/test/ui/destructure-trait-ref.stderr | 18 +- src/test/ui/did_you_mean/E0178.rs | 2 + src/test/ui/did_you_mean/E0178.stderr | 8 +- src/test/ui/did_you_mean/bad-assoc-ty.rs | 2 +- src/test/ui/did_you_mean/bad-assoc-ty.stderr | 8 +- src/test/ui/did_you_mean/issue-40006.rs | 2 +- src/test/ui/did_you_mean/issue-40006.stderr | 10 +- ...ect-reference-without-parens-suggestion.rs | 2 + ...reference-without-parens-suggestion.stderr | 6 +- .../ui/dropck/dropck_trait_cycle_checked.rs | 16 +- .../dropck/dropck_trait_cycle_checked.stderr | 24 +-- src/test/ui/dst/dst-bad-assign-2.rs | 4 +- src/test/ui/dst/dst-bad-assign-3.rs | 4 +- src/test/ui/dst/dst-bad-assign.rs | 4 +- src/test/ui/dst/dst-bad-coerce1.rs | 4 +- src/test/ui/dst/dst-bad-coerce1.stderr | 12 +- src/test/ui/dst/dst-bad-coerce2.rs | 4 +- src/test/ui/dst/dst-bad-coerce2.stderr | 12 +- src/test/ui/dst/dst-bad-coerce3.rs | 4 +- src/test/ui/dst/dst-bad-coerce3.stderr | 8 +- src/test/ui/dst/dst-bad-coercions.rs | 8 +- src/test/ui/dst/dst-bad-coercions.stderr | 36 ++-- src/test/ui/dst/dst-index.rs | 4 +- .../ui/dst/dst-object-from-unsized-type.rs | 8 +- .../dst/dst-object-from-unsized-type.stderr | 24 +-- .../ui/elide-errors-on-mismatched-tuple.rs | 2 +- src/test/ui/error-codes/E0033-teach.rs | 2 +- src/test/ui/error-codes/E0033-teach.stderr | 10 +- src/test/ui/error-codes/E0033.rs | 2 +- src/test/ui/error-codes/E0033.stderr | 10 +- src/test/ui/error-codes/E0038.rs | 2 +- src/test/ui/error-codes/E0038.stderr | 4 +- src/test/ui/error-codes/E0120.rs | 2 +- src/test/ui/error-codes/E0120.stderr | 4 +- src/test/ui/error-codes/E0191.rs | 2 +- src/test/ui/error-codes/E0191.stderr | 4 +- src/test/ui/error-codes/E0220.rs | 4 +- src/test/ui/error-codes/E0220.stderr | 10 +- src/test/ui/error-codes/E0393.rs | 2 +- src/test/ui/error-codes/E0393.stderr | 6 +- src/test/ui/error-codes/E0478.rs | 2 +- src/test/ui/error-codes/E0478.stderr | 4 +- src/test/ui/error-codes/E0719.rs | 4 +- src/test/ui/error-codes/E0719.stderr | 10 +- src/test/ui/fat-ptr-cast.rs | 2 +- src/test/ui/fat-ptr-cast.stderr | 6 +- .../feature-gate-trivial_bounds.rs | 4 +- .../feature-gate-trivial_bounds.stderr | 4 +- .../feature-gate-unsized_locals.rs | 2 +- .../feature-gate-unsized_locals.stderr | 2 +- .../feature-gate-unsized_tuple_coercion.rs | 2 +- ...feature-gate-unsized_tuple_coercion.stderr | 6 +- src/test/ui/fn/fn-trait-formatting.rs | 6 +- src/test/ui/fn/fn-trait-formatting.stderr | 12 +- src/test/ui/higher-lifetime-bounds.rs | 4 +- src/test/ui/higher-lifetime-bounds.stderr | 12 +- src/test/ui/imports/extern-crate-used.rs | 8 +- .../mismatched_trait_impl-2.rs | 4 +- .../mismatched_trait_impl-2.stderr | 6 +- src/test/ui/issues/issue-10291.nll.stderr | 2 +- src/test/ui/issues/issue-10291.rs | 2 +- src/test/ui/issues/issue-10291.stderr | 8 +- src/test/ui/issues/issue-10902.rs | 8 +- src/test/ui/issues/issue-11374.rs | 6 +- src/test/ui/issues/issue-11515.rs | 4 +- src/test/ui/issues/issue-11612.rs | 4 +- src/test/ui/issues/issue-12470.rs | 4 +- src/test/ui/issues/issue-13033.rs | 4 +- src/test/ui/issues/issue-13033.stderr | 12 +- src/test/ui/issues/issue-13352.rs | 2 +- src/test/ui/issues/issue-13853-2.rs | 2 +- src/test/ui/issues/issue-13853-2.stderr | 6 +- src/test/ui/issues/issue-14285.rs | 4 +- src/test/ui/issues/issue-14285.stderr | 4 +- src/test/ui/issues/issue-14366.rs | 2 +- src/test/ui/issues/issue-14366.stderr | 2 +- src/test/ui/issues/issue-14901.rs | 4 +- src/test/ui/issues/issue-14959.rs | 12 +- src/test/ui/issues/issue-16668.rs | 2 +- src/test/ui/issues/issue-16922.rs | 4 +- src/test/ui/issues/issue-16922.stderr | 4 +- src/test/ui/issues/issue-16994.rs | 2 +- src/test/ui/issues/issue-17441.rs | 4 +- src/test/ui/issues/issue-17441.stderr | 12 +- src/test/ui/issues/issue-17959.rs | 2 +- src/test/ui/issues/issue-18107.rs | 2 +- src/test/ui/issues/issue-18107.stderr | 4 +- src/test/ui/issues/issue-18188.rs | 2 +- src/test/ui/issues/issue-18446-2.rs | 2 +- src/test/ui/issues/issue-18446.rs | 4 +- src/test/ui/issues/issue-18783.rs | 6 +- src/test/ui/issues/issue-18819.rs | 2 +- src/test/ui/issues/issue-18819.stderr | 4 +- src/test/ui/issues/issue-18919.rs | 2 +- src/test/ui/issues/issue-18937.rs | 2 +- src/test/ui/issues/issue-18959.rs | 4 +- src/test/ui/issues/issue-18959.stderr | 4 +- src/test/ui/issues/issue-18988.rs | 2 +- src/test/ui/issues/issue-19380.rs | 2 +- src/test/ui/issues/issue-19380.stderr | 4 +- src/test/ui/issues/issue-19404.rs | 8 +- src/test/ui/issues/issue-19482.rs | 2 +- src/test/ui/issues/issue-19482.stderr | 4 +- src/test/ui/issues/issue-19538.rs | 2 +- src/test/ui/issues/issue-19538.stderr | 10 +- src/test/ui/issues/issue-20396.rs | 2 +- src/test/ui/issues/issue-20605.rs | 2 +- src/test/ui/issues/issue-20692.rs | 2 +- src/test/ui/issues/issue-20692.stderr | 4 +- src/test/ui/issues/issue-20831-debruijn.rs | 6 +- .../ui/issues/issue-20831-debruijn.stderr | 12 +- src/test/ui/issues/issue-20939.rs | 2 +- src/test/ui/issues/issue-20939.stderr | 4 +- src/test/ui/issues/issue-21363.rs | 2 +- src/test/ui/issues/issue-21950.rs | 2 +- src/test/ui/issues/issue-21950.stderr | 10 +- src/test/ui/issues/issue-22034.rs | 4 +- src/test/ui/issues/issue-22034.stderr | 2 +- src/test/ui/issues/issue-22289.rs | 2 +- src/test/ui/issues/issue-22289.stderr | 4 +- src/test/ui/issues/issue-22312.rs | 2 +- src/test/ui/issues/issue-22312.stderr | 4 +- src/test/ui/issues/issue-22370.rs | 2 +- src/test/ui/issues/issue-22370.stderr | 6 +- src/test/ui/issues/issue-22434.rs | 2 +- src/test/ui/issues/issue-22434.stderr | 4 +- src/test/ui/issues/issue-22560.rs | 2 +- src/test/ui/issues/issue-22560.stderr | 18 +- src/test/ui/issues/issue-22781.rs | 2 +- src/test/ui/issues/issue-22872.rs | 2 +- src/test/ui/issues/issue-22872.stderr | 6 +- src/test/ui/issues/issue-23024.rs | 4 +- src/test/ui/issues/issue-23024.stderr | 16 +- src/test/ui/issues/issue-23041.rs | 2 +- src/test/ui/issues/issue-23046.rs | 2 +- src/test/ui/issues/issue-23281.rs | 2 +- src/test/ui/issues/issue-23281.stderr | 4 +- src/test/ui/issues/issue-24446.rs | 2 +- src/test/ui/issues/issue-24446.stderr | 4 +- src/test/ui/issues/issue-25180.rs | 2 +- src/test/ui/issues/issue-26056.rs | 2 +- src/test/ui/issues/issue-26056.stderr | 4 +- src/test/ui/issues/issue-26638.rs | 2 +- src/test/ui/issues/issue-26638.stderr | 6 +- src/test/ui/issues/issue-26905.rs | 2 +- src/test/ui/issues/issue-27105.rs | 2 +- src/test/ui/issues/issue-28279.rs | 4 +- src/test/ui/issues/issue-28576.rs | 2 +- src/test/ui/issues/issue-28576.stderr | 2 +- src/test/ui/issues/issue-2904.rs | 2 +- src/test/ui/issues/issue-32963.rs | 2 +- src/test/ui/issues/issue-32963.stderr | 20 +-- src/test/ui/issues/issue-32995.rs | 4 +- src/test/ui/issues/issue-32995.stderr | 12 +- .../issues/issue-33140-traitobject-crate.rs | 158 +++++++++--------- .../issue-33140-traitobject-crate.stderr | 26 +-- src/test/ui/issues/issue-33140.rs | 12 +- src/test/ui/issues/issue-33241.rs | 2 +- src/test/ui/issues/issue-3424.rs | 2 +- src/test/ui/issues/issue-35139.rs | 6 +- src/test/ui/issues/issue-35546.rs | 4 +- src/test/ui/issues/issue-35570.rs | 2 +- src/test/ui/issues/issue-35976.rs | 4 +- src/test/ui/issues/issue-3609.rs | 2 +- src/test/ui/issues/issue-36839.rs | 2 +- src/test/ui/issues/issue-3702-2.rs | 4 +- src/test/ui/issues/issue-37515.rs | 2 +- src/test/ui/issues/issue-37515.stderr | 4 +- src/test/ui/issues/issue-38404.rs | 2 +- src/test/ui/issues/issue-38404.stderr | 4 +- src/test/ui/issues/issue-38604.rs | 2 +- src/test/ui/issues/issue-38604.stderr | 4 +- src/test/ui/issues/issue-40000.rs | 4 +- src/test/ui/issues/issue-41139.rs | 4 +- src/test/ui/issues/issue-41139.stderr | 6 +- src/test/ui/issues/issue-42312.rs | 2 +- src/test/ui/issues/issue-42312.stderr | 6 +- src/test/ui/issues/issue-4335.rs | 2 +- src/test/ui/issues/issue-4335.stderr | 2 +- src/test/ui/issues/issue-45730.rs | 2 +- src/test/ui/issues/issue-4972.rs | 4 +- src/test/ui/issues/issue-50761.rs | 2 +- src/test/ui/issues/issue-50781.rs | 2 +- src/test/ui/issues/issue-5153.rs | 2 +- src/test/ui/issues/issue-5153.stderr | 6 +- src/test/ui/issues/issue-5216.rs | 4 +- src/test/ui/issues/issue-53419.rs | 2 +- src/test/ui/issues/issue-54582.rs | 2 +- src/test/ui/issues/issue-55796.rs | 4 +- src/test/ui/issues/issue-5883.rs | 4 +- src/test/ui/issues/issue-5883.stderr | 2 +- src/test/ui/issues/issue-60989.rs | 2 +- src/test/ui/issues/issue-60989.stderr | 4 +- src/test/ui/issues/issue-7013.rs | 4 +- src/test/ui/issues/issue-7013.stderr | 2 +- ...7673-cast-generically-implemented-trait.rs | 4 +- src/test/ui/issues/issue-8398.rs | 2 +- src/test/ui/issues/issue-9719.rs | 12 +- src/test/ui/kindck/kindck-copy.rs | 12 +- src/test/ui/kindck/kindck-copy.stderr | 12 +- .../kindck/kindck-impl-type-params.nll.stderr | 24 +-- src/test/ui/kindck/kindck-impl-type-params.rs | 10 +- .../ui/kindck/kindck-impl-type-params.stderr | 26 +-- .../ui/kindck/kindck-inherited-copy-bound.rs | 2 +- .../kindck/kindck-inherited-copy-bound.stderr | 6 +- src/test/ui/kindck/kindck-send-object.rs | 8 +- src/test/ui/kindck/kindck-send-object.stderr | 8 +- .../ui/kindck/kindck-send-object1.nll.stderr | 8 +- src/test/ui/kindck/kindck-send-object1.rs | 10 +- src/test/ui/kindck/kindck-send-object1.stderr | 12 +- src/test/ui/kindck/kindck-send-object2.rs | 8 +- src/test/ui/kindck/kindck-send-object2.stderr | 8 +- ...etime-bound-will-change-warning.nll.stderr | 4 +- .../lifetime-bound-will-change-warning.rs | 16 +- .../lifetime-bound-will-change-warning.stderr | 4 +- .../lifetime-elision-return-type-trait.rs | 2 +- .../lifetime-elision-return-type-trait.stderr | 4 +- ...non-regions-using-trait-objects.nll.stderr | 12 +- ...3-both-anon-regions-using-trait-objects.rs | 2 +- ...th-anon-regions-using-trait-objects.stderr | 4 +- src/test/ui/lint/lint-ctypes.rs | 2 +- src/test/ui/lint/lint-ctypes.stderr | 4 +- src/test/ui/lint/lint-dead-code-3.rs | 2 +- src/test/ui/lint/lint-stability-2.rs | 4 +- src/test/ui/lint/lint-stability-deprecated.rs | 6 +- src/test/ui/lint/lint-stability.rs | 6 +- .../ui/lint/lint-unconditional-recursion.rs | 4 +- .../loops-reject-lifetime-shadowing-label.rs | 2 +- ...ops-reject-lifetime-shadowing-label.stderr | 6 +- src/test/ui/lub-glb/old-lub-glb-object.rs | 10 +- src/test/ui/map-types.rs | 4 +- src/test/ui/map-types.stderr | 6 +- .../method-call-lifetime-args-lint-fail.rs | 4 +- src/test/ui/mismatched_types/cast-rfc0401.rs | 10 +- .../ui/mismatched_types/cast-rfc0401.stderr | 8 +- src/test/ui/mismatched_types/issue-19109.rs | 4 +- .../ui/mismatched_types/issue-19109.stderr | 8 +- .../trait-bounds-cant-coerce.rs | 6 +- ...ased-on-type-no-recursive-stack-closure.rs | 2 +- src/test/ui/nll/issue-52663-trait-object.rs | 2 +- .../ui/nll/issue-52663-trait-object.stderr | 4 +- src/test/ui/nll/issue-53570.rs | 4 +- src/test/ui/object-does-not-impl-trait.rs | 2 +- src/test/ui/object-does-not-impl-trait.stderr | 6 +- .../object-lifetime-default-ambiguous.rs | 12 +- .../object-lifetime-default-ambiguous.stderr | 14 +- ...object-lifetime-default-elision.nll.stderr | 2 +- .../object-lifetime-default-elision.rs | 10 +- .../object-lifetime-default-elision.stderr | 8 +- ...lifetime-default-from-box-error.nll.stderr | 4 +- .../object-lifetime-default-from-box-error.rs | 8 +- ...ect-lifetime-default-from-box-error.stderr | 4 +- ...ime-default-from-rptr-box-error.nll.stderr | 2 +- ...ct-lifetime-default-from-rptr-box-error.rs | 4 +- ...ifetime-default-from-rptr-box-error.stderr | 2 +- ...-default-from-rptr-struct-error.nll.stderr | 2 +- ...lifetime-default-from-rptr-struct-error.rs | 6 +- ...time-default-from-rptr-struct-error.stderr | 2 +- .../object-lifetime-default-mybox.nll.stderr | 4 +- .../object-lifetime-default-mybox.rs | 10 +- .../object-lifetime-default-mybox.stderr | 12 +- src/test/ui/object-pointer-types.rs | 6 +- .../object-safety-associated-consts.rs | 2 +- .../object-safety-associated-consts.stderr | 4 +- .../object-safety-by-value-self-use.rs | 2 +- .../object-safety-by-value-self.rs | 18 +- .../object-safety/object-safety-generics.rs | 12 +- .../object-safety-generics.stderr | 8 +- .../object-safety-issue-22040.rs | 6 +- .../object-safety-issue-22040.stderr | 4 +- .../object-safety-mentions-Self.rs | 10 +- .../object-safety-mentions-Self.stderr | 8 +- .../object-safety/object-safety-no-static.rs | 2 +- .../object-safety-no-static.stderr | 4 +- .../object-safety/object-safety-phantom-fn.rs | 4 +- .../ui/object-safety/object-safety-sized-2.rs | 2 +- .../object-safety-sized-2.stderr | 4 +- .../ui/object-safety/object-safety-sized.rs | 2 +- .../object-safety/object-safety-sized.stderr | 4 +- .../object-safety-supertrait-mentions-Self.rs | 4 +- ...ect-safety-supertrait-mentions-Self.stderr | 4 +- .../private-in-public-non-principal-2.rs | 2 +- .../private-in-public-non-principal.rs | 2 +- .../private-in-public-non-principal.stderr | 4 +- src/test/ui/privacy/private-inferred-type.rs | 6 +- .../region-borrow-params-issue-29793-small.rs | 30 ++-- ...n-bounds-on-objects-and-type-parameters.rs | 16 +- ...unds-on-objects-and-type-parameters.stderr | 10 +- .../region-object-lifetime-2.nll.stderr | 2 +- .../ui/regions/region-object-lifetime-2.rs | 2 +- .../regions/region-object-lifetime-2.stderr | 4 +- .../region-object-lifetime-4.nll.stderr | 2 +- .../ui/regions/region-object-lifetime-4.rs | 2 +- .../regions/region-object-lifetime-4.stderr | 4 +- .../ui/regions/region-object-lifetime-5.rs | 2 +- ...ion-object-lifetime-in-coercion.nll.stderr | 12 +- .../region-object-lifetime-in-coercion.rs | 12 +- .../region-object-lifetime-in-coercion.stderr | 16 +- ...gions-close-associated-type-into-object.rs | 16 +- ...ions-close-object-into-object-2.nll.stderr | 10 +- .../regions-close-object-into-object-2.rs | 6 +- .../regions-close-object-into-object-2.stderr | 6 +- ...ions-close-object-into-object-4.nll.stderr | 14 +- .../regions-close-object-into-object-4.rs | 6 +- .../regions-close-object-into-object-4.stderr | 6 +- ...ons-close-over-type-parameter-1.nll.stderr | 4 +- .../regions-close-over-type-parameter-1.rs | 12 +- ...regions-close-over-type-parameter-1.stderr | 32 ++-- ...se-over-type-parameter-multiple.nll.stderr | 6 +- ...ions-close-over-type-parameter-multiple.rs | 12 +- ...-close-over-type-parameter-multiple.stderr | 12 +- .../regions-close-param-into-object.rs | 8 +- .../regions-close-param-into-object.stderr | 8 +- ...ions-implied-bounds-projection-gap-hr-1.rs | 2 +- ...-implied-bounds-projection-gap-hr-1.stderr | 6 +- .../regions/regions-infer-at-fn-not-param.rs | 6 +- ...ns-infer-invariance-due-to-mutability-3.rs | 2 +- ...ns-infer-invariance-due-to-mutability-4.rs | 2 +- .../ui/regions/regions-infer-not-param.rs | 4 +- .../ui/regions/regions-name-undeclared.rs | 6 +- .../ui/regions/regions-nested-fns.nll.stderr | 8 +- src/test/ui/regions/regions-nested-fns.rs | 4 +- src/test/ui/regions/regions-nested-fns.stderr | 24 +-- .../ui/regions/regions-proc-bound-capture.rs | 4 +- .../regions/regions-proc-bound-capture.stderr | 2 +- src/test/ui/regions/regions-steal-closure.rs | 4 +- src/test/ui/regions/regions-trait-1.rs | 4 +- .../regions-trait-object-subtyping.nll.stderr | 4 +- .../regions/regions-trait-object-subtyping.rs | 8 +- .../regions-trait-object-subtyping.stderr | 12 +- src/test/ui/regions/regions-trait-variance.rs | 4 +- .../ui/regions/regions-wf-trait-object.rs | 2 +- .../ui/regions/regions-wf-trait-object.stderr | 4 +- src/test/ui/resolve/issue-23305.rs | 2 +- src/test/ui/resolve/issue-23305.stderr | 10 +- src/test/ui/resolve/issue-33876.rs | 2 +- src/test/ui/resolve/issue-33876.stderr | 6 +- src/test/ui/resolve/issue-3907-2.rs | 2 +- src/test/ui/resolve/issue-3907.rs | 2 +- src/test/ui/resolve/issue-5035-2.rs | 2 +- src/test/ui/resolve/issue-5035.rs | 2 +- .../rfc-2093-infer-outlives/self-structs.rs | 2 +- .../self-structs.stderr | 2 +- .../generic-associated-types-where.rs | 4 +- src/test/ui/rfc1623.rs | 2 +- src/test/ui/save-analysis/issue-59134-0.rs | 2 +- .../arbitrary-self-types-not-object-safe.rs | 4 +- ...rbitrary-self-types-not-object-safe.stderr | 6 +- .../arbitrary_self_types_raw_pointer_trait.rs | 8 +- .../ui/self/explicit-self-objects-uniq.rs | 2 +- .../object-safety-sized-self-by-value-self.rs | 2 +- ...object-safety-sized-self-generic-method.rs | 2 +- .../object-safety-sized-self-return-Self.rs | 2 +- .../borrowck-call-is-borrow-issue-12224.rs | 8 +- ...borrowck-call-is-borrow-issue-12224.stderr | 2 +- .../ui/span/borrowck-object-mutability.rs | 8 +- .../ui/span/borrowck-object-mutability.stderr | 6 +- src/test/ui/span/dropck-object-cycle.rs | 8 +- src/test/ui/span/issue-25199.rs | 2 +- src/test/ui/span/issue-26656.rs | 2 +- .../regions-close-over-borrowed-ref-in-obj.rs | 2 +- .../regions-close-over-type-parameter-2.rs | 4 +- .../send-is-not-static-ensures-scoping.rs | 2 +- ...use-type-argument-instead-of-assoc-type.rs | 2 +- ...type-argument-instead-of-assoc-type.stderr | 18 +- .../traits/trait-alias/trait-alias-bounds.rs | 2 +- .../trait-alias/trait-alias-no-duplicates.rs | 4 +- .../trait-alias-no-duplicates.stderr | 20 +-- .../traits/trait-bounds-not-on-bare-trait.rs | 1 + .../trait-bounds-not-on-bare-trait.stderr | 8 + src/test/ui/traits/trait-bounds-sugar.rs | 8 +- .../ui/traits/trait-coercion-generic-bad.rs | 2 +- .../traits/trait-coercion-generic-bad.stderr | 6 +- .../traits/trait-coercion-generic-regions.rs | 2 +- .../trait-coercion-generic-regions.stderr | 2 +- src/test/ui/traits/trait-impl-1.rs | 2 +- src/test/ui/traits/trait-item-privacy.rs | 6 +- .../traits/trait-object-auto-dedup-in-impl.rs | 8 +- .../ui/traits/trait-object-macro-matcher.rs | 7 +- .../traits/trait-object-macro-matcher.stderr | 10 +- src/test/ui/traits/trait-object-safety.rs | 2 +- src/test/ui/traits/trait-object-safety.stderr | 10 +- .../ui/traits/trait-object-vs-lifetime-2.rs | 2 +- .../traits/trait-object-vs-lifetime-2.stderr | 4 +- .../ui/traits/trait-object-vs-lifetime.rs | 4 +- .../ui/traits/trait-object-vs-lifetime.stderr | 14 +- src/test/ui/traits/trait-test-2.rs | 2 +- src/test/ui/traits/trait-test-2.stderr | 6 +- .../traits-repeated-supertrait-ambig.rs | 2 +- .../trivial-bounds-inconsistent-sized.rs | 4 +- .../trivial-bounds-inconsistent-sized.stderr | 6 +- .../trivial-bounds-inconsistent.rs | 4 +- .../trivial-bounds-inconsistent.stderr | 6 +- src/test/ui/trivial_casts.rs | 28 ++-- src/test/ui/trivial_casts.stderr | 28 ++-- src/test/ui/type/type-arg-out-of-scope.rs | 2 +- src/test/ui/type/type-arg-out-of-scope.stderr | 12 +- ...rameter-defaults-referencing-Self-ppaux.rs | 2 +- ...ter-defaults-referencing-Self-ppaux.stderr | 10 +- ...ype-parameter-defaults-referencing-Self.rs | 2 +- ...parameter-defaults-referencing-Self.stderr | 6 +- .../typeck-builtin-bound-type-parameters.rs | 2 +- ...ypeck-builtin-bound-type-parameters.stderr | 4 +- .../unboxed-closure-feature-gate.rs | 8 +- .../unboxed-closure-feature-gate.stderr | 6 +- .../unboxed-closure-sugar-default.rs | 6 +- .../unboxed-closure-sugar-default.stderr | 4 +- .../unboxed-closure-sugar-equiv.rs | 34 ++-- .../unboxed-closure-sugar-equiv.stderr | 6 +- .../unboxed-closure-sugar-lifetime-elision.rs | 10 +- ...oxed-closure-sugar-lifetime-elision.stderr | 6 +- .../unboxed-closure-sugar-not-used-on-fn.rs | 2 +- ...nboxed-closure-sugar-not-used-on-fn.stderr | 6 +- .../unboxed-closure-sugar-region.rs | 6 +- .../unboxed-closure-sugar-region.stderr | 6 +- ...r-wrong-number-number-type-parameters-1.rs | 2 +- ...ong-number-number-type-parameters-1.stderr | 6 +- ...r-wrong-number-number-type-parameters-3.rs | 2 +- ...ong-number-number-type-parameters-3.stderr | 12 +- ...gar-wrong-number-number-type-parameters.rs | 2 +- ...wrong-number-number-type-parameters.stderr | 12 +- .../unboxed-closures-failed-recursive-fn-1.rs | 4 +- ...oxed-closures-failed-recursive-fn-1.stderr | 8 +- ...oxed-closures-recursive-fn-using-fn-mut.rs | 6 +- .../underscore-lifetime-binders.rs | 2 +- .../underscore-lifetime-binders.stderr | 12 +- src/test/ui/unique-object-noncopyable.rs | 2 +- src/test/ui/unsized/unsized-enum2.rs | 16 +- src/test/ui/unsized/unsized-enum2.stderr | 16 +- ...use-after-move-implicity-coerced-object.rs | 4 +- ...riance-contravariant-arg-object.nll.stderr | 4 +- .../variance-contravariant-arg-object.rs | 8 +- .../variance-contravariant-arg-object.stderr | 8 +- .../variance-covariant-arg-object.nll.stderr | 4 +- .../variance/variance-covariant-arg-object.rs | 8 +- .../variance-covariant-arg-object.stderr | 8 +- .../variance-invariant-arg-object.nll.stderr | 4 +- .../variance/variance-invariant-arg-object.rs | 8 +- .../variance-invariant-arg-object.stderr | 8 +- src/test/ui/variance/variance-object-types.rs | 2 +- .../ui/variance/variance-object-types.stderr | 2 +- .../variance/variance-trait-object-bound.rs | 2 +- .../variance-trait-object-bound.stderr | 2 +- src/test/ui/variance/variance-types-bounds.rs | 4 +- .../ui/variance/variance-types-bounds.stderr | 4 +- src/test/ui/wf/wf-in-obj-type-static.rs | 2 +- src/test/ui/wf/wf-in-obj-type-static.stderr | 8 +- src/test/ui/wf/wf-in-obj-type-trait.rs | 2 +- src/test/ui/wf/wf-in-obj-type-trait.stderr | 4 +- src/test/ui/wf/wf-object-safe.rs | 2 +- src/test/ui/wf/wf-object-safe.stderr | 4 +- .../ui/wf/wf-outlives-ty-in-fn-or-trait.rs | 2 +- .../wf/wf-outlives-ty-in-fn-or-trait.stderr | 8 +- .../where-lifetime-resolution.rs | 6 +- .../where-lifetime-resolution.stderr | 18 +- 529 files changed, 1620 insertions(+), 1605 deletions(-) diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.rs b/src/test/ui/anonymous-higher-ranked-lifetime.rs index 2e2a124db9a..8a1744ed5f8 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.rs +++ b/src/test/ui/anonymous-higher-ranked-lifetime.rs @@ -31,11 +31,11 @@ fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} // Nested -fn g1(_: F) where F: Fn(&(), Box) {} +fn g1(_: F) where F: Fn(&(), Box) {} fn g2(_: F) where F: Fn(&(), fn(&())) {} -fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} +fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} // Mixed -fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} -fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} +fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} +fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index 86547303978..0ca3ca84374 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -149,8 +149,8 @@ LL | g1(|_: (), _: ()| {}); note: required by `g1` --> $DIR/anonymous-higher-ranked-lifetime.rs:34:1 | -LL | fn g1(_: F) where F: Fn(&(), Box) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn g1(_: F) where F: Fn(&(), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:12:5 @@ -163,8 +163,8 @@ LL | g1(|_: (), _: ()| {}); note: required by `g1` --> $DIR/anonymous-higher-ranked-lifetime.rs:34:1 | -LL | fn g1(_: F) where F: Fn(&(), Box) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn g1(_: F) where F: Fn(&(), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -205,8 +205,8 @@ LL | g3(|_: (), _: ()| {}); note: required by `g3` --> $DIR/anonymous-higher-ranked-lifetime.rs:36:1 | -LL | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -219,8 +219,8 @@ LL | g3(|_: (), _: ()| {}); note: required by `g3` --> $DIR/anonymous-higher-ranked-lifetime.rs:36:1 | -LL | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -261,8 +261,8 @@ LL | h1(|_: (), _: (), _: (), _: ()| {}); note: required by `h1` --> $DIR/anonymous-higher-ranked-lifetime.rs:40:1 | -LL | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -275,8 +275,8 @@ LL | h1(|_: (), _: (), _: (), _: ()| {}); note: required by `h1` --> $DIR/anonymous-higher-ranked-lifetime.rs:40:1 | -LL | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -289,8 +289,8 @@ LL | h2(|_: (), _: (), _: (), _: ()| {}); note: required by `h2` --> $DIR/anonymous-higher-ranked-lifetime.rs:41:1 | -LL | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -303,8 +303,8 @@ LL | h2(|_: (), _: (), _: (), _: ()| {}); note: required by `h2` --> $DIR/anonymous-higher-ranked-lifetime.rs:41:1 | -LL | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 22 previous errors diff --git a/src/test/ui/associated-const/associated-const-in-trait.rs b/src/test/ui/associated-const/associated-const-in-trait.rs index 187708a60b4..cc3acd53956 100644 --- a/src/test/ui/associated-const/associated-const-in-trait.rs +++ b/src/test/ui/associated-const/associated-const-in-trait.rs @@ -6,7 +6,7 @@ trait Trait { const N: usize; } -impl Trait { +impl dyn Trait { //~^ ERROR the trait `Trait` cannot be made into an object [E0038] const fn n() -> usize { Self::N } } diff --git a/src/test/ui/associated-const/associated-const-in-trait.stderr b/src/test/ui/associated-const/associated-const-in-trait.stderr index 44a92639b5d..dff268a55c9 100644 --- a/src/test/ui/associated-const/associated-const-in-trait.stderr +++ b/src/test/ui/associated-const/associated-const-in-trait.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/associated-const-in-trait.rs:9:6 | -LL | impl Trait { - | ^^^^^ the trait `Trait` cannot be made into an object +LL | impl dyn Trait { + | ^^^^^^^^^ the trait `Trait` cannot be made into an object | = note: the trait cannot contain associated consts like `N` diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs index df9143d685f..7a678445796 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs @@ -20,7 +20,7 @@ fn dent(c: C, color: C::Color) { //~^ ERROR ambiguous associated type `Color` in bounds of `C` } -fn dent_object(c: BoxCar) { +fn dent_object(c: dyn BoxCar) { //~^ ERROR ambiguous associated type //~| ERROR the value of the associated type `Color` (from the trait `Vehicle`) must be specified } diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr index dd46ad64692..6118ebef125 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr @@ -11,7 +11,7 @@ LL | fn dent(c: C, color: C::Color) { | ^^^^^^^^ ambiguous associated type `Color` error[E0221]: ambiguous associated type `Color` in bounds of `BoxCar` - --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:33 + --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:37 | LL | type Color; | ----------- ambiguous `Color` from `Vehicle` @@ -19,8 +19,8 @@ LL | type Color; LL | type Color; | ----------- ambiguous `Color` from `Box` ... -LL | fn dent_object(c: BoxCar) { - | ^^^^^^^^^^^ ambiguous associated type `Color` +LL | fn dent_object(c: dyn BoxCar) { + | ^^^^^^^^^^^ ambiguous associated type `Color` error[E0191]: the value of the associated type `Color` (from the trait `Vehicle`) must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:26 @@ -28,8 +28,8 @@ error[E0191]: the value of the associated type `Color` (from the trait `Vehicle` LL | type Color; | ----------- `Color` defined here ... -LL | fn dent_object(c: BoxCar) { - | ^^^^^^^^^^^^^^^^^^^ associated type `Color` must be specified +LL | fn dent_object(c: dyn BoxCar) { + | ^^^^^^^^^^^^^^^^^^^^^^^ associated type `Color` must be specified error[E0221]: ambiguous associated type `Color` in bounds of `C` --> $DIR/associated-type-projection-from-multiple-supertraits.rs:28:29 diff --git a/src/test/ui/associated-types/associated-types-eq-3.rs b/src/test/ui/associated-types/associated-types-eq-3.rs index 1a58dcca9e2..9366148b587 100644 --- a/src/test/ui/associated-types/associated-types-eq-3.rs +++ b/src/test/ui/associated-types/associated-types-eq-3.rs @@ -28,7 +28,7 @@ fn foo2(x: I) { } -pub fn baz(x: &Foo) { +pub fn baz(x: &dyn Foo) { let _: Bar = x.boo(); } diff --git a/src/test/ui/associated-types/associated-types-incomplete-object.rs b/src/test/ui/associated-types/associated-types-incomplete-object.rs index c93f3bec4d7..4993b131215 100644 --- a/src/test/ui/associated-types/associated-types-incomplete-object.rs +++ b/src/test/ui/associated-types/associated-types-incomplete-object.rs @@ -18,14 +18,14 @@ impl Foo for isize { } pub fn main() { - let a = &42isize as &Foo; + let a = &42isize as &dyn Foo; - let b = &42isize as &Foo; + let b = &42isize as &dyn Foo; //~^ ERROR the value of the associated type `B` (from the trait `Foo`) must be specified - let c = &42isize as &Foo; + let c = &42isize as &dyn Foo; //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified - let d = &42isize as &Foo; + let d = &42isize as &dyn Foo; //~^ ERROR the value of the associated types `A` (from the trait `Foo`), `B` (from the trait } diff --git a/src/test/ui/associated-types/associated-types-incomplete-object.stderr b/src/test/ui/associated-types/associated-types-incomplete-object.stderr index d152e028eb7..b4c08f4a4cc 100644 --- a/src/test/ui/associated-types/associated-types-incomplete-object.stderr +++ b/src/test/ui/associated-types/associated-types-incomplete-object.stderr @@ -4,8 +4,8 @@ error[E0191]: the value of the associated type `B` (from the trait `Foo`) must b LL | type B; | ------- `B` defined here ... -LL | let b = &42isize as &Foo; - | ^^^^^^^^^^^^ associated type `B` must be specified +LL | let b = &42isize as &dyn Foo; + | ^^^^^^^^^^^^^^^^ associated type `B` must be specified error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified --> $DIR/associated-types-incomplete-object.rs:26:26 @@ -13,8 +13,8 @@ error[E0191]: the value of the associated type `A` (from the trait `Foo`) must b LL | type A; | ------- `A` defined here ... -LL | let c = &42isize as &Foo; - | ^^^^^^^^^^^ associated type `A` must be specified +LL | let c = &42isize as &dyn Foo; + | ^^^^^^^^^^^^^^^ associated type `A` must be specified error[E0191]: the value of the associated types `A` (from the trait `Foo`), `B` (from the trait `Foo`) must be specified --> $DIR/associated-types-incomplete-object.rs:29:26 @@ -24,8 +24,8 @@ LL | type A; LL | type B; | ------- `B` defined here ... -LL | let d = &42isize as &Foo; - | ^^^ +LL | let d = &42isize as &dyn Foo; + | ^^^^^^^ | | | associated type `A` must be specified | associated type `B` must be specified diff --git a/src/test/ui/associated-types/associated-types-overridden-binding-2.rs b/src/test/ui/associated-types/associated-types-overridden-binding-2.rs index 7467f332047..109feb8e969 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding-2.rs +++ b/src/test/ui/associated-types/associated-types-overridden-binding-2.rs @@ -3,6 +3,6 @@ trait I32Iterator = Iterator; fn main() { - let _: &I32Iterator = &vec![42].into_iter(); + let _: &dyn I32Iterator = &vec![42].into_iter(); //~^ ERROR type mismatch } diff --git a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr index 85724cb7c6e..aff067c2891 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr +++ b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr @@ -1,8 +1,8 @@ error[E0271]: type mismatch resolving ` as std::iter::Iterator>::Item == i32` - --> $DIR/associated-types-overridden-binding-2.rs:6:39 + --> $DIR/associated-types-overridden-binding-2.rs:6:43 | -LL | let _: &I32Iterator = &vec![42].into_iter(); - | ^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32 +LL | let _: &dyn I32Iterator = &vec![42].into_iter(); + | ^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32 | = note: expected type `u32` found type `i32` diff --git a/src/test/ui/associated-types/associated-types-overridden-binding.rs b/src/test/ui/associated-types/associated-types-overridden-binding.rs index ea3a61b2bef..fa1889389fd 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding.rs +++ b/src/test/ui/associated-types/associated-types-overridden-binding.rs @@ -7,5 +7,5 @@ trait I32Iterator = Iterator; trait U32Iterator = I32Iterator; fn main() { - let _: &I32Iterator; + let _: &dyn I32Iterator; } diff --git a/src/test/ui/associated-types/bound-lifetime-constrained.object.stderr b/src/test/ui/associated-types/bound-lifetime-constrained.object.stderr index 9258854245c..36fa06cce4d 100644 --- a/src/test/ui/associated-types/bound-lifetime-constrained.object.stderr +++ b/src/test/ui/associated-types/bound-lifetime-constrained.object.stderr @@ -1,14 +1,14 @@ error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/bound-lifetime-constrained.rs:28:56 + --> $DIR/bound-lifetime-constrained.rs:28:60 | -LL | fn object1(_: Box Fn(<() as Foo<'a>>::Item) -> &'a i32>) { - | ^^^^^^^ +LL | fn object1(_: Box Fn(<() as Foo<'a>>::Item) -> &'a i32>) { + | ^^^^^^^ error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/bound-lifetime-constrained.rs:33:35 + --> $DIR/bound-lifetime-constrained.rs:33:39 | -LL | fn object2(_: Box Fn() -> <() as Foo<'a>>::Item>) { - | ^^^^^^^^^^^^^^^^^^^^^ +LL | fn object2(_: Box Fn() -> <() as Foo<'a>>::Item>) { + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/bound-lifetime-constrained.rs b/src/test/ui/associated-types/bound-lifetime-constrained.rs index b590f88b60d..fb82b3fa666 100644 --- a/src/test/ui/associated-types/bound-lifetime-constrained.rs +++ b/src/test/ui/associated-types/bound-lifetime-constrained.rs @@ -25,12 +25,12 @@ fn func2(_: for<'a> fn() -> <() as Foo<'a>>::Item) { } #[cfg(object)] -fn object1(_: Box Fn(<() as Foo<'a>>::Item) -> &'a i32>) { +fn object1(_: Box Fn(<() as Foo<'a>>::Item) -> &'a i32>) { //[object]~^ ERROR E0582 } #[cfg(object)] -fn object2(_: Box Fn() -> <() as Foo<'a>>::Item>) { +fn object2(_: Box Fn() -> <() as Foo<'a>>::Item>) { //[object]~^ ERROR E0582 } diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr b/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr index fee64c0f663..54f4bb9076b 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr @@ -17,10 +17,10 @@ LL | fn angle2() where for<'a> T: Foo { | ^^^^^^^^^^^^ error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/bound-lifetime-in-binding-only.rs:27:27 + --> $DIR/bound-lifetime-in-binding-only.rs:27:31 | -LL | fn angle3(_: &for<'a> Foo) { - | ^^^^^^^^^^^^ +LL | fn angle3(_: &dyn for<'a> Foo) { + | ^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.paren.stderr b/src/test/ui/associated-types/bound-lifetime-in-binding-only.paren.stderr index 8c9480027e6..74bc84c222a 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.paren.stderr +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.paren.stderr @@ -17,10 +17,10 @@ LL | fn paren2() where for<'a> T: Fn() -> &'a i32 { | ^^^^^^^ error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/bound-lifetime-in-binding-only.rs:47:31 + --> $DIR/bound-lifetime-in-binding-only.rs:47:35 | -LL | fn paren3(_: &for<'a> Fn() -> &'a i32) { - | ^^^^^^^ +LL | fn paren3(_: &dyn for<'a> Fn() -> &'a i32) { + | ^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs b/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs index e1989d35bbb..843f5f06195 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs @@ -24,7 +24,7 @@ fn angle2() where for<'a> T: Foo { } #[cfg(angle)] -fn angle3(_: &for<'a> Foo) { +fn angle3(_: &dyn for<'a> Foo) { //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` } @@ -44,7 +44,7 @@ fn paren2() where for<'a> T: Fn() -> &'a i32 { } #[cfg(paren)] -fn paren3(_: &for<'a> Fn() -> &'a i32) { +fn paren3(_: &dyn for<'a> Fn() -> &'a i32) { //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` } diff --git a/src/test/ui/associated-types/bound-lifetime-in-return-only.rs b/src/test/ui/associated-types/bound-lifetime-in-return-only.rs index 5a7e086fd47..9c0dc61494d 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-return-only.rs +++ b/src/test/ui/associated-types/bound-lifetime-in-return-only.rs @@ -38,11 +38,11 @@ fn elision(_: fn() -> &i32) { struct Parameterized<'a> { x: &'a str } #[cfg(ok)] -fn ok1(_: &for<'a> Fn(&Parameterized<'a>) -> &'a i32) { +fn ok1(_: &dyn for<'a> Fn(&Parameterized<'a>) -> &'a i32) { } #[cfg(ok)] -fn ok2(_: &for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) { +fn ok2(_: &dyn for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) { } #[rustc_error] diff --git a/src/test/ui/async-await/async-with-closure.rs b/src/test/ui/async-await/async-with-closure.rs index 856a778078a..e94a5f0853d 100644 --- a/src/test/ui/async-await/async-with-closure.rs +++ b/src/test/ui/async-await/async-with-closure.rs @@ -19,7 +19,7 @@ struct MyStream { async fn get_future(_stream: MyStream) {} async fn f() { - let messages: MyStream = unimplemented!(); + let messages: MyStream = unimplemented!(); await!(get_future(messages)); } diff --git a/src/test/ui/async-await/issues/issue-53249.rs b/src/test/ui/async-await/issues/issue-53249.rs index 9e4ff43ecd1..2157cf7d4f7 100644 --- a/src/test/ui/async-await/issues/issue-53249.rs +++ b/src/test/ui/async-await/issues/issue-53249.rs @@ -35,7 +35,7 @@ impl Future for Lazy } async fn __receive(want: WantFn) -> () - where Fut: Future, WantFn: Fn(&Box) -> Fut, + where Fut: Future, WantFn: Fn(&Box) -> Fut, { await!(lazy(|_| ())); } diff --git a/src/test/ui/async-await/issues/issue-54974.rs b/src/test/ui/async-await/issues/issue-54974.rs index d6f18875c9e..ad18f411875 100644 --- a/src/test/ui/async-await/issues/issue-54974.rs +++ b/src/test/ui/async-await/issues/issue-54974.rs @@ -9,7 +9,7 @@ trait SomeTrait: Send + Sync + 'static { fn do_something(&self); } -async fn my_task(obj: Arc) { +async fn my_task(obj: Arc) { unimplemented!() } diff --git a/src/test/ui/bad/bad-sized.rs b/src/test/ui/bad/bad-sized.rs index 0da4e456f08..b899c59ff2e 100644 --- a/src/test/ui/bad/bad-sized.rs +++ b/src/test/ui/bad/bad-sized.rs @@ -1,7 +1,7 @@ trait Trait {} pub fn main() { - let x: Vec = Vec::new(); + let x: Vec = Vec::new(); //~^ ERROR only auto traits can be used as additional traits in a trait object //~| ERROR the size for values of type //~| ERROR the size for values of type diff --git a/src/test/ui/bad/bad-sized.stderr b/src/test/ui/bad/bad-sized.stderr index 6307af5d725..e9ded557281 100644 --- a/src/test/ui/bad/bad-sized.stderr +++ b/src/test/ui/bad/bad-sized.stderr @@ -1,29 +1,29 @@ error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/bad-sized.rs:4:24 + --> $DIR/bad-sized.rs:4:28 | -LL | let x: Vec = Vec::new(); - | ----- ^^^^^ - | | | - | | additional non-auto trait - | | trait alias used in trait object type (additional use) - | first non-auto trait - | trait alias used in trait object type (first use) +LL | let x: Vec = Vec::new(); + | ----- ^^^^^ + | | | + | | additional non-auto trait + | | trait alias used in trait object type (additional use) + | first non-auto trait + | trait alias used in trait object type (first use) error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time --> $DIR/bad-sized.rs:4:12 | -LL | let x: Vec = Vec::new(); - | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +LL | let x: Vec = Vec::new(); + | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` = note: to learn more, visit = note: required by `std::vec::Vec` error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time - --> $DIR/bad-sized.rs:4:33 + --> $DIR/bad-sized.rs:4:37 | -LL | let x: Vec = Vec::new(); - | ^^^^^^^^ doesn't have a size known at compile-time +LL | let x: Vec = Vec::new(); + | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` = note: to learn more, visit diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.rs b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.rs index 5e853afd38c..b4d85b60cd5 100644 --- a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.rs +++ b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.rs @@ -8,7 +8,7 @@ trait Foo { fn f2(&mut self); } -fn test(x: &mut Foo) { +fn test(x: &mut dyn Foo) { let y = x.f1(); x.f2(); //~ ERROR cannot borrow `*x` as mutable y.use_ref(); diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.rs b/src/test/ui/borrowck/borrowck-consume-upcast-box.rs index ed669c4d901..6b32d185b6f 100644 --- a/src/test/ui/borrowck/borrowck-consume-upcast-box.rs +++ b/src/test/ui/borrowck/borrowck-consume-upcast-box.rs @@ -2,10 +2,10 @@ trait Foo { fn dummy(&self); } -fn consume(_: Box) { +fn consume(_: Box) { } -fn foo(b: Box) { +fn foo(b: Box) { consume(b); consume(b); //~ ERROR use of moved value } diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr index e8194ad6944..356cda01e29 100644 --- a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr +++ b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr @@ -1,7 +1,7 @@ error[E0382]: use of moved value: `b` --> $DIR/borrowck-consume-upcast-box.rs:10:13 | -LL | fn foo(b: Box) { +LL | fn foo(b: Box) { | - move occurs because `b` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | consume(b); | - value moved here diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.rs b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.rs index a44e3031e25..b50d455637b 100644 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.rs +++ b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.rs @@ -6,7 +6,7 @@ // closure may outlive the current function, but it borrows `books`, // which is owned by the current function -fn foo<'a>(x: &'a i32) -> Box { +fn foo<'a>(x: &'a i32) -> Box { let mut books = vec![1,2,3]; Box::new(|| books.push(4)) //~^ ERROR E0373 diff --git a/src/test/ui/borrowck/borrowck-in-static.rs b/src/test/ui/borrowck/borrowck-in-static.rs index 43bb652a024..c468740bc3b 100644 --- a/src/test/ui/borrowck/borrowck-in-static.rs +++ b/src/test/ui/borrowck/borrowck-in-static.rs @@ -1,6 +1,6 @@ // check that borrowck looks inside consts/statics -static FN : &'static (Fn() -> (BoxBox>) + Sync) = &|| { +static FN : &'static (dyn Fn() -> (BoxBox>) + Sync) = &|| { let x = Box::new(0); Box::new(|| x) //~ ERROR cannot move out of captured variable in an `Fn` closure }; diff --git a/src/test/ui/borrowck/borrowck-object-lifetime.rs b/src/test/ui/borrowck/borrowck-object-lifetime.rs index 495516cf976..137a9adbc40 100644 --- a/src/test/ui/borrowck/borrowck-object-lifetime.rs +++ b/src/test/ui/borrowck/borrowck-object-lifetime.rs @@ -8,26 +8,26 @@ trait Foo { fn mut_borrowed(&mut self) -> &(); } -fn borrowed_receiver(x: &Foo) { +fn borrowed_receiver(x: &dyn Foo) { let y = x.borrowed(); let z = x.borrowed(); z.use_ref(); y.use_ref(); } -fn mut_borrowed_receiver(x: &mut Foo) { +fn mut_borrowed_receiver(x: &mut dyn Foo) { let y = x.borrowed(); let z = x.mut_borrowed(); //~ ERROR cannot borrow y.use_ref(); } -fn mut_owned_receiver(mut x: Box) { +fn mut_owned_receiver(mut x: Box) { let y = x.borrowed(); let z = &mut x; //~ ERROR cannot borrow y.use_ref(); } -fn imm_owned_receiver(mut x: Box) { +fn imm_owned_receiver(mut x: Box) { let y = x.borrowed(); let z = &x; z.use_ref(); diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs index 1e272372f6c..3ce72161814 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs @@ -6,5 +6,5 @@ impl Foo for i32 { } fn main() { let x: &i32; - let y = x as *const Foo; //~ ERROR [E0381] + let y = x as *const dyn Foo; //~ ERROR [E0381] } diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr index df610cbb561..2b80140c6b3 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr @@ -1,7 +1,7 @@ error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13 | -LL | let y = x as *const Foo; +LL | let y = x as *const dyn Foo; | ^ use of possibly uninitialized `*x` error: aborting due to previous error diff --git a/src/test/ui/borrowck/regions-escape-unboxed-closure.rs b/src/test/ui/borrowck/regions-escape-unboxed-closure.rs index 62ddf4decfc..d8bef927fd7 100644 --- a/src/test/ui/borrowck/regions-escape-unboxed-closure.rs +++ b/src/test/ui/borrowck/regions-escape-unboxed-closure.rs @@ -1,4 +1,4 @@ -fn with_int(f: &mut FnMut(&isize)) { +fn with_int(f: &mut dyn FnMut(&isize)) { } fn main() { diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr index fca425da34d..baf122df5e2 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr @@ -29,7 +29,7 @@ LL | f(f(10)); error[E0382]: use of moved value: `f` --> $DIR/two-phase-nonrecv-autoref.rs:80:11 | -LL | fn twice_ten_oo(f: Box i32>) { +LL | fn twice_ten_oo(f: Box i32>) { | - move occurs because `f` has type `std::boxed::Box i32>`, which does not implement the `Copy` trait LL | f(f(10)); | - ^ value used here after move diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs index c0a117d6766..b29664e3d8c 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs @@ -68,15 +68,15 @@ fn overloaded_call_traits() { //[g2p]~^^ ERROR use of moved value: `f` } - fn twice_ten_om(f: &mut FnMut(i32) -> i32) { + fn twice_ten_om(f: &mut dyn FnMut(i32) -> i32) { f(f(10)); //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time } - fn twice_ten_oi(f: &mut Fn(i32) -> i32) { + fn twice_ten_oi(f: &mut dyn Fn(i32) -> i32) { f(f(10)); } - fn twice_ten_oo(f: Box i32>) { + fn twice_ten_oo(f: Box i32>) { f(f(10)); //[nll]~^ ERROR use of moved value: `f` //[g2p]~^^ ERROR use of moved value: `f` diff --git a/src/test/ui/bounds-lifetime.rs b/src/test/ui/bounds-lifetime.rs index 8abfe3e4b76..31aa4011b91 100644 --- a/src/test/ui/bounds-lifetime.rs +++ b/src/test/ui/bounds-lifetime.rs @@ -2,6 +2,6 @@ type A = for<'b, 'a: 'b> fn(); //~ ERROR lifetime bounds cannot be used in this type B = for<'b, 'a: 'b,> fn(); //~ ERROR lifetime bounds cannot be used in this context type C = for<'b, 'a: 'b +> fn(); //~ ERROR lifetime bounds cannot be used in this context type D = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context -type E = for Fn(); //~ ERROR only lifetime parameters can be used in this context +type E = dyn for Fn(); //~ ERROR only lifetime parameters can be used in this context fn main() {} diff --git a/src/test/ui/bounds-lifetime.stderr b/src/test/ui/bounds-lifetime.stderr index 21a78146267..a0395ed4904 100644 --- a/src/test/ui/bounds-lifetime.stderr +++ b/src/test/ui/bounds-lifetime.stderr @@ -23,10 +23,10 @@ LL | type D = for<'a, T> fn(); | ^ error: only lifetime parameters can be used in this context - --> $DIR/bounds-lifetime.rs:5:14 + --> $DIR/bounds-lifetime.rs:5:18 | -LL | type E = for Fn(); - | ^ +LL | type E = dyn for Fn(); + | ^ error: aborting due to 5 previous errors diff --git a/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.rs b/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.rs index ac859c51263..5342b595c7c 100644 --- a/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.rs +++ b/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.rs @@ -1,4 +1,4 @@ fn main() { - &1 as Send; //~ ERROR cast to unsized - Box::new(1) as Send; //~ ERROR cast to unsized + &1 as dyn Send; //~ ERROR cast to unsized + Box::new(1) as dyn Send; //~ ERROR cast to unsized } diff --git a/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.stderr b/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.stderr index bd7a0e1834a..ffa02533d8b 100644 --- a/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.stderr +++ b/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.stderr @@ -1,18 +1,18 @@ error[E0620]: cast to unsized type: `&{integer}` as `dyn std::marker::Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:2:5 | -LL | &1 as Send; - | ^^^^^^---- +LL | &1 as dyn Send; + | ^^^^^^-------- | | - | help: try casting to a reference instead: `&Send` + | help: try casting to a reference instead: `&dyn Send` error[E0620]: cast to unsized type: `std::boxed::Box<{integer}>` as `dyn std::marker::Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:3:5 | -LL | Box::new(1) as Send; - | ^^^^^^^^^^^^^^^---- +LL | Box::new(1) as dyn Send; + | ^^^^^^^^^^^^^^^-------- | | - | help: try casting to a `Box` instead: `Box` + | help: try casting to a `Box` instead: `Box` error: aborting due to 2 previous errors diff --git a/src/test/ui/casts-differing-anon.rs b/src/test/ui/casts-differing-anon.rs index cba178104c9..d4a0f961305 100644 --- a/src/test/ui/casts-differing-anon.rs +++ b/src/test/ui/casts-differing-anon.rs @@ -5,7 +5,7 @@ fn foo() -> Box { x } fn bar() -> Box { - let y: Box = Box::new([0]); + let y: Box = Box::new([0]); y } diff --git a/src/test/ui/class-cast-to-trait.rs b/src/test/ui/class-cast-to-trait.rs index 3ae4987254f..bb4c3fac938 100644 --- a/src/test/ui/class-cast-to-trait.rs +++ b/src/test/ui/class-cast-to-trait.rs @@ -49,6 +49,6 @@ fn cat(in_x : usize, in_y : isize, in_name: String) -> Cat { } fn main() { - let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; + let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; nyan.eat(); //~ ERROR no method named `eat` found } diff --git a/src/test/ui/closure_context/issue-26046-fn-mut.rs b/src/test/ui/closure_context/issue-26046-fn-mut.rs index e5840181e41..0a015ea1436 100644 --- a/src/test/ui/closure_context/issue-26046-fn-mut.rs +++ b/src/test/ui/closure_context/issue-26046-fn-mut.rs @@ -1,4 +1,4 @@ -fn foo() -> Box { +fn foo() -> Box { let num = 5; let closure = || { //~ ERROR expected a closure that diff --git a/src/test/ui/closure_context/issue-26046-fn-once.rs b/src/test/ui/closure_context/issue-26046-fn-once.rs index d33420c52a0..511690e9dd4 100644 --- a/src/test/ui/closure_context/issue-26046-fn-once.rs +++ b/src/test/ui/closure_context/issue-26046-fn-once.rs @@ -1,4 +1,4 @@ -fn get_closure() -> Box Vec> { +fn get_closure() -> Box Vec> { let vec = vec![1u8, 2u8]; let closure = move || { //~ ERROR expected a closure diff --git a/src/test/ui/closures/closure-immutable-outer-variable.fixed b/src/test/ui/closures/closure-immutable-outer-variable.fixed index 03240d4857c..102f1f94a36 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.fixed +++ b/src/test/ui/closures/closure-immutable-outer-variable.fixed @@ -2,7 +2,7 @@ // Point at the captured immutable outer variable -fn foo(mut f: Box) { +fn foo(mut f: Box) { f(); } diff --git a/src/test/ui/closures/closure-immutable-outer-variable.rs b/src/test/ui/closures/closure-immutable-outer-variable.rs index 8fa9e44845d..6eb43b372c9 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.rs +++ b/src/test/ui/closures/closure-immutable-outer-variable.rs @@ -2,7 +2,7 @@ // Point at the captured immutable outer variable -fn foo(mut f: Box) { +fn foo(mut f: Box) { f(); } diff --git a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs index f35fbad7cd6..414acfd84ce 100644 --- a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs +++ b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] trait C {} -impl C { fn f() {} } //~ ERROR duplicate -impl C { fn f() {} } +impl dyn C { fn f() {} } //~ ERROR duplicate +impl dyn C { fn f() {} } fn main() { } diff --git a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr index 16cdca774ba..a97161b131d 100644 --- a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr +++ b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr @@ -1,10 +1,10 @@ error[E0592]: duplicate definitions with name `f` - --> $DIR/coherence-overlapping-inherent-impl-trait.rs:4:10 + --> $DIR/coherence-overlapping-inherent-impl-trait.rs:4:14 | -LL | impl C { fn f() {} } - | ^^^^^^^^^ duplicate definitions for `f` -LL | impl C { fn f() {} } - | --------- other definition for `f` +LL | impl dyn C { fn f() {} } + | ^^^^^^^^^ duplicate definitions for `f` +LL | impl dyn C { fn f() {} } + | --------- other definition for `f` error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/two_files_data.rs b/src/test/ui/codemap_tests/two_files_data.rs index db8ab14e673..b4d2f5d3c6d 100644 --- a/src/test/ui/codemap_tests/two_files_data.rs +++ b/src/test/ui/codemap_tests/two_files_data.rs @@ -2,4 +2,4 @@ trait Foo { } -type Bar = Foo; +type Bar = dyn Foo; diff --git a/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs b/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs index 9a4e134cb39..c139e823c2a 100644 --- a/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs +++ b/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs @@ -10,23 +10,23 @@ pub fn main() { let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; //~^ ERROR mismatched types - let _ = box { |x| (x as u8) }: Box _>; //~ ERROR mismatched types - let _ = box if true { false } else { true }: Box; //~ ERROR mismatched types - let _ = box match true { true => 'a', false => 'b' }: Box; //~ ERROR mismatched types + let _ = box { |x| (x as u8) }: Box _>; //~ ERROR mismatched types + let _ = box if true { false } else { true }: Box; //~ ERROR mismatched types + let _ = box match true { true => 'a', false => 'b' }: Box; //~ ERROR mismatched types let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; //~^ ERROR mismatched types - let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; //~ ERROR mismatched types - let _ = &if true { false } else { true }: &Debug; //~ ERROR mismatched types - let _ = &match true { true => 'a', false => 'b' }: &Debug; //~ ERROR mismatched types + let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; //~ ERROR mismatched types + let _ = &if true { false } else { true }: &dyn Debug; //~ ERROR mismatched types + let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; //~ ERROR mismatched types let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types - let _ = Box::new(|x| (x as u8)): Box _>; //~ ERROR mismatched types + let _ = Box::new(|x| (x as u8)): Box _>; //~ ERROR mismatched types let _ = vec![ Box::new(|x| (x as u8)), box |x| (x as i16 as u8), - ]: Vec _>>; + ]: Vec _>>; } diff --git a/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr b/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr index be362c9a78b..3b81610a06e 100644 --- a/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr +++ b/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr @@ -28,7 +28,7 @@ LL | let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[ error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:13:13 | -LL | let _ = box { |x| (x as u8) }: Box _>; +LL | let _ = box { |x| (x as u8) }: Box _>; | ^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure | = note: expected type `std::boxed::Box u8>` @@ -37,7 +37,7 @@ LL | let _ = box { |x| (x as u8) }: Box _>; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:14:13 | -LL | let _ = box if true { false } else { true }: Box; +LL | let _ = box if true { false } else { true }: Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool | = note: expected type `std::boxed::Box` @@ -46,7 +46,7 @@ LL | let _ = box if true { false } else { true }: Box; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:15:13 | -LL | let _ = box match true { true => 'a', false => 'b' }: Box; +LL | let _ = box match true { true => 'a', false => 'b' }: Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char | = note: expected type `std::boxed::Box` @@ -82,7 +82,7 @@ LL | let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:21:13 | -LL | let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; +LL | let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; | ^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure | = note: expected type `&dyn std::ops::Fn(i32) -> u8` @@ -91,7 +91,7 @@ LL | let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:22:13 | -LL | let _ = &if true { false } else { true }: &Debug; +LL | let _ = &if true { false } else { true }: &dyn Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool | = note: expected type `&dyn std::fmt::Debug` @@ -100,7 +100,7 @@ LL | let _ = &if true { false } else { true }: &Debug; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:23:13 | -LL | let _ = &match true { true => 'a', false => 'b' }: &Debug; +LL | let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char | = note: expected type `&dyn std::fmt::Debug` @@ -118,7 +118,7 @@ LL | let _ = Box::new([1, 2, 3]): Box<[i32]>; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:26:13 | -LL | let _ = Box::new(|x| (x as u8)): Box _>; +LL | let _ = Box::new(|x| (x as u8)): Box _>; | ^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure | = note: expected type `std::boxed::Box _>` diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr index b48f6bbfb94..c38d7456a99 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr @@ -1,7 +1,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6 | -LL | impl NotObjectSafe for NotObjectSafe { } +LL | impl NotObjectSafe for dyn NotObjectSafe { } | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object | = note: method `eq` references the `Self` type in its arguments or return type diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr index b48f6bbfb94..c38d7456a99 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr @@ -1,7 +1,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6 | -LL | impl NotObjectSafe for NotObjectSafe { } +LL | impl NotObjectSafe for dyn NotObjectSafe { } | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object | = note: method `eq` references the `Self` type in its arguments or return type diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs index 803e8fc6bca..b4c88e93783 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs @@ -8,7 +8,7 @@ // If the trait is not object-safe, we give a more tailored message // because we're such schnuckels: trait NotObjectSafe { fn eq(&self, other: Self); } -impl NotObjectSafe for NotObjectSafe { } +impl NotObjectSafe for dyn NotObjectSafe { } //[old]~^ ERROR E0038 //[re]~^^ ERROR E0038 diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr index 324747603f9..4819ce9260e 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr @@ -1,20 +1,20 @@ error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` --> $DIR/coherence-impl-trait-for-trait.rs:13:1 | -LL | impl Foo for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` +LL | impl Foo for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` --> $DIR/coherence-impl-trait-for-trait.rs:16:1 | -LL | impl Bar for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` +LL | impl Bar for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` --> $DIR/coherence-impl-trait-for-trait.rs:19:1 | -LL | impl Baz for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` +LL | impl Baz for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` error: aborting due to 3 previous errors diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr index 324747603f9..4819ce9260e 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr @@ -1,20 +1,20 @@ error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` --> $DIR/coherence-impl-trait-for-trait.rs:13:1 | -LL | impl Foo for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` +LL | impl Foo for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` --> $DIR/coherence-impl-trait-for-trait.rs:16:1 | -LL | impl Bar for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` +LL | impl Bar for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` --> $DIR/coherence-impl-trait-for-trait.rs:19:1 | -LL | impl Baz for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` +LL | impl Baz for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` error: aborting due to 3 previous errors diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.rs b/src/test/ui/coherence/coherence-impl-trait-for-trait.rs index dcaf564fdec..3ce3dca0660 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.rs +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.rs @@ -10,18 +10,18 @@ trait Bar: Foo { } trait Baz: Bar { } // Supertraits of Baz are not legal: -impl Foo for Baz { } +impl Foo for dyn Baz { } //[old]~^ ERROR E0371 //[re]~^^ ERROR E0371 -impl Bar for Baz { } +impl Bar for dyn Baz { } //[old]~^ ERROR E0371 //[re]~^^ ERROR E0371 -impl Baz for Baz { } +impl Baz for dyn Baz { } //[old]~^ ERROR E0371 //[re]~^^ ERROR E0371 // But other random traits are: trait Other { } -impl Other for Baz { } // OK, Other not a supertrait of Baz +impl Other for dyn Baz { } // OK, Other not a supertrait of Baz fn main() { } diff --git a/src/test/ui/confuse-field-and-method/issue-2392.rs b/src/test/ui/confuse-field-and-method/issue-2392.rs index c242b6c2c20..8aef091fe31 100644 --- a/src/test/ui/confuse-field-and-method/issue-2392.rs +++ b/src/test/ui/confuse-field-and-method/issue-2392.rs @@ -14,7 +14,7 @@ struct Obj where F: FnOnce() -> u32 { } struct BoxedObj { - boxed_closure: Box u32>, + boxed_closure: Box u32>, } struct Wrapper where F: FnMut() -> u32 { @@ -25,8 +25,8 @@ fn func() -> u32 { 0 } -fn check_expression() -> Obj u32>> { - Obj { closure: Box::new(|| 42_u32) as Box u32>, not_closure: 42 } +fn check_expression() -> Obj u32>> { + Obj { closure: Box::new(|| 42_u32) as Box u32>, not_closure: 42 } } fn main() { @@ -44,7 +44,7 @@ fn main() { let boxed_fn = BoxedObj { boxed_closure: Box::new(func) }; boxed_fn.boxed_closure();//~ ERROR no method named `boxed_closure` found - let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box u32> }; + let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box u32> }; boxed_closure.boxed_closure();//~ ERROR no method named `boxed_closure` found // test expression writing in the notes diff --git a/src/test/ui/confuse-field-and-method/issue-32128.rs b/src/test/ui/confuse-field-and-method/issue-32128.rs index 02c6838d419..5a024aa4b67 100644 --- a/src/test/ui/confuse-field-and-method/issue-32128.rs +++ b/src/test/ui/confuse-field-and-method/issue-32128.rs @@ -1,5 +1,5 @@ struct Example { - example: Box i32> + example: Box i32> } fn main() { diff --git a/src/test/ui/consts/const-eval/const_transmute.rs b/src/test/ui/consts/const-eval/const_transmute.rs index e4f7fb155ab..4726f9dde3a 100644 --- a/src/test/ui/consts/const-eval/const_transmute.rs +++ b/src/test/ui/consts/const-eval/const_transmute.rs @@ -41,7 +41,7 @@ struct VTable { bar: for<'a> fn(&'a Foo) -> u32, } -const FOO: &Bar = &Foo { foo: 128, bar: false }; +const FOO: &dyn Bar = &Foo { foo: 128, bar: false }; const G: Fat = unsafe { Transmute { t: FOO }.u }; const F: Option fn(&'a mut Foo)> = G.1.drop; const H: for<'a> fn(&'a Foo) -> u32 = G.1.bar; diff --git a/src/test/ui/consts/const-eval/issue-53401.rs b/src/test/ui/consts/const-eval/issue-53401.rs index 89834aa94fc..e8ac5a90880 100644 --- a/src/test/ui/consts/const-eval/issue-53401.rs +++ b/src/test/ui/consts/const-eval/issue-53401.rs @@ -1,6 +1,6 @@ // compile-pass -pub const STATIC_TRAIT: &Test = &(); +pub const STATIC_TRAIT: &dyn Test = &(); fn main() {} diff --git a/src/test/ui/consts/const-eval/ub-upvars.rs b/src/test/ui/consts/const-eval/ub-upvars.rs index 9b7bca6b72d..0a427cd8857 100644 --- a/src/test/ui/consts/const-eval/ub-upvars.rs +++ b/src/test/ui/consts/const-eval/ub-upvars.rs @@ -3,7 +3,7 @@ use std::mem; -const BAD_UPVAR: &FnOnce() = &{ //~ ERROR it is undefined behavior to use this value +const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR it is undefined behavior to use this value let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; let another_var = 13; move || { let _ = bad_ref; let _ = another_var; } diff --git a/src/test/ui/consts/const-eval/ub-upvars.stderr b/src/test/ui/consts/const-eval/ub-upvars.stderr index 21d2847db1e..f8273ba902a 100644 --- a/src/test/ui/consts/const-eval/ub-upvars.stderr +++ b/src/test/ui/consts/const-eval/ub-upvars.stderr @@ -1,7 +1,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-upvars.rs:6:1 | -LL | / const BAD_UPVAR: &FnOnce() = &{ +LL | / const BAD_UPVAR: &dyn FnOnce() = &{ LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; LL | | let another_var = 13; LL | | move || { let _ = bad_ref; let _ = another_var; } diff --git a/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs b/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs index 13489c50a12..d5405f3441f 100644 --- a/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs +++ b/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs @@ -59,7 +59,7 @@ union DynTransmute { repr: DynRepr, repr2: DynRepr2, bad: BadDynRepr, - rust: &'static Trait, + rust: &'static dyn Trait, } trait Trait {} @@ -94,17 +94,17 @@ const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: & //~^ ERROR it is undefined behavior to use this value // bad trait object -const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; +const D: &dyn Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; //~^ ERROR it is undefined behavior to use this value // bad trait object -const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; +const E: &dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; //~^ ERROR it is undefined behavior to use this value // bad trait object -const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; +const F: &dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; //~^ ERROR it is undefined behavior to use this value // bad data *inside* the trait object -const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl }; +const G: &dyn Trait = &unsafe { BoolTransmute { val: 3 }.bl }; //~^ ERROR it is undefined behavior to use this value // bad data *inside* the slice diff --git a/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr b/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr index 761a5fc4445..5048a97d195 100644 --- a/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr +++ b/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr @@ -41,32 +41,32 @@ LL | const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, l error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:97:1 | -LL | const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable +LL | const D: &dyn Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:100:1 | -LL | const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable +LL | const E: &dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:103:1 | -LL | const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-pointer vtable in fat pointer +LL | const F: &dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-pointer vtable in fat pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:107:1 | -LL | const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .., but expected something less or equal to 1 +LL | const G: &dyn Trait = &unsafe { BoolTransmute { val: 3 }.bl }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .., but expected something less or equal to 1 | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior diff --git a/src/test/ui/consts/const-unsized.rs b/src/test/ui/consts/const-unsized.rs index e20ded68ceb..319b8ef97de 100644 --- a/src/test/ui/consts/const-unsized.rs +++ b/src/test/ui/consts/const-unsized.rs @@ -1,12 +1,12 @@ use std::fmt::Debug; -const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); +const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); //~^ ERROR the size for values of type const CONST_FOO: str = *"foo"; //~^ ERROR the size for values of type -static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); +static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); //~^ ERROR the size for values of type static STATIC_BAR: str = *"bar"; diff --git a/src/test/ui/consts/const-unsized.stderr b/src/test/ui/consts/const-unsized.stderr index 0f996fcd943..beeea87bfb1 100644 --- a/src/test/ui/consts/const-unsized.stderr +++ b/src/test/ui/consts/const-unsized.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `(dyn std::fmt::Debug + std::marker::Sync + 'static)` cannot be known at compilation time --> $DIR/const-unsized.rs:3:16 | -LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); - | ^^^^^^^^^^ doesn't have a size known at compile-time +LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); + | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` = note: to learn more, visit @@ -19,8 +19,8 @@ LL | const CONST_FOO: str = *"foo"; error[E0277]: the size for values of type `(dyn std::fmt::Debug + std::marker::Sync + 'static)` cannot be known at compilation time --> $DIR/const-unsized.rs:9:18 | -LL | static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); - | ^^^^^^^^^^ doesn't have a size known at compile-time +LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); + | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` = note: to learn more, visit diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr index 8d962384a12..7a10c469c51 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr @@ -298,8 +298,8 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable --> $DIR/min_const_fn.rs:144:41 | -LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = help: add #![feature(const_fn)] to the crate attributes to enable diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.rs b/src/test/ui/consts/min_const_fn/min_const_fn.rs index 783c79005ae..96b6057c8fd 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn.rs @@ -141,7 +141,7 @@ const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } const fn no_unsafe() { unsafe {} } -const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } +const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } //~^ ERROR trait bounds other than `Sized` const fn no_fn_ptrs(_x: fn()) {} diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.stderr index 93b57bc24a8..e388b443d23 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.stderr @@ -302,8 +302,8 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable --> $DIR/min_const_fn.rs:144:41 | -LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = help: add #![feature(const_fn)] to the crate attributes to enable diff --git a/src/test/ui/cross/cross-borrow-trait.rs b/src/test/ui/cross/cross-borrow-trait.rs index d8d7537f24a..274cdad75ec 100644 --- a/src/test/ui/cross/cross-borrow-trait.rs +++ b/src/test/ui/cross/cross-borrow-trait.rs @@ -6,8 +6,8 @@ trait Trait { fn foo(&self) {} } impl Trait for Foo {} pub fn main() { - let x: Box = Box::new(Foo); - let _y: &Trait = x; //~ ERROR E0308 - //~| expected type `&dyn Trait` - //~| found type `std::boxed::Box` + let x: Box = Box::new(Foo); + let _y: &dyn Trait = x; //~ ERROR E0308 + //~| expected type `&dyn Trait` + //~| found type `std::boxed::Box` } diff --git a/src/test/ui/cross/cross-borrow-trait.stderr b/src/test/ui/cross/cross-borrow-trait.stderr index b35f59658c0..ada1c0204eb 100644 --- a/src/test/ui/cross/cross-borrow-trait.stderr +++ b/src/test/ui/cross/cross-borrow-trait.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/cross-borrow-trait.rs:10:22 + --> $DIR/cross-borrow-trait.rs:10:26 | -LL | let _y: &Trait = x; - | ^ - | | - | expected &dyn Trait, found struct `std::boxed::Box` - | help: consider borrowing here: `&x` +LL | let _y: &dyn Trait = x; + | ^ + | | + | expected &dyn Trait, found struct `std::boxed::Box` + | help: consider borrowing here: `&x` | = note: expected type `&dyn Trait` found type `std::boxed::Box` diff --git a/src/test/ui/custom-test-frameworks-simple.rs b/src/test/ui/custom-test-frameworks-simple.rs index a8aac6ec142..aee0040ef4d 100644 --- a/src/test/ui/custom-test-frameworks-simple.rs +++ b/src/test/ui/custom-test-frameworks-simple.rs @@ -5,7 +5,7 @@ #![test_runner(crate::foo_runner)] #[cfg(test)] -fn foo_runner(ts: &[&Fn(usize)->()]) { +fn foo_runner(ts: &[&dyn Fn(usize)->()]) { for (i, t) in ts.iter().enumerate() { t(i); } diff --git a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs index d658753eb24..6175b7df110 100644 --- a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs +++ b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs @@ -1,7 +1,7 @@ // Test a cycle where a type parameter on a trait has a default that // again references the trait. -trait Foo> { +trait Foo> { //~^ ERROR cycle detected } diff --git a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr index aa45462a52e..e89d25742a0 100644 --- a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr +++ b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr @@ -1,15 +1,15 @@ error[E0391]: cycle detected when processing `Foo::X` - --> $DIR/cycle-trait-default-type-trait.rs:4:19 + --> $DIR/cycle-trait-default-type-trait.rs:4:23 | -LL | trait Foo> { - | ^^^ +LL | trait Foo> { + | ^^^ | = note: ...which again requires processing `Foo::X`, completing the cycle note: cycle used when collecting item types in top-level module --> $DIR/cycle-trait-default-type-trait.rs:4:1 | -LL | trait Foo> { - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Foo> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/destructure-trait-ref.rs b/src/test/ui/destructure-trait-ref.rs index 66be493cb1f..71cf37ca849 100644 --- a/src/test/ui/destructure-trait-ref.rs +++ b/src/test/ui/destructure-trait-ref.rs @@ -18,27 +18,28 @@ fn main() { // if n > m, it's a type mismatch error. // n < m - let &x = &(&1isize as &T); - let &x = &&(&1isize as &T); - let &&x = &&(&1isize as &T); + let &x = &(&1isize as &dyn T); + let &x = &&(&1isize as &dyn T); + let &&x = &&(&1isize as &dyn T); // n == m - let &x = &1isize as &T; //~ ERROR type `&dyn T` cannot be dereferenced - let &&x = &(&1isize as &T); //~ ERROR type `&dyn T` cannot be dereferenced - let box x = box 1isize as Box; //~ ERROR type `std::boxed::Box` cannot be dereferenced + let &x = &1isize as &dyn T; //~ ERROR type `&dyn T` cannot be dereferenced + let &&x = &(&1isize as &dyn T); //~ ERROR type `&dyn T` cannot be dereferenced + let box x = box 1isize as Box; + //~^ ERROR type `std::boxed::Box` cannot be dereferenced // n > m - let &&x = &1isize as &T; + let &&x = &1isize as &dyn T; //~^ ERROR mismatched types //~| expected type `dyn T` //~| found type `&_` //~| expected trait T, found reference - let &&&x = &(&1isize as &T); + let &&&x = &(&1isize as &dyn T); //~^ ERROR mismatched types //~| expected type `dyn T` //~| found type `&_` //~| expected trait T, found reference - let box box x = box 1isize as Box; + let box box x = box 1isize as Box; //~^ ERROR mismatched types //~| expected type `dyn T` //~| found type `std::boxed::Box<_>` diff --git a/src/test/ui/destructure-trait-ref.stderr b/src/test/ui/destructure-trait-ref.stderr index bc3013b78b3..d3ad21eb24f 100644 --- a/src/test/ui/destructure-trait-ref.stderr +++ b/src/test/ui/destructure-trait-ref.stderr @@ -1,25 +1,25 @@ error[E0033]: type `&dyn T` cannot be dereferenced --> $DIR/destructure-trait-ref.rs:26:9 | -LL | let &x = &1isize as &T; +LL | let &x = &1isize as &dyn T; | ^^ type `&dyn T` cannot be dereferenced error[E0033]: type `&dyn T` cannot be dereferenced --> $DIR/destructure-trait-ref.rs:27:10 | -LL | let &&x = &(&1isize as &T); +LL | let &&x = &(&1isize as &dyn T); | ^^ type `&dyn T` cannot be dereferenced error[E0033]: type `std::boxed::Box` cannot be dereferenced --> $DIR/destructure-trait-ref.rs:28:9 | -LL | let box x = box 1isize as Box; +LL | let box x = box 1isize as Box; | ^^^^^ type `std::boxed::Box` cannot be dereferenced error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:31:10 + --> $DIR/destructure-trait-ref.rs:32:10 | -LL | let &&x = &1isize as &T; +LL | let &&x = &1isize as &dyn T; | ^^ | | | expected trait T, found reference @@ -29,9 +29,9 @@ LL | let &&x = &1isize as &T; found type `&_` error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:36:11 + --> $DIR/destructure-trait-ref.rs:37:11 | -LL | let &&&x = &(&1isize as &T); +LL | let &&&x = &(&1isize as &dyn T); | ^^ | | | expected trait T, found reference @@ -41,9 +41,9 @@ LL | let &&&x = &(&1isize as &T); found type `&_` error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:41:13 + --> $DIR/destructure-trait-ref.rs:42:13 | -LL | let box box x = box 1isize as Box; +LL | let box box x = box 1isize as Box; | ^^^^^ expected trait T, found struct `std::boxed::Box` | = note: expected type `dyn T` diff --git a/src/test/ui/did_you_mean/E0178.rs b/src/test/ui/did_you_mean/E0178.rs index aad95dc2c20..095df640c38 100644 --- a/src/test/ui/did_you_mean/E0178.rs +++ b/src/test/ui/did_you_mean/E0178.rs @@ -1,3 +1,5 @@ +#![allow(bare_trait_objects)] + trait Foo {} struct Bar<'a> { diff --git a/src/test/ui/did_you_mean/E0178.stderr b/src/test/ui/did_you_mean/E0178.stderr index 44e6ddd0eac..58ac6e90823 100644 --- a/src/test/ui/did_you_mean/E0178.stderr +++ b/src/test/ui/did_you_mean/E0178.stderr @@ -1,23 +1,23 @@ error[E0178]: expected a path on the left-hand side of `+`, not `&'a Foo` - --> $DIR/E0178.rs:4:8 + --> $DIR/E0178.rs:6:8 | LL | w: &'a Foo + Copy, | ^^^^^^^^^^^^^^ help: try adding parentheses: `&'a (Foo + Copy)` error[E0178]: expected a path on the left-hand side of `+`, not `&'a Foo` - --> $DIR/E0178.rs:5:8 + --> $DIR/E0178.rs:7:8 | LL | x: &'a Foo + 'a, | ^^^^^^^^^^^^ help: try adding parentheses: `&'a (Foo + 'a)` error[E0178]: expected a path on the left-hand side of `+`, not `&'a mut Foo` - --> $DIR/E0178.rs:6:8 + --> $DIR/E0178.rs:8:8 | LL | y: &'a mut Foo + 'a, | ^^^^^^^^^^^^^^^^ help: try adding parentheses: `&'a mut (Foo + 'a)` error[E0178]: expected a path on the left-hand side of `+`, not `fn() -> Foo` - --> $DIR/E0178.rs:7:8 + --> $DIR/E0178.rs:9:8 | LL | z: fn() -> Foo + 'a, | ^^^^^^^^^^^^^^^^ perhaps you forgot parentheses? diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.rs b/src/test/ui/did_you_mean/bad-assoc-ty.rs index 85e36f887be..fccfb7911ce 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.rs +++ b/src/test/ui/did_you_mean/bad-assoc-ty.rs @@ -24,7 +24,7 @@ type F = &'static (u8)::AssocTy; // Qualified paths cannot appear in bounds, so the recovery // should apply to the whole sum and not `(Send)`. -type G = 'static + (Send)::AssocTy; +type G = dyn 'static + (Send)::AssocTy; //~^ ERROR missing angle brackets in associated item path //~| ERROR ambiguous associated type diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.stderr b/src/test/ui/did_you_mean/bad-assoc-ty.stderr index 8c694f9d42b..0ae64edcc05 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-ty.stderr @@ -37,8 +37,8 @@ LL | type F = &'static (u8)::AssocTy; error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:27:10 | -LL | type G = 'static + (Send)::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<'static + (Send)>::AssocTy` +LL | type G = dyn 'static + (Send)::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `::AssocTy` error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:44:10 @@ -94,8 +94,8 @@ LL | type F = &'static (u8)::AssocTy; error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:27:10 | -LL | type G = 'static + (Send)::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy` +LL | type G = dyn 'static + (Send)::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:33:10 diff --git a/src/test/ui/did_you_mean/issue-40006.rs b/src/test/ui/did_you_mean/issue-40006.rs index 75ea02b6a9d..a1184f757e2 100644 --- a/src/test/ui/did_you_mean/issue-40006.rs +++ b/src/test/ui/did_you_mean/issue-40006.rs @@ -1,4 +1,4 @@ -impl X { //~ ERROR cannot be made into an object +impl dyn X { //~ ERROR cannot be made into an object //~^ ERROR missing Y } diff --git a/src/test/ui/did_you_mean/issue-40006.stderr b/src/test/ui/did_you_mean/issue-40006.stderr index f6f7fe5fa38..87e48cd1e1c 100644 --- a/src/test/ui/did_you_mean/issue-40006.stderr +++ b/src/test/ui/did_you_mean/issue-40006.stderr @@ -1,8 +1,8 @@ error: missing `fn`, `type`, or `const` for impl-item declaration - --> $DIR/issue-40006.rs:1:9 + --> $DIR/issue-40006.rs:1:13 | -LL | impl X { - | _________^ +LL | impl dyn X { + | _____________^ LL | | LL | | Y | |____^ missing `fn`, `type`, or `const` @@ -59,8 +59,8 @@ LL | pub hello_method(&self) { error[E0038]: the trait `X` cannot be made into an object --> $DIR/issue-40006.rs:1:6 | -LL | impl X { - | ^ the trait `X` cannot be made into an object +LL | impl dyn X { + | ^^^^^ the trait `X` cannot be made into an object | = note: method `xxx` has no receiver diff --git a/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs b/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs index a05227416cf..c9a097d3610 100644 --- a/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs +++ b/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs @@ -1,3 +1,5 @@ +#![allow(bare_trait_objects)] + fn main() { let _: &Copy + 'static; //~ ERROR expected a path //~^ ERROR cannot be made into an object diff --git a/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr b/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr index de1efcd7e0f..8c6c33b1186 100644 --- a/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr +++ b/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr @@ -1,17 +1,17 @@ error[E0178]: expected a path on the left-hand side of `+`, not `&Copy` - --> $DIR/trait-object-reference-without-parens-suggestion.rs:2:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12 | LL | let _: &Copy + 'static; | ^^^^^^^^^^^^^^^ help: try adding parentheses: `&(Copy + 'static)` error[E0178]: expected a path on the left-hand side of `+`, not `&'static Copy` - --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:6:12 | LL | let _: &'static Copy + 'static; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try adding parentheses: `&'static (Copy + 'static)` error[E0038]: the trait `std::marker::Copy` cannot be made into an object - --> $DIR/trait-object-reference-without-parens-suggestion.rs:2:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12 | LL | let _: &Copy + 'static; | ^^^^^ the trait `std::marker::Copy` cannot be made into an object diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.rs b/src/test/ui/dropck/dropck_trait_cycle_checked.rs index 128bbb04ee0..bea77dc9f5c 100644 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.rs +++ b/src/test/ui/dropck/dropck_trait_cycle_checked.rs @@ -63,14 +63,14 @@ impl Drop for CheckId { } trait Obj<'a> : HasId { - fn set0(&self, b: &'a Box>); - fn set1(&self, b: &'a Box>); + fn set0(&self, b: &'a Box>); + fn set1(&self, b: &'a Box>); } struct O<'a> { id: Id, - obj0: CheckId>>>>, - obj1: CheckId>>>>, + obj0: CheckId>>>>, + obj1: CheckId>>>>, } impl<'a> HasId for O<'a> { @@ -87,7 +87,7 @@ impl<'a> O<'a> { } } -impl<'a> HasId for Cell>>> { +impl<'a> HasId for Cell>>> { fn count(&self) -> usize { match self.get() { None => 1, @@ -97,17 +97,17 @@ impl<'a> HasId for Cell>>> { } impl<'a> Obj<'a> for O<'a> { - fn set0(&self, b: &'a Box>) { + fn set0(&self, b: &'a Box>) { self.obj0.v.set(Some(b)) } - fn set1(&self, b: &'a Box>) { + fn set1(&self, b: &'a Box>) { self.obj1.v.set(Some(b)) } } fn f() { - let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); o1.set0(&o2); //~ ERROR `o2` does not live long enough o1.set1(&o3); //~ ERROR `o3` does not live long enough o2.set0(&o2); //~ ERROR `o2` does not live long enough diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr index 8c669b597c3..1e779208e58 100644 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr +++ b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr @@ -1,8 +1,8 @@ error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:111:13 | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` LL | o1.set0(&o2); | ^^^ borrowed value does not live long enough ... @@ -12,8 +12,8 @@ LL | } error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:112:13 | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` LL | o1.set0(&o2); LL | o1.set1(&o3); | ^^^ borrowed value does not live long enough @@ -24,8 +24,8 @@ LL | } error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:113:13 | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` ... LL | o2.set0(&o2); | ^^^ borrowed value does not live long enough @@ -36,8 +36,8 @@ LL | } error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:114:13 | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` ... LL | o2.set1(&o3); | ^^^ borrowed value does not live long enough @@ -48,8 +48,8 @@ LL | } error[E0597]: `o1` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:115:13 | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o1` is borrowed for `'static` +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o1` is borrowed for `'static` ... LL | o3.set0(&o1); | ^^^ borrowed value does not live long enough @@ -60,8 +60,8 @@ LL | } error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:116:13 | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` ... LL | o3.set1(&o2); | ^^^ borrowed value does not live long enough diff --git a/src/test/ui/dst/dst-bad-assign-2.rs b/src/test/ui/dst/dst-bad-assign-2.rs index b4f72d034f5..7ba31bf2e51 100644 --- a/src/test/ui/dst/dst-bad-assign-2.rs +++ b/src/test/ui/dst/dst-bad-assign-2.rs @@ -30,8 +30,8 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. - let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - let z: Box = Box::new(Bar1 {f: 36}); + let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + let z: Box = Box::new(Bar1 {f: 36}); f5.ptr = *z; //~^ ERROR the size for values of type diff --git a/src/test/ui/dst/dst-bad-assign-3.rs b/src/test/ui/dst/dst-bad-assign-3.rs index 5124abc7d82..691909a2317 100644 --- a/src/test/ui/dst/dst-bad-assign-3.rs +++ b/src/test/ui/dst/dst-bad-assign-3.rs @@ -28,8 +28,8 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. - let f5: &mut Fat = &mut (5, "some str", Bar1 {f :42}); - let z: Box = Box::new(Bar1 {f: 36}); + let f5: &mut Fat = &mut (5, "some str", Bar1 {f :42}); + let z: Box = Box::new(Bar1 {f: 36}); f5.2 = Bar1 {f: 36}; //~^ ERROR mismatched types //~| expected type `dyn ToBar` diff --git a/src/test/ui/dst/dst-bad-assign.rs b/src/test/ui/dst/dst-bad-assign.rs index 003c80b4dc4..4f2648653f0 100644 --- a/src/test/ui/dst/dst-bad-assign.rs +++ b/src/test/ui/dst/dst-bad-assign.rs @@ -30,8 +30,8 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. - let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - let z: Box = Box::new(Bar1 {f: 36}); + let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + let z: Box = Box::new(Bar1 {f: 36}); f5.ptr = Bar1 {f: 36}; //~^ ERROR mismatched types //~| expected type `dyn ToBar` diff --git a/src/test/ui/dst/dst-bad-coerce1.rs b/src/test/ui/dst/dst-bad-coerce1.rs index 8ca34234c03..7ef237e39e3 100644 --- a/src/test/ui/dst/dst-bad-coerce1.rs +++ b/src/test/ui/dst/dst-bad-coerce1.rs @@ -19,7 +19,7 @@ pub fn main() { // With a trait. let f1 = Fat { ptr: Foo }; let f2: &Fat = &f1; - let f3: &Fat = f2; + let f3: &Fat = f2; //~^ ERROR `Foo: Bar` is not satisfied // Tuple with a vec of isize. @@ -31,6 +31,6 @@ pub fn main() { // Tuple with a trait. let f1 = (Foo,); let f2: &(Foo,) = &f1; - let f3: &(Bar,) = f2; + let f3: &(dyn Bar,) = f2; //~^ ERROR `Foo: Bar` is not satisfied } diff --git a/src/test/ui/dst/dst-bad-coerce1.stderr b/src/test/ui/dst/dst-bad-coerce1.stderr index 3776ce71c61..a48f37b20be 100644 --- a/src/test/ui/dst/dst-bad-coerce1.stderr +++ b/src/test/ui/dst/dst-bad-coerce1.stderr @@ -8,10 +8,10 @@ LL | let f3: &Fat<[usize]> = f2; found type `&Fat<[isize; 3]>` error[E0277]: the trait bound `Foo: Bar` is not satisfied - --> $DIR/dst-bad-coerce1.rs:22:25 + --> $DIR/dst-bad-coerce1.rs:22:29 | -LL | let f3: &Fat = f2; - | ^^ the trait `Bar` is not implemented for `Foo` +LL | let f3: &Fat = f2; + | ^^ the trait `Bar` is not implemented for `Foo` | = note: required for the cast to the object type `dyn Bar` @@ -25,10 +25,10 @@ LL | let f3: &([usize],) = f2; found type `&([isize; 3],)` error[E0277]: the trait bound `Foo: Bar` is not satisfied - --> $DIR/dst-bad-coerce1.rs:34:23 + --> $DIR/dst-bad-coerce1.rs:34:27 | -LL | let f3: &(Bar,) = f2; - | ^^ the trait `Bar` is not implemented for `Foo` +LL | let f3: &(dyn Bar,) = f2; + | ^^ the trait `Bar` is not implemented for `Foo` | = note: required for the cast to the object type `dyn Bar` diff --git a/src/test/ui/dst/dst-bad-coerce2.rs b/src/test/ui/dst/dst-bad-coerce2.rs index 2bc7ecced0a..e7ce20b8958 100644 --- a/src/test/ui/dst/dst-bad-coerce2.rs +++ b/src/test/ui/dst/dst-bad-coerce2.rs @@ -17,7 +17,7 @@ pub fn main() { // With a trait. let f1 = Fat { ptr: Foo }; let f2: &Fat = &f1; - let f3: &mut Fat = f2; //~ ERROR mismatched types + let f3: &mut Fat = f2; //~ ERROR mismatched types // Tuple with a vec of ints. let f1 = ([1, 2, 3],); @@ -27,5 +27,5 @@ pub fn main() { // Tuple with a trait. let f1 = (Foo,); let f2: &(Foo,) = &f1; - let f3: &mut (Bar,) = f2; //~ ERROR mismatched types + let f3: &mut (dyn Bar,) = f2; //~ ERROR mismatched types } diff --git a/src/test/ui/dst/dst-bad-coerce2.stderr b/src/test/ui/dst/dst-bad-coerce2.stderr index cae4ec51c37..d1da9b6ca07 100644 --- a/src/test/ui/dst/dst-bad-coerce2.stderr +++ b/src/test/ui/dst/dst-bad-coerce2.stderr @@ -8,10 +8,10 @@ LL | let f3: &mut Fat<[isize]> = f2; found type `&Fat<[isize; 3]>` error[E0308]: mismatched types - --> $DIR/dst-bad-coerce2.rs:20:29 + --> $DIR/dst-bad-coerce2.rs:20:33 | -LL | let f3: &mut Fat = f2; - | ^^ types differ in mutability +LL | let f3: &mut Fat = f2; + | ^^ types differ in mutability | = note: expected type `&mut Fat` found type `&Fat` @@ -26,10 +26,10 @@ LL | let f3: &mut ([isize],) = f2; found type `&([isize; 3],)` error[E0308]: mismatched types - --> $DIR/dst-bad-coerce2.rs:30:27 + --> $DIR/dst-bad-coerce2.rs:30:31 | -LL | let f3: &mut (Bar,) = f2; - | ^^ types differ in mutability +LL | let f3: &mut (dyn Bar,) = f2; + | ^^ types differ in mutability | = note: expected type `&mut (dyn Bar,)` found type `&(Foo,)` diff --git a/src/test/ui/dst/dst-bad-coerce3.rs b/src/test/ui/dst/dst-bad-coerce3.rs index 58c988520eb..fd5ee3b57bb 100644 --- a/src/test/ui/dst/dst-bad-coerce3.rs +++ b/src/test/ui/dst/dst-bad-coerce3.rs @@ -19,7 +19,7 @@ fn baz<'a>() { // With a trait. let f1 = Fat { ptr: Foo }; let f2: &Fat = &f1; //~ ERROR `f1` does not live long enough - let f3: &'a Fat = f2; + let f3: &'a Fat = f2; // Tuple with a vec of ints. let f1 = ([1, 2, 3],); @@ -29,7 +29,7 @@ fn baz<'a>() { // Tuple with a trait. let f1 = (Foo,); let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough - let f3: &'a (Bar,) = f2; + let f3: &'a (dyn Bar,) = f2; } pub fn main() { diff --git a/src/test/ui/dst/dst-bad-coerce3.stderr b/src/test/ui/dst/dst-bad-coerce3.stderr index 289d451f02a..957e98bbeee 100644 --- a/src/test/ui/dst/dst-bad-coerce3.stderr +++ b/src/test/ui/dst/dst-bad-coerce3.stderr @@ -20,8 +20,8 @@ LL | fn baz<'a>() { ... LL | let f2: &Fat = &f1; | ^^^ borrowed value does not live long enough -LL | let f3: &'a Fat = f2; - | ------------ type annotation requires that `f1` is borrowed for `'a` +LL | let f3: &'a Fat = f2; + | ---------------- type annotation requires that `f1` is borrowed for `'a` ... LL | } | - `f1` dropped here while still borrowed @@ -48,8 +48,8 @@ LL | fn baz<'a>() { ... LL | let f2: &(Foo,) = &f1; | ^^^ borrowed value does not live long enough -LL | let f3: &'a (Bar,) = f2; - | ---------- type annotation requires that `f1` is borrowed for `'a` +LL | let f3: &'a (dyn Bar,) = f2; + | -------------- type annotation requires that `f1` is borrowed for `'a` LL | } | - `f1` dropped here while still borrowed diff --git a/src/test/ui/dst/dst-bad-coercions.rs b/src/test/ui/dst/dst-bad-coercions.rs index 9aa697225d5..bffef378c92 100644 --- a/src/test/ui/dst/dst-bad-coercions.rs +++ b/src/test/ui/dst/dst-bad-coercions.rs @@ -12,15 +12,15 @@ pub fn main() { // Test that we cannot convert from *-ptr to &S and &T let x: *const S = &S; let y: &S = x; //~ ERROR mismatched types - let y: &T = x; //~ ERROR mismatched types + let y: &dyn T = x; //~ ERROR mismatched types // Test that we cannot convert from *-ptr to &S and &T (mut version) let x: *mut S = &mut S; let y: &S = x; //~ ERROR mismatched types - let y: &T = x; //~ ERROR mismatched types + let y: &dyn T = x; //~ ERROR mismatched types // Test that we cannot convert an immutable ptr to a mutable one using *-ptrs - let x: &mut T = &S; //~ ERROR mismatched types - let x: *mut T = &S; //~ ERROR mismatched types + let x: &mut dyn T = &S; //~ ERROR mismatched types + let x: *mut dyn T = &S; //~ ERROR mismatched types let x: *mut S = &S; //~ ERROR mismatched types } diff --git a/src/test/ui/dst/dst-bad-coercions.stderr b/src/test/ui/dst/dst-bad-coercions.stderr index 27016829a07..e4bc6ee0010 100644 --- a/src/test/ui/dst/dst-bad-coercions.stderr +++ b/src/test/ui/dst/dst-bad-coercions.stderr @@ -8,13 +8,13 @@ LL | let y: &S = x; found type `*const S` error[E0308]: mismatched types - --> $DIR/dst-bad-coercions.rs:15:17 + --> $DIR/dst-bad-coercions.rs:15:21 | -LL | let y: &T = x; - | ^ - | | - | expected &dyn T, found *-ptr - | help: consider borrowing here: `&x` +LL | let y: &dyn T = x; + | ^ + | | + | expected &dyn T, found *-ptr + | help: consider borrowing here: `&x` | = note: expected type `&dyn T` found type `*const S` @@ -29,31 +29,31 @@ LL | let y: &S = x; found type `*mut S` error[E0308]: mismatched types - --> $DIR/dst-bad-coercions.rs:20:17 + --> $DIR/dst-bad-coercions.rs:20:21 | -LL | let y: &T = x; - | ^ - | | - | expected &dyn T, found *-ptr - | help: consider borrowing here: `&x` +LL | let y: &dyn T = x; + | ^ + | | + | expected &dyn T, found *-ptr + | help: consider borrowing here: `&x` | = note: expected type `&dyn T` found type `*mut S` error[E0308]: mismatched types - --> $DIR/dst-bad-coercions.rs:23:21 + --> $DIR/dst-bad-coercions.rs:23:25 | -LL | let x: &mut T = &S; - | ^^ types differ in mutability +LL | let x: &mut dyn T = &S; + | ^^ types differ in mutability | = note: expected type `&mut dyn T` found type `&S` error[E0308]: mismatched types - --> $DIR/dst-bad-coercions.rs:24:21 + --> $DIR/dst-bad-coercions.rs:24:25 | -LL | let x: *mut T = &S; - | ^^ types differ in mutability +LL | let x: *mut dyn T = &S; + | ^^ types differ in mutability | = note: expected type `*mut dyn T` found type `&S` diff --git a/src/test/ui/dst/dst-index.rs b/src/test/ui/dst/dst-index.rs index 71ff067bbd9..fced3144eb8 100644 --- a/src/test/ui/dst/dst-index.rs +++ b/src/test/ui/dst/dst-index.rs @@ -19,9 +19,9 @@ impl Index for S { struct T; impl Index for T { - type Output = Debug + 'static; + type Output = dyn Debug + 'static; - fn index<'a>(&'a self, idx: usize) -> &'a (Debug + 'static) { + fn index<'a>(&'a self, idx: usize) -> &'a (dyn Debug + 'static) { static x: usize = 42; &x } diff --git a/src/test/ui/dst/dst-object-from-unsized-type.rs b/src/test/ui/dst/dst-object-from-unsized-type.rs index f4ee1783a2e..3cd5b1ed6f4 100644 --- a/src/test/ui/dst/dst-object-from-unsized-type.rs +++ b/src/test/ui/dst/dst-object-from-unsized-type.rs @@ -5,22 +5,22 @@ impl Foo for str {} impl Foo for [u8] {} fn test1(t: &T) { - let u: &Foo = t; + let u: &dyn Foo = t; //~^ ERROR the size for values of type } fn test2(t: &T) { - let v: &Foo = t as &Foo; + let v: &dyn Foo = t as &dyn Foo; //~^ ERROR the size for values of type } fn test3() { - let _: &[&Foo] = &["hi"]; + let _: &[&dyn Foo] = &["hi"]; //~^ ERROR the size for values of type } fn test4(x: &[u8]) { - let _: &Foo = x as &Foo; + let _: &dyn Foo = x as &dyn Foo; //~^ ERROR the size for values of type } diff --git a/src/test/ui/dst/dst-object-from-unsized-type.stderr b/src/test/ui/dst/dst-object-from-unsized-type.stderr index 4851ca10828..55ac625fc98 100644 --- a/src/test/ui/dst/dst-object-from-unsized-type.stderr +++ b/src/test/ui/dst/dst-object-from-unsized-type.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/dst-object-from-unsized-type.rs:8:19 + --> $DIR/dst-object-from-unsized-type.rs:8:23 | -LL | let u: &Foo = t; - | ^ doesn't have a size known at compile-time +LL | let u: &dyn Foo = t; + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` = note: to learn more, visit @@ -10,10 +10,10 @@ LL | let u: &Foo = t; = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/dst-object-from-unsized-type.rs:13:19 + --> $DIR/dst-object-from-unsized-type.rs:13:23 | -LL | let v: &Foo = t as &Foo; - | ^ doesn't have a size known at compile-time +LL | let v: &dyn Foo = t as &dyn Foo; + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` = note: to learn more, visit @@ -21,20 +21,20 @@ LL | let v: &Foo = t as &Foo; = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/dst-object-from-unsized-type.rs:18:24 + --> $DIR/dst-object-from-unsized-type.rs:18:28 | -LL | let _: &[&Foo] = &["hi"]; - | ^^^^ doesn't have a size known at compile-time +LL | let _: &[&dyn Foo] = &["hi"]; + | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/dst-object-from-unsized-type.rs:23:19 + --> $DIR/dst-object-from-unsized-type.rs:23:23 | -LL | let _: &Foo = x as &Foo; - | ^ doesn't have a size known at compile-time +LL | let _: &dyn Foo = x as &dyn Foo; + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit diff --git a/src/test/ui/elide-errors-on-mismatched-tuple.rs b/src/test/ui/elide-errors-on-mismatched-tuple.rs index e68358fd978..7d87b0a7756 100644 --- a/src/test/ui/elide-errors-on-mismatched-tuple.rs +++ b/src/test/ui/elide-errors-on-mismatched-tuple.rs @@ -13,6 +13,6 @@ impl A { fn main() { let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three //~^ ERROR mismatched types - let ts: Vec<&T> = vec![&a, &b, &c]; + let ts: Vec<&dyn T> = vec![&a, &b, &c]; // There is no E0277 error above, as `a`, `b` and `c` are `TyErr` } diff --git a/src/test/ui/error-codes/E0033-teach.rs b/src/test/ui/error-codes/E0033-teach.rs index 0f0b8d864dc..6a27b07fa8b 100644 --- a/src/test/ui/error-codes/E0033-teach.rs +++ b/src/test/ui/error-codes/E0033-teach.rs @@ -5,7 +5,7 @@ trait SomeTrait { } fn main() { - let trait_obj: &SomeTrait = SomeTrait; + let trait_obj: &dyn SomeTrait = SomeTrait; //~^ ERROR expected value, found trait `SomeTrait` //~| ERROR E0038 //~| method `foo` has no receiver diff --git a/src/test/ui/error-codes/E0033-teach.stderr b/src/test/ui/error-codes/E0033-teach.stderr index 1b78820cae0..fb630de7fc1 100644 --- a/src/test/ui/error-codes/E0033-teach.stderr +++ b/src/test/ui/error-codes/E0033-teach.stderr @@ -1,14 +1,14 @@ error[E0423]: expected value, found trait `SomeTrait` - --> $DIR/E0033-teach.rs:8:33 + --> $DIR/E0033-teach.rs:8:37 | -LL | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^ not a value +LL | let trait_obj: &dyn SomeTrait = SomeTrait; + | ^^^^^^^^^ not a value error[E0038]: the trait `SomeTrait` cannot be made into an object --> $DIR/E0033-teach.rs:8:20 | -LL | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object +LL | let trait_obj: &dyn SomeTrait = SomeTrait; + | ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object | = note: method `foo` has no receiver diff --git a/src/test/ui/error-codes/E0033.rs b/src/test/ui/error-codes/E0033.rs index 5a4f3cbce60..582600e110b 100644 --- a/src/test/ui/error-codes/E0033.rs +++ b/src/test/ui/error-codes/E0033.rs @@ -3,7 +3,7 @@ trait SomeTrait { } fn main() { - let trait_obj: &SomeTrait = SomeTrait; + let trait_obj: &dyn SomeTrait = SomeTrait; //~^ ERROR expected value, found trait `SomeTrait` //~| ERROR E0038 //~| method `foo` has no receiver diff --git a/src/test/ui/error-codes/E0033.stderr b/src/test/ui/error-codes/E0033.stderr index 976b0e0286f..fe9f45d86a6 100644 --- a/src/test/ui/error-codes/E0033.stderr +++ b/src/test/ui/error-codes/E0033.stderr @@ -1,14 +1,14 @@ error[E0423]: expected value, found trait `SomeTrait` - --> $DIR/E0033.rs:6:33 + --> $DIR/E0033.rs:6:37 | -LL | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^ not a value +LL | let trait_obj: &dyn SomeTrait = SomeTrait; + | ^^^^^^^^^ not a value error[E0038]: the trait `SomeTrait` cannot be made into an object --> $DIR/E0033.rs:6:20 | -LL | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object +LL | let trait_obj: &dyn SomeTrait = SomeTrait; + | ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object | = note: method `foo` has no receiver diff --git a/src/test/ui/error-codes/E0038.rs b/src/test/ui/error-codes/E0038.rs index b2226803da7..9757e2ab10c 100644 --- a/src/test/ui/error-codes/E0038.rs +++ b/src/test/ui/error-codes/E0038.rs @@ -2,7 +2,7 @@ trait Trait { fn foo(&self) -> Self; } -fn call_foo(x: Box) { +fn call_foo(x: Box) { //~^ ERROR E0038 let y = x.foo(); } diff --git a/src/test/ui/error-codes/E0038.stderr b/src/test/ui/error-codes/E0038.stderr index 74b77338c85..e3d7593e42a 100644 --- a/src/test/ui/error-codes/E0038.stderr +++ b/src/test/ui/error-codes/E0038.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/E0038.rs:5:1 | -LL | fn call_foo(x: Box) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object +LL | fn call_foo(x: Box) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object | = note: method `foo` references the `Self` type in its arguments or return type diff --git a/src/test/ui/error-codes/E0120.rs b/src/test/ui/error-codes/E0120.rs index 049707415e5..287a4088183 100644 --- a/src/test/ui/error-codes/E0120.rs +++ b/src/test/ui/error-codes/E0120.rs @@ -1,6 +1,6 @@ trait MyTrait { fn foo() {} } -impl Drop for MyTrait { +impl Drop for dyn MyTrait { //~^ ERROR E0120 fn drop(&mut self) {} } diff --git a/src/test/ui/error-codes/E0120.stderr b/src/test/ui/error-codes/E0120.stderr index 9b6603dbaca..68ca7d800d5 100644 --- a/src/test/ui/error-codes/E0120.stderr +++ b/src/test/ui/error-codes/E0120.stderr @@ -1,8 +1,8 @@ error[E0120]: the Drop trait may only be implemented on structures --> $DIR/E0120.rs:3:15 | -LL | impl Drop for MyTrait { - | ^^^^^^^ implementing Drop requires a struct +LL | impl Drop for dyn MyTrait { + | ^^^^^^^^^^^ implementing Drop requires a struct error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0191.rs b/src/test/ui/error-codes/E0191.rs index 356110671e7..22f739b9e76 100644 --- a/src/test/ui/error-codes/E0191.rs +++ b/src/test/ui/error-codes/E0191.rs @@ -2,6 +2,6 @@ trait Trait { type Bar; } -type Foo = Trait; //~ ERROR E0191 +type Foo = dyn Trait; //~ ERROR E0191 fn main() {} diff --git a/src/test/ui/error-codes/E0191.stderr b/src/test/ui/error-codes/E0191.stderr index 2d9fdfe5d29..92fa85bca0e 100644 --- a/src/test/ui/error-codes/E0191.stderr +++ b/src/test/ui/error-codes/E0191.stderr @@ -4,8 +4,8 @@ error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) mu LL | type Bar; | --------- `Bar` defined here ... -LL | type Foo = Trait; - | ^^^^^ associated type `Bar` must be specified +LL | type Foo = dyn Trait; + | ^^^^^^^^^ associated type `Bar` must be specified error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0220.rs b/src/test/ui/error-codes/E0220.rs index f4798042538..e11a570df79 100644 --- a/src/test/ui/error-codes/E0220.rs +++ b/src/test/ui/error-codes/E0220.rs @@ -2,7 +2,7 @@ trait Trait { type Bar; } -type Foo = Trait; //~ ERROR E0220 - //~| ERROR E0191 +type Foo = dyn Trait; //~ ERROR E0220 + //~| ERROR E0191 fn main() { } diff --git a/src/test/ui/error-codes/E0220.stderr b/src/test/ui/error-codes/E0220.stderr index bd2205fb752..5da302748cd 100644 --- a/src/test/ui/error-codes/E0220.stderr +++ b/src/test/ui/error-codes/E0220.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `F` not found for `Trait` - --> $DIR/E0220.rs:5:18 + --> $DIR/E0220.rs:5:22 | -LL | type Foo = Trait; - | ^^^^^ associated type `F` not found +LL | type Foo = dyn Trait; + | ^^^^^ associated type `F` not found error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified --> $DIR/E0220.rs:5:12 @@ -10,8 +10,8 @@ error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) mu LL | type Bar; | --------- `Bar` defined here ... -LL | type Foo = Trait; - | ^^^^^^^^^^^^ associated type `Bar` must be specified +LL | type Foo = dyn Trait; + | ^^^^^^^^^^^^^^^^ associated type `Bar` must be specified error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0393.rs b/src/test/ui/error-codes/E0393.rs index bdd4deafc83..0c1a369806d 100644 --- a/src/test/ui/error-codes/E0393.rs +++ b/src/test/ui/error-codes/E0393.rs @@ -1,6 +1,6 @@ trait A {} -fn together_we_will_rule_the_galaxy(son: &A) {} +fn together_we_will_rule_the_galaxy(son: &dyn A) {} //~^ ERROR E0393 fn main() { diff --git a/src/test/ui/error-codes/E0393.stderr b/src/test/ui/error-codes/E0393.stderr index bf564ef1021..543e3213633 100644 --- a/src/test/ui/error-codes/E0393.stderr +++ b/src/test/ui/error-codes/E0393.stderr @@ -1,8 +1,8 @@ error[E0393]: the type parameter `T` must be explicitly specified - --> $DIR/E0393.rs:3:43 + --> $DIR/E0393.rs:3:47 | -LL | fn together_we_will_rule_the_galaxy(son: &A) {} - | ^ missing reference to `T` +LL | fn together_we_will_rule_the_galaxy(son: &dyn A) {} + | ^ missing reference to `T` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/error-codes/E0478.rs b/src/test/ui/error-codes/E0478.rs index 1b5ca09d5a6..b1562dc0a8b 100644 --- a/src/test/ui/error-codes/E0478.rs +++ b/src/test/ui/error-codes/E0478.rs @@ -1,7 +1,7 @@ trait Wedding<'t>: 't { } struct Prince<'kiss, 'SnowWhite> { - child: Box + 'SnowWhite>, //~ ERROR E0478 + child: Box + 'SnowWhite>, //~ ERROR E0478 } fn main() { diff --git a/src/test/ui/error-codes/E0478.stderr b/src/test/ui/error-codes/E0478.stderr index 71e490364d7..587125fdc33 100644 --- a/src/test/ui/error-codes/E0478.stderr +++ b/src/test/ui/error-codes/E0478.stderr @@ -1,8 +1,8 @@ error[E0478]: lifetime bound not satisfied --> $DIR/E0478.rs:4:5 | -LL | child: Box + 'SnowWhite>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | child: Box + 'SnowWhite>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime 'SnowWhite as defined on the struct at 3:22 --> $DIR/E0478.rs:3:22 diff --git a/src/test/ui/error-codes/E0719.rs b/src/test/ui/error-codes/E0719.rs index 6b572f49cee..3311e190937 100644 --- a/src/test/ui/error-codes/E0719.rs +++ b/src/test/ui/error-codes/E0719.rs @@ -3,12 +3,12 @@ trait Foo: Iterator {} type Unit = (); -fn test() -> Box> { +fn test() -> Box> { //~^ ERROR is already specified Box::new(None.into_iter()) } fn main() { - let _: &Iterator; + let _: &dyn Iterator; test(); } diff --git a/src/test/ui/error-codes/E0719.stderr b/src/test/ui/error-codes/E0719.stderr index 5854cd7e143..c5b9a71c659 100644 --- a/src/test/ui/error-codes/E0719.stderr +++ b/src/test/ui/error-codes/E0719.stderr @@ -7,12 +7,12 @@ LL | trait Foo: Iterator {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified - --> $DIR/E0719.rs:6:38 + --> $DIR/E0719.rs:6:42 | -LL | fn test() -> Box> { - | --------- ^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first +LL | fn test() -> Box> { + | --------- ^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first error: aborting due to 2 previous errors diff --git a/src/test/ui/fat-ptr-cast.rs b/src/test/ui/fat-ptr-cast.rs index eb419ba2036..a0fad583a16 100644 --- a/src/test/ui/fat-ptr-cast.rs +++ b/src/test/ui/fat-ptr-cast.rs @@ -19,6 +19,6 @@ fn main() { q as *const [i32]; //~ ERROR cannot cast // #21397 - let t: *mut (Trait + 'static) = 0 as *mut _; //~ ERROR casting + let t: *mut (dyn Trait + 'static) = 0 as *mut _; //~ ERROR casting let mut fail: *const str = 0 as *const str; //~ ERROR casting } diff --git a/src/test/ui/fat-ptr-cast.stderr b/src/test/ui/fat-ptr-cast.stderr index bb7a4d3ff7f..93e1471838f 100644 --- a/src/test/ui/fat-ptr-cast.stderr +++ b/src/test/ui/fat-ptr-cast.stderr @@ -53,10 +53,10 @@ LL | q as *const [i32]; | ^^^^^^^^^^^^^^^^^ error[E0606]: casting `usize` as `*mut (dyn Trait + 'static)` is invalid - --> $DIR/fat-ptr-cast.rs:22:37 + --> $DIR/fat-ptr-cast.rs:22:41 | -LL | let t: *mut (Trait + 'static) = 0 as *mut _; - | ^^^^^^^^^^^ +LL | let t: *mut (dyn Trait + 'static) = 0 as *mut _; + | ^^^^^^^^^^^ error[E0606]: casting `usize` as `*const str` is invalid --> $DIR/fat-ptr-cast.rs:23:32 diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs index e5028f2f8aa..3dbaf5dea25 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs @@ -52,8 +52,8 @@ struct Dst { struct TwoStrs(str, str) where str: Sized; //~ ERROR -fn unsized_local() where Dst: Sized { //~ ERROR - let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); +fn unsized_local() where Dst: Sized { //~ ERROR + let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); } fn return_str() -> str where str: Sized { //~ ERROR diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index b04a6e4d671..1d346fd42ff 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -102,8 +102,8 @@ LL | struct TwoStrs(str, str) where str: Sized; error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time --> $DIR/feature-gate-trivial_bounds.rs:55:1 | -LL | / fn unsized_local() where Dst: Sized { -LL | | let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); +LL | / fn unsized_local() where Dst: Sized { +LL | | let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); LL | | } | |_^ doesn't have a size known at compile-time | diff --git a/src/test/ui/feature-gates/feature-gate-unsized_locals.rs b/src/test/ui/feature-gates/feature-gate-unsized_locals.rs index a8f81f3f113..3686e7b37f4 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_locals.rs +++ b/src/test/ui/feature-gates/feature-gate-unsized_locals.rs @@ -1,4 +1,4 @@ -fn f(f: FnOnce()) {} +fn f(f: dyn FnOnce()) {} //~^ ERROR E0277 fn main() { diff --git a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr index bde39cbeaeb..d20b9e2981e 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr @@ -1,7 +1,7 @@ error[E0277]: the size for values of type `(dyn std::ops::FnOnce() + 'static)` cannot be known at compilation time --> $DIR/feature-gate-unsized_locals.rs:1:6 | -LL | fn f(f: FnOnce()) {} +LL | fn f(f: dyn FnOnce()) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::FnOnce() + 'static)` diff --git a/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs b/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs index f781bc9aedd..c3d62a231e5 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs +++ b/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs @@ -1,4 +1,4 @@ fn main() { - let _ : &(Send,) = &((),); + let _ : &(dyn Send,) = &((),); //~^ ERROR unsized tuple coercion is not stable enough } diff --git a/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr b/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr index 669e87ceada..5b93c889db1 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr @@ -1,8 +1,8 @@ error[E0658]: unsized tuple coercion is not stable enough for use and is subject to change - --> $DIR/feature-gate-unsized_tuple_coercion.rs:2:24 + --> $DIR/feature-gate-unsized_tuple_coercion.rs:2:28 | -LL | let _ : &(Send,) = &((),); - | ^^^^^^ +LL | let _ : &(dyn Send,) = &((),); + | ^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/42877 = help: add #![feature(unsized_tuple_coercion)] to the crate attributes to enable diff --git a/src/test/ui/fn/fn-trait-formatting.rs b/src/test/ui/fn/fn-trait-formatting.rs index 21da39dd400..5c16c1a7e88 100644 --- a/src/test/ui/fn/fn-trait-formatting.rs +++ b/src/test/ui/fn/fn-trait-formatting.rs @@ -3,15 +3,15 @@ fn needs_fn(x: F) where F: Fn(isize) -> isize {} fn main() { - let _: () = (box |_: isize| {}) as Box; + let _: () = (box |_: isize| {}) as Box; //~^ ERROR mismatched types //~| expected type `()` //~| found type `std::boxed::Box` - let _: () = (box |_: isize, isize| {}) as Box; + let _: () = (box |_: isize, isize| {}) as Box; //~^ ERROR mismatched types //~| expected type `()` //~| found type `std::boxed::Box` - let _: () = (box || -> isize { unimplemented!() }) as Box isize>; + let _: () = (box || -> isize { unimplemented!() }) as Box isize>; //~^ ERROR mismatched types //~| expected type `()` //~| found type `std::boxed::Box isize>` diff --git a/src/test/ui/fn/fn-trait-formatting.stderr b/src/test/ui/fn/fn-trait-formatting.stderr index 6b76a6c914f..504bc2605ec 100644 --- a/src/test/ui/fn/fn-trait-formatting.stderr +++ b/src/test/ui/fn/fn-trait-formatting.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types --> $DIR/fn-trait-formatting.rs:6:17 | -LL | let _: () = (box |_: isize| {}) as Box; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` +LL | let _: () = (box |_: isize| {}) as Box; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` | = note: expected type `()` found type `std::boxed::Box` @@ -10,8 +10,8 @@ LL | let _: () = (box |_: isize| {}) as Box; error[E0308]: mismatched types --> $DIR/fn-trait-formatting.rs:10:17 | -LL | let _: () = (box |_: isize, isize| {}) as Box; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` +LL | let _: () = (box |_: isize, isize| {}) as Box; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` | = note: expected type `()` found type `std::boxed::Box` @@ -19,8 +19,8 @@ LL | let _: () = (box |_: isize, isize| {}) as Box; error[E0308]: mismatched types --> $DIR/fn-trait-formatting.rs:14:17 | -LL | let _: () = (box || -> isize { unimplemented!() }) as Box isize>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` +LL | let _: () = (box || -> isize { unimplemented!() }) as Box isize>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` | = note: expected type `()` found type `std::boxed::Box isize>` diff --git a/src/test/ui/higher-lifetime-bounds.rs b/src/test/ui/higher-lifetime-bounds.rs index 546f4d43663..f3393347d90 100644 --- a/src/test/ui/higher-lifetime-bounds.rs +++ b/src/test/ui/higher-lifetime-bounds.rs @@ -58,12 +58,12 @@ struct S3(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); //~^ ERROR lifetime bounds cannot be used in this context -type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; +type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; //~^ ERROR lifetime bounds cannot be used in this context fn main() { let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = None; //~^ ERROR lifetime bounds cannot be used in this context - let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; + let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; //~^ ERROR lifetime bounds cannot be used in this context } diff --git a/src/test/ui/higher-lifetime-bounds.stderr b/src/test/ui/higher-lifetime-bounds.stderr index 431a89f5eb8..bc6d2288cdf 100644 --- a/src/test/ui/higher-lifetime-bounds.stderr +++ b/src/test/ui/higher-lifetime-bounds.stderr @@ -47,10 +47,10 @@ LL | struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); | ^^^ error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:61:29 + --> $DIR/higher-lifetime-bounds.rs:61:33 | -LL | type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; - | ^^^ +LL | type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; + | ^^^ error: lifetime bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:65:34 @@ -59,10 +59,10 @@ LL | let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = | ^^^ error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:67:38 + --> $DIR/higher-lifetime-bounds.rs:67:42 | -LL | let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; - | ^^^ +LL | let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; + | ^^^ error: aborting due to 11 previous errors diff --git a/src/test/ui/imports/extern-crate-used.rs b/src/test/ui/imports/extern-crate-used.rs index 26150c7d4a1..8198c1816a1 100644 --- a/src/test/ui/imports/extern-crate-used.rs +++ b/src/test/ui/imports/extern-crate-used.rs @@ -20,13 +20,13 @@ extern crate core; //~ ERROR unused extern crate mod m { use iso1::any as are_you_okay1; use ::iso2::any as are_you_okay2; - type AreYouOkay1 = iso3::any::Any; - type AreYouOkay2 = ::iso4::any::Any; + type AreYouOkay1 = dyn iso3::any::Any; + type AreYouOkay2 = dyn (::iso4::any::Any); use core::any as are_you_okay3; use ::core::any as are_you_okay4; - type AreYouOkay3 = core::any::Any; - type AreYouOkay4 = ::core::any::Any; + type AreYouOkay3 = dyn core::any::Any; + type AreYouOkay4 = dyn (::core::any::Any); } fn main() {} diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs index d4535ac4425..d131a944721 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs @@ -4,8 +4,8 @@ trait Trait {} struct Struct; impl Deref for Struct { - type Target = Trait; - fn deref(&self) -> &Trait { + type Target = dyn Trait; + fn deref(&self) -> &dyn Trait { unimplemented!(); } } diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr index e56a56e2dae..b50a926c637 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr @@ -1,13 +1,13 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in generic type due to conflicting requirements --> $DIR/mismatched_trait_impl-2.rs:8:5 | -LL | fn deref(&self) -> &Trait { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn deref(&self) -> &dyn Trait { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 8:5... --> $DIR/mismatched_trait_impl-2.rs:8:5 | -LL | / fn deref(&self) -> &Trait { +LL | / fn deref(&self) -> &dyn Trait { LL | | unimplemented!(); LL | | } | |_____^ diff --git a/src/test/ui/issues/issue-10291.nll.stderr b/src/test/ui/issues/issue-10291.nll.stderr index 45f29fd7956..a7b827d27a8 100644 --- a/src/test/ui/issues/issue-10291.nll.stderr +++ b/src/test/ui/issues/issue-10291.nll.stderr @@ -3,7 +3,7 @@ error: lifetime may not live long enough | LL | fn test<'x>(x: &'x isize) { | -- lifetime `'x` defined here -LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { +LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { LL | x | ^ returning this value requires that `'x` must outlive `'static` diff --git a/src/test/ui/issues/issue-10291.rs b/src/test/ui/issues/issue-10291.rs index 877b0aba473..559c5fcac95 100644 --- a/src/test/ui/issues/issue-10291.rs +++ b/src/test/ui/issues/issue-10291.rs @@ -1,5 +1,5 @@ fn test<'x>(x: &'x isize) { - drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { x //~ ERROR E0312 })); } diff --git a/src/test/ui/issues/issue-10291.stderr b/src/test/ui/issues/issue-10291.stderr index 0d653e6ced1..5e63469da59 100644 --- a/src/test/ui/issues/issue-10291.stderr +++ b/src/test/ui/issues/issue-10291.stderr @@ -4,11 +4,11 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... LL | x | ^ | -note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 2:65... - --> $DIR/issue-10291.rs:2:65 +note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 2:69... + --> $DIR/issue-10291.rs:2:69 | -LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | _________________________________________________________________^ +LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | _____________________________________________________________________^ LL | | x LL | | })); | |_____^ diff --git a/src/test/ui/issues/issue-10902.rs b/src/test/ui/issues/issue-10902.rs index 672386bc8a6..5e7f8ed7fd5 100644 --- a/src/test/ui/issues/issue-10902.rs +++ b/src/test/ui/issues/issue-10902.rs @@ -4,16 +4,16 @@ pub mod two_tuple { pub trait T { fn dummy(&self) { } } - pub struct P<'a>(&'a (T + 'a), &'a (T + 'a)); - pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { + pub struct P<'a>(&'a (dyn T + 'a), &'a (dyn T + 'a)); + pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { P(car, cdr) } } pub mod two_fields { pub trait T { fn dummy(&self) { } } - pub struct P<'a> { car: &'a (T + 'a), cdr: &'a (T + 'a) } - pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { + pub struct P<'a> { car: &'a (dyn T + 'a), cdr: &'a (dyn T + 'a) } + pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { P{ car: car, cdr: cdr } } } diff --git a/src/test/ui/issues/issue-11374.rs b/src/test/ui/issues/issue-11374.rs index f00da0acf81..7519ba2826e 100644 --- a/src/test/ui/issues/issue-11374.rs +++ b/src/test/ui/issues/issue-11374.rs @@ -2,11 +2,11 @@ use std::io::{self, Read}; use std::vec; pub struct Container<'a> { - reader: &'a mut Read + reader: &'a mut dyn Read } impl<'a> Container<'a> { - pub fn wrap<'s>(reader: &'s mut io::Read) -> Container<'s> { + pub fn wrap<'s>(reader: &'s mut dyn io::Read) -> Container<'s> { Container { reader: reader } } @@ -17,7 +17,7 @@ impl<'a> Container<'a> { pub fn for_stdin<'a>() -> Container<'a> { let mut r = io::stdin(); - Container::wrap(&mut r as &mut io::Read) + Container::wrap(&mut r as &mut dyn io::Read) } fn main() { diff --git a/src/test/ui/issues/issue-11515.rs b/src/test/ui/issues/issue-11515.rs index 7eab2a26178..a7671b9282a 100644 --- a/src/test/ui/issues/issue-11515.rs +++ b/src/test/ui/issues/issue-11515.rs @@ -1,10 +1,10 @@ #![feature(box_syntax)] struct Test { - func: Box + func: Box } fn main() { - let closure: Box = Box::new(|| ()); + let closure: Box = Box::new(|| ()); let test = box Test { func: closure }; //~ ERROR mismatched types } diff --git a/src/test/ui/issues/issue-11612.rs b/src/test/ui/issues/issue-11612.rs index 4d6f4656d58..fd4fb2443cb 100644 --- a/src/test/ui/issues/issue-11612.rs +++ b/src/test/ui/issues/issue-11612.rs @@ -14,11 +14,11 @@ struct B<'a, T:'a> { impl<'a, T> A for B<'a, T> {} -fn foo(_: &A) {} +fn foo(_: &dyn A) {} fn bar(b: &B) { foo(b); // Coercion should work - foo(b as &A); // Explicit cast should work as well + foo(b as &dyn A); // Explicit cast should work as well } fn main() {} diff --git a/src/test/ui/issues/issue-12470.rs b/src/test/ui/issues/issue-12470.rs index 77b78c8a1f7..0ade359923a 100644 --- a/src/test/ui/issues/issue-12470.rs +++ b/src/test/ui/issues/issue-12470.rs @@ -16,10 +16,10 @@ impl X for B { } struct A<'a> { - p: &'a (X+'a) + p: &'a (dyn X + 'a) } -fn make_a<'a>(p: &'a X) -> A<'a> { +fn make_a<'a>(p: &'a dyn X) -> A<'a> { A { p: p } } diff --git a/src/test/ui/issues/issue-13033.rs b/src/test/ui/issues/issue-13033.rs index a6c9e9712c0..e5274eb823d 100644 --- a/src/test/ui/issues/issue-13033.rs +++ b/src/test/ui/issues/issue-13033.rs @@ -1,11 +1,11 @@ trait Foo { - fn bar(&mut self, other: &mut Foo); + fn bar(&mut self, other: &mut dyn Foo); } struct Baz; impl Foo for Baz { - fn bar(&mut self, other: &Foo) {} + fn bar(&mut self, other: &dyn Foo) {} //~^ ERROR method `bar` has an incompatible type for trait //~| expected type `fn(&mut Baz, &mut dyn Foo)` //~| found type `fn(&mut Baz, &dyn Foo)` diff --git a/src/test/ui/issues/issue-13033.stderr b/src/test/ui/issues/issue-13033.stderr index d1e8eb31c88..195d0c39b29 100644 --- a/src/test/ui/issues/issue-13033.stderr +++ b/src/test/ui/issues/issue-13033.stderr @@ -1,18 +1,18 @@ error[E0053]: method `bar` has an incompatible type for trait --> $DIR/issue-13033.rs:8:30 | -LL | fn bar(&mut self, other: &mut Foo); - | -------- type in trait +LL | fn bar(&mut self, other: &mut dyn Foo); + | ------------ type in trait ... -LL | fn bar(&mut self, other: &Foo) {} - | ^^^^ types differ in mutability +LL | fn bar(&mut self, other: &dyn Foo) {} + | ^^^^^^^^ types differ in mutability | = note: expected type `fn(&mut Baz, &mut dyn Foo)` found type `fn(&mut Baz, &dyn Foo)` help: consider change the type to match the mutability in trait | -LL | fn bar(&mut self, other: &mut Foo) {} - | ^^^^^^^^ +LL | fn bar(&mut self, other: &mut dyn Foo) {} + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-13352.rs b/src/test/ui/issues/issue-13352.rs index c711e3b713f..e6995be27d2 100644 --- a/src/test/ui/issues/issue-13352.rs +++ b/src/test/ui/issues/issue-13352.rs @@ -1,6 +1,6 @@ // ignore-cloudabi no std::process -fn foo(_: Box) {} +fn foo(_: Box) {} fn main() { foo(loop { diff --git a/src/test/ui/issues/issue-13853-2.rs b/src/test/ui/issues/issue-13853-2.rs index b58f2bd3b3b..27319c98d6e 100644 --- a/src/test/ui/issues/issue-13853-2.rs +++ b/src/test/ui/issues/issue-13853-2.rs @@ -2,5 +2,5 @@ trait FromStructReader<'a> { } trait ResponseHook { fn get(&self); } -fn foo(res : Box) { res.get } //~ ERROR attempted to take value of method +fn foo(res : Box) { res.get } //~ ERROR attempted to take value of method fn main() {} diff --git a/src/test/ui/issues/issue-13853-2.stderr b/src/test/ui/issues/issue-13853-2.stderr index 0853f5cffb7..ea3b38940cf 100644 --- a/src/test/ui/issues/issue-13853-2.stderr +++ b/src/test/ui/issues/issue-13853-2.stderr @@ -1,8 +1,8 @@ error[E0615]: attempted to take value of method `get` on type `std::boxed::Box<(dyn ResponseHook + 'static)>` - --> $DIR/issue-13853-2.rs:5:39 + --> $DIR/issue-13853-2.rs:5:43 | -LL | fn foo(res : Box) { res.get } - | ^^^ help: use parentheses to call the method: `get()` +LL | fn foo(res : Box) { res.get } + | ^^^ help: use parentheses to call the method: `get()` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-14285.rs b/src/test/ui/issues/issue-14285.rs index 934d72a67ca..2ba9ff71773 100644 --- a/src/test/ui/issues/issue-14285.rs +++ b/src/test/ui/issues/issue-14285.rs @@ -6,9 +6,9 @@ struct A; impl Foo for A {} -struct B<'a>(&'a (Foo+'a)); +struct B<'a>(&'a (dyn Foo + 'a)); -fn foo<'a>(a: &Foo) -> B<'a> { +fn foo<'a>(a: &dyn Foo) -> B<'a> { B(a) //~ ERROR explicit lifetime required in the type of `a` [E0621] } diff --git a/src/test/ui/issues/issue-14285.stderr b/src/test/ui/issues/issue-14285.stderr index c180ed03e54..5c07066018e 100644 --- a/src/test/ui/issues/issue-14285.stderr +++ b/src/test/ui/issues/issue-14285.stderr @@ -1,8 +1,8 @@ error[E0621]: explicit lifetime required in the type of `a` --> $DIR/issue-14285.rs:12:5 | -LL | fn foo<'a>(a: &Foo) -> B<'a> { - | ---- help: add explicit lifetime `'a` to the type of `a`: `&'a (dyn Foo + 'a)` +LL | fn foo<'a>(a: &dyn Foo) -> B<'a> { + | -------- help: add explicit lifetime `'a` to the type of `a`: `&'a (dyn Foo + 'a)` LL | B(a) | ^^^^ lifetime `'a` required diff --git a/src/test/ui/issues/issue-14366.rs b/src/test/ui/issues/issue-14366.rs index a6298f25d47..bb338860d8b 100644 --- a/src/test/ui/issues/issue-14366.rs +++ b/src/test/ui/issues/issue-14366.rs @@ -1,4 +1,4 @@ fn main() { - let _x = "test" as &::std::any::Any; + let _x = "test" as &dyn (::std::any::Any); //~^ ERROR the size for values of type } diff --git a/src/test/ui/issues/issue-14366.stderr b/src/test/ui/issues/issue-14366.stderr index a3588bb8ebe..542d8a904c4 100644 --- a/src/test/ui/issues/issue-14366.stderr +++ b/src/test/ui/issues/issue-14366.stderr @@ -1,7 +1,7 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/issue-14366.rs:2:14 | -LL | let _x = "test" as &::std::any::Any; +LL | let _x = "test" as &dyn (::std::any::Any); | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` diff --git a/src/test/ui/issues/issue-14901.rs b/src/test/ui/issues/issue-14901.rs index 61b2b64ddf0..9b89c1631df 100644 --- a/src/test/ui/issues/issue-14901.rs +++ b/src/test/ui/issues/issue-14901.rs @@ -2,7 +2,7 @@ pub trait Reader {} enum Wrapper<'a> { - WrapReader(&'a (Reader + 'a)) + WrapReader(&'a (dyn Reader + 'a)) } trait Wrap<'a> { @@ -11,7 +11,7 @@ trait Wrap<'a> { impl<'a, R: Reader> Wrap<'a> for &'a mut R { fn wrap(self) -> Wrapper<'a> { - Wrapper::WrapReader(self as &'a mut Reader) + Wrapper::WrapReader(self as &'a mut dyn Reader) } } diff --git a/src/test/ui/issues/issue-14959.rs b/src/test/ui/issues/issue-14959.rs index 78ae21e2837..60daaafbcc8 100644 --- a/src/test/ui/issues/issue-14959.rs +++ b/src/test/ui/issues/issue-14959.rs @@ -26,20 +26,20 @@ impl Alloy { } } -impl<'b> Fn<(&'b mut (Response+'b),)> for SendFile { - extern "rust-call" fn call(&self, (_res,): (&'b mut (Response+'b),)) {} +impl<'b> Fn<(&'b mut (dyn Response + 'b),)> for SendFile { + extern "rust-call" fn call(&self, (_res,): (&'b mut (dyn Response + 'b),)) {} } -impl<'b> FnMut<(&'b mut (Response+'b),)> for SendFile { - extern "rust-call" fn call_mut(&mut self, (_res,): (&'b mut (Response+'b),)) { +impl<'b> FnMut<(&'b mut (dyn Response + 'b),)> for SendFile { + extern "rust-call" fn call_mut(&mut self, (_res,): (&'b mut (dyn Response+'b),)) { self.call((_res,)) } } -impl<'b> FnOnce<(&'b mut (Response+'b),)> for SendFile { +impl<'b> FnOnce<(&'b mut (dyn Response + 'b),)> for SendFile { type Output = (); - extern "rust-call" fn call_once(self, (_res,): (&'b mut (Response+'b),)) { + extern "rust-call" fn call_once(self, (_res,): (&'b mut (dyn Response+'b),)) { self.call((_res,)) } } diff --git a/src/test/ui/issues/issue-16668.rs b/src/test/ui/issues/issue-16668.rs index f69ca4677c9..b570a2ced67 100644 --- a/src/test/ui/issues/issue-16668.rs +++ b/src/test/ui/issues/issue-16668.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(dead_code)] struct Parser<'a, I, O> { - parse: Box Result + 'a> + parse: Box Result + 'a> } impl<'a, I: 'a, O: 'a> Parser<'a, I, O> { diff --git a/src/test/ui/issues/issue-16922.rs b/src/test/ui/issues/issue-16922.rs index 1e865515c4b..10a5cccbcee 100644 --- a/src/test/ui/issues/issue-16922.rs +++ b/src/test/ui/issues/issue-16922.rs @@ -1,7 +1,7 @@ use std::any::Any; -fn foo(value: &T) -> Box { - Box::new(value) as Box +fn foo(value: &T) -> Box { + Box::new(value) as Box //~^ ERROR explicit lifetime required in the type of `value` [E0621] } diff --git a/src/test/ui/issues/issue-16922.stderr b/src/test/ui/issues/issue-16922.stderr index 1f3b3fe739c..4e3d3ecb9c0 100644 --- a/src/test/ui/issues/issue-16922.stderr +++ b/src/test/ui/issues/issue-16922.stderr @@ -1,9 +1,9 @@ error[E0621]: explicit lifetime required in the type of `value` --> $DIR/issue-16922.rs:4:5 | -LL | fn foo(value: &T) -> Box { +LL | fn foo(value: &T) -> Box { | -- help: add explicit lifetime `'static` to the type of `value`: `&'static T` -LL | Box::new(value) as Box +LL | Box::new(value) as Box | ^^^^^^^^^^^^^^^ lifetime `'static` required error: aborting due to previous error diff --git a/src/test/ui/issues/issue-16994.rs b/src/test/ui/issues/issue-16994.rs index d356ce8a4da..d5f1b1310eb 100644 --- a/src/test/ui/issues/issue-16994.rs +++ b/src/test/ui/issues/issue-16994.rs @@ -1,6 +1,6 @@ // compile-pass // skip-codegen -fn cb<'a,T>(_x: Box, bool))) -> T>) -> T { +fn cb<'a,T>(_x: Box, bool))) -> T>) -> T { panic!() } diff --git a/src/test/ui/issues/issue-17441.rs b/src/test/ui/issues/issue-17441.rs index cfb2fe674ed..b9813ef1eef 100644 --- a/src/test/ui/issues/issue-17441.rs +++ b/src/test/ui/issues/issue-17441.rs @@ -2,10 +2,10 @@ fn main() { let _foo = &[1_usize, 2] as [usize]; //~^ ERROR cast to unsized type: `&[usize; 2]` as `[usize]` - let _bar = Box::new(1_usize) as std::fmt::Debug; + let _bar = Box::new(1_usize) as dyn std::fmt::Debug; //~^ ERROR cast to unsized type: `std::boxed::Box` as `dyn std::fmt::Debug` - let _baz = 1_usize as std::fmt::Debug; + let _baz = 1_usize as dyn std::fmt::Debug; //~^ ERROR cast to unsized type: `usize` as `dyn std::fmt::Debug` let _quux = [1_usize, 2] as [usize]; diff --git a/src/test/ui/issues/issue-17441.stderr b/src/test/ui/issues/issue-17441.stderr index 436ee7325f8..0ab035515a0 100644 --- a/src/test/ui/issues/issue-17441.stderr +++ b/src/test/ui/issues/issue-17441.stderr @@ -13,21 +13,21 @@ LL | let _foo = &[1_usize, 2] as [usize]; error[E0620]: cast to unsized type: `std::boxed::Box` as `dyn std::fmt::Debug` --> $DIR/issue-17441.rs:5:16 | -LL | let _bar = Box::new(1_usize) as std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^--------------- +LL | let _bar = Box::new(1_usize) as dyn std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^------------------- | | - | help: try casting to a `Box` instead: `Box` + | help: try casting to a `Box` instead: `Box` error[E0620]: cast to unsized type: `usize` as `dyn std::fmt::Debug` --> $DIR/issue-17441.rs:8:16 | -LL | let _baz = 1_usize as std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _baz = 1_usize as dyn std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider using a box or reference as appropriate --> $DIR/issue-17441.rs:8:16 | -LL | let _baz = 1_usize as std::fmt::Debug; +LL | let _baz = 1_usize as dyn std::fmt::Debug; | ^^^^^^^ error[E0620]: cast to unsized type: `[usize; 2]` as `[usize]` diff --git a/src/test/ui/issues/issue-17959.rs b/src/test/ui/issues/issue-17959.rs index d56f346ecd4..73865ae2d2e 100644 --- a/src/test/ui/issues/issue-17959.rs +++ b/src/test/ui/issues/issue-17959.rs @@ -17,5 +17,5 @@ impl Drop for G { } fn main() { - let x:G; + let x:G; } diff --git a/src/test/ui/issues/issue-18107.rs b/src/test/ui/issues/issue-18107.rs index 184d122d5cd..122940f1c17 100644 --- a/src/test/ui/issues/issue-18107.rs +++ b/src/test/ui/issues/issue-18107.rs @@ -1,7 +1,7 @@ pub trait AbstractRenderer {} fn _create_render(_: &()) -> - AbstractRenderer + dyn AbstractRenderer //~^ ERROR the size for values of type { match 0 { diff --git a/src/test/ui/issues/issue-18107.stderr b/src/test/ui/issues/issue-18107.stderr index 23b58c3f6df..9bdf470413b 100644 --- a/src/test/ui/issues/issue-18107.stderr +++ b/src/test/ui/issues/issue-18107.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `(dyn AbstractRenderer + 'static)` cannot be known at compilation time --> $DIR/issue-18107.rs:4:5 | -LL | AbstractRenderer - | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +LL | dyn AbstractRenderer + | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn AbstractRenderer + 'static)` = note: to learn more, visit diff --git a/src/test/ui/issues/issue-18188.rs b/src/test/ui/issues/issue-18188.rs index 8e39dc15597..4d0c4464759 100644 --- a/src/test/ui/issues/issue-18188.rs +++ b/src/test/ui/issues/issue-18188.rs @@ -5,7 +5,7 @@ pub trait Promisable: Send + Sync {} impl Promisable for T {} pub fn propagate<'a, T, E, F, G>(mut action: F) - -> Box) -> Result + 'a> + -> Box) -> Result + 'a> where T: Promisable + Clone + 'a, E: Promisable + Clone + 'a, diff --git a/src/test/ui/issues/issue-18446-2.rs b/src/test/ui/issues/issue-18446-2.rs index 2f05ece3197..3e04a914d45 100644 --- a/src/test/ui/issues/issue-18446-2.rs +++ b/src/test/ui/issues/issue-18446-2.rs @@ -6,7 +6,7 @@ trait T { fn foo(&self) -> i32 { 0 } } -impl<'a> T + 'a { +impl<'a> dyn T + 'a { fn foo(&self) -> i32 { 1 } } diff --git a/src/test/ui/issues/issue-18446.rs b/src/test/ui/issues/issue-18446.rs index 64c89df3868..a2e238da03a 100644 --- a/src/test/ui/issues/issue-18446.rs +++ b/src/test/ui/issues/issue-18446.rs @@ -5,7 +5,7 @@ trait T { fn foo(&self); } -impl<'a> T + 'a { +impl<'a> dyn T + 'a { fn foo(&self) {} } @@ -14,6 +14,6 @@ impl T for i32 { } fn main() { - let x: &T = &0i32; + let x: &dyn T = &0i32; x.foo(); //~ ERROR multiple applicable items in scope [E0034] } diff --git a/src/test/ui/issues/issue-18783.rs b/src/test/ui/issues/issue-18783.rs index b84a1adb425..d4851ac1418 100644 --- a/src/test/ui/issues/issue-18783.rs +++ b/src/test/ui/issues/issue-18783.rs @@ -18,11 +18,11 @@ fn ufcs() { } trait Push<'c> { - fn push<'f: 'c>(&self, push: Box); + fn push<'f: 'c>(&self, push: Box); } -impl<'c> Push<'c> for RefCell>> { - fn push<'f: 'c>(&self, fun: Box) { +impl<'c> Push<'c> for RefCell>> { + fn push<'f: 'c>(&self, fun: Box) { self.borrow_mut().push(fun) } } diff --git a/src/test/ui/issues/issue-18819.rs b/src/test/ui/issues/issue-18819.rs index 80db056e7dd..e634c55f824 100644 --- a/src/test/ui/issues/issue-18819.rs +++ b/src/test/ui/issues/issue-18819.rs @@ -8,7 +8,7 @@ impl Foo for X { type Item = bool; } -fn print_x(_: &Foo, extra: &str) { +fn print_x(_: &dyn Foo, extra: &str) { println!("{}", extra); } diff --git a/src/test/ui/issues/issue-18819.stderr b/src/test/ui/issues/issue-18819.stderr index eb7e4ad405f..41e8470ecd0 100644 --- a/src/test/ui/issues/issue-18819.stderr +++ b/src/test/ui/issues/issue-18819.stderr @@ -1,8 +1,8 @@ error[E0061]: this function takes 2 parameters but 1 parameter was supplied --> $DIR/issue-18819.rs:16:5 | -LL | fn print_x(_: &Foo, extra: &str) { - | ------------------------------------------- defined here +LL | fn print_x(_: &dyn Foo, extra: &str) { + | ----------------------------------------------- defined here ... LL | print_x(X); | ^^^^^^^^^^ expected 2 parameters diff --git a/src/test/ui/issues/issue-18919.rs b/src/test/ui/issues/issue-18919.rs index 9db30849182..91fbb13cd69 100644 --- a/src/test/ui/issues/issue-18919.rs +++ b/src/test/ui/issues/issue-18919.rs @@ -1,4 +1,4 @@ -type FuncType<'f> = Fn(&isize) -> isize + 'f; +type FuncType<'f> = dyn Fn(&isize) -> isize + 'f; fn ho_func(f: Option) { //~^ ERROR the size for values of type diff --git a/src/test/ui/issues/issue-18937.rs b/src/test/ui/issues/issue-18937.rs index f3824765f23..ab4c9c736d8 100644 --- a/src/test/ui/issues/issue-18937.rs +++ b/src/test/ui/issues/issue-18937.rs @@ -6,7 +6,7 @@ use std::fmt; struct MyString<'a>(&'a String); struct B { - list: Vec>, + list: Vec>, } trait A<'a> { diff --git a/src/test/ui/issues/issue-18959.rs b/src/test/ui/issues/issue-18959.rs index b07800928bc..4b6f04e251b 100644 --- a/src/test/ui/issues/issue-18959.rs +++ b/src/test/ui/issues/issue-18959.rs @@ -8,13 +8,13 @@ impl Foo for Thing { } #[inline(never)] -fn foo(b: &Bar) { +fn foo(b: &dyn Bar) { //~^ ERROR E0038 b.foo(&0) } fn main() { let mut thing = Thing; - let test: &Bar = &mut thing; + let test: &dyn Bar = &mut thing; foo(test); } diff --git a/src/test/ui/issues/issue-18959.stderr b/src/test/ui/issues/issue-18959.stderr index 939390102c3..63c33b7f447 100644 --- a/src/test/ui/issues/issue-18959.stderr +++ b/src/test/ui/issues/issue-18959.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/issue-18959.rs:11:1 | -LL | fn foo(b: &Bar) { - | ^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn foo(b: &dyn Bar) { + | ^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `foo` has generic type parameters diff --git a/src/test/ui/issues/issue-18988.rs b/src/test/ui/issues/issue-18988.rs index e0393486649..7fe662e907d 100644 --- a/src/test/ui/issues/issue-18988.rs +++ b/src/test/ui/issues/issue-18988.rs @@ -3,7 +3,7 @@ pub trait Foo : Send { } pub struct MyFoo { - children: Vec>, + children: Vec>, } impl Foo for MyFoo { } diff --git a/src/test/ui/issues/issue-19380.rs b/src/test/ui/issues/issue-19380.rs index efbc5a0346a..5c10e2067e4 100644 --- a/src/test/ui/issues/issue-19380.rs +++ b/src/test/ui/issues/issue-19380.rs @@ -8,7 +8,7 @@ impl Qiz for Foo { } struct Bar { - foos: &'static [&'static (Qiz + 'static)] + foos: &'static [&'static (dyn Qiz + 'static)] //~^ ERROR E0038 } diff --git a/src/test/ui/issues/issue-19380.stderr b/src/test/ui/issues/issue-19380.stderr index 060e160f2e4..27e3ff57bf9 100644 --- a/src/test/ui/issues/issue-19380.stderr +++ b/src/test/ui/issues/issue-19380.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Qiz` cannot be made into an object --> $DIR/issue-19380.rs:11:3 | -LL | foos: &'static [&'static (Qiz + 'static)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qiz` cannot be made into an object +LL | foos: &'static [&'static (dyn Qiz + 'static)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qiz` cannot be made into an object | = note: method `qiz` has no receiver diff --git a/src/test/ui/issues/issue-19404.rs b/src/test/ui/issues/issue-19404.rs index cdec74fe968..59544393bae 100644 --- a/src/test/ui/issues/issue-19404.rs +++ b/src/test/ui/issues/issue-19404.rs @@ -12,10 +12,10 @@ trait Component: 'static {} impl Component for Engine {} trait Env { - fn get_component_type_id(&self, type_id: TypeId) -> Option>; + fn get_component_type_id(&self, type_id: TypeId) -> Option>; } -impl<'a> Env+'a { +impl<'a> dyn Env + 'a { fn get_component(&self) -> Option> { let x = self.get_component_type_id(TypeId::of::()); None @@ -23,13 +23,13 @@ impl<'a> Env+'a { } trait Figment { - fn init(&mut self, env: &Env); + fn init(&mut self, env: &dyn Env); } struct MyFigment; impl Figment for MyFigment { - fn init(&mut self, env: &Env) { + fn init(&mut self, env: &dyn Env) { let engine = env.get_component::(); } } diff --git a/src/test/ui/issues/issue-19482.rs b/src/test/ui/issues/issue-19482.rs index 6ba33490549..9e4b77d87f8 100644 --- a/src/test/ui/issues/issue-19482.rs +++ b/src/test/ui/issues/issue-19482.rs @@ -7,7 +7,7 @@ trait Foo { fn dummy(&self) { } } -fn bar(x: &Foo) {} +fn bar(x: &dyn Foo) {} //~^ ERROR the associated type `A` (from the trait `Foo`) must be specified pub fn main() {} diff --git a/src/test/ui/issues/issue-19482.stderr b/src/test/ui/issues/issue-19482.stderr index a8894f84e74..f1e5419c712 100644 --- a/src/test/ui/issues/issue-19482.stderr +++ b/src/test/ui/issues/issue-19482.stderr @@ -4,8 +4,8 @@ error[E0191]: the value of the associated type `A` (from the trait `Foo`) must b LL | type A; | ------- `A` defined here ... -LL | fn bar(x: &Foo) {} - | ^^^ associated type `A` must be specified +LL | fn bar(x: &dyn Foo) {} + | ^^^^^^^ associated type `A` must be specified error: aborting due to previous error diff --git a/src/test/ui/issues/issue-19538.rs b/src/test/ui/issues/issue-19538.rs index 9f0b08d6c35..7054ef41b1c 100644 --- a/src/test/ui/issues/issue-19538.rs +++ b/src/test/ui/issues/issue-19538.rs @@ -14,7 +14,7 @@ impl Bar for Thing { } fn main() { let mut thing = Thing; - let test: &mut Bar = &mut thing; + let test: &mut dyn Bar = &mut thing; //~^ ERROR E0038 //~| ERROR E0038 } diff --git a/src/test/ui/issues/issue-19538.stderr b/src/test/ui/issues/issue-19538.stderr index d0f05a41d4d..e5da0a9b0da 100644 --- a/src/test/ui/issues/issue-19538.stderr +++ b/src/test/ui/issues/issue-19538.stderr @@ -1,16 +1,16 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/issue-19538.rs:17:15 | -LL | let test: &mut Bar = &mut thing; - | ^^^^^^^^ the trait `Bar` cannot be made into an object +LL | let test: &mut dyn Bar = &mut thing; + | ^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `foo` has generic type parameters error[E0038]: the trait `Bar` cannot be made into an object - --> $DIR/issue-19538.rs:17:26 + --> $DIR/issue-19538.rs:17:30 | -LL | let test: &mut Bar = &mut thing; - | ^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | let test: &mut dyn Bar = &mut thing; + | ^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `foo` has generic type parameters = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&mut dyn Bar>` for `&mut Thing` diff --git a/src/test/ui/issues/issue-20396.rs b/src/test/ui/issues/issue-20396.rs index b6dfffbd69e..0e69b7f3d1e 100644 --- a/src/test/ui/issues/issue-20396.rs +++ b/src/test/ui/issues/issue-20396.rs @@ -10,7 +10,7 @@ trait Foo { enum Bar { Bla(T) } struct Baz<'a> { - inner: for<'b> Foo> + 'a, + inner: dyn for<'b> Foo> + 'a, } fn main() {} diff --git a/src/test/ui/issues/issue-20605.rs b/src/test/ui/issues/issue-20605.rs index 11a2a573ea6..17b7d32ebf5 100644 --- a/src/test/ui/issues/issue-20605.rs +++ b/src/test/ui/issues/issue-20605.rs @@ -1,4 +1,4 @@ -fn changer<'a>(mut things: Box>) { +fn changer<'a>(mut things: Box>) { for item in *things { *item = 0 } //~^ ERROR the size for values of type } diff --git a/src/test/ui/issues/issue-20692.rs b/src/test/ui/issues/issue-20692.rs index ea89bca78d0..2a05bba7b16 100644 --- a/src/test/ui/issues/issue-20692.rs +++ b/src/test/ui/issues/issue-20692.rs @@ -4,7 +4,7 @@ fn f(x: &T) { let _ = x //~^ ERROR `Array` cannot be made into an object as - &Array; + &dyn Array; //~^ ERROR `Array` cannot be made into an object } diff --git a/src/test/ui/issues/issue-20692.stderr b/src/test/ui/issues/issue-20692.stderr index acc223c0b2d..66309394a42 100644 --- a/src/test/ui/issues/issue-20692.stderr +++ b/src/test/ui/issues/issue-20692.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Array` cannot be made into an object --> $DIR/issue-20692.rs:7:5 | -LL | &Array; - | ^^^^^^ the trait `Array` cannot be made into an object +LL | &dyn Array; + | ^^^^^^^^^^ the trait `Array` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/issues/issue-20831-debruijn.rs b/src/test/ui/issues/issue-20831-debruijn.rs index 6d3c7331a45..ef4b1581fd8 100644 --- a/src/test/ui/issues/issue-20831-debruijn.rs +++ b/src/test/ui/issues/issue-20831-debruijn.rs @@ -12,7 +12,7 @@ pub trait Subscriber { pub trait Publisher<'a> { type Output; - fn subscribe(&mut self, _: Box + 'a>); + fn subscribe(&mut self, _: Box + 'a>); } pub trait Processor<'a> : Subscriber + Publisher<'a> { } @@ -20,12 +20,12 @@ pub trait Processor<'a> : Subscriber + Publisher<'a> { } impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { } struct MyStruct<'a> { - sub: Box + 'a> + sub: Box + 'a> } impl<'a> Publisher<'a> for MyStruct<'a> { type Output = u64; - fn subscribe(&mut self, t : Box::Output> + 'a>) { + fn subscribe(&mut self, t : Box::Output> + 'a>) { // Not obvious, but there is an implicit lifetime here -------^ //~^^ ERROR cannot infer //~| ERROR mismatched types diff --git a/src/test/ui/issues/issue-20831-debruijn.stderr b/src/test/ui/issues/issue-20831-debruijn.stderr index 70a395d0b89..64e3cdc64c1 100644 --- a/src/test/ui/issues/issue-20831-debruijn.stderr +++ b/src/test/ui/issues/issue-20831-debruijn.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -15,7 +15,7 @@ LL | | } note: the anonymous lifetime #2 defined on the method body at 28:5... --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -32,7 +32,7 @@ LL | impl<'a> Publisher<'a> for MyStruct<'a> { error[E0308]: mismatched types --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -51,7 +51,7 @@ LL | impl<'a> Publisher<'a> for MyStruct<'a> { note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 28:5 --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -63,7 +63,7 @@ LL | | } error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -75,7 +75,7 @@ LL | | } note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5... --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | diff --git a/src/test/ui/issues/issue-20939.rs b/src/test/ui/issues/issue-20939.rs index 259fff2e6c2..c0c22297897 100644 --- a/src/test/ui/issues/issue-20939.rs +++ b/src/test/ui/issues/issue-20939.rs @@ -1,6 +1,6 @@ trait Foo {} -impl<'a> Foo for Foo+'a {} +impl<'a> Foo for dyn Foo + 'a {} //~^ ERROR the object type `(dyn Foo + 'a)` automatically implements the trait `Foo` fn main() {} diff --git a/src/test/ui/issues/issue-20939.stderr b/src/test/ui/issues/issue-20939.stderr index d15a5196667..3819a21a2cf 100644 --- a/src/test/ui/issues/issue-20939.stderr +++ b/src/test/ui/issues/issue-20939.stderr @@ -1,8 +1,8 @@ error[E0371]: the object type `(dyn Foo + 'a)` automatically implements the trait `Foo` --> $DIR/issue-20939.rs:3:1 | -LL | impl<'a> Foo for Foo+'a {} - | ^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Foo + 'a)` automatically implements trait `Foo` +LL | impl<'a> Foo for dyn Foo + 'a {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Foo + 'a)` automatically implements trait `Foo` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21363.rs b/src/test/ui/issues/issue-21363.rs index 5e30db17c6d..12efce9496e 100644 --- a/src/test/ui/issues/issue-21363.rs +++ b/src/test/ui/issues/issue-21363.rs @@ -8,7 +8,7 @@ trait Iterator { fn dummy(&self) { } } -impl<'a, T> Iterator for &'a mut (Iterator + 'a) { +impl<'a, T> Iterator for &'a mut (dyn Iterator + 'a) { type Item = T; } diff --git a/src/test/ui/issues/issue-21950.rs b/src/test/ui/issues/issue-21950.rs index b902893bf82..0bc87824cce 100644 --- a/src/test/ui/issues/issue-21950.rs +++ b/src/test/ui/issues/issue-21950.rs @@ -2,7 +2,7 @@ use std::ops::Add; fn main() { let x = &10 as - &Add; + &dyn Add; //~^ ERROR E0393 //~| ERROR E0191 } diff --git a/src/test/ui/issues/issue-21950.stderr b/src/test/ui/issues/issue-21950.stderr index 7655e0811e0..9be7b052da3 100644 --- a/src/test/ui/issues/issue-21950.stderr +++ b/src/test/ui/issues/issue-21950.stderr @@ -1,16 +1,16 @@ error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-21950.rs:5:14 + --> $DIR/issue-21950.rs:5:18 | -LL | &Add; - | ^^^ missing reference to `Rhs` +LL | &dyn Add; + | ^^^ missing reference to `Rhs` | = note: because of the default `Self` reference, type parameters must be specified on object types error[E0191]: the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified --> $DIR/issue-21950.rs:5:14 | -LL | &Add; - | ^^^ associated type `Output` must be specified +LL | &dyn Add; + | ^^^^^^^ associated type `Output` must be specified error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-22034.rs b/src/test/ui/issues/issue-22034.rs index 75ac78ad24f..508c9c91b04 100644 --- a/src/test/ui/issues/issue-22034.rs +++ b/src/test/ui/issues/issue-22034.rs @@ -4,8 +4,8 @@ extern crate libc; fn main() { let ptr: *mut () = 0 as *mut _; - let _: &mut Fn() = unsafe { - &mut *(ptr as *mut Fn()) + let _: &mut dyn Fn() = unsafe { + &mut *(ptr as *mut dyn Fn()) //~^ ERROR expected a `std::ops::Fn<()>` closure, found `()` }; } diff --git a/src/test/ui/issues/issue-22034.stderr b/src/test/ui/issues/issue-22034.stderr index de2d315ff5c..19fb080154a 100644 --- a/src/test/ui/issues/issue-22034.stderr +++ b/src/test/ui/issues/issue-22034.stderr @@ -1,7 +1,7 @@ error[E0277]: expected a `std::ops::Fn<()>` closure, found `()` --> $DIR/issue-22034.rs:8:16 | -LL | &mut *(ptr as *mut Fn()) +LL | &mut *(ptr as *mut dyn Fn()) | ^^^ expected an `Fn<()>` closure, found `()` | = help: the trait `std::ops::Fn<()>` is not implemented for `()` diff --git a/src/test/ui/issues/issue-22289.rs b/src/test/ui/issues/issue-22289.rs index b683834de44..e1b3dfe5b61 100644 --- a/src/test/ui/issues/issue-22289.rs +++ b/src/test/ui/issues/issue-22289.rs @@ -1,3 +1,3 @@ fn main() { - 0 as &std::any::Any; //~ ERROR non-primitive cast + 0 as &dyn std::any::Any; //~ ERROR non-primitive cast } diff --git a/src/test/ui/issues/issue-22289.stderr b/src/test/ui/issues/issue-22289.stderr index e9846b848f4..cc7ace30cab 100644 --- a/src/test/ui/issues/issue-22289.stderr +++ b/src/test/ui/issues/issue-22289.stderr @@ -1,8 +1,8 @@ error[E0605]: non-primitive cast: `i32` as `&(dyn std::any::Any + 'static)` --> $DIR/issue-22289.rs:2:5 | -LL | 0 as &std::any::Any; - | ^^^^^^^^^^^^^^^^^^^ +LL | 0 as &dyn std::any::Any; + | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait diff --git a/src/test/ui/issues/issue-22312.rs b/src/test/ui/issues/issue-22312.rs index f7ebdb0372a..250fec25887 100644 --- a/src/test/ui/issues/issue-22312.rs +++ b/src/test/ui/issues/issue-22312.rs @@ -8,7 +8,7 @@ pub trait Array2D: Index { return None; } let i = y * self.columns() + x; - let indexer = &(*self as &Index>::Output>); + let indexer = &(*self as &dyn Index>::Output>); //~^ERROR non-primitive cast Some(indexer.index(i)) } diff --git a/src/test/ui/issues/issue-22312.stderr b/src/test/ui/issues/issue-22312.stderr index 6a012b214c5..fc32fd376b7 100644 --- a/src/test/ui/issues/issue-22312.stderr +++ b/src/test/ui/issues/issue-22312.stderr @@ -1,8 +1,8 @@ error[E0605]: non-primitive cast: `Self` as `&dyn std::ops::Index>::Output>` --> $DIR/issue-22312.rs:11:24 | -LL | let indexer = &(*self as &Index>::Output>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let indexer = &(*self as &dyn Index>::Output>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait diff --git a/src/test/ui/issues/issue-22370.rs b/src/test/ui/issues/issue-22370.rs index 90912cfda0d..bab0469c011 100644 --- a/src/test/ui/issues/issue-22370.rs +++ b/src/test/ui/issues/issue-22370.rs @@ -1,6 +1,6 @@ trait A {} -fn f(a: &A) {} +fn f(a: &dyn A) {} //~^ ERROR E0393 fn main() {} diff --git a/src/test/ui/issues/issue-22370.stderr b/src/test/ui/issues/issue-22370.stderr index f21551a55bc..3ce164e9548 100644 --- a/src/test/ui/issues/issue-22370.stderr +++ b/src/test/ui/issues/issue-22370.stderr @@ -1,8 +1,8 @@ error[E0393]: the type parameter `T` must be explicitly specified - --> $DIR/issue-22370.rs:3:10 + --> $DIR/issue-22370.rs:3:14 | -LL | fn f(a: &A) {} - | ^ missing reference to `T` +LL | fn f(a: &dyn A) {} + | ^ missing reference to `T` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/issues/issue-22434.rs b/src/test/ui/issues/issue-22434.rs index 0d7d67cbc1b..3e800a2b61d 100644 --- a/src/test/ui/issues/issue-22434.rs +++ b/src/test/ui/issues/issue-22434.rs @@ -2,7 +2,7 @@ pub trait Foo { type A; } -type I<'a> = &'a (Foo + 'a); +type I<'a> = &'a (dyn Foo + 'a); //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified fn main() {} diff --git a/src/test/ui/issues/issue-22434.stderr b/src/test/ui/issues/issue-22434.stderr index bbdbeb6ae98..eb78c4fc311 100644 --- a/src/test/ui/issues/issue-22434.stderr +++ b/src/test/ui/issues/issue-22434.stderr @@ -4,8 +4,8 @@ error[E0191]: the value of the associated type `A` (from the trait `Foo`) must b LL | type A; | ------- `A` defined here ... -LL | type I<'a> = &'a (Foo + 'a); - | ^^^^^^^^ associated type `A` must be specified +LL | type I<'a> = &'a (dyn Foo + 'a); + | ^^^^^^^^^^^^ associated type `A` must be specified error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22560.rs b/src/test/ui/issues/issue-22560.rs index 4b8e3aa9eb3..acee99dbedc 100644 --- a/src/test/ui/issues/issue-22560.rs +++ b/src/test/ui/issues/issue-22560.rs @@ -1,6 +1,6 @@ use std::ops::{Add, Sub}; -type Test = Add + +type Test = dyn Add + //~^ ERROR E0393 //~| ERROR E0191 Sub; diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/issues/issue-22560.stderr index 322136d35ca..5b58adb197c 100644 --- a/src/test/ui/issues/issue-22560.stderr +++ b/src/test/ui/issues/issue-22560.stderr @@ -7,21 +7,21 @@ LL | Sub; = note: because of the default `Self` reference, type parameters must be specified on object types error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-22560.rs:3:13 + --> $DIR/issue-22560.rs:3:17 | -LL | type Test = Add + - | ^^^ missing reference to `Rhs` +LL | type Test = dyn Add + + | ^^^ missing reference to `Rhs` | = note: because of the default `Self` reference, type parameters must be specified on object types error[E0225]: only auto traits can be used as additional traits in a trait object --> $DIR/issue-22560.rs:6:13 | -LL | type Test = Add + - | --- - | | - | first non-auto trait - | trait alias used in trait object type (first use) +LL | type Test = dyn Add + + | --- + | | + | first non-auto trait + | trait alias used in trait object type (first use) ... LL | Sub; | ^^^ @@ -32,7 +32,7 @@ LL | Sub; error[E0191]: the value of the associated types `Output` (from the trait `std::ops::Add`), `Output` (from the trait `std::ops::Sub`) must be specified --> $DIR/issue-22560.rs:3:13 | -LL | type Test = Add + +LL | type Test = dyn Add + | _____________^ | |_____________| | | diff --git a/src/test/ui/issues/issue-22781.rs b/src/test/ui/issues/issue-22781.rs index 5df3d88b168..a7b94c106a4 100644 --- a/src/test/ui/issues/issue-22781.rs +++ b/src/test/ui/issues/issue-22781.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use std::collections::hash_map::Entry::Vacant; pub fn foo() { - type F = Box; + type F = Box; let mut map: HashMap<(), F> = HashMap::new(); let x: &mut F = match map.entry(()) { Vacant(_) => unimplemented!(), diff --git a/src/test/ui/issues/issue-22872.rs b/src/test/ui/issues/issue-22872.rs index 8ef4af15bd4..5db2891e65e 100644 --- a/src/test/ui/issues/issue-22872.rs +++ b/src/test/ui/issues/issue-22872.rs @@ -17,7 +17,7 @@ pub trait Process<'a> { } fn push_process

(process: P) where P: Process<'static> { - let _: Box Wrap<'b>> = Box::new(Wrapper(process)); + let _: Box Wrap<'b>> = Box::new(Wrapper(process)); //~^ ERROR is not an iterator } diff --git a/src/test/ui/issues/issue-22872.stderr b/src/test/ui/issues/issue-22872.stderr index ebd096f1dde..fc5de23752b 100644 --- a/src/test/ui/issues/issue-22872.stderr +++ b/src/test/ui/issues/issue-22872.stderr @@ -1,8 +1,8 @@ error[E0277]: `

>::Item` is not an iterator - --> $DIR/issue-22872.rs:20:36 + --> $DIR/issue-22872.rs:20:40 | -LL | let _: Box Wrap<'b>> = Box::new(Wrapper(process)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `

>::Item` is not an iterator +LL | let _: Box Wrap<'b>> = Box::new(Wrapper(process)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `

>::Item` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `

>::Item` = help: consider adding a `where

>::Item: std::iter::Iterator` bound diff --git a/src/test/ui/issues/issue-23024.rs b/src/test/ui/issues/issue-23024.rs index 0639ce30aa0..2638e15f0ea 100644 --- a/src/test/ui/issues/issue-23024.rs +++ b/src/test/ui/issues/issue-23024.rs @@ -4,9 +4,9 @@ use std::any::Any; fn main() { fn h(x:i32) -> i32 {3*x} - let mut vfnfer:Vec> = vec![]; + let mut vfnfer:Vec> = vec![]; vfnfer.push(box h); - println!("{:?}",(vfnfer[0] as Fn)(3)); + println!("{:?}",(vfnfer[0] as dyn Fn)(3)); //~^ ERROR the precise format of `Fn`-family traits' //~| ERROR wrong number of type arguments: expected 1, found 0 [E0107] //~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`) diff --git a/src/test/ui/issues/issue-23024.stderr b/src/test/ui/issues/issue-23024.stderr index fbefbe4f56e..e99854539de 100644 --- a/src/test/ui/issues/issue-23024.stderr +++ b/src/test/ui/issues/issue-23024.stderr @@ -1,23 +1,23 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead - --> $DIR/issue-23024.rs:9:35 + --> $DIR/issue-23024.rs:9:39 | -LL | println!("{:?}",(vfnfer[0] as Fn)(3)); - | ^^ +LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); + | ^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add #![feature(unboxed_closures)] to the crate attributes to enable error[E0107]: wrong number of type arguments: expected 1, found 0 - --> $DIR/issue-23024.rs:9:35 + --> $DIR/issue-23024.rs:9:39 | -LL | println!("{:?}",(vfnfer[0] as Fn)(3)); - | ^^ expected 1 type argument +LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); + | ^^ expected 1 type argument error[E0191]: the value of the associated type `Output` (from the trait `std::ops::FnOnce`) must be specified --> $DIR/issue-23024.rs:9:35 | -LL | println!("{:?}",(vfnfer[0] as Fn)(3)); - | ^^ associated type `Output` must be specified +LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); + | ^^^^^^ associated type `Output` must be specified error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-23041.rs b/src/test/ui/issues/issue-23041.rs index a18e85806d9..a1371521a0a 100644 --- a/src/test/ui/issues/issue-23041.rs +++ b/src/test/ui/issues/issue-23041.rs @@ -2,6 +2,6 @@ use std::any::Any; fn main() { fn bar(x:i32) ->i32 { 3*x }; - let b:Box = Box::new(bar as fn(_)->_); + let b:Box = Box::new(bar as fn(_)->_); b.downcast_ref::_>(); //~ ERROR E0282 } diff --git a/src/test/ui/issues/issue-23046.rs b/src/test/ui/issues/issue-23046.rs index 898654b7b59..a68369616d8 100644 --- a/src/test/ui/issues/issue-23046.rs +++ b/src/test/ui/issues/issue-23046.rs @@ -1,6 +1,6 @@ pub enum Expr<'var, VAR> { Let(Box>, - Box Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>) + Box Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>) } pub fn add<'var, VAR> diff --git a/src/test/ui/issues/issue-23281.rs b/src/test/ui/issues/issue-23281.rs index 2b457a57d3e..d5f74728862 100644 --- a/src/test/ui/issues/issue-23281.rs +++ b/src/test/ui/issues/issue-23281.rs @@ -1,7 +1,7 @@ pub struct Struct; impl Struct { - pub fn function(funs: Vec ()>) {} + pub fn function(funs: Vec ()>) {} //~^ ERROR the size for values of type } diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index e540d4e8192..f1def474583 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `(dyn std::ops::Fn() + 'static)` cannot be known at compilation time --> $DIR/issue-23281.rs:4:5 | -LL | pub fn function(funs: Vec ()>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +LL | pub fn function(funs: Vec ()>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() + 'static)` = note: to learn more, visit diff --git a/src/test/ui/issues/issue-24446.rs b/src/test/ui/issues/issue-24446.rs index c5e1b49e5ed..ffd6dfabc28 100644 --- a/src/test/ui/issues/issue-24446.rs +++ b/src/test/ui/issues/issue-24446.rs @@ -1,5 +1,5 @@ fn main() { - static foo: Fn() -> u32 = || -> u32 { + static foo: dyn Fn() -> u32 = || -> u32 { //~^ ERROR the size for values of type 0 }; diff --git a/src/test/ui/issues/issue-24446.stderr b/src/test/ui/issues/issue-24446.stderr index ffec73b1ab4..344443e7830 100644 --- a/src/test/ui/issues/issue-24446.stderr +++ b/src/test/ui/issues/issue-24446.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `(dyn std::ops::Fn() -> u32 + 'static)` cannot be known at compilation time --> $DIR/issue-24446.rs:2:17 | -LL | static foo: Fn() -> u32 = || -> u32 { - | ^^^^^^^^^^^ doesn't have a size known at compile-time +LL | static foo: dyn Fn() -> u32 = || -> u32 { + | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() -> u32 + 'static)` = note: to learn more, visit diff --git a/src/test/ui/issues/issue-25180.rs b/src/test/ui/issues/issue-25180.rs index 739d571d727..297f403c05e 100644 --- a/src/test/ui/issues/issue-25180.rs +++ b/src/test/ui/issues/issue-25180.rs @@ -2,6 +2,6 @@ #![allow(dead_code)] #![allow(non_upper_case_globals)] -const x: &'static Fn() = &|| println!("ICE here"); +const x: &'static dyn Fn() = &|| println!("ICE here"); fn main() {} diff --git a/src/test/ui/issues/issue-26056.rs b/src/test/ui/issues/issue-26056.rs index 0d9973b4548..99d43ec792b 100644 --- a/src/test/ui/issues/issue-26056.rs +++ b/src/test/ui/issues/issue-26056.rs @@ -17,6 +17,6 @@ impl Map for K { fn main() { let _ = &() - as &Map; + as &dyn Map; //~^ ERROR E0038 } diff --git a/src/test/ui/issues/issue-26056.stderr b/src/test/ui/issues/issue-26056.stderr index 44fabd0db19..9c4cf0b18ac 100644 --- a/src/test/ui/issues/issue-26056.stderr +++ b/src/test/ui/issues/issue-26056.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Map` cannot be made into an object --> $DIR/issue-26056.rs:20:13 | -LL | as &Map; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Map` cannot be made into an object +LL | as &dyn Map; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Map` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/issues/issue-26638.rs b/src/test/ui/issues/issue-26638.rs index 0f5ed5caa74..72fe4286a06 100644 --- a/src/test/ui/issues/issue-26638.rs +++ b/src/test/ui/issues/issue-26638.rs @@ -1,4 +1,4 @@ -fn parse_type(iter: Box+'static>) -> &str { iter.next() } +fn parse_type(iter: Box+'static>) -> &str { iter.next() } //~^ ERROR missing lifetime specifier [E0106] fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } diff --git a/src/test/ui/issues/issue-26638.stderr b/src/test/ui/issues/issue-26638.stderr index 64c2cd43264..6d7c1b0c43f 100644 --- a/src/test/ui/issues/issue-26638.stderr +++ b/src/test/ui/issues/issue-26638.stderr @@ -1,8 +1,8 @@ error[E0106]: missing lifetime specifier - --> $DIR/issue-26638.rs:1:58 + --> $DIR/issue-26638.rs:1:62 | -LL | fn parse_type(iter: Box+'static>) -> &str { iter.next() } - | ^ expected lifetime parameter +LL | fn parse_type(iter: Box+'static>) -> &str { iter.next() } + | ^ expected lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say which one of `iter`'s 2 lifetimes it is borrowed from diff --git a/src/test/ui/issues/issue-26905.rs b/src/test/ui/issues/issue-26905.rs index efd06219c3d..4c5c67d58bc 100644 --- a/src/test/ui/issues/issue-26905.rs +++ b/src/test/ui/issues/issue-26905.rs @@ -19,5 +19,5 @@ fn main() { let data = [1, 2, 3]; let iter = data.iter(); let x = MyRc { _ptr: &iter, _boo: NotPhantomData(PhantomData) }; - let _y: MyRc> = x; + let _y: MyRc> = x; } diff --git a/src/test/ui/issues/issue-27105.rs b/src/test/ui/issues/issue-27105.rs index 5f0dff12aec..1aafa11768f 100644 --- a/src/test/ui/issues/issue-27105.rs +++ b/src/test/ui/issues/issue-27105.rs @@ -3,7 +3,7 @@ use std::cell::RefCell; use std::rc::Rc; pub struct Callbacks { - callbacks: Vec>>, + callbacks: Vec>>, } impl Callbacks { diff --git a/src/test/ui/issues/issue-28279.rs b/src/test/ui/issues/issue-28279.rs index c770c509859..fab91160a88 100644 --- a/src/test/ui/issues/issue-28279.rs +++ b/src/test/ui/issues/issue-28279.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] use std::rc::Rc; -fn test1() -> Rc Fn(&'a usize) + 'static> { +fn test1() -> Rc Fn(&'a usize) + 'static> { if let Some(_) = Some(1) { loop{} } else { @@ -10,7 +10,7 @@ fn test1() -> Rc Fn(&'a usize) + 'static> { } } -fn test2() -> *mut (for<'a> Fn(&'a usize) + 'static) { +fn test2() -> *mut (dyn for<'a> Fn(&'a usize) + 'static) { if let Some(_) = Some(1) { loop{} } else { diff --git a/src/test/ui/issues/issue-28576.rs b/src/test/ui/issues/issue-28576.rs index de665d5aa16..972c839b648 100644 --- a/src/test/ui/issues/issue-28576.rs +++ b/src/test/ui/issues/issue-28576.rs @@ -4,7 +4,7 @@ pub trait Foo { pub trait Bar: Foo { fn new(&self, b: & - Bar //~ ERROR the trait `Bar` cannot be made into an object + dyn Bar //~ ERROR the trait `Bar` cannot be made into an object ); } diff --git a/src/test/ui/issues/issue-28576.stderr b/src/test/ui/issues/issue-28576.stderr index cf6174ba857..3249d76e69b 100644 --- a/src/test/ui/issues/issue-28576.stderr +++ b/src/test/ui/issues/issue-28576.stderr @@ -1,7 +1,7 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/issue-28576.rs:7:12 | -LL | / Bar +LL | / dyn Bar LL | | | |________________________^ the trait `Bar` cannot be made into an object | diff --git a/src/test/ui/issues/issue-2904.rs b/src/test/ui/issues/issue-2904.rs index 7755b7ecee3..42f71a1b096 100644 --- a/src/test/ui/issues/issue-2904.rs +++ b/src/test/ui/issues/issue-2904.rs @@ -55,7 +55,7 @@ fn square_from_char(c: char) -> square { fn read_board_grid(mut input: rdr) -> Vec> { - let mut input: &mut Read = &mut input; + let mut input: &mut dyn Read = &mut input; let mut grid = Vec::new(); let mut line = [0; 10]; input.read(&mut line); diff --git a/src/test/ui/issues/issue-32963.rs b/src/test/ui/issues/issue-32963.rs index be59d3522b8..ee099069f02 100644 --- a/src/test/ui/issues/issue-32963.rs +++ b/src/test/ui/issues/issue-32963.rs @@ -5,7 +5,7 @@ trait Misc {} fn size_of_copy() -> usize { mem::size_of::() } fn main() { - size_of_copy::(); + size_of_copy::(); //~^ ERROR only auto traits can be used as additional traits in a trait object //~| ERROR the trait bound `dyn Misc: std::marker::Copy` is not satisfied } diff --git a/src/test/ui/issues/issue-32963.stderr b/src/test/ui/issues/issue-32963.stderr index cde4123dc3f..a31a74a07f4 100644 --- a/src/test/ui/issues/issue-32963.stderr +++ b/src/test/ui/issues/issue-32963.stderr @@ -1,19 +1,19 @@ error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/issue-32963.rs:8:25 + --> $DIR/issue-32963.rs:8:31 | -LL | size_of_copy::(); - | ---- ^^^^ - | | | - | | additional non-auto trait - | | trait alias used in trait object type (additional use) - | first non-auto trait - | trait alias used in trait object type (first use) +LL | size_of_copy::(); + | ---- ^^^^ + | | | + | | additional non-auto trait + | | trait alias used in trait object type (additional use) + | first non-auto trait + | trait alias used in trait object type (first use) error[E0277]: the trait bound `dyn Misc: std::marker::Copy` is not satisfied --> $DIR/issue-32963.rs:8:5 | -LL | size_of_copy::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `dyn Misc` +LL | size_of_copy::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `dyn Misc` | note: required by `size_of_copy` --> $DIR/issue-32963.rs:5:1 diff --git a/src/test/ui/issues/issue-32995.rs b/src/test/ui/issues/issue-32995.rs index c32fb63f1e5..3526deffc79 100644 --- a/src/test/ui/issues/issue-32995.rs +++ b/src/test/ui/issues/issue-32995.rs @@ -17,11 +17,11 @@ fn main() { //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait //~| WARN previously accepted - let o : Box<::std::marker()::Send> = Box::new(1); + let o : Box = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait //~| WARN previously accepted - let o : Box = Box::new(1); + let o : Box = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait //~| WARN previously accepted } diff --git a/src/test/ui/issues/issue-32995.stderr b/src/test/ui/issues/issue-32995.stderr index 97b4b7fa76c..f97d86f6522 100644 --- a/src/test/ui/issues/issue-32995.stderr +++ b/src/test/ui/issues/issue-32995.stderr @@ -36,19 +36,19 @@ LL | let p = ::std::str::from_utf8::()(b"foo").unwrap(); = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:20:30 + --> $DIR/issue-32995.rs:20:35 | -LL | let o : Box<::std::marker()::Send> = Box::new(1); - | ^^ +LL | let o : Box = Box::new(1); + | ^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:24:37 + --> $DIR/issue-32995.rs:24:41 | -LL | let o : Box = Box::new(1); - | ^^ +LL | let o : Box = Box::new(1); + | ^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 diff --git a/src/test/ui/issues/issue-33140-traitobject-crate.rs b/src/test/ui/issues/issue-33140-traitobject-crate.rs index 2b644817df1..078f3f3dd2c 100644 --- a/src/test/ui/issues/issue-33140-traitobject-crate.rs +++ b/src/test/ui/issues/issue-33140-traitobject-crate.rs @@ -13,85 +13,85 @@ /// Implementations for all traits in std are provided. pub unsafe trait Trait {} -unsafe impl Trait for ::std::any::Any + Send { } -unsafe impl Trait for ::std::any::Any + Sync { } -unsafe impl Trait for ::std::any::Any + Send + Sync { } -unsafe impl Trait for ::std::borrow::Borrow + Send { } -unsafe impl Trait for ::std::borrow::Borrow + Sync { } -unsafe impl Trait for ::std::borrow::Borrow + Send + Sync { } -unsafe impl Trait for ::std::borrow::BorrowMut + Send { } -unsafe impl Trait for ::std::borrow::BorrowMut + Sync { } -unsafe impl Trait for ::std::borrow::BorrowMut + Send + Sync { } -unsafe impl Trait for ::std::convert::AsMut + Send { } -unsafe impl Trait for ::std::convert::AsMut + Sync { } -unsafe impl Trait for ::std::convert::AsMut + Send + Sync { } -unsafe impl Trait for ::std::convert::AsRef + Send { } -unsafe impl Trait for ::std::convert::AsRef + Sync { } -unsafe impl Trait for ::std::convert::AsRef + Send + Sync { } -unsafe impl Trait for ::std::error::Error + Send { } -unsafe impl Trait for ::std::error::Error + Sync { } -unsafe impl Trait for ::std::error::Error + Send + Sync { } -unsafe impl Trait for ::std::fmt::Binary + Send { } -unsafe impl Trait for ::std::fmt::Binary + Sync { } -unsafe impl Trait for ::std::fmt::Binary + Send + Sync { } -unsafe impl Trait for ::std::fmt::Debug + Send { } -unsafe impl Trait for ::std::fmt::Debug + Sync { } -unsafe impl Trait for ::std::fmt::Debug + Send + Sync { } -unsafe impl Trait for ::std::fmt::Display + Send { } -unsafe impl Trait for ::std::fmt::Display + Sync { } -unsafe impl Trait for ::std::fmt::Display + Send + Sync { } -unsafe impl Trait for ::std::fmt::LowerExp + Send { } -unsafe impl Trait for ::std::fmt::LowerExp + Sync { } -unsafe impl Trait for ::std::fmt::LowerExp + Send + Sync { } -unsafe impl Trait for ::std::fmt::LowerHex + Send { } -unsafe impl Trait for ::std::fmt::LowerHex + Sync { } -unsafe impl Trait for ::std::fmt::LowerHex + Send + Sync { } -unsafe impl Trait for ::std::fmt::Octal + Send { } -unsafe impl Trait for ::std::fmt::Octal + Sync { } -unsafe impl Trait for ::std::fmt::Octal + Send + Sync { } -unsafe impl Trait for ::std::fmt::Pointer + Send { } -unsafe impl Trait for ::std::fmt::Pointer + Sync { } -unsafe impl Trait for ::std::fmt::Pointer + Send + Sync { } -unsafe impl Trait for ::std::fmt::UpperExp + Send { } -unsafe impl Trait for ::std::fmt::UpperExp + Sync { } -unsafe impl Trait for ::std::fmt::UpperExp + Send + Sync { } -unsafe impl Trait for ::std::fmt::UpperHex + Send { } -unsafe impl Trait for ::std::fmt::UpperHex + Sync { } -unsafe impl Trait for ::std::fmt::UpperHex + Send + Sync { } -unsafe impl Trait for ::std::fmt::Write + Send { } -unsafe impl Trait for ::std::fmt::Write + Sync { } -unsafe impl Trait for ::std::fmt::Write + Send + Sync { } -unsafe impl Trait for ::std::hash::Hasher + Send { } -unsafe impl Trait for ::std::hash::Hasher + Sync { } -unsafe impl Trait for ::std::hash::Hasher + Send + Sync { } -unsafe impl Trait for ::std::io::BufRead + Send { } -unsafe impl Trait for ::std::io::BufRead + Sync { } -unsafe impl Trait for ::std::io::BufRead + Send + Sync { } -unsafe impl Trait for ::std::io::Read + Send { } -unsafe impl Trait for ::std::io::Read + Sync { } -unsafe impl Trait for ::std::io::Read + Send + Sync { } -unsafe impl Trait for ::std::io::Seek + Send { } -unsafe impl Trait for ::std::io::Seek + Sync { } -unsafe impl Trait for ::std::io::Seek + Send + Sync { } -unsafe impl Trait for ::std::io::Write + Send { } -unsafe impl Trait for ::std::io::Write + Sync { } -unsafe impl Trait for ::std::io::Write + Send + Sync { } -unsafe impl Trait for ::std::iter::IntoIterator { } -unsafe impl Trait for ::std::iter::Iterator + Send { } -unsafe impl Trait for ::std::iter::Iterator + Sync { } -unsafe impl Trait for ::std::iter::Iterator + Send + Sync { } -unsafe impl Trait for ::std::marker::Send + Send { } -unsafe impl Trait for ::std::marker::Send + Sync { } -unsafe impl Trait for ::std::marker::Send + Send + Sync { } -unsafe impl Trait for ::std::marker::Sync + Send { } -unsafe impl Trait for ::std::marker::Sync + Sync { } -unsafe impl Trait for ::std::marker::Sync + Send + Sync { } -unsafe impl Trait for ::std::ops::Drop + Send { } -unsafe impl Trait for ::std::ops::Drop + Sync { } -unsafe impl Trait for ::std::ops::Drop + Send + Sync { } -unsafe impl Trait for ::std::string::ToString + Send { } -unsafe impl Trait for ::std::string::ToString + Sync { } -unsafe impl Trait for ::std::string::ToString + Send + Sync { } +unsafe impl Trait for dyn (::std::any::Any) + Send { } +unsafe impl Trait for dyn (::std::any::Any) + Sync { } +unsafe impl Trait for dyn (::std::any::Any) + Send + Sync { } +unsafe impl Trait for dyn (::std::borrow::Borrow) + Send { } +unsafe impl Trait for dyn (::std::borrow::Borrow) + Sync { } +unsafe impl Trait for dyn (::std::borrow::Borrow) + Send + Sync { } +unsafe impl Trait for dyn (::std::borrow::BorrowMut) + Send { } +unsafe impl Trait for dyn (::std::borrow::BorrowMut) + Sync { } +unsafe impl Trait for dyn (::std::borrow::BorrowMut) + Send + Sync { } +unsafe impl Trait for dyn (::std::convert::AsMut) + Send { } +unsafe impl Trait for dyn (::std::convert::AsMut) + Sync { } +unsafe impl Trait for dyn (::std::convert::AsMut) + Send + Sync { } +unsafe impl Trait for dyn (::std::convert::AsRef) + Send { } +unsafe impl Trait for dyn (::std::convert::AsRef) + Sync { } +unsafe impl Trait for dyn (::std::convert::AsRef) + Send + Sync { } +unsafe impl Trait for dyn (::std::error::Error) + Send { } +unsafe impl Trait for dyn (::std::error::Error) + Sync { } +unsafe impl Trait for dyn (::std::error::Error) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Binary) + Send { } +unsafe impl Trait for dyn (::std::fmt::Binary) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Binary) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Debug) + Send { } +unsafe impl Trait for dyn (::std::fmt::Debug) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Debug) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Display) + Send { } +unsafe impl Trait for dyn (::std::fmt::Display) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Display) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::LowerExp) + Send { } +unsafe impl Trait for dyn (::std::fmt::LowerExp) + Sync { } +unsafe impl Trait for dyn (::std::fmt::LowerExp) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::LowerHex) + Send { } +unsafe impl Trait for dyn (::std::fmt::LowerHex) + Sync { } +unsafe impl Trait for dyn (::std::fmt::LowerHex) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Octal) + Send { } +unsafe impl Trait for dyn (::std::fmt::Octal) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Octal) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Pointer) + Send { } +unsafe impl Trait for dyn (::std::fmt::Pointer) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Pointer) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::UpperExp) + Send { } +unsafe impl Trait for dyn (::std::fmt::UpperExp) + Sync { } +unsafe impl Trait for dyn (::std::fmt::UpperExp) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::UpperHex) + Send { } +unsafe impl Trait for dyn (::std::fmt::UpperHex) + Sync { } +unsafe impl Trait for dyn (::std::fmt::UpperHex) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Write) + Send { } +unsafe impl Trait for dyn (::std::fmt::Write) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Write) + Send + Sync { } +unsafe impl Trait for dyn (::std::hash::Hasher) + Send { } +unsafe impl Trait for dyn (::std::hash::Hasher) + Sync { } +unsafe impl Trait for dyn (::std::hash::Hasher) + Send + Sync { } +unsafe impl Trait for dyn (::std::io::BufRead) + Send { } +unsafe impl Trait for dyn (::std::io::BufRead) + Sync { } +unsafe impl Trait for dyn (::std::io::BufRead) + Send + Sync { } +unsafe impl Trait for dyn (::std::io::Read) + Send { } +unsafe impl Trait for dyn (::std::io::Read) + Sync { } +unsafe impl Trait for dyn (::std::io::Read) + Send + Sync { } +unsafe impl Trait for dyn (::std::io::Seek) + Send { } +unsafe impl Trait for dyn (::std::io::Seek) + Sync { } +unsafe impl Trait for dyn (::std::io::Seek) + Send + Sync { } +unsafe impl Trait for dyn (::std::io::Write) + Send { } +unsafe impl Trait for dyn (::std::io::Write) + Sync { } +unsafe impl Trait for dyn (::std::io::Write) + Send + Sync { } +unsafe impl Trait for dyn (::std::iter::IntoIterator) { } +unsafe impl Trait for dyn (::std::iter::Iterator) + Send { } +unsafe impl Trait for dyn (::std::iter::Iterator) + Sync { } +unsafe impl Trait for dyn (::std::iter::Iterator) + Send + Sync { } +unsafe impl Trait for dyn (::std::marker::Send) + Send { } +unsafe impl Trait for dyn (::std::marker::Send) + Sync { } +unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } +unsafe impl Trait for dyn (::std::marker::Sync) + Send { } +unsafe impl Trait for dyn (::std::marker::Sync) + Sync { } +unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } +unsafe impl Trait for dyn (::std::ops::Drop) + Send { } +unsafe impl Trait for dyn (::std::ops::Drop) + Sync { } +unsafe impl Trait for dyn (::std::ops::Drop) + Send + Sync { } +unsafe impl Trait for dyn (::std::string::ToString) + Send { } +unsafe impl Trait for dyn (::std::string::ToString) + Sync { } +unsafe impl Trait for dyn (::std::string::ToString) + Send + Sync { } fn assert_trait() {} fn main() { diff --git a/src/test/ui/issues/issue-33140-traitobject-crate.stderr b/src/test/ui/issues/issue-33140-traitobject-crate.stderr index 6f71e79d0ee..76db98aa38b 100644 --- a/src/test/ui/issues/issue-33140-traitobject-crate.stderr +++ b/src/test/ui/issues/issue-33140-traitobject-crate.stderr @@ -1,10 +1,10 @@ warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:85:1 | -LL | unsafe impl Trait for ::std::marker::Send + Sync { } - | ------------------------------------------------ first implementation here -LL | unsafe impl Trait for ::std::marker::Send + Send + Sync { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` +LL | unsafe impl Trait for dyn (::std::marker::Send) + Sync { } + | ------------------------------------------------------ first implementation here +LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` | note: lint level defined here --> $DIR/issue-33140-traitobject-crate.rs:3:9 @@ -17,10 +17,10 @@ LL | #![warn(order_dependent_trait_objects)] warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:86:1 | -LL | unsafe impl Trait for ::std::marker::Send + Send + Sync { } - | ------------------------------------------------------- first implementation here -LL | unsafe impl Trait for ::std::marker::Sync + Send { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` +LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } + | ------------------------------------------------------------- first implementation here +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 @@ -28,11 +28,11 @@ LL | unsafe impl Trait for ::std::marker::Sync + Send { } warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:88:1 | -LL | unsafe impl Trait for ::std::marker::Sync + Send { } - | ------------------------------------------------ first implementation here -LL | unsafe impl Trait for ::std::marker::Sync + Sync { } -LL | unsafe impl Trait for ::std::marker::Sync + Send + Sync { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } + | ------------------------------------------------------ first implementation here +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Sync { } +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 diff --git a/src/test/ui/issues/issue-33140.rs b/src/test/ui/issues/issue-33140.rs index 930e24218ac..9bdac4b8375 100644 --- a/src/test/ui/issues/issue-33140.rs +++ b/src/test/ui/issues/issue-33140.rs @@ -38,10 +38,10 @@ impl Foo { } fn main() { - assert_eq!(::xyz(), false); - assert_eq!(::xyz(), true); - assert_eq!(::uvw(), false); - assert_eq!(::uvw(), true); - assert_eq!(>::abc(), false); - assert_eq!(>::abc(), true); + assert_eq!(::xyz(), false); + assert_eq!(::xyz(), true); + assert_eq!(::uvw(), false); + assert_eq!(::uvw(), true); + assert_eq!(>::abc(), false); + assert_eq!(>::abc(), true); } diff --git a/src/test/ui/issues/issue-33241.rs b/src/test/ui/issues/issue-33241.rs index 4c5052a60d3..4d6204cb288 100644 --- a/src/test/ui/issues/issue-33241.rs +++ b/src/test/ui/issues/issue-33241.rs @@ -9,6 +9,6 @@ fn any() -> T { unreachable!() } fn main() { - let t: &(u8, fmt::Debug) = any(); + let t: &(u8, dyn fmt::Debug) = any(); println!("{:?}", &t.1); } diff --git a/src/test/ui/issues/issue-3424.rs b/src/test/ui/issues/issue-3424.rs index a9ba5f5408b..19f9f13e144 100644 --- a/src/test/ui/issues/issue-3424.rs +++ b/src/test/ui/issues/issue-3424.rs @@ -5,7 +5,7 @@ pub struct Path; -type rsrc_loader = Box Result>; +type rsrc_loader = Box Result>; fn tester() { diff --git a/src/test/ui/issues/issue-35139.rs b/src/test/ui/issues/issue-35139.rs index 1ee00fc7ec2..e462f354373 100644 --- a/src/test/ui/issues/issue-35139.rs +++ b/src/test/ui/issues/issue-35139.rs @@ -7,14 +7,14 @@ pub trait MethodType { pub struct MTFn; impl<'a> MethodType for MTFn { //~ ERROR E0207 - type GetProp = fmt::Debug + 'a; + type GetProp = dyn fmt::Debug + 'a; } -fn bad(a: Box<::GetProp>) -> Box { +fn bad(a: Box<::GetProp>) -> Box { a } -fn dangling(a: &str) -> Box { +fn dangling(a: &str) -> Box { bad(Box::new(a)) } diff --git a/src/test/ui/issues/issue-35546.rs b/src/test/ui/issues/issue-35546.rs index 19c0491e4bc..500ba48e0b7 100644 --- a/src/test/ui/issues/issue-35546.rs +++ b/src/test/ui/issues/issue-35546.rs @@ -6,11 +6,11 @@ // `value` field of `Node`). struct Node { - next: Option>>, + next: Option>>, value: T, } -fn clear(head: &mut Option>>) { +fn clear(head: &mut Option>>) { match head.take() { Some(node) => *head = node.next, None => (), diff --git a/src/test/ui/issues/issue-35570.rs b/src/test/ui/issues/issue-35570.rs index e809b46bcdc..9bb9db63951 100644 --- a/src/test/ui/issues/issue-35570.rs +++ b/src/test/ui/issues/issue-35570.rs @@ -8,7 +8,7 @@ trait Trait2<'a> { type Ty; } -fn _ice(param: Box Trait1<<() as Trait2<'a>>::Ty>>) { +fn _ice(param: Box Trait1<<() as Trait2<'a>>::Ty>>) { let _e: (usize, usize) = unsafe{mem::transmute(param)}; } diff --git a/src/test/ui/issues/issue-35976.rs b/src/test/ui/issues/issue-35976.rs index 95c0cc95bb2..d075794d994 100644 --- a/src/test/ui/issues/issue-35976.rs +++ b/src/test/ui/issues/issue-35976.rs @@ -3,14 +3,14 @@ mod private { fn wait(&self) where Self: Sized; } - impl Future for Box { + impl Future for Box { fn wait(&self) { } } } //use private::Future; -fn bar(arg: Box) { +fn bar(arg: Box) { arg.wait(); //~^ ERROR the `wait` method cannot be invoked on a trait object } diff --git a/src/test/ui/issues/issue-3609.rs b/src/test/ui/issues/issue-3609.rs index c76c183821e..9bccb2a21e3 100644 --- a/src/test/ui/issues/issue-3609.rs +++ b/src/test/ui/issues/issue-3609.rs @@ -6,7 +6,7 @@ use std::thread; use std::sync::mpsc::Sender; type RingBuffer = Vec ; -type SamplesFn = Box; +type SamplesFn = Box; enum Msg { diff --git a/src/test/ui/issues/issue-36839.rs b/src/test/ui/issues/issue-36839.rs index 0944d07896e..a660368f401 100644 --- a/src/test/ui/issues/issue-36839.rs +++ b/src/test/ui/issues/issue-36839.rs @@ -19,5 +19,5 @@ impl Broken for T { fn main() { - let _m: &Broken = &(); + let _m: &dyn Broken = &(); } diff --git a/src/test/ui/issues/issue-3702-2.rs b/src/test/ui/issues/issue-3702-2.rs index c3a92a23cef..d47f6d248f7 100644 --- a/src/test/ui/issues/issue-3702-2.rs +++ b/src/test/ui/issues/issue-3702-2.rs @@ -7,12 +7,12 @@ impl ToPrimitive for isize {} trait Add { fn to_int(&self) -> isize; - fn add_dynamic(&self, other: &Add) -> isize; + fn add_dynamic(&self, other: &dyn Add) -> isize; } impl Add for isize { fn to_int(&self) -> isize { *self } - fn add_dynamic(&self, other: &Add) -> isize { + fn add_dynamic(&self, other: &dyn Add) -> isize { self.to_int() + other.to_int() //~ ERROR multiple applicable items in scope } } diff --git a/src/test/ui/issues/issue-37515.rs b/src/test/ui/issues/issue-37515.rs index 090b9bbf1ec..cc07bd1d915 100644 --- a/src/test/ui/issues/issue-37515.rs +++ b/src/test/ui/issues/issue-37515.rs @@ -2,7 +2,7 @@ // compile-pass #![warn(unused)] -type Z = for<'x> Send; +type Z = dyn for<'x> Send; //~^ WARN type alias is never used diff --git a/src/test/ui/issues/issue-37515.stderr b/src/test/ui/issues/issue-37515.stderr index 1b496559484..1476d17cdc6 100644 --- a/src/test/ui/issues/issue-37515.stderr +++ b/src/test/ui/issues/issue-37515.stderr @@ -1,8 +1,8 @@ warning: type alias is never used: `Z` --> $DIR/issue-37515.rs:5:1 | -LL | type Z = for<'x> Send; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | type Z = dyn for<'x> Send; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here --> $DIR/issue-37515.rs:3:9 diff --git a/src/test/ui/issues/issue-38404.rs b/src/test/ui/issues/issue-38404.rs index cddd75e267c..1a92acc3404 100644 --- a/src/test/ui/issues/issue-38404.rs +++ b/src/test/ui/issues/issue-38404.rs @@ -1,6 +1,6 @@ trait A: std::ops::Add + Sized {} trait B: A {} -trait C: A> {} +trait C: A> {} //~^ ERROR the trait `B` cannot be made into an object fn main() {} diff --git a/src/test/ui/issues/issue-38404.stderr b/src/test/ui/issues/issue-38404.stderr index 06bcf220f18..d18a26b3a76 100644 --- a/src/test/ui/issues/issue-38404.stderr +++ b/src/test/ui/issues/issue-38404.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `B` cannot be made into an object --> $DIR/issue-38404.rs:3:15 | -LL | trait C: A> {} - | ^^^^^^^^^^^^^^^^^^ the trait `B` cannot be made into an object +LL | trait C: A> {} + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `B` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/issues/issue-38604.rs b/src/test/ui/issues/issue-38604.rs index c172595a245..002a3c43fcb 100644 --- a/src/test/ui/issues/issue-38604.rs +++ b/src/test/ui/issues/issue-38604.rs @@ -11,6 +11,6 @@ impl Foo for () { } fn main() { - let _f: Box = //~ ERROR `Foo` cannot be made into an object + let _f: Box = //~ ERROR `Foo` cannot be made into an object Box::new(()); //~ ERROR `Foo` cannot be made into an object } diff --git a/src/test/ui/issues/issue-38604.stderr b/src/test/ui/issues/issue-38604.stderr index 77b42b80613..8ef7d346cb3 100644 --- a/src/test/ui/issues/issue-38604.stderr +++ b/src/test/ui/issues/issue-38604.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/issue-38604.rs:14:13 | -LL | let _f: Box = - | ^^^^^^^^ the trait `Foo` cannot be made into an object +LL | let _f: Box = + | ^^^^^^^^^^^^ the trait `Foo` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/issues/issue-40000.rs b/src/test/ui/issues/issue-40000.rs index 320992c0764..9d5ef481afc 100644 --- a/src/test/ui/issues/issue-40000.rs +++ b/src/test/ui/issues/issue-40000.rs @@ -1,7 +1,7 @@ fn main() { let bar: fn(&mut u32) = |_| {}; - fn foo(x: Box) {} - let bar = Box::new(|x: &i32| {}) as Box; + fn foo(x: Box) {} + let bar = Box::new(|x: &i32| {}) as Box; foo(bar); //~ ERROR E0308 } diff --git a/src/test/ui/issues/issue-41139.rs b/src/test/ui/issues/issue-41139.rs index f3e6c44ecb9..4814232607c 100644 --- a/src/test/ui/issues/issue-41139.rs +++ b/src/test/ui/issues/issue-41139.rs @@ -1,8 +1,8 @@ trait Trait {} -fn get_function<'a>() -> &'a Fn() -> Trait { panic!("") } +fn get_function<'a>() -> &'a dyn Fn() -> dyn Trait { panic!("") } fn main() { - let t : &Trait = &get_function()(); + let t : &dyn Trait = &get_function()(); //~^ ERROR cannot move a value of type dyn Trait } diff --git a/src/test/ui/issues/issue-41139.stderr b/src/test/ui/issues/issue-41139.stderr index 4dd017b0a91..829d0cfa72c 100644 --- a/src/test/ui/issues/issue-41139.stderr +++ b/src/test/ui/issues/issue-41139.stderr @@ -1,8 +1,8 @@ error[E0161]: cannot move a value of type dyn Trait: the size of dyn Trait cannot be statically determined - --> $DIR/issue-41139.rs:6:23 + --> $DIR/issue-41139.rs:6:27 | -LL | let t : &Trait = &get_function()(); - | ^^^^^^^^^^^^^^^^ +LL | let t : &dyn Trait = &get_function()(); + | ^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-42312.rs b/src/test/ui/issues/issue-42312.rs index b1c651f665b..426efcbf9b1 100644 --- a/src/test/ui/issues/issue-42312.rs +++ b/src/test/ui/issues/issue-42312.rs @@ -5,7 +5,7 @@ pub trait Foo { //~^ ERROR the size for values of type } -pub fn f(_: ToString) {} +pub fn f(_: dyn ToString) {} //~^ ERROR the size for values of type fn main() { } diff --git a/src/test/ui/issues/issue-42312.stderr b/src/test/ui/issues/issue-42312.stderr index 20c8d085cbc..bfdc4272fb3 100644 --- a/src/test/ui/issues/issue-42312.stderr +++ b/src/test/ui/issues/issue-42312.stderr @@ -11,10 +11,10 @@ LL | fn baz(_: Self::Target) where Self: Deref {} = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `(dyn std::string::ToString + 'static)` cannot be known at compilation time - --> $DIR/issue-42312.rs:8:23 + --> $DIR/issue-42312.rs:8:27 | -LL | pub fn f(_: ToString) {} - | ^ doesn't have a size known at compile-time +LL | pub fn f(_: dyn ToString) {} + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::string::ToString + 'static)` = note: to learn more, visit diff --git a/src/test/ui/issues/issue-4335.rs b/src/test/ui/issues/issue-4335.rs index d3c9954cdb0..a10ae9a1243 100644 --- a/src/test/ui/issues/issue-4335.rs +++ b/src/test/ui/issues/issue-4335.rs @@ -2,7 +2,7 @@ fn id(t: T) -> T { t } -fn f<'r, T>(v: &'r T) -> Box T + 'r> { +fn f<'r, T>(v: &'r T) -> Box T + 'r> { id(Box::new(|| *v)) //~^ ERROR E0373 //~| ERROR E0507 diff --git a/src/test/ui/issues/issue-4335.stderr b/src/test/ui/issues/issue-4335.stderr index 1b5cab24929..f1b6e475949 100644 --- a/src/test/ui/issues/issue-4335.stderr +++ b/src/test/ui/issues/issue-4335.stderr @@ -1,7 +1,7 @@ error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/issue-4335.rs:6:20 | -LL | fn f<'r, T>(v: &'r T) -> Box T + 'r> { +LL | fn f<'r, T>(v: &'r T) -> Box T + 'r> { | - captured outer variable LL | id(Box::new(|| *v)) | ^^ cannot move out of captured variable in an `FnMut` closure diff --git a/src/test/ui/issues/issue-45730.rs b/src/test/ui/issues/issue-45730.rs index 5709125e5f0..3776759fe07 100644 --- a/src/test/ui/issues/issue-45730.rs +++ b/src/test/ui/issues/issue-45730.rs @@ -3,7 +3,7 @@ fn main() { let x: *const _ = 0 as _; //~ ERROR cannot cast let x: *const _ = 0 as *const _; //~ ERROR cannot cast - let y: Option<*const fmt::Debug> = Some(x) as _; + let y: Option<*const dyn fmt::Debug> = Some(x) as _; let x = 0 as *const i32 as *const _ as *mut _; //~ ERROR cannot cast } diff --git a/src/test/ui/issues/issue-4972.rs b/src/test/ui/issues/issue-4972.rs index 9c95a979476..fab258f137e 100644 --- a/src/test/ui/issues/issue-4972.rs +++ b/src/test/ui/issues/issue-4972.rs @@ -6,10 +6,10 @@ trait MyTrait { } pub enum TraitWrapper { - A(Box), + A(Box), } -fn get_tw_map(tw: &TraitWrapper) -> &MyTrait { +fn get_tw_map(tw: &TraitWrapper) -> &dyn MyTrait { match *tw { TraitWrapper::A(box ref map) => map, //~ ERROR cannot be dereferenced } diff --git a/src/test/ui/issues/issue-50761.rs b/src/test/ui/issues/issue-50761.rs index bcf3ebcd60a..70b4bc8b755 100644 --- a/src/test/ui/issues/issue-50761.rs +++ b/src/test/ui/issues/issue-50761.rs @@ -14,7 +14,7 @@ mod b { } impl Builder { - pub fn with_a(&mut self, _a: fn() -> ::a::A) {} + pub fn with_a(&mut self, _a: fn() -> dyn (::a::A)) {} } } diff --git a/src/test/ui/issues/issue-50781.rs b/src/test/ui/issues/issue-50781.rs index edf8d82b480..3c5e5a9f69a 100644 --- a/src/test/ui/issues/issue-50781.rs +++ b/src/test/ui/issues/issue-50781.rs @@ -15,5 +15,5 @@ impl Trait for dyn X {} pub fn main() { // Check that this does not segfault. - ::foo(&()); + ::foo(&()); } diff --git a/src/test/ui/issues/issue-5153.rs b/src/test/ui/issues/issue-5153.rs index 551880ae009..e6737662088 100644 --- a/src/test/ui/issues/issue-5153.rs +++ b/src/test/ui/issues/issue-5153.rs @@ -7,6 +7,6 @@ impl Foo for isize { } fn main() { - (&5isize as &Foo).foo(); + (&5isize as &dyn Foo).foo(); //~^ ERROR: no method named `foo` found for type `&dyn Foo` in the current scope } diff --git a/src/test/ui/issues/issue-5153.stderr b/src/test/ui/issues/issue-5153.stderr index 48adfee0dec..97214fbdc52 100644 --- a/src/test/ui/issues/issue-5153.stderr +++ b/src/test/ui/issues/issue-5153.stderr @@ -1,8 +1,8 @@ error[E0599]: no method named `foo` found for type `&dyn Foo` in the current scope - --> $DIR/issue-5153.rs:10:23 + --> $DIR/issue-5153.rs:10:27 | -LL | (&5isize as &Foo).foo(); - | ^^^ +LL | (&5isize as &dyn Foo).foo(); + | ^^^ | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `foo`, perhaps you need to implement it: diff --git a/src/test/ui/issues/issue-5216.rs b/src/test/ui/issues/issue-5216.rs index fd490884fa1..35b343edfbd 100644 --- a/src/test/ui/issues/issue-5216.rs +++ b/src/test/ui/issues/issue-5216.rs @@ -1,10 +1,10 @@ fn f() { } -struct S(Box); +struct S(Box); pub static C: S = S(f); //~ ERROR mismatched types fn g() { } -type T = Box; +type T = Box; pub static D: T = g; //~ ERROR mismatched types fn main() {} diff --git a/src/test/ui/issues/issue-53419.rs b/src/test/ui/issues/issue-53419.rs index 52149cf486d..bf6791734d4 100644 --- a/src/test/ui/issues/issue-53419.rs +++ b/src/test/ui/issues/issue-53419.rs @@ -1,7 +1,7 @@ //compile-pass struct Foo { - bar: for<'r> Fn(usize, &'r FnMut()) + bar: dyn for<'r> Fn(usize, &'r dyn FnMut()) } fn main() { diff --git a/src/test/ui/issues/issue-54582.rs b/src/test/ui/issues/issue-54582.rs index c2dbf361911..8c50cac67f8 100644 --- a/src/test/ui/issues/issue-54582.rs +++ b/src/test/ui/issues/issue-54582.rs @@ -9,7 +9,7 @@ pub enum Enum { impl Stage for Enum {} -pub static ARRAY: [(&Stage, &str); 1] = [ +pub static ARRAY: [(&dyn Stage, &str); 1] = [ (&Enum::A, ""), ]; diff --git a/src/test/ui/issues/issue-55796.rs b/src/test/ui/issues/issue-55796.rs index efdea5c9b1e..088d4301c51 100644 --- a/src/test/ui/issues/issue-55796.rs +++ b/src/test/ui/issues/issue-55796.rs @@ -12,12 +12,12 @@ pub trait Graph<'a> { fn out_edges(&'a self, u: &Self::Node) -> Self::EdgesIter; fn in_edges(&'a self, u: &Self::Node) -> Self::EdgesIter; - fn out_neighbors(&'a self, u: &Self::Node) -> Box> { + fn out_neighbors(&'a self, u: &Self::Node) -> Box> { Box::new(self.out_edges(u).map(|e| e.target())) //~^ ERROR cannot infer } - fn in_neighbors(&'a self, u: &Self::Node) -> Box> { + fn in_neighbors(&'a self, u: &Self::Node) -> Box> { Box::new(self.in_edges(u).map(|e| e.target())) //~^ ERROR cannot infer } diff --git a/src/test/ui/issues/issue-5883.rs b/src/test/ui/issues/issue-5883.rs index b4a73ba99c5..0de53502397 100644 --- a/src/test/ui/issues/issue-5883.rs +++ b/src/test/ui/issues/issue-5883.rs @@ -1,10 +1,10 @@ trait A {} struct Struct { - r: A+'static + r: dyn A + 'static } -fn new_struct(r: A+'static) +fn new_struct(r: dyn A + 'static) -> Struct { //~^ ERROR the size for values of type //~^ ERROR the size for values of type Struct { r: r } diff --git a/src/test/ui/issues/issue-5883.stderr b/src/test/ui/issues/issue-5883.stderr index 7753881f736..c2de1d09550 100644 --- a/src/test/ui/issues/issue-5883.stderr +++ b/src/test/ui/issues/issue-5883.stderr @@ -1,7 +1,7 @@ error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time --> $DIR/issue-5883.rs:7:15 | -LL | fn new_struct(r: A+'static) +LL | fn new_struct(r: dyn A + 'static) | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` diff --git a/src/test/ui/issues/issue-60989.rs b/src/test/ui/issues/issue-60989.rs index 930e98bedce..6dae1e1347b 100644 --- a/src/test/ui/issues/issue-60989.rs +++ b/src/test/ui/issues/issue-60989.rs @@ -13,6 +13,6 @@ fn main() { //~^ ERROR type arguments are not allowed for this type let c1 = A {}; - c1::>; + c1::>; //~^ ERROR type arguments are not allowed for this type } diff --git a/src/test/ui/issues/issue-60989.stderr b/src/test/ui/issues/issue-60989.stderr index 55a0b9626df..5d2d9e83c9b 100644 --- a/src/test/ui/issues/issue-60989.stderr +++ b/src/test/ui/issues/issue-60989.stderr @@ -7,8 +7,8 @@ LL | c1::<()>; error[E0109]: type arguments are not allowed for this type --> $DIR/issue-60989.rs:16:10 | -LL | c1::>; - | ^^^^^^^ type argument not allowed +LL | c1::>; + | ^^^^^^^^^^^ type argument not allowed error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-7013.rs b/src/test/ui/issues/issue-7013.rs index ee68aa8623b..3d72b67e391 100644 --- a/src/test/ui/issues/issue-7013.rs +++ b/src/test/ui/issues/issue-7013.rs @@ -19,10 +19,10 @@ impl Foo for B { } struct A { - v: Box, + v: Box, } fn main() { - let a = A {v: box B{v: None} as Box}; + let a = A {v: box B{v: None} as Box}; //~^ ERROR `std::rc::Rc>` cannot be sent between threads safely } diff --git a/src/test/ui/issues/issue-7013.stderr b/src/test/ui/issues/issue-7013.stderr index 22185c7da34..f2668d33122 100644 --- a/src/test/ui/issues/issue-7013.stderr +++ b/src/test/ui/issues/issue-7013.stderr @@ -1,7 +1,7 @@ error[E0277]: `std::rc::Rc>` cannot be sent between threads safely --> $DIR/issue-7013.rs:26:19 | -LL | let a = A {v: box B{v: None} as Box}; +LL | let a = A {v: box B{v: None} as Box}; | ^^^^^^^^^^^^^^ `std::rc::Rc>` cannot be sent between threads safely | = help: within `B`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` diff --git a/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs b/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs index 7dd6b07177f..619256c7871 100644 --- a/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs +++ b/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs @@ -18,5 +18,5 @@ trait A { impl A for T {} -fn owned2(a: Box) { a as Box; } -fn owned3(a: Box) { box a as Box; } +fn owned2(a: Box) { a as Box; } +fn owned3(a: Box) { box a as Box; } diff --git a/src/test/ui/issues/issue-8398.rs b/src/test/ui/issues/issue-8398.rs index bd37b8582b2..a65c667b08e 100644 --- a/src/test/ui/issues/issue-8398.rs +++ b/src/test/ui/issues/issue-8398.rs @@ -6,7 +6,7 @@ pub trait Writer { fn write(&mut self, b: &[u8]) -> Result<(), ()>; } -fn foo(a: &mut Writer) { +fn foo(a: &mut dyn Writer) { a.write(&[]).unwrap(); } diff --git a/src/test/ui/issues/issue-9719.rs b/src/test/ui/issues/issue-9719.rs index 96865344e74..1e38ab9c6c2 100644 --- a/src/test/ui/issues/issue-9719.rs +++ b/src/test/ui/issues/issue-9719.rs @@ -12,8 +12,8 @@ mod a { } impl X for isize {} - pub struct Z<'a>(Enum<&'a (X+'a)>); - fn foo() { let x: isize = 42; let z = Z(Enum::A(&x as &X)); let _ = z; } + pub struct Z<'a>(Enum<&'a (dyn X + 'a)>); + fn foo() { let x: isize = 42; let z = Z(Enum::A(&x as &dyn X)); let _ = z; } } mod b { @@ -22,20 +22,20 @@ mod b { } impl X for isize {} struct Y<'a>{ - x:Option<&'a (X+'a)>, + x:Option<&'a (dyn X + 'a)>, } fn bar() { let x: isize = 42; - let _y = Y { x: Some(&x as &X) }; + let _y = Y { x: Some(&x as &dyn X) }; } } mod c { pub trait X { fn f(&self); } impl X for isize { fn f(&self) {} } - pub struct Z<'a>(Option<&'a (X+'a)>); - fn main() { let x: isize = 42; let z = Z(Some(&x as &X)); let _ = z; } + pub struct Z<'a>(Option<&'a (dyn X + 'a)>); + fn main() { let x: isize = 42; let z = Z(Some(&x as &dyn X)); let _ = z; } } pub fn main() {} diff --git a/src/test/ui/kindck/kindck-copy.rs b/src/test/ui/kindck/kindck-copy.rs index dadeb956964..eb18613682f 100644 --- a/src/test/ui/kindck/kindck-copy.rs +++ b/src/test/ui/kindck/kindck-copy.rs @@ -34,16 +34,16 @@ fn test<'a,T,U:Copy>(_: &'a isize) { assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied // borrowed object types are generally ok - assert_copy::<&'a Dummy>(); - assert_copy::<&'a (Dummy+Send)>(); - assert_copy::<&'static (Dummy+Send)>(); + assert_copy::<&'a dyn Dummy>(); + assert_copy::<&'a (dyn Dummy + Send)>(); + assert_copy::<&'static (dyn Dummy + Send)>(); // owned object types are not ok - assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied - assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied // mutable object types are not ok - assert_copy::<&'a mut (Dummy+Send)>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::<&'a mut (dyn Dummy + Send)>(); //~ ERROR : std::marker::Copy` is not satisfied // unsafe ptrs are ok assert_copy::<*const isize>(); diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index 2680cb7c012..929a8076562 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -77,8 +77,8 @@ LL | fn assert_copy() { } error[E0277]: the trait bound `std::boxed::Box: std::marker::Copy` is not satisfied --> $DIR/kindck-copy.rs:42:5 | -LL | assert_copy::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` +LL | assert_copy::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` | note: required by `assert_copy` --> $DIR/kindck-copy.rs:5:1 @@ -89,8 +89,8 @@ LL | fn assert_copy() { } error[E0277]: the trait bound `std::boxed::Box: std::marker::Copy` is not satisfied --> $DIR/kindck-copy.rs:43:5 | -LL | assert_copy::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` +LL | assert_copy::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` | note: required by `assert_copy` --> $DIR/kindck-copy.rs:5:1 @@ -101,8 +101,8 @@ LL | fn assert_copy() { } error[E0277]: the trait bound `&'a mut (dyn Dummy + std::marker::Send + 'a): std::marker::Copy` is not satisfied --> $DIR/kindck-copy.rs:46:5 | -LL | assert_copy::<&'a mut (Dummy+Send)>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut (dyn Dummy + std::marker::Send + 'a)` +LL | assert_copy::<&'a mut (dyn Dummy + Send)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut (dyn Dummy + std::marker::Send + 'a)` | note: required by `assert_copy` --> $DIR/kindck-copy.rs:5:1 diff --git a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr index c1f662fda61..25d0e74187f 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr @@ -1,7 +1,7 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | let a = &t as &Gettable; +LL | let a = &t as &dyn Gettable; | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` @@ -12,7 +12,7 @@ LL | let a = &t as &Gettable; error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | let a = &t as &Gettable; +LL | let a = &t as &dyn Gettable; | ^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound @@ -20,10 +20,10 @@ LL | let a = &t as &Gettable; = note: required for the cast to the object type `dyn Gettable` error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:25:27 + --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | let a: &Gettable = &t; - | ^^ `T` cannot be sent between threads safely +LL | let a: &dyn Gettable = &t; + | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` = help: consider adding a `where T: std::marker::Send` bound @@ -31,10 +31,10 @@ LL | let a: &Gettable = &t; = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:25:27 + --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | let a: &Gettable = &t; - | ^^ the trait `std::marker::Copy` is not implemented for `T` +LL | let a: &dyn Gettable = &t; + | ^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound = note: required because of the requirements on the impl of `Gettable` for `S` @@ -43,17 +43,17 @@ LL | let a: &Gettable = &t; error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:38:13 | -LL | let a = t as Box>; +LL | let a = t as Box>; | ^ the trait `std::marker::Copy` is not implemented for `std::string::String` | = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `foo3::Foo: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:46:33 + --> $DIR/kindck-impl-type-params.rs:46:37 | -LL | let a: Box> = t; - | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` +LL | let a: Box> = t; + | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` | = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` diff --git a/src/test/ui/kindck/kindck-impl-type-params.rs b/src/test/ui/kindck/kindck-impl-type-params.rs index a47e418709d..c4f90f36acf 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.rs +++ b/src/test/ui/kindck/kindck-impl-type-params.rs @@ -15,27 +15,27 @@ impl Gettable for S {} fn f(val: T) { let t: S = S(marker::PhantomData); - let a = &t as &Gettable; + let a = &t as &dyn Gettable; //~^ ERROR `T` cannot be sent between threads safely //~| ERROR : std::marker::Copy` is not satisfied } fn g(val: T) { let t: S = S(marker::PhantomData); - let a: &Gettable = &t; + let a: &dyn Gettable = &t; //~^ ERROR `T` cannot be sent between threads safely //~| ERROR : std::marker::Copy` is not satisfied } fn foo<'a>() { let t: S<&'a isize> = S(marker::PhantomData); - let a = &t as &Gettable<&'a isize>; + let a = &t as &dyn Gettable<&'a isize>; //~^ ERROR does not fulfill } fn foo2<'a>() { let t: Box> = box S(marker::PhantomData); - let a = t as Box>; + let a = t as Box>; //~^ ERROR : std::marker::Copy` is not satisfied } @@ -43,7 +43,7 @@ fn foo3<'a>() { struct Foo; // does not impl Copy let t: Box> = box S(marker::PhantomData); - let a: Box> = t; + let a: Box> = t; //~^ ERROR : std::marker::Copy` is not satisfied } diff --git a/src/test/ui/kindck/kindck-impl-type-params.stderr b/src/test/ui/kindck/kindck-impl-type-params.stderr index 8580e6812b4..e6f7088bd46 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.stderr @@ -1,7 +1,7 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | let a = &t as &Gettable; +LL | let a = &t as &dyn Gettable; | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` @@ -12,7 +12,7 @@ LL | let a = &t as &Gettable; error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | let a = &t as &Gettable; +LL | let a = &t as &dyn Gettable; | ^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound @@ -20,10 +20,10 @@ LL | let a = &t as &Gettable; = note: required for the cast to the object type `dyn Gettable` error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:25:27 + --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | let a: &Gettable = &t; - | ^^ `T` cannot be sent between threads safely +LL | let a: &dyn Gettable = &t; + | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` = help: consider adding a `where T: std::marker::Send` bound @@ -31,10 +31,10 @@ LL | let a: &Gettable = &t; = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:25:27 + --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | let a: &Gettable = &t; - | ^^ the trait `std::marker::Copy` is not implemented for `T` +LL | let a: &dyn Gettable = &t; + | ^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound = note: required because of the requirements on the impl of `Gettable` for `S` @@ -43,7 +43,7 @@ LL | let a: &Gettable = &t; error[E0477]: the type `&'a isize` does not fulfill the required lifetime --> $DIR/kindck-impl-type-params.rs:32:13 | -LL | let a = &t as &Gettable<&'a isize>; +LL | let a = &t as &dyn Gettable<&'a isize>; | ^^ | = note: type must satisfy the static lifetime @@ -51,17 +51,17 @@ LL | let a = &t as &Gettable<&'a isize>; error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:38:13 | -LL | let a = t as Box>; +LL | let a = t as Box>; | ^ the trait `std::marker::Copy` is not implemented for `std::string::String` | = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `foo3::Foo: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:46:33 + --> $DIR/kindck-impl-type-params.rs:46:37 | -LL | let a: Box> = t; - | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` +LL | let a: Box> = t; + | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` | = note: required because of the requirements on the impl of `Gettable` for `S` = note: required for the cast to the object type `dyn Gettable` diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.rs b/src/test/ui/kindck/kindck-inherited-copy-bound.rs index 0134636fa0d..61e72908248 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.rs +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.rs @@ -21,7 +21,7 @@ fn a() { fn b() { let x: Box<_> = box 3; let y = &x; - let z = &x as &Foo; + let z = &x as &dyn Foo; //~^ ERROR E0038 //~| ERROR E0038 } diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.stderr b/src/test/ui/kindck/kindck-inherited-copy-bound.stderr index 0ed2da46fba..1e719e26084 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.stderr +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.stderr @@ -14,15 +14,15 @@ LL | fn take_param(foo: &T) { } error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/kindck-inherited-copy-bound.rs:24:19 | -LL | let z = &x as &Foo; - | ^^^^ the trait `Foo` cannot be made into an object +LL | let z = &x as &dyn Foo; + | ^^^^^^^^ the trait `Foo` cannot be made into an object | = note: the trait cannot require that `Self : Sized` error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/kindck-inherited-copy-bound.rs:24:13 | -LL | let z = &x as &Foo; +LL | let z = &x as &dyn Foo; | ^^ the trait `Foo` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/kindck/kindck-send-object.rs b/src/test/ui/kindck/kindck-send-object.rs index 97f46c3953d..6411e688b4a 100644 --- a/src/test/ui/kindck/kindck-send-object.rs +++ b/src/test/ui/kindck/kindck-send-object.rs @@ -9,18 +9,18 @@ trait Message : Send { } // careful with object types, who knows what they close over... fn object_ref_with_static_bound_not_ok() { - assert_send::<&'static (Dummy+'static)>(); + assert_send::<&'static (dyn Dummy + 'static)>(); //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277] } fn box_object_with_no_bound_not_ok<'a>() { - assert_send::>(); + assert_send::>(); //~^ ERROR `dyn Dummy` cannot be sent between threads safely } fn object_with_send_bound_ok() { - assert_send::<&'static (Dummy+Sync)>(); - assert_send::>(); + assert_send::<&'static (dyn Dummy + Sync)>(); + assert_send::>(); } fn main() { } diff --git a/src/test/ui/kindck/kindck-send-object.stderr b/src/test/ui/kindck/kindck-send-object.stderr index 8d993566029..c9aadd85a53 100644 --- a/src/test/ui/kindck/kindck-send-object.stderr +++ b/src/test/ui/kindck/kindck-send-object.stderr @@ -1,8 +1,8 @@ error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely --> $DIR/kindck-send-object.rs:12:5 | -LL | assert_send::<&'static (Dummy+'static)>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely +LL | assert_send::<&'static (dyn Dummy + 'static)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'static)` = note: required because of the requirements on the impl of `std::marker::Send` for `&'static (dyn Dummy + 'static)` @@ -15,8 +15,8 @@ LL | fn assert_send() { } error[E0277]: `dyn Dummy` cannot be sent between threads safely --> $DIR/kindck-send-object.rs:17:5 | -LL | assert_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `dyn Dummy` = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique` diff --git a/src/test/ui/kindck/kindck-send-object1.nll.stderr b/src/test/ui/kindck/kindck-send-object1.nll.stderr index 1df7412132b..998dc90456f 100644 --- a/src/test/ui/kindck/kindck-send-object1.nll.stderr +++ b/src/test/ui/kindck/kindck-send-object1.nll.stderr @@ -1,8 +1,8 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely --> $DIR/kindck-send-object1.rs:10:5 | -LL | assert_send::<&'a Dummy>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely +LL | assert_send::<&'a dyn Dummy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `std::marker::Send` for `&'a (dyn Dummy + 'a)` @@ -15,8 +15,8 @@ LL | fn assert_send() { } error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely --> $DIR/kindck-send-object1.rs:29:5 | -LL | assert_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn Dummy + 'a)>` diff --git a/src/test/ui/kindck/kindck-send-object1.rs b/src/test/ui/kindck/kindck-send-object1.rs index 341985467de..0e198395c26 100644 --- a/src/test/ui/kindck/kindck-send-object1.rs +++ b/src/test/ui/kindck/kindck-send-object1.rs @@ -7,26 +7,26 @@ trait Dummy { } // careful with object types, who knows what they close over... fn test51<'a>() { - assert_send::<&'a Dummy>(); + assert_send::<&'a dyn Dummy>(); //~^ ERROR `(dyn Dummy + 'a)` cannot be shared between threads safely [E0277] } fn test52<'a>() { - assert_send::<&'a (Dummy+Sync)>(); + assert_send::<&'a (dyn Dummy + Sync)>(); //~^ ERROR does not fulfill the required lifetime } // ...unless they are properly bounded fn test60() { - assert_send::<&'static (Dummy+Sync)>(); + assert_send::<&'static (dyn Dummy + Sync)>(); } fn test61() { - assert_send::>(); + assert_send::>(); } // closure and object types can have lifetime bounds which make // them not ok fn test_71<'a>() { - assert_send::>(); + assert_send::>(); //~^ ERROR `(dyn Dummy + 'a)` cannot be sent between threads safely } diff --git a/src/test/ui/kindck/kindck-send-object1.stderr b/src/test/ui/kindck/kindck-send-object1.stderr index a4b908e4101..757b41ab6cb 100644 --- a/src/test/ui/kindck/kindck-send-object1.stderr +++ b/src/test/ui/kindck/kindck-send-object1.stderr @@ -1,8 +1,8 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely --> $DIR/kindck-send-object1.rs:10:5 | -LL | assert_send::<&'a Dummy>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely +LL | assert_send::<&'a dyn Dummy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `std::marker::Send` for `&'a (dyn Dummy + 'a)` @@ -15,16 +15,16 @@ LL | fn assert_send() { } error[E0477]: the type `&'a (dyn Dummy + std::marker::Sync + 'a)` does not fulfill the required lifetime --> $DIR/kindck-send-object1.rs:14:5 | -LL | assert_send::<&'a (Dummy+Sync)>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | assert_send::<&'a (dyn Dummy + Sync)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: type must satisfy the static lifetime error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely --> $DIR/kindck-send-object1.rs:29:5 | -LL | assert_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn Dummy + 'a)>` diff --git a/src/test/ui/kindck/kindck-send-object2.rs b/src/test/ui/kindck/kindck-send-object2.rs index 911ad988081..b797588e446 100644 --- a/src/test/ui/kindck/kindck-send-object2.rs +++ b/src/test/ui/kindck/kindck-send-object2.rs @@ -4,21 +4,21 @@ fn assert_send() { } trait Dummy { } fn test50() { - assert_send::<&'static Dummy>(); + assert_send::<&'static dyn Dummy>(); //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277] } fn test53() { - assert_send::>(); + assert_send::>(); //~^ ERROR `dyn Dummy` cannot be sent between threads safely } // ...unless they are properly bounded fn test60() { - assert_send::<&'static (Dummy+Sync)>(); + assert_send::<&'static (dyn Dummy + Sync)>(); } fn test61() { - assert_send::>(); + assert_send::>(); } fn main() { } diff --git a/src/test/ui/kindck/kindck-send-object2.stderr b/src/test/ui/kindck/kindck-send-object2.stderr index db79989dc5f..c1c9db9da83 100644 --- a/src/test/ui/kindck/kindck-send-object2.stderr +++ b/src/test/ui/kindck/kindck-send-object2.stderr @@ -1,8 +1,8 @@ error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely --> $DIR/kindck-send-object2.rs:7:5 | -LL | assert_send::<&'static Dummy>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely +LL | assert_send::<&'static dyn Dummy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'static)` = note: required because of the requirements on the impl of `std::marker::Send` for `&'static (dyn Dummy + 'static)` @@ -15,8 +15,8 @@ LL | fn assert_send() { } error[E0277]: `dyn Dummy` cannot be sent between threads safely --> $DIR/kindck-send-object2.rs:12:5 | -LL | assert_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `dyn Dummy` = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique` diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr index 8b24563e920..f2cf19abdac 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr @@ -1,7 +1,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/lifetime-bound-will-change-warning.rs:34:5 | -LL | fn test2<'a>(x: &'a Box) { +LL | fn test2<'a>(x: &'a Box) { | - `x` is a reference that is only valid in the function body LL | // but ref_obj will not, so warn. LL | ref_obj(x) @@ -10,7 +10,7 @@ LL | ref_obj(x) error[E0521]: borrowed data escapes outside of function --> $DIR/lifetime-bound-will-change-warning.rs:39:5 | -LL | fn test2cc<'a>(x: &'a Box) { +LL | fn test2cc<'a>(x: &'a Box) { | - `x` is a reference that is only valid in the function body LL | // same as test2, but cross crate LL | lib::ref_obj(x) diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs index 5461f875af6..3c6d92234c4 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs @@ -9,42 +9,42 @@ extern crate lifetime_bound_will_change_warning_lib as lib; -fn just_ref(x: &Fn()) { +fn just_ref(x: &dyn Fn()) { } -fn ref_obj(x: &Box) { +fn ref_obj(x: &Box) { // this will change to &Box... // Note: no warning is issued here, because the type of `x` will change to 'static if false { ref_obj(x); } } -fn test1<'a>(x: &'a Box) { +fn test1<'a>(x: &'a Box) { // just_ref will stay the same. just_ref(&**x) } -fn test1cc<'a>(x: &'a Box) { +fn test1cc<'a>(x: &'a Box) { // same as test1, but cross-crate lib::just_ref(&**x) } -fn test2<'a>(x: &'a Box) { +fn test2<'a>(x: &'a Box) { // but ref_obj will not, so warn. ref_obj(x) //~ ERROR mismatched types } -fn test2cc<'a>(x: &'a Box) { +fn test2cc<'a>(x: &'a Box) { // same as test2, but cross crate lib::ref_obj(x) //~ ERROR mismatched types } -fn test3<'a>(x: &'a Box) { +fn test3<'a>(x: &'a Box) { // here, we have a 'static bound, so even when ref_obj changes, no error results ref_obj(x) } -fn test3cc<'a>(x: &'a Box) { +fn test3cc<'a>(x: &'a Box) { // same as test3, but cross crate lib::ref_obj(x) } diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr index 1af4bd501ba..35d63c17276 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr @@ -9,7 +9,7 @@ LL | ref_obj(x) note: the lifetime 'a as defined on the function body at 32:10... --> $DIR/lifetime-bound-will-change-warning.rs:32:10 | -LL | fn test2<'a>(x: &'a Box) { +LL | fn test2<'a>(x: &'a Box) { | ^^ = note: ...does not necessarily outlive the static lifetime @@ -24,7 +24,7 @@ LL | lib::ref_obj(x) note: the lifetime 'a as defined on the function body at 37:12... --> $DIR/lifetime-bound-will-change-warning.rs:37:12 | -LL | fn test2cc<'a>(x: &'a Box) { +LL | fn test2cc<'a>(x: &'a Box) { | ^^ = note: ...does not necessarily outlive the static lifetime diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs index 1c288a7e44f..2370084b072 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs @@ -5,7 +5,7 @@ trait Future { use std::error::Error; -fn foo() -> impl Future> { +fn foo() -> impl Future> { //~^ ERROR missing lifetime Ok(()) } diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr index b2a3d9a9436..06b317ce952 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr @@ -1,8 +1,8 @@ error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-trait.rs:8:44 | -LL | fn foo() -> impl Future> { - | ^^^^^ help: consider giving it a 'static lifetime: `Error + 'static` +LL | fn foo() -> impl Future> { + | ^^^^^^^^^ help: consider giving it a 'static lifetime: `dyn Error + 'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr index c4e7ff90069..3c95be95db0 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr @@ -1,18 +1,18 @@ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 | -LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { - | - help: consider changing this to be mutable: `mut y` +LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { + | - help: consider changing this to be mutable: `mut y` LL | y.push(z); | ^ cannot borrow as mutable error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 | -LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` +LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { + | - - let's call the lifetime of this reference `'1` + | | + | let's call the lifetime of this reference `'2` LL | y.push(z); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs index 324a5846c94..6625d41c7de 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs @@ -1,4 +1,4 @@ -fn foo(x:Box , y: Vec<&u8>, z: &u8) { +fn foo(x:Box , y: Vec<&u8>, z: &u8) { y.push(z); //~ ERROR lifetime mismatch } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr index 6cd175b8a61..bfecb4d3393 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr @@ -1,8 +1,8 @@ error[E0623]: lifetime mismatch --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:10 | -LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { - | --- --- these two types are declared with different lifetimes... +LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { + | --- --- these two types are declared with different lifetimes... LL | y.push(z); | ^ ...but data from `z` flows into `y` here diff --git a/src/test/ui/lint/lint-ctypes.rs b/src/test/ui/lint/lint-ctypes.rs index 816177abdea..a3d9b6febdb 100644 --- a/src/test/ui/lint/lint-ctypes.rs +++ b/src/test/ui/lint/lint-ctypes.rs @@ -51,7 +51,7 @@ extern { pub fn char_type(p: char); //~ ERROR uses type `char` pub fn i128_type(p: i128); //~ ERROR uses type `i128` pub fn u128_type(p: u128); //~ ERROR uses type `u128` - pub fn trait_type(p: &Clone); //~ ERROR uses type `dyn std::clone::Clone` + pub fn trait_type(p: &dyn Clone); //~ ERROR uses type `dyn std::clone::Clone` pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` pub fn zero_size(p: ZeroSize); //~ ERROR struct has no fields diff --git a/src/test/ui/lint/lint-ctypes.stderr b/src/test/ui/lint/lint-ctypes.stderr index 67ba30a81c5..03c18e4530b 100644 --- a/src/test/ui/lint/lint-ctypes.stderr +++ b/src/test/ui/lint/lint-ctypes.stderr @@ -76,8 +76,8 @@ LL | pub fn u128_type(p: u128); error: `extern` block uses type `dyn std::clone::Clone` which is not FFI-safe: trait objects have no C equivalent --> $DIR/lint-ctypes.rs:54:26 | -LL | pub fn trait_type(p: &Clone); - | ^^^^^^ +LL | pub fn trait_type(p: &dyn Clone); + | ^^^^^^^^^^ error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout --> $DIR/lint-ctypes.rs:55:26 diff --git a/src/test/ui/lint/lint-dead-code-3.rs b/src/test/ui/lint/lint-dead-code-3.rs index 00b250f83dd..4397522f3f3 100644 --- a/src/test/ui/lint/lint-dead-code-3.rs +++ b/src/test/ui/lint/lint-dead-code-3.rs @@ -73,6 +73,6 @@ mod inner { } pub fn foo() { - let a: &inner::Trait = &1_isize; + let a: &dyn inner::Trait = &1_isize; a.f(); } diff --git a/src/test/ui/lint/lint-stability-2.rs b/src/test/ui/lint/lint-stability-2.rs index 12e7b086d35..53eee35a9ca 100644 --- a/src/test/ui/lint/lint-stability-2.rs +++ b/src/test/ui/lint/lint-stability-2.rs @@ -148,7 +148,7 @@ mod cross_crate { ::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); foo.trait_deprecated_text(); foo.trait_deprecated_unstable(); @@ -373,7 +373,7 @@ mod this_crate { ::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); foo.trait_deprecated_text(); foo.trait_unstable(); diff --git a/src/test/ui/lint/lint-stability-deprecated.rs b/src/test/ui/lint/lint-stability-deprecated.rs index bf574d7144d..a2031c2189a 100644 --- a/src/test/ui/lint/lint-stability-deprecated.rs +++ b/src/test/ui/lint/lint-stability-deprecated.rs @@ -98,7 +98,7 @@ mod cross_crate { struct S1(T::TypeUnstable); struct S2(T::TypeDeprecated); //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated': text - type A = TraitWithAssociatedTypes< + type A = dyn TraitWithAssociatedTypes< TypeUnstable = u8, TypeDeprecated = u16, //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated' @@ -170,7 +170,7 @@ mod cross_crate { ::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' @@ -423,7 +423,7 @@ mod this_crate { ::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text foo.trait_unstable(); diff --git a/src/test/ui/lint/lint-stability.rs b/src/test/ui/lint/lint-stability.rs index 3e4a3874d2c..fde27eec7d3 100644 --- a/src/test/ui/lint/lint-stability.rs +++ b/src/test/ui/lint/lint-stability.rs @@ -88,7 +88,7 @@ mod cross_crate { struct S1(T::TypeUnstable); //~^ ERROR use of unstable library feature struct S2(T::TypeDeprecated); - type A = TraitWithAssociatedTypes< + type A = dyn TraitWithAssociatedTypes< TypeUnstable = u8, //~ ERROR use of unstable library feature TypeDeprecated = u16, >; @@ -161,7 +161,7 @@ mod cross_crate { ::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); foo.trait_deprecated_text(); foo.trait_stable(); @@ -414,7 +414,7 @@ mod this_crate { ::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); foo.trait_deprecated_text(); foo.trait_unstable(); diff --git a/src/test/ui/lint/lint-unconditional-recursion.rs b/src/test/ui/lint/lint-unconditional-recursion.rs index 44af1179097..ab60a326cd2 100644 --- a/src/test/ui/lint/lint-unconditional-recursion.rs +++ b/src/test/ui/lint/lint-unconditional-recursion.rs @@ -39,7 +39,7 @@ trait Foo { } } -impl Foo for Box { +impl Foo for Box { fn bar(&self) { //~ ERROR function cannot return without recursing loop { self.bar() @@ -67,7 +67,7 @@ trait Foo2 { } } -impl Foo2 for Box { +impl Foo2 for Box { fn bar(&self) { //~ ERROR function cannot return without recursing loop { Foo2::bar(self) diff --git a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs index f48e9848456..656ed6576e2 100644 --- a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs +++ b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs @@ -18,7 +18,7 @@ fn foo() { let z = 3_i8; 'a: loop { - let b = Box::new(|x: &i8| *x) as Box Fn(&'a i8) -> i8>; + let b = Box::new(|x: &i8| *x) as Box Fn(&'a i8) -> i8>; //~^ WARN lifetime name `'a` shadows a label name that is already in scope assert_eq!((*b)(&z), z); break 'a; diff --git a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.stderr b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.stderr index 4c4d9218ec9..e5d376675c6 100644 --- a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.stderr +++ b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.stderr @@ -1,8 +1,8 @@ warning: lifetime name `'a` shadows a label name that is already in scope - --> $DIR/loops-reject-lifetime-shadowing-label.rs:21:51 + --> $DIR/loops-reject-lifetime-shadowing-label.rs:21:55 | LL | 'a: loop { | -- first declared here -LL | let b = Box::new(|x: &i8| *x) as Box Fn(&'a i8) -> i8>; - | ^^ lifetime 'a already in scope +LL | let b = Box::new(|x: &i8| *x) as Box Fn(&'a i8) -> i8>; + | ^^ lifetime 'a already in scope diff --git a/src/test/ui/lub-glb/old-lub-glb-object.rs b/src/test/ui/lub-glb/old-lub-glb-object.rs index dcd604a5157..f303c07e6d7 100644 --- a/src/test/ui/lub-glb/old-lub-glb-object.rs +++ b/src/test/ui/lub-glb/old-lub-glb-object.rs @@ -4,8 +4,8 @@ trait Foo { } fn foo( - x: &for<'a, 'b> Foo<&'a u8, &'b u8>, - y: &for<'a> Foo<&'a u8, &'a u8>, + x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, + y: &dyn for<'a> Foo<&'a u8, &'a u8>, ) { let z = match 22 { 0 => x, @@ -14,12 +14,12 @@ fn foo( } fn bar( - x: &for<'a, 'b> Foo<&'a u8, &'b u8>, - y: &for<'a> Foo<&'a u8, &'a u8>, + x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, + y: &dyn for<'a> Foo<&'a u8, &'a u8>, ) { // Accepted with explicit case: let z = match 22 { - 0 => x as &for<'a> Foo<&'a u8, &'a u8>, + 0 => x as &dyn for<'a> Foo<&'a u8, &'a u8>, _ => y, }; } diff --git a/src/test/ui/map-types.rs b/src/test/ui/map-types.rs index dab7863415f..c355a0e420f 100644 --- a/src/test/ui/map-types.rs +++ b/src/test/ui/map-types.rs @@ -13,7 +13,7 @@ impl Map for HashMap {} fn main() { let x: Box> = box HashMap::new(); - let x: Box> = x; - let y: Box> = Box::new(x); + let x: Box> = x; + let y: Box> = Box::new(x); //~^ ERROR `std::boxed::Box>: Map` is not satisfied } diff --git a/src/test/ui/map-types.stderr b/src/test/ui/map-types.stderr index 9aa98044242..21dac1ab1ed 100644 --- a/src/test/ui/map-types.stderr +++ b/src/test/ui/map-types.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `std::boxed::Box>: Map` is not satisfied - --> $DIR/map-types.rs:17:37 + --> $DIR/map-types.rs:17:41 | -LL | let y: Box> = Box::new(x); - | ^^^^^^^^^^^ the trait `Map` is not implemented for `std::boxed::Box>` +LL | let y: Box> = Box::new(x); + | ^^^^^^^^^^^ the trait `Map` is not implemented for `std::boxed::Box>` | = note: required for the cast to the object type `dyn Map` diff --git a/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs b/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs index 36a1a2fda69..23893911eab 100644 --- a/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs +++ b/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs @@ -11,10 +11,10 @@ impl S { // 'late lifetimes here belong to nested types not to the tested functions. fn early_tricky_explicit<'a>(_: for<'late> fn(&'late u8), - _: Box Fn(&'late u8)>) + _: Box Fn(&'late u8)>) -> &'a u8 { loop {} } fn early_tricky_implicit<'a>(_: fn(&u8), - _: Box) + _: Box) -> &'a u8 { loop {} } } diff --git a/src/test/ui/mismatched_types/cast-rfc0401.rs b/src/test/ui/mismatched_types/cast-rfc0401.rs index a5e03a18e6a..2f88c6496c4 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.rs +++ b/src/test/ui/mismatched_types/cast-rfc0401.rs @@ -24,7 +24,7 @@ fn main() let v = 0 as *const u8; let fat_v : *const [u8] = unsafe { &*(0 as *const [u8; 1])}; let fat_sv : *const [i8] = unsafe { &*(0 as *const [i8; 1])}; - let foo: &Foo = &f; + let foo: &dyn Foo = &f; let _ = v as &u8; //~ ERROR non-primitive cast let _ = v as E; //~ ERROR non-primitive cast @@ -50,7 +50,7 @@ fn main() let _ = 42usize as *const [u8]; //~ ERROR is invalid let _ = v as *const [u8]; //~ ERROR cannot cast - let _ = fat_v as *const Foo; //~ ERROR the size for values of type + let _ = fat_v as *const dyn Foo; //~ ERROR the size for values of type let _ = foo as *const str; //~ ERROR is invalid let _ = foo as *mut str; //~ ERROR is invalid let _ = main as *mut str; //~ ERROR is invalid @@ -59,14 +59,14 @@ fn main() let _ = fat_sv as usize; //~ ERROR is invalid let a : *const str = "hello"; - let _ = a as *const Foo; //~ ERROR the size for values of type + let _ = a as *const dyn Foo; //~ ERROR the size for values of type // check no error cascade let _ = main.f as *const u32; //~ ERROR no field - let cf: *const Foo = &0; + let cf: *const dyn Foo = &0; let _ = cf as *const [u16]; //~ ERROR is invalid - let _ = cf as *const Bar; //~ ERROR is invalid + let _ = cf as *const dyn Bar; //~ ERROR is invalid vec![0.0].iter().map(|s| s as f32).collect::>(); //~ ERROR is invalid } diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr index 0e0bb8da81e..f94dfd100a6 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.stderr +++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr @@ -207,15 +207,15 @@ LL | let _ = cf as *const [u16]; error[E0606]: casting `*const dyn Foo` as `*const dyn Bar` is invalid --> $DIR/cast-rfc0401.rs:69:13 | -LL | let _ = cf as *const Bar; - | ^^^^^^^^^^^^^^^^ +LL | let _ = cf as *const dyn Bar; + | ^^^^^^^^^^^^^^^^^^^^ | = note: vtable kinds may not match error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/cast-rfc0401.rs:53:13 | -LL | let _ = fat_v as *const Foo; +LL | let _ = fat_v as *const dyn Foo; | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` @@ -225,7 +225,7 @@ LL | let _ = fat_v as *const Foo; error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/cast-rfc0401.rs:62:13 | -LL | let _ = a as *const Foo; +LL | let _ = a as *const dyn Foo; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` diff --git a/src/test/ui/mismatched_types/issue-19109.rs b/src/test/ui/mismatched_types/issue-19109.rs index 030b7a40ca6..eae6a87905b 100644 --- a/src/test/ui/mismatched_types/issue-19109.rs +++ b/src/test/ui/mismatched_types/issue-19109.rs @@ -1,7 +1,7 @@ trait Trait { } -fn function(t: &mut Trait) { - t as *mut Trait +fn function(t: &mut dyn Trait) { + t as *mut dyn Trait //~^ ERROR: mismatched types } diff --git a/src/test/ui/mismatched_types/issue-19109.stderr b/src/test/ui/mismatched_types/issue-19109.stderr index db2d484edff..b826ca66c68 100644 --- a/src/test/ui/mismatched_types/issue-19109.stderr +++ b/src/test/ui/mismatched_types/issue-19109.stderr @@ -1,10 +1,10 @@ error[E0308]: mismatched types --> $DIR/issue-19109.rs:4:5 | -LL | fn function(t: &mut Trait) { - | - help: try adding a return type: `-> *mut dyn Trait` -LL | t as *mut Trait - | ^^^^^^^^^^^^^^^ expected (), found *-ptr +LL | fn function(t: &mut dyn Trait) { + | - help: try adding a return type: `-> *mut dyn Trait` +LL | t as *mut dyn Trait + | ^^^^^^^^^^^^^^^^^^^ expected (), found *-ptr | = note: expected type `()` found type `*mut dyn Trait` diff --git a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs index be5fab871b4..882533992bd 100644 --- a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs +++ b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs @@ -2,14 +2,14 @@ trait Foo { fn dummy(&self) { } } -fn a(_x: Box) { +fn a(_x: Box) { } -fn c(x: Box) { +fn c(x: Box) { a(x); } -fn d(x: Box) { +fn d(x: Box) { a(x); //~ ERROR mismatched types [E0308] } diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs index 3fa11878629..0385a120ce2 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs @@ -6,7 +6,7 @@ struct R<'a> { // This struct is needed to create the // otherwise infinite type of a fn that // accepts itself as argument: - c: Box + c: Box } fn innocent_looking_victim() { diff --git a/src/test/ui/nll/issue-52663-trait-object.rs b/src/test/ui/nll/issue-52663-trait-object.rs index e8e571aadc3..a7be365bde4 100644 --- a/src/test/ui/nll/issue-52663-trait-object.rs +++ b/src/test/ui/nll/issue-52663-trait-object.rs @@ -10,7 +10,7 @@ fn main() { let _ = { let tmp0 = 3; let tmp1 = &tmp0; - box tmp1 as Box + box tmp1 as Box }; //~^^^ ERROR `tmp0` does not live long enough } diff --git a/src/test/ui/nll/issue-52663-trait-object.stderr b/src/test/ui/nll/issue-52663-trait-object.stderr index 9262117f397..b71893de7f8 100644 --- a/src/test/ui/nll/issue-52663-trait-object.stderr +++ b/src/test/ui/nll/issue-52663-trait-object.stderr @@ -3,8 +3,8 @@ error[E0597]: `tmp0` does not live long enough | LL | let tmp1 = &tmp0; | ^^^^^ borrowed value does not live long enough -LL | box tmp1 as Box - | ------------------------- borrow later captured here by trait object +LL | box tmp1 as Box + | ----------------------------- borrow later captured here by trait object LL | }; | - `tmp0` dropped here while still borrowed diff --git a/src/test/ui/nll/issue-53570.rs b/src/test/ui/nll/issue-53570.rs index cea458dcb65..81c50edfed1 100644 --- a/src/test/ui/nll/issue-53570.rs +++ b/src/test/ui/nll/issue-53570.rs @@ -14,11 +14,11 @@ trait AnyVec<'a> { } trait GenericVec { - fn unwrap<'a, 'b>(vec: &'b AnyVec<'a>) -> &'b [T] where T: 'a; + fn unwrap<'a, 'b>(vec: &'b dyn AnyVec<'a>) -> &'b [T] where T: 'a; } struct Scratchpad<'a> { - buffers: RefCell>>, + buffers: RefCell>>, } impl<'a> Scratchpad<'a> { diff --git a/src/test/ui/object-does-not-impl-trait.rs b/src/test/ui/object-does-not-impl-trait.rs index 2d72b4588f7..104e7b2e215 100644 --- a/src/test/ui/object-does-not-impl-trait.rs +++ b/src/test/ui/object-does-not-impl-trait.rs @@ -3,6 +3,6 @@ trait Foo {} fn take_foo(f: F) {} -fn take_object(f: Box) { take_foo(f); } +fn take_object(f: Box) { take_foo(f); } //~^ ERROR `std::boxed::Box: Foo` is not satisfied fn main() {} diff --git a/src/test/ui/object-does-not-impl-trait.stderr b/src/test/ui/object-does-not-impl-trait.stderr index 0e28875ced6..288ce9682c2 100644 --- a/src/test/ui/object-does-not-impl-trait.stderr +++ b/src/test/ui/object-does-not-impl-trait.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `std::boxed::Box: Foo` is not satisfied - --> $DIR/object-does-not-impl-trait.rs:6:31 + --> $DIR/object-does-not-impl-trait.rs:6:35 | -LL | fn take_object(f: Box) { take_foo(f); } - | ^^^^^^^^ the trait `Foo` is not implemented for `std::boxed::Box` +LL | fn take_object(f: Box) { take_foo(f); } + | ^^^^^^^^ the trait `Foo` is not implemented for `std::boxed::Box` | note: required by `take_foo` --> $DIR/object-does-not-impl-trait.rs:5:1 diff --git a/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.rs b/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.rs index d14351aef9a..5dae92fee5f 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.rs @@ -20,27 +20,27 @@ struct Ref2<'a,'b:'a,T:'a+'b+?Sized> { r: &'a &'b T } -fn a<'a,'b>(t: Ref2<'a,'b,Test>) { +fn a<'a,'b>(t: Ref2<'a,'b, dyn Test>) { //~^ ERROR lifetime bound for this object type cannot be deduced from context } -fn b(t: Ref2) { +fn b(t: Ref2) { //~^ ERROR lifetime bound for this object type cannot be deduced from context } -fn c(t: Ref2<&Test>) { +fn c(t: Ref2<&dyn Test>) { // In this case, the &'a overrides. } -fn d(t: Ref2>) { +fn d(t: Ref2>) { // In this case, the lifetime parameter from the Ref1 overrides. } -fn e(t: Ref2>) { +fn e(t: Ref2>) { // In this case, Ref2 is ambiguous, but Ref0 overrides with 'static. } -fn f(t: &Ref2) { +fn f(t: &Ref2) { //~^ ERROR lifetime bound for this object type cannot be deduced from context } diff --git a/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.stderr b/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.stderr index 0319c7bfbe2..0c3dbffeea6 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.stderr @@ -1,20 +1,20 @@ error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound - --> $DIR/object-lifetime-default-ambiguous.rs:23:27 + --> $DIR/object-lifetime-default-ambiguous.rs:23:28 | -LL | fn a<'a,'b>(t: Ref2<'a,'b,Test>) { - | ^^^^ +LL | fn a<'a,'b>(t: Ref2<'a,'b, dyn Test>) { + | ^^^^^^^^ error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-ambiguous.rs:27:14 | -LL | fn b(t: Ref2) { - | ^^^^ +LL | fn b(t: Ref2) { + | ^^^^^^^^ error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-ambiguous.rs:43:15 | -LL | fn f(t: &Ref2) { - | ^^^^ +LL | fn f(t: &Ref2) { + | ^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr index 19cdd66ef75..e94f2a92125 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/object-lifetime-default-elision.rs:71:5 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs index cf15a4e8676..dc42edfba2c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs @@ -8,7 +8,7 @@ trait SomeTrait { } struct SomeStruct<'a> { - r: Box + r: Box } fn deref(ss: &T) -> T { @@ -17,7 +17,7 @@ fn deref(ss: &T) -> T { loop { } } -fn load0<'a>(ss: &'a Box) -> Box { +fn load0<'a>(ss: &'a Box) -> Box { // Under old rules, the fully elaborated types of input/output were: // // for<'a,'b> fn(&'a Box) -> Box @@ -31,7 +31,7 @@ fn load0<'a>(ss: &'a Box) -> Box { deref(ss) } -fn load1(ss: &SomeTrait) -> &SomeTrait { +fn load1(ss: &dyn SomeTrait) -> &dyn SomeTrait { // Under old rules, the fully elaborated types of input/output were: // // for<'a,'b> fn(&'a (SomeTrait+'b)) -> &'a (SomeTrait+'a) @@ -45,13 +45,13 @@ fn load1(ss: &SomeTrait) -> &SomeTrait { ss } -fn load2<'a>(ss: &'a SomeTrait) -> &SomeTrait { +fn load2<'a>(ss: &'a dyn SomeTrait) -> &dyn SomeTrait { // Same as `load1` but with an explicit name thrown in for fun. ss } -fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { // Under old rules, the fully elaborated types of input/output were: // // for<'a,'b,'c>fn(&'a (SomeTrait+'c)) -> &'b (SomeTrait+'a) diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr index dcb07a1706f..2cdd6c5d890 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr @@ -7,7 +7,7 @@ LL | ss note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 54:10... --> $DIR/object-lifetime-default-elision.rs:54:10 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/object-lifetime-default-elision.rs:71:5 @@ -17,7 +17,7 @@ LL | ss note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 54:13... --> $DIR/object-lifetime-default-elision.rs:54:13 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ = note: ...so that the expression is assignable: expected &'b (dyn SomeTrait + 'b) @@ -32,7 +32,7 @@ LL | ss note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 54:10... --> $DIR/object-lifetime-default-elision.rs:54:10 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the declared lifetime parameter bounds are satisfied --> $DIR/object-lifetime-default-elision.rs:71:5 @@ -42,7 +42,7 @@ LL | ss note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 54:13... --> $DIR/object-lifetime-default-elision.rs:54:13 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ = note: ...so that the expression is assignable: expected &'b (dyn SomeTrait + 'b) diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr index 9e68647214c..17fb7c4acdf 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr @@ -1,7 +1,7 @@ error[E0621]: explicit lifetime required in the type of `ss` --> $DIR/object-lifetime-default-from-box-error.rs:18:5 | -LL | fn load(ss: &mut SomeStruct) -> Box { +LL | fn load(ss: &mut SomeStruct) -> Box { | --------------- help: add explicit lifetime `'static` to the type of `ss`: `&mut SomeStruct<'static>` ... LL | ss.r @@ -16,7 +16,7 @@ LL | ss.r error[E0621]: explicit lifetime required in the type of `ss` --> $DIR/object-lifetime-default-from-box-error.rs:31:5 | -LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { +LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` ... LL | ss.r = b; diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs index b6d72f1fce3..587aab1edce 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs @@ -8,24 +8,24 @@ trait SomeTrait { } struct SomeStruct<'a> { - r: Box + r: Box } -fn load(ss: &mut SomeStruct) -> Box { +fn load(ss: &mut SomeStruct) -> Box { // `Box` defaults to a `'static` bound, so this return // is illegal. ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] } -fn store(ss: &mut SomeStruct, b: Box) { +fn store(ss: &mut SomeStruct, b: Box) { // No error: b is bounded by 'static which outlives the // (anonymous) lifetime on the struct. ss.r = b; } -fn store1<'b>(ss: &mut SomeStruct, b: Box) { +fn store1<'b>(ss: &mut SomeStruct, b: Box) { // Here we override the lifetimes explicitly, and so naturally we get an error. ss.r = b; //~ ERROR explicit lifetime required in the type of `ss` [E0621] diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr index 0077c95139f..78e4bdd374d 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr @@ -1,7 +1,7 @@ error[E0621]: explicit lifetime required in the type of `ss` --> $DIR/object-lifetime-default-from-box-error.rs:18:5 | -LL | fn load(ss: &mut SomeStruct) -> Box { +LL | fn load(ss: &mut SomeStruct) -> Box { | --------------- help: add explicit lifetime `'static` to the type of `ss`: `&mut SomeStruct<'static>` ... LL | ss.r @@ -10,7 +10,7 @@ LL | ss.r error[E0621]: explicit lifetime required in the type of `ss` --> $DIR/object-lifetime-default-from-box-error.rs:31:12 | -LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { +LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` ... LL | ss.r = b; diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr index 6d183ddf22d..7d6f9f39d13 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/object-lifetime-default-from-rptr-box-error.rs:15:5 | -LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { +LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here LL | ss.t = t; | ^^^^^^^^ assignment requires that `'a` must outlive `'static` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs index 91b384e0071..bf9e0beb57c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs @@ -8,10 +8,10 @@ trait Test { } struct SomeStruct<'a> { - t: &'a Box, + t: &'a Box, } -fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { +fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { ss.t = t; //~ ERROR mismatched types } diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr index d7e3a171333..4f9cef12c5e 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr @@ -9,7 +9,7 @@ LL | ss.t = t; note: the lifetime 'a as defined on the function body at 14:6... --> $DIR/object-lifetime-default-from-rptr-box-error.rs:14:6 | -LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { +LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { | ^^ = note: ...does not necessarily outlive the static lifetime diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr index fe3b21fa39c..6df54638ce0 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:21:5 | -LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { +LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here LL | ss.t = t; | ^^^^^^^^ assignment requires that `'a` must outlive `'static` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs index 6a84621f59e..ae2878539cf 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs @@ -9,15 +9,15 @@ trait Test { } struct SomeStruct<'a> { - t: &'a MyBox, - u: &'a MyBox, + t: &'a MyBox, + u: &'a MyBox, } struct MyBox { b: Box } -fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { +fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { ss.t = t; //~ ERROR mismatched types } diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr index 4d082530dc5..3b7faee68aa 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr @@ -9,7 +9,7 @@ LL | ss.t = t; note: the lifetime 'a as defined on the function body at 20:6... --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:20:6 | -LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { +LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { | ^^ = note: ...does not necessarily outlive the static lifetime diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr index 448fe9e5510..cdfbf0fc878 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/object-lifetime-default-mybox.rs:27:5 | -LL | fn load1<'a,'b>(a: &'a MyBox, +LL | fn load1<'a,'b>(a: &'a MyBox, | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here @@ -12,7 +12,7 @@ LL | a error[E0521]: borrowed data escapes outside of function --> $DIR/object-lifetime-default-mybox.rs:31:5 | -LL | fn load2<'a>(ss: &MyBox) -> MyBox { +LL | fn load2<'a>(ss: &MyBox) -> MyBox { | -- `ss` is a reference that is only valid in the function body LL | load0(ss) | ^^^^^^^^^ `ss` escapes the function body here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs index c94df82a177..eb27fe90f47 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs @@ -16,18 +16,18 @@ fn deref(ss: &T) -> T { loop { } } -fn load0(ss: &MyBox) -> MyBox { +fn load0(ss: &MyBox) -> MyBox { deref(ss) } -fn load1<'a,'b>(a: &'a MyBox, - b: &'b MyBox) - -> &'b MyBox +fn load1<'a,'b>(a: &'a MyBox, + b: &'b MyBox) + -> &'b MyBox { a //~ ERROR lifetime mismatch } -fn load2<'a>(ss: &MyBox) -> MyBox { +fn load2<'a>(ss: &MyBox) -> MyBox { load0(ss) //~ ERROR mismatched types } diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr index 4c23f867be8..928b9201982 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr @@ -1,11 +1,11 @@ error[E0623]: lifetime mismatch --> $DIR/object-lifetime-default-mybox.rs:27:5 | -LL | fn load1<'a,'b>(a: &'a MyBox, - | -------------------- this parameter and the return type are declared with different lifetimes... -LL | b: &'b MyBox) -LL | -> &'b MyBox - | -------------------- +LL | fn load1<'a,'b>(a: &'a MyBox, + | ------------------------ this parameter and the return type are declared with different lifetimes... +LL | b: &'b MyBox) +LL | -> &'b MyBox + | ------------------------ LL | { LL | a | ^ ...but data from `a` is returned here @@ -21,7 +21,7 @@ LL | load0(ss) note: the lifetime 'a as defined on the function body at 30:10... --> $DIR/object-lifetime-default-mybox.rs:30:10 | -LL | fn load2<'a>(ss: &MyBox) -> MyBox { +LL | fn load2<'a>(ss: &MyBox) -> MyBox { | ^^ = note: ...does not necessarily outlive the static lifetime diff --git a/src/test/ui/object-pointer-types.rs b/src/test/ui/object-pointer-types.rs index a8a482fb5a6..760a50e5b79 100644 --- a/src/test/ui/object-pointer-types.rs +++ b/src/test/ui/object-pointer-types.rs @@ -5,19 +5,19 @@ trait Foo { fn owned(self: Box); } -fn borrowed_receiver(x: &Foo) { +fn borrowed_receiver(x: &dyn Foo) { x.borrowed(); x.borrowed_mut(); // See [1] x.owned(); //~ ERROR no method named `owned` found } -fn borrowed_mut_receiver(x: &mut Foo) { +fn borrowed_mut_receiver(x: &mut dyn Foo) { x.borrowed(); x.borrowed_mut(); x.owned(); //~ ERROR no method named `owned` found } -fn owned_receiver(x: Box) { +fn owned_receiver(x: Box) { x.borrowed(); x.borrowed_mut(); // See [1] x.managed(); //~ ERROR no method named `managed` found diff --git a/src/test/ui/object-safety/object-safety-associated-consts.rs b/src/test/ui/object-safety/object-safety-associated-consts.rs index 79b7e541af8..5900019ea91 100644 --- a/src/test/ui/object-safety/object-safety-associated-consts.rs +++ b/src/test/ui/object-safety/object-safety-associated-consts.rs @@ -6,7 +6,7 @@ trait Bar { const X: usize; } -fn make_bar(t: &T) -> &Bar { +fn make_bar(t: &T) -> &dyn Bar { //~^ ERROR E0038 t } diff --git a/src/test/ui/object-safety/object-safety-associated-consts.stderr b/src/test/ui/object-safety/object-safety-associated-consts.stderr index 96962c10720..55f9e3f9f13 100644 --- a/src/test/ui/object-safety/object-safety-associated-consts.stderr +++ b/src/test/ui/object-safety/object-safety-associated-consts.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-associated-consts.rs:9:1 | -LL | fn make_bar(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: the trait cannot contain associated consts like `X` diff --git a/src/test/ui/object-safety/object-safety-by-value-self-use.rs b/src/test/ui/object-safety/object-safety-by-value-self-use.rs index 0b70c8ad45e..f903f26c090 100644 --- a/src/test/ui/object-safety/object-safety-by-value-self-use.rs +++ b/src/test/ui/object-safety/object-safety-by-value-self-use.rs @@ -11,7 +11,7 @@ trait Baz { fn baz(self: Self); } -fn use_bar(t: Box) { +fn use_bar(t: Box) { t.bar() //~ ERROR cannot move a value of type dyn Bar } diff --git a/src/test/ui/object-safety/object-safety-by-value-self.rs b/src/test/ui/object-safety/object-safety-by-value-self.rs index dee31f6e370..a8b1ddfaba7 100644 --- a/src/test/ui/object-safety/object-safety-by-value-self.rs +++ b/src/test/ui/object-safety/object-safety-by-value-self.rs @@ -17,28 +17,28 @@ trait Quux { fn baz(self: Self) where Self : Sized; } -fn make_bar(t: &T) -> &Bar { +fn make_bar(t: &T) -> &dyn Bar { t // legal } -fn make_bar_explicit(t: &T) -> &Bar { - t as &Bar // legal +fn make_bar_explicit(t: &T) -> &dyn Bar { + t as &dyn Bar // legal } -fn make_baz(t: &T) -> &Baz { +fn make_baz(t: &T) -> &dyn Baz { t // legal } -fn make_baz_explicit(t: &T) -> &Baz { - t as &Baz // legal +fn make_baz_explicit(t: &T) -> &dyn Baz { + t as &dyn Baz // legal } -fn make_quux(t: &T) -> &Quux { +fn make_quux(t: &T) -> &dyn Quux { t } -fn make_quux_explicit(t: &T) -> &Quux { - t as &Quux +fn make_quux_explicit(t: &T) -> &dyn Quux { + t as &dyn Quux } diff --git a/src/test/ui/object-safety/object-safety-generics.rs b/src/test/ui/object-safety/object-safety-generics.rs index 5f4aabf5469..d63ea28c8f2 100644 --- a/src/test/ui/object-safety/object-safety-generics.rs +++ b/src/test/ui/object-safety/object-safety-generics.rs @@ -11,22 +11,22 @@ trait Quux { where Self : Sized; } -fn make_bar(t: &T) -> &Bar { +fn make_bar(t: &T) -> &dyn Bar { //~^ ERROR E0038 t } -fn make_bar_explicit(t: &T) -> &Bar { +fn make_bar_explicit(t: &T) -> &dyn Bar { //~^ ERROR E0038 - t as &Bar + t as &dyn Bar } -fn make_quux(t: &T) -> &Quux { +fn make_quux(t: &T) -> &dyn Quux { t } -fn make_quux_explicit(t: &T) -> &Quux { - t as &Quux +fn make_quux_explicit(t: &T) -> &dyn Quux { + t as &dyn Quux } fn main() { diff --git a/src/test/ui/object-safety/object-safety-generics.stderr b/src/test/ui/object-safety/object-safety-generics.stderr index 7ae44794ceb..d66cdb98448 100644 --- a/src/test/ui/object-safety/object-safety-generics.stderr +++ b/src/test/ui/object-safety/object-safety-generics.stderr @@ -1,16 +1,16 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-generics.rs:14:1 | -LL | fn make_bar(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `bar` has generic type parameters error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-generics.rs:19:1 | -LL | fn make_bar_explicit(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar_explicit(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `bar` has generic type parameters diff --git a/src/test/ui/object-safety/object-safety-issue-22040.rs b/src/test/ui/object-safety/object-safety-issue-22040.rs index eb28fcf0d5a..1fc5c5442c2 100644 --- a/src/test/ui/object-safety/object-safety-issue-22040.rs +++ b/src/test/ui/object-safety/object-safety-issue-22040.rs @@ -9,7 +9,7 @@ trait Expr: Debug + PartialEq { //#[derive(PartialEq)] #[derive(Debug)] struct SExpr<'x> { - elements: Vec>, + elements: Vec>, //~^ ERROR E0038 } @@ -35,8 +35,8 @@ impl <'x> Expr for SExpr<'x> { } fn main() { - let a: Box = Box::new(SExpr::new()); - let b: Box = Box::new(SExpr::new()); + let a: Box = Box::new(SExpr::new()); + let b: Box = Box::new(SExpr::new()); // assert_eq!(a , b); } diff --git a/src/test/ui/object-safety/object-safety-issue-22040.stderr b/src/test/ui/object-safety/object-safety-issue-22040.stderr index 85721f1a5f8..1f5c472ddc2 100644 --- a/src/test/ui/object-safety/object-safety-issue-22040.stderr +++ b/src/test/ui/object-safety/object-safety-issue-22040.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Expr` cannot be made into an object --> $DIR/object-safety-issue-22040.rs:12:23 | -LL | elements: Vec>, - | ^^^^^^^^ the trait `Expr` cannot be made into an object +LL | elements: Vec>, + | ^^^^^^^^^^^^^ the trait `Expr` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/object-safety/object-safety-mentions-Self.rs b/src/test/ui/object-safety/object-safety-mentions-Self.rs index 8e1bd83cec0..f13ffe53626 100644 --- a/src/test/ui/object-safety/object-safety-mentions-Self.rs +++ b/src/test/ui/object-safety/object-safety-mentions-Self.rs @@ -14,22 +14,22 @@ trait Quux { fn get(&self, s: &Self) -> Self where Self : Sized; } -fn make_bar(t: &T) -> &Bar { +fn make_bar(t: &T) -> &dyn Bar { //~^ ERROR E0038 loop { } } -fn make_baz(t: &T) -> &Baz { +fn make_baz(t: &T) -> &dyn Baz { //~^ ERROR E0038 t } -fn make_quux(t: &T) -> &Quux { +fn make_quux(t: &T) -> &dyn Quux { t } -fn make_quux_explicit(t: &T) -> &Quux { - t as &Quux +fn make_quux_explicit(t: &T) -> &dyn Quux { + t as &dyn Quux } fn main() { diff --git a/src/test/ui/object-safety/object-safety-mentions-Self.stderr b/src/test/ui/object-safety/object-safety-mentions-Self.stderr index ed3aed983cf..c0c471c2b1e 100644 --- a/src/test/ui/object-safety/object-safety-mentions-Self.stderr +++ b/src/test/ui/object-safety/object-safety-mentions-Self.stderr @@ -1,16 +1,16 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-mentions-Self.rs:17:1 | -LL | fn make_bar(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `bar` references the `Self` type in its arguments or return type error[E0038]: the trait `Baz` cannot be made into an object --> $DIR/object-safety-mentions-Self.rs:22:1 | -LL | fn make_baz(t: &T) -> &Baz { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Baz` cannot be made into an object +LL | fn make_baz(t: &T) -> &dyn Baz { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Baz` cannot be made into an object | = note: method `bar` references the `Self` type in its arguments or return type diff --git a/src/test/ui/object-safety/object-safety-no-static.rs b/src/test/ui/object-safety/object-safety-no-static.rs index 4faf9386f9a..55d31ce8087 100644 --- a/src/test/ui/object-safety/object-safety-no-static.rs +++ b/src/test/ui/object-safety/object-safety-no-static.rs @@ -5,7 +5,7 @@ trait Foo { fn foo(); } -fn foo_implicit(b: Box) -> Box { +fn foo_implicit(b: Box) -> Box { //~^ ERROR E0038 loop { } } diff --git a/src/test/ui/object-safety/object-safety-no-static.stderr b/src/test/ui/object-safety/object-safety-no-static.stderr index 3b8ccb594c1..da8dd657c2a 100644 --- a/src/test/ui/object-safety/object-safety-no-static.stderr +++ b/src/test/ui/object-safety/object-safety-no-static.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/object-safety-no-static.rs:8:1 | -LL | fn foo_implicit(b: Box) -> Box { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object +LL | fn foo_implicit(b: Box) -> Box { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object | = note: method `foo` has no receiver diff --git a/src/test/ui/object-safety/object-safety-phantom-fn.rs b/src/test/ui/object-safety/object-safety-phantom-fn.rs index f8875e4995b..59ed12c78f0 100644 --- a/src/test/ui/object-safety/object-safety-phantom-fn.rs +++ b/src/test/ui/object-safety/object-safety-phantom-fn.rs @@ -9,11 +9,11 @@ trait Baz { trait Bar { } -fn make_bar>(t: &T) -> &Bar { +fn make_bar>(t: &T) -> &dyn Bar { t } -fn make_baz(t: &T) -> &Baz { +fn make_baz(t: &T) -> &dyn Baz { t } diff --git a/src/test/ui/object-safety/object-safety-sized-2.rs b/src/test/ui/object-safety/object-safety-sized-2.rs index baeb3734677..7235b22404e 100644 --- a/src/test/ui/object-safety/object-safety-sized-2.rs +++ b/src/test/ui/object-safety/object-safety-sized-2.rs @@ -7,7 +7,7 @@ trait Bar fn bar(&self, t: T); } -fn make_bar(t: &T) -> &Bar { +fn make_bar(t: &T) -> &dyn Bar { //~^ ERROR E0038 loop { } } diff --git a/src/test/ui/object-safety/object-safety-sized-2.stderr b/src/test/ui/object-safety/object-safety-sized-2.stderr index 2b8bfa341d7..dcaf2ff0bc2 100644 --- a/src/test/ui/object-safety/object-safety-sized-2.stderr +++ b/src/test/ui/object-safety/object-safety-sized-2.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-sized-2.rs:10:1 | -LL | fn make_bar(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/object-safety/object-safety-sized.rs b/src/test/ui/object-safety/object-safety-sized.rs index 77dc7390aff..1312bb34717 100644 --- a/src/test/ui/object-safety/object-safety-sized.rs +++ b/src/test/ui/object-safety/object-safety-sized.rs @@ -5,7 +5,7 @@ trait Bar : Sized { fn bar(&self, t: T); } -fn make_bar(t: &T) -> &Bar { +fn make_bar(t: &T) -> &dyn Bar { //~^ ERROR E0038 t } diff --git a/src/test/ui/object-safety/object-safety-sized.stderr b/src/test/ui/object-safety/object-safety-sized.stderr index ba98e2f1ef6..98bc73e38d4 100644 --- a/src/test/ui/object-safety/object-safety-sized.stderr +++ b/src/test/ui/object-safety/object-safety-sized.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-sized.rs:8:1 | -LL | fn make_bar(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.rs b/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.rs index 9d0da4e327c..2445b33c814 100644 --- a/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.rs +++ b/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.rs @@ -8,11 +8,11 @@ trait Bar { trait Baz : Bar { } -fn make_bar>(t: &T) -> &Bar { +fn make_bar>(t: &T) -> &dyn Bar { t } -fn make_baz(t: &T) -> &Baz { +fn make_baz(t: &T) -> &dyn Baz { //~^ ERROR E0038 t } diff --git a/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.stderr b/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.stderr index 5db34a23fff..8ae89832703 100644 --- a/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.stderr +++ b/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Baz` cannot be made into an object --> $DIR/object-safety-supertrait-mentions-Self.rs:15:31 | -LL | fn make_baz(t: &T) -> &Baz { - | ^^^ the trait `Baz` cannot be made into an object +LL | fn make_baz(t: &T) -> &dyn Baz { + | ^^^^^^^ the trait `Baz` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/privacy/private-in-public-non-principal-2.rs b/src/test/ui/privacy/private-in-public-non-principal-2.rs index 02fd92aa7a4..8a59073fa6c 100644 --- a/src/test/ui/privacy/private-in-public-non-principal-2.rs +++ b/src/test/ui/privacy/private-in-public-non-principal-2.rs @@ -4,7 +4,7 @@ mod m { pub trait PubPrincipal {} auto trait PrivNonPrincipal {} - pub fn leak_dyn_nonprincipal() -> Box { loop {} } + pub fn leak_dyn_nonprincipal() -> Box { loop {} } } fn main() { diff --git a/src/test/ui/privacy/private-in-public-non-principal.rs b/src/test/ui/privacy/private-in-public-non-principal.rs index 5de5a685208..5d89d8105b1 100644 --- a/src/test/ui/privacy/private-in-public-non-principal.rs +++ b/src/test/ui/privacy/private-in-public-non-principal.rs @@ -3,7 +3,7 @@ pub trait PubPrincipal {} auto trait PrivNonPrincipal {} -pub fn leak_dyn_nonprincipal() -> Box { loop {} } +pub fn leak_dyn_nonprincipal() -> Box { loop {} } //~^ WARN private trait `PrivNonPrincipal` in public interface //~| WARN this was previously accepted diff --git a/src/test/ui/privacy/private-in-public-non-principal.stderr b/src/test/ui/privacy/private-in-public-non-principal.stderr index 729b94ed892..578f4380b42 100644 --- a/src/test/ui/privacy/private-in-public-non-principal.stderr +++ b/src/test/ui/privacy/private-in-public-non-principal.stderr @@ -1,8 +1,8 @@ warning: private trait `PrivNonPrincipal` in public interface (error E0445) --> $DIR/private-in-public-non-principal.rs:6:1 | -LL | pub fn leak_dyn_nonprincipal() -> Box { loop {} } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub fn leak_dyn_nonprincipal() -> Box { loop {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[warn(private_in_public)] on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! diff --git a/src/test/ui/privacy/private-inferred-type.rs b/src/test/ui/privacy/private-inferred-type.rs index d9bb421b53f..dab440b2d99 100644 --- a/src/test/ui/privacy/private-inferred-type.rs +++ b/src/test/ui/privacy/private-inferred-type.rs @@ -65,9 +65,9 @@ mod m { pub fn leak_anon2() -> impl TraitWithTyParam { 0 } pub fn leak_anon3() -> impl TraitWithAssocTy { 0 } - pub fn leak_dyn1() -> Box { Box::new(0) } - pub fn leak_dyn2() -> Box> { Box::new(0) } - pub fn leak_dyn3() -> Box> { Box::new(0) } + pub fn leak_dyn1() -> Box { Box::new(0) } + pub fn leak_dyn2() -> Box> { Box::new(0) } + pub fn leak_dyn3() -> Box> { Box::new(0) } } mod adjust { diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-small.rs b/src/test/ui/regions/region-borrow-params-issue-29793-small.rs index a1ccf667671..5f1c2ed08f6 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-small.rs +++ b/src/test/ui/regions/region-borrow-params-issue-29793-small.rs @@ -51,7 +51,7 @@ fn ok_borrow_of_fn_params(a: usize, b:usize) { // TOP-LEVEL FN'S fn escaping_borrow_of_fn_params_1() { - fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -62,7 +62,7 @@ fn escaping_borrow_of_fn_params_1() { } fn escaping_borrow_of_fn_params_2() { - fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -73,7 +73,7 @@ fn escaping_borrow_of_fn_params_2() { } fn move_of_fn_params() { - fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { let f = move |t: bool| if t { x } else { y }; return Box::new(f); }; @@ -86,7 +86,7 @@ fn move_of_fn_params() { fn escaping_borrow_of_method_params_1() { struct S; impl S { - fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -100,7 +100,7 @@ fn escaping_borrow_of_method_params_1() { fn escaping_borrow_of_method_params_2() { struct S; impl S { - fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -113,7 +113,7 @@ fn escaping_borrow_of_method_params_2() { fn move_of_method_params() { struct S; impl S { - fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = move |t: bool| if t { x } else { y }; return Box::new(f); } @@ -125,10 +125,10 @@ fn move_of_method_params() { // TRAIT IMPL METHODS fn escaping_borrow_of_trait_impl_params_1() { - trait T { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a>; } + trait T { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a>; } struct S; impl T for S { - fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -140,10 +140,10 @@ fn escaping_borrow_of_trait_impl_params_1() { } fn escaping_borrow_of_trait_impl_params_2() { - trait T { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a>; } + trait T { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a>; } struct S; impl T for S { - fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -154,10 +154,10 @@ fn escaping_borrow_of_trait_impl_params_2() { } fn move_of_trait_impl_params() { - trait T { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a>; } + trait T { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a>; } struct S; impl T for S { - fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = move |t: bool| if t { x } else { y }; return Box::new(f); } @@ -171,7 +171,7 @@ fn move_of_trait_impl_params() { fn escaping_borrow_of_trait_default_params_1() { struct S; trait T { - fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -185,7 +185,7 @@ fn escaping_borrow_of_trait_default_params_1() { fn escaping_borrow_of_trait_default_params_2() { struct S; trait T { - fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -199,7 +199,7 @@ fn escaping_borrow_of_trait_default_params_2() { fn move_of_trait_default_params() { struct S; trait T { - fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = move |t: bool| if t { x } else { y }; return Box::new(f); } diff --git a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.rs b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.rs index 3a211b04636..40d2b740b43 100644 --- a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.rs +++ b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.rs @@ -10,15 +10,15 @@ trait SomeTrait { } struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used // All of these are ok, because we can derive exactly one bound: - a: Box, - b: Box>, - c: Box>, - d: Box, - e: Box+Send>, // we can derive two bounds, but one is 'static, so ok - f: Box, // OK, defaults to 'static due to RFC 599. - g: Box, + a: Box, + b: Box>, + c: Box>, + d: Box, + e: Box+Send>, // we can derive two bounds, but one is 'static, so ok + f: Box, // OK, defaults to 'static due to RFC 599. + g: Box, - z: Box+'b+'c>, + z: Box+'b+'c>, //~^ ERROR only a single explicit lifetime bound is permitted //~| ERROR lifetime bound not satisfied } diff --git a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr index 8bcb2da4577..003dd0699d3 100644 --- a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr +++ b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr @@ -1,14 +1,14 @@ error[E0226]: only a single explicit lifetime bound is permitted - --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:22 + --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:26 | -LL | z: Box+'b+'c>, - | ^^ +LL | z: Box+'b+'c>, + | ^^ error[E0478]: lifetime bound not satisfied --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:5 | -LL | z: Box+'b+'c>, - | ^^^^^^^^^^^^^^^^^^^^ +LL | z: Box+'b+'c>, + | ^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime 'b as defined on the struct at 11:15 --> $DIR/region-bounds-on-objects-and-type-parameters.rs:11:15 diff --git a/src/test/ui/regions/region-object-lifetime-2.nll.stderr b/src/test/ui/regions/region-object-lifetime-2.nll.stderr index 56e8c40c99f..60084773466 100644 --- a/src/test/ui/regions/region-object-lifetime-2.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-2.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/region-object-lifetime-2.rs:10:5 | -LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/regions/region-object-lifetime-2.rs b/src/test/ui/regions/region-object-lifetime-2.rs index 92c85020e9a..42798487893 100644 --- a/src/test/ui/regions/region-object-lifetime-2.rs +++ b/src/test/ui/regions/region-object-lifetime-2.rs @@ -6,7 +6,7 @@ trait Foo { } // Borrowed receiver but two distinct lifetimes, we get an error. -fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { +fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { x.borrowed() //~ ERROR cannot infer } diff --git a/src/test/ui/regions/region-object-lifetime-2.stderr b/src/test/ui/regions/region-object-lifetime-2.stderr index d3552ab0c4b..0c5e22ebae2 100644 --- a/src/test/ui/regions/region-object-lifetime-2.stderr +++ b/src/test/ui/regions/region-object-lifetime-2.stderr @@ -7,7 +7,7 @@ LL | x.borrowed() note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 9:42... --> $DIR/region-object-lifetime-2.rs:9:42 | -LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/region-object-lifetime-2.rs:10:5 @@ -17,7 +17,7 @@ LL | x.borrowed() note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 9:45... --> $DIR/region-object-lifetime-2.rs:9:45 | -LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/region-object-lifetime-2.rs:10:5 diff --git a/src/test/ui/regions/region-object-lifetime-4.nll.stderr b/src/test/ui/regions/region-object-lifetime-4.nll.stderr index aa91c371f41..75b049dae21 100644 --- a/src/test/ui/regions/region-object-lifetime-4.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-4.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/region-object-lifetime-4.rs:12:5 | -LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/regions/region-object-lifetime-4.rs b/src/test/ui/regions/region-object-lifetime-4.rs index d2ab617ebb7..4fe12b2acfc 100644 --- a/src/test/ui/regions/region-object-lifetime-4.rs +++ b/src/test/ui/regions/region-object-lifetime-4.rs @@ -8,7 +8,7 @@ trait Foo { // Here we have two distinct lifetimes, but we try to return a pointer // with the longer lifetime when (from the signature) we only know // that it lives as long as the shorter lifetime. Therefore, error. -fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { +fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { x.borrowed() //~ ERROR cannot infer } diff --git a/src/test/ui/regions/region-object-lifetime-4.stderr b/src/test/ui/regions/region-object-lifetime-4.stderr index 75b26ffc6d5..e737d27d560 100644 --- a/src/test/ui/regions/region-object-lifetime-4.stderr +++ b/src/test/ui/regions/region-object-lifetime-4.stderr @@ -7,7 +7,7 @@ LL | x.borrowed() note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 11:41... --> $DIR/region-object-lifetime-4.rs:11:41 | -LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/region-object-lifetime-4.rs:12:5 @@ -17,7 +17,7 @@ LL | x.borrowed() note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 11:44... --> $DIR/region-object-lifetime-4.rs:11:44 | -LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/region-object-lifetime-4.rs:12:5 diff --git a/src/test/ui/regions/region-object-lifetime-5.rs b/src/test/ui/regions/region-object-lifetime-5.rs index bd68aebbeeb..307bbcbd58d 100644 --- a/src/test/ui/regions/region-object-lifetime-5.rs +++ b/src/test/ui/regions/region-object-lifetime-5.rs @@ -7,7 +7,7 @@ trait Foo { // Here, the object is bounded by an anonymous lifetime and returned // as `&'static`, so you get an error. -fn owned_receiver(x: Box) -> &'static () { +fn owned_receiver(x: Box) -> &'static () { x.borrowed() //~ ERROR cannot return value referencing local data `*x` } diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr index a54f8f5faab..43acbfd412d 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr @@ -1,15 +1,15 @@ error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:8:12 | -LL | fn a(v: &[u8]) -> Box { +LL | fn a(v: &[u8]) -> Box { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` -LL | let x: Box = Box::new(v); - | ^^^^^^^^^^^^^^^^^^ lifetime `'static` required +LL | let x: Box = Box::new(v); + | ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:14:5 | -LL | fn b(v: &[u8]) -> Box { +LL | fn b(v: &[u8]) -> Box { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` LL | Box::new(v) | ^^^^^^^^^^^ lifetime `'static` required @@ -17,7 +17,7 @@ LL | Box::new(v) error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:21:5 | -LL | fn c(v: &[u8]) -> Box { +LL | fn c(v: &[u8]) -> Box { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` ... LL | Box::new(v) @@ -26,7 +26,7 @@ LL | Box::new(v) error: lifetime may not live long enough --> $DIR/region-object-lifetime-in-coercion.rs:26:5 | -LL | fn d<'a,'b>(v: &'a [u8]) -> Box { +LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.rs b/src/test/ui/regions/region-object-lifetime-in-coercion.rs index dfba04b0d25..2dc67599913 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.rs +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.rs @@ -4,30 +4,30 @@ trait Foo {} impl<'a> Foo for &'a [u8] {} -fn a(v: &[u8]) -> Box { - let x: Box = Box::new(v); +fn a(v: &[u8]) -> Box { + let x: Box = Box::new(v); //~^ ERROR explicit lifetime required in the type of `v` [E0621] x } -fn b(v: &[u8]) -> Box { +fn b(v: &[u8]) -> Box { Box::new(v) //~^ ERROR explicit lifetime required in the type of `v` [E0621] } -fn c(v: &[u8]) -> Box { +fn c(v: &[u8]) -> Box { // same as previous case due to RFC 599 Box::new(v) //~^ ERROR explicit lifetime required in the type of `v` [E0621] } -fn d<'a,'b>(v: &'a [u8]) -> Box { +fn d<'a,'b>(v: &'a [u8]) -> Box { Box::new(v) //~^ ERROR cannot infer an appropriate lifetime due to conflicting } -fn e<'a:'b,'b>(v: &'a [u8]) -> Box { +fn e<'a:'b,'b>(v: &'a [u8]) -> Box { Box::new(v) // OK, thanks to 'a:'b } diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr index c94a25ce604..8209fa1840d 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr @@ -1,15 +1,15 @@ error[E0621]: explicit lifetime required in the type of `v` - --> $DIR/region-object-lifetime-in-coercion.rs:8:33 + --> $DIR/region-object-lifetime-in-coercion.rs:8:37 | -LL | fn a(v: &[u8]) -> Box { +LL | fn a(v: &[u8]) -> Box { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` -LL | let x: Box = Box::new(v); - | ^^^^^^^^^^^ lifetime `'static` required +LL | let x: Box = Box::new(v); + | ^^^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:14:5 | -LL | fn b(v: &[u8]) -> Box { +LL | fn b(v: &[u8]) -> Box { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` LL | Box::new(v) | ^^^^^^^^^^^ lifetime `'static` required @@ -17,7 +17,7 @@ LL | Box::new(v) error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:21:5 | -LL | fn c(v: &[u8]) -> Box { +LL | fn c(v: &[u8]) -> Box { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` ... LL | Box::new(v) @@ -32,7 +32,7 @@ LL | Box::new(v) note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 25:6... --> $DIR/region-object-lifetime-in-coercion.rs:25:6 | -LL | fn d<'a,'b>(v: &'a [u8]) -> Box { +LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | ^^ = note: ...so that the expression is assignable: expected &[u8] @@ -40,7 +40,7 @@ LL | fn d<'a,'b>(v: &'a [u8]) -> Box { note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 25:9... --> $DIR/region-object-lifetime-in-coercion.rs:25:9 | -LL | fn d<'a,'b>(v: &'a [u8]) -> Box { +LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | ^^ = note: ...so that the expression is assignable: expected std::boxed::Box<(dyn Foo + 'b)> diff --git a/src/test/ui/regions/regions-close-associated-type-into-object.rs b/src/test/ui/regions/regions-close-associated-type-into-object.rs index 853d9611387..0cbdc828c50 100644 --- a/src/test/ui/regions/regions-close-associated-type-into-object.rs +++ b/src/test/ui/regions/regions-close-associated-type-into-object.rs @@ -9,54 +9,54 @@ trait Iter { fn as_item(&self) -> &Self::Item; } -fn bad1(v: T) -> Box +fn bad1(v: T) -> Box { let item = v.into_item(); Box::new(item) //~ ERROR associated type `::Item` may not live long enough } -fn bad2(v: T) -> Box +fn bad2(v: T) -> Box where Box : X { let item: Box<_> = box v.into_item(); Box::new(item) //~ ERROR associated type `::Item` may not live long enough } -fn bad3<'a, T: Iter>(v: T) -> Box +fn bad3<'a, T: Iter>(v: T) -> Box { let item = v.into_item(); Box::new(item) //~ ERROR associated type `::Item` may not live long enough } -fn bad4<'a, T: Iter>(v: T) -> Box +fn bad4<'a, T: Iter>(v: T) -> Box where Box : X { let item: Box<_> = box v.into_item(); Box::new(item) //~ ERROR associated type `::Item` may not live long enough } -fn ok1<'a, T: Iter>(v: T) -> Box +fn ok1<'a, T: Iter>(v: T) -> Box where T::Item : 'a { let item = v.into_item(); Box::new(item) // OK, T::Item : 'a is declared } -fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box +fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box where T::Item : Clone { let item = Clone::clone(w); Box::new(item) // OK, T::Item : 'a is implied } -fn ok3<'a, T: Iter>(v: &'a T) -> Box +fn ok3<'a, T: Iter>(v: &'a T) -> Box where T::Item : Clone + 'a { let item = Clone::clone(v.as_item()); Box::new(item) // OK, T::Item : 'a was declared } -fn meh1<'a, T: Iter>(v: &'a T) -> Box +fn meh1<'a, T: Iter>(v: &'a T) -> Box where T::Item : Clone { // This case is kind of interesting. It's the same as `ok3` but diff --git a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr index 42df9b1c49f..806a3ca8242 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr @@ -1,16 +1,16 @@ error: lifetime may not live long enough --> $DIR/regions-close-object-into-object-2.rs:10:5 | -LL | fn g<'a, T: 'static>(v: Box+'a>) -> Box { +LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { | -- lifetime `'a` defined here -LL | box B(&*v) as Box - | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` +LL | box B(&*v) as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error[E0515]: cannot return value referencing local data `*v` --> $DIR/regions-close-object-into-object-2.rs:10:5 | -LL | box B(&*v) as Box - | ^^^^^^---^^^^^^^^^^^ +LL | box B(&*v) as Box + | ^^^^^^---^^^^^^^^^^^^^^^ | | | | | `*v` is borrowed here | returns a value referencing data owned by the current function diff --git a/src/test/ui/regions/regions-close-object-into-object-2.rs b/src/test/ui/regions/regions-close-object-into-object-2.rs index cebb4ac68cb..2364ba27286 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.rs +++ b/src/test/ui/regions/regions-close-object-into-object-2.rs @@ -1,13 +1,13 @@ #![feature(box_syntax)] trait A { } -struct B<'a, T:'a>(&'a (A+'a)); +struct B<'a, T:'a>(&'a (dyn A + 'a)); trait X { } impl<'a, T> X for B<'a, T> {} -fn g<'a, T: 'static>(v: Box+'a>) -> Box { - box B(&*v) as Box //~ ERROR cannot infer +fn g<'a, T: 'static>(v: Box + 'a>) -> Box { + box B(&*v) as Box //~ ERROR cannot infer } fn main() { } diff --git a/src/test/ui/regions/regions-close-object-into-object-2.stderr b/src/test/ui/regions/regions-close-object-into-object-2.stderr index b5b03e618e1..fa203debb3a 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.stderr @@ -1,18 +1,18 @@ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements --> $DIR/regions-close-object-into-object-2.rs:10:11 | -LL | box B(&*v) as Box +LL | box B(&*v) as Box | ^^^ | note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 9:6... --> $DIR/regions-close-object-into-object-2.rs:9:6 | -LL | fn g<'a, T: 'static>(v: Box+'a>) -> Box { +LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { | ^^ note: ...so that the type `(dyn A + 'a)` is not borrowed for too long --> $DIR/regions-close-object-into-object-2.rs:10:11 | -LL | box B(&*v) as Box +LL | box B(&*v) as Box | ^^^ = note: but, the lifetime must be valid for the static lifetime... = note: ...so that the expression is assignable: diff --git a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr index 8af94fa7e79..1e57023bc23 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr @@ -1,7 +1,7 @@ error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:10:5 | -LL | box B(&*v) as Box +LL | box B(&*v) as Box | ^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `U: 'static`... @@ -9,16 +9,16 @@ LL | box B(&*v) as Box error: lifetime may not live long enough --> $DIR/regions-close-object-into-object-4.rs:10:5 | -LL | fn i<'a, T, U>(v: Box+'a>) -> Box { +LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | -- lifetime `'a` defined here -LL | box B(&*v) as Box - | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` +LL | box B(&*v) as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error[E0515]: cannot return value referencing local data `*v` --> $DIR/regions-close-object-into-object-4.rs:10:5 | -LL | box B(&*v) as Box - | ^^^^^^---^^^^^^^^^^^ +LL | box B(&*v) as Box + | ^^^^^^---^^^^^^^^^^^^^^^ | | | | | `*v` is borrowed here | returns a value referencing data owned by the current function @@ -26,7 +26,7 @@ LL | box B(&*v) as Box error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:10:9 | -LL | box B(&*v) as Box +LL | box B(&*v) as Box | ^^^^^^ | = help: consider adding an explicit lifetime bound `U: 'static`... diff --git a/src/test/ui/regions/regions-close-object-into-object-4.rs b/src/test/ui/regions/regions-close-object-into-object-4.rs index 91aab057bb9..d5310770436 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.rs +++ b/src/test/ui/regions/regions-close-object-into-object-4.rs @@ -1,13 +1,13 @@ #![feature(box_syntax)] trait A { } -struct B<'a, T:'a>(&'a (A+'a)); +struct B<'a, T:'a>(&'a (dyn A + 'a)); trait X { } impl<'a, T> X for B<'a, T> {} -fn i<'a, T, U>(v: Box+'a>) -> Box { - box B(&*v) as Box //~ ERROR cannot infer +fn i<'a, T, U>(v: Box+'a>) -> Box { + box B(&*v) as Box //~ ERROR cannot infer } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-4.stderr b/src/test/ui/regions/regions-close-object-into-object-4.stderr index 20cbcbb841f..f5e66f84a9e 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.stderr @@ -1,18 +1,18 @@ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements --> $DIR/regions-close-object-into-object-4.rs:10:11 | -LL | box B(&*v) as Box +LL | box B(&*v) as Box | ^^^ | note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 9:6... --> $DIR/regions-close-object-into-object-4.rs:9:6 | -LL | fn i<'a, T, U>(v: Box+'a>) -> Box { +LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | ^^ note: ...so that the type `(dyn A + 'a)` is not borrowed for too long --> $DIR/regions-close-object-into-object-4.rs:10:11 | -LL | box B(&*v) as Box +LL | box B(&*v) as Box | ^^^ = note: but, the lifetime must be valid for the static lifetime... = note: ...so that the expression is assignable: diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr index 30fdb820e36..7d3d51bdb43 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr @@ -1,7 +1,7 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | box v as Box +LL | box v as Box | ^^^^^ | = help: consider adding an explicit lifetime bound `A: 'static`... @@ -9,7 +9,7 @@ LL | box v as Box error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | box v as Box +LL | box v as Box | ^^^^^ | = help: consider adding an explicit lifetime bound `A: 'b`... diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.rs b/src/test/ui/regions/regions-close-over-type-parameter-1.rs index 9aee9663e8f..6a9aa66a446 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.rs +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.rs @@ -6,18 +6,18 @@ trait SomeTrait { fn get(&self) -> isize; } -fn make_object1(v: A) -> Box { - box v as Box +fn make_object1(v: A) -> Box { + box v as Box //~^ ERROR the parameter type `A` may not live long enough //~| ERROR the parameter type `A` may not live long enough } -fn make_object2<'a,A:SomeTrait+'a>(v: A) -> Box { - box v as Box +fn make_object2<'a,A:SomeTrait+'a>(v: A) -> Box { + box v as Box } -fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { - box v as Box +fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { + box v as Box //~^ ERROR the parameter type `A` may not live long enough //~| ERROR the parameter type `A` may not live long enough } diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.stderr index 615c55d9da3..81534b7b770 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.stderr @@ -1,58 +1,58 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | fn make_object1(v: A) -> Box { +LL | fn make_object1(v: A) -> Box { | -- help: consider adding an explicit lifetime bound `A: 'static`... -LL | box v as Box +LL | box v as Box | ^^^^^ | note: ...so that the type `A` will meet its required lifetime bounds --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | box v as Box +LL | box v as Box | ^^^^^ error[E0310]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | fn make_object1(v: A) -> Box { +LL | fn make_object1(v: A) -> Box { | -- help: consider adding an explicit lifetime bound `A: 'static`... -LL | box v as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...so that it can be closed over into an object --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | box v as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { +LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { | -- help: consider adding an explicit lifetime bound `A: 'b`... -LL | box v as Box +LL | box v as Box | ^^^^^ | note: ...so that the type `A` will meet its required lifetime bounds --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | box v as Box +LL | box v as Box | ^^^^^ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { +LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { | -- help: consider adding an explicit lifetime bound `A: 'b`... -LL | box v as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...so that it can be closed over into an object --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | box v as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr index 001ed7fe4c5..88d6abd1428 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr @@ -1,13 +1,13 @@ error: lifetime may not live long enough --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 | -LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { | -- -- lifetime `'c` defined here | | | lifetime `'a` defined here LL | // A outlives 'a AND 'b...but not 'c. -LL | box v as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'c` +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'c` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs b/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs index defbc5d9f23..26643e08985 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs @@ -5,19 +5,19 @@ trait SomeTrait { fn get(&self) -> isize; } -fn make_object_good1<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { +fn make_object_good1<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { // A outlives 'a AND 'b... - box v as Box // ...hence this type is safe. + box v as Box // ...hence this type is safe. } -fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { +fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { // A outlives 'a AND 'b... - box v as Box // ...hence this type is safe. + box v as Box // ...hence this type is safe. } -fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { +fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { // A outlives 'a AND 'b...but not 'c. - box v as Box //~ ERROR cannot infer an appropriate lifetime + box v as Box //~ ERROR cannot infer an appropriate lifetime } fn main() { diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr index 96e6a329e7d..8b3dbc8b649 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr @@ -1,23 +1,23 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 | -LL | box v as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 18:20... --> $DIR/regions-close-over-type-parameter-multiple.rs:18:20 | -LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { | ^^ note: ...so that the declared lifetime parameter bounds are satisfied --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 | -LL | box v as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: but, the lifetime must be valid for the lifetime 'c as defined on the function body at 18:26... --> $DIR/regions-close-over-type-parameter-multiple.rs:18:26 | -LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { | ^^ = note: ...so that the expression is assignable: expected std::boxed::Box<(dyn SomeTrait + 'c)> diff --git a/src/test/ui/regions/regions-close-param-into-object.rs b/src/test/ui/regions/regions-close-param-into-object.rs index 86590748cb2..2760e5eed95 100644 --- a/src/test/ui/regions/regions-close-param-into-object.rs +++ b/src/test/ui/regions/regions-close-param-into-object.rs @@ -1,24 +1,24 @@ trait X { fn foo(&self) {} } -fn p1(v: T) -> Box +fn p1(v: T) -> Box where T : X { Box::new(v) //~ ERROR parameter type `T` may not live long enough } -fn p2(v: Box) -> Box +fn p2(v: Box) -> Box where Box : X { Box::new(v) //~ ERROR parameter type `T` may not live long enough } -fn p3<'a,T>(v: T) -> Box +fn p3<'a,T>(v: T) -> Box where T : X { Box::new(v) //~ ERROR parameter type `T` may not live long enough } -fn p4<'a,T>(v: Box) -> Box +fn p4<'a,T>(v: Box) -> Box where Box : X { Box::new(v) //~ ERROR parameter type `T` may not live long enough diff --git a/src/test/ui/regions/regions-close-param-into-object.stderr b/src/test/ui/regions/regions-close-param-into-object.stderr index ef226073de6..7f2c646c121 100644 --- a/src/test/ui/regions/regions-close-param-into-object.stderr +++ b/src/test/ui/regions/regions-close-param-into-object.stderr @@ -1,7 +1,7 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:6:5 | -LL | fn p1(v: T) -> Box +LL | fn p1(v: T) -> Box | - help: consider adding an explicit lifetime bound `T: 'static`... ... LL | Box::new(v) @@ -16,7 +16,7 @@ LL | Box::new(v) error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:12:5 | -LL | fn p2(v: Box) -> Box +LL | fn p2(v: Box) -> Box | - help: consider adding an explicit lifetime bound `T: 'static`... ... LL | Box::new(v) @@ -31,7 +31,7 @@ LL | Box::new(v) error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:18:5 | -LL | fn p3<'a,T>(v: T) -> Box +LL | fn p3<'a,T>(v: T) -> Box | - help: consider adding an explicit lifetime bound `T: 'a`... ... LL | Box::new(v) @@ -46,7 +46,7 @@ LL | Box::new(v) error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:24:5 | -LL | fn p4<'a,T>(v: Box) -> Box +LL | fn p4<'a,T>(v: Box) -> Box | - help: consider adding an explicit lifetime bound `T: 'a`... ... LL | Box::new(v) diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs index 7e04b6782eb..a4272802af5 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs @@ -18,7 +18,7 @@ trait Trait2<'a, 'b> { // this argument `t` is not automatically considered well-formed, // since for it to be WF, we would need to know that `'y: 'x`, but we // do not infer that. -fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< >::Foo >) +fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< >::Foo >) //~^ ERROR reference has a longer lifetime than the data it references { } diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr index ca86eb7edae..b3390bcc4d5 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr @@ -1,7 +1,7 @@ error[E0491]: in type `&'x (dyn for<'z> Trait1<>::Foo> + 'x)`, reference has a longer lifetime than the data it references --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:1 | -LL | / fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< >::Foo >) +LL | / fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< >::Foo >) LL | | LL | | { LL | | } @@ -10,12 +10,12 @@ LL | | } note: the pointer is valid for the lifetime 'x as defined on the function body at 21:11 --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:11 | -LL | fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< >::Foo >) +LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< >::Foo >) | ^^ note: but the referenced data is only valid for the lifetime 'y as defined on the function body at 21:15 --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:15 | -LL | fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< >::Foo >) +LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< >::Foo >) | ^^ error: aborting due to previous error diff --git a/src/test/ui/regions/regions-infer-at-fn-not-param.rs b/src/test/ui/regions/regions-infer-at-fn-not-param.rs index 0fd734d57b5..fb9c5d5c210 100644 --- a/src/test/ui/regions/regions-infer-at-fn-not-param.rs +++ b/src/test/ui/regions/regions-infer-at-fn-not-param.rs @@ -1,13 +1,13 @@ struct Parameterized1<'a> { - g: Box + g: Box } struct NotParameterized1 { - g: Box + g: Box } struct NotParameterized2 { - g: Box + g: Box } fn take1<'a>(p: Parameterized1) -> Parameterized1<'a> { p } diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs index 168bf0284a1..5843598ab48 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs @@ -1,5 +1,5 @@ struct Invariant<'a> { - f: Box, + f: Box, } fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs index 90c86cebce3..f0af18cf618 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs @@ -1,5 +1,5 @@ struct Invariant<'a> { - f: Box *mut &'a isize + 'static>, + f: Box *mut &'a isize + 'static>, } fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { diff --git a/src/test/ui/regions/regions-infer-not-param.rs b/src/test/ui/regions/regions-infer-not-param.rs index 214402952a3..d1744f8a51e 100644 --- a/src/test/ui/regions/regions-infer-not-param.rs +++ b/src/test/ui/regions/regions-infer-not-param.rs @@ -4,12 +4,12 @@ struct Direct<'a> { struct Indirect1 { // Here the lifetime parameter of direct is bound by the fn() - g: Box + g: Box } struct Indirect2<'a> { // But here it is set to 'a - g: Box) + 'static> + g: Box) + 'static> } fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } //~ ERROR mismatched types diff --git a/src/test/ui/regions/regions-name-undeclared.rs b/src/test/ui/regions/regions-name-undeclared.rs index 230a97a04b6..044c6889772 100644 --- a/src/test/ui/regions/regions-name-undeclared.rs +++ b/src/test/ui/regions/regions-name-undeclared.rs @@ -33,14 +33,14 @@ fn bar<'a>(x: &'a isize) { // &'a CAN be declared on functions and used then: fn g<'a>(a: &'a isize) { } // OK - fn h(a: Box FnOnce(&'a isize)>) { } // OK + fn h(a: Box FnOnce(&'a isize)>) { } // OK } // Test nesting of lifetimes in fn type declarations fn fn_types(a: &'a isize, //~ ERROR undeclared lifetime - b: Box FnOnce(&'a isize, + b: Box FnOnce(&'a isize, &'b isize, //~ ERROR undeclared lifetime - Box FnOnce(&'a isize, + Box FnOnce(&'a isize, &'b isize)>, &'b isize)>, //~ ERROR undeclared lifetime c: &'a isize) //~ ERROR undeclared lifetime diff --git a/src/test/ui/regions/regions-nested-fns.nll.stderr b/src/test/ui/regions/regions-nested-fns.nll.stderr index c11c09b6d0d..97650636cb6 100644 --- a/src/test/ui/regions/regions-nested-fns.nll.stderr +++ b/src/test/ui/regions/regions-nested-fns.nll.stderr @@ -4,8 +4,8 @@ error[E0521]: borrowed data escapes outside of closure LL | let mut ay = &y; | ------ `ay` is declared here, outside of the closure body LL | -LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { - | - `z` is a reference that is only valid in the closure body +LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { + | - `z` is a reference that is only valid in the closure body ... LL | ay = z; | ^^^^^^ `z` escapes the closure body here @@ -25,8 +25,8 @@ LL | } error[E0597]: `y` does not live long enough --> $DIR/regions-nested-fns.rs:9:15 | -LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { - | --- value captured here +LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { + | --- value captured here LL | ay = x; LL | ay = &y; | ^ borrowed value does not live long enough diff --git a/src/test/ui/regions/regions-nested-fns.rs b/src/test/ui/regions/regions-nested-fns.rs index 161d812f016..c02d4e0ce45 100644 --- a/src/test/ui/regions/regions-nested-fns.rs +++ b/src/test/ui/regions/regions-nested-fns.rs @@ -4,13 +4,13 @@ fn nested<'x>(x: &'x isize) { let y = 3; let mut ay = &y; //~ ERROR E0495 - ignore:: FnMut(&'z isize)>>(Box::new(|z| { + ignore:: FnMut(&'z isize)>>(Box::new(|z| { ay = x; ay = &y; ay = z; })); - ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { if false { return x; } //~ ERROR E0312 if false { return ay; } return z; diff --git a/src/test/ui/regions/regions-nested-fns.stderr b/src/test/ui/regions/regions-nested-fns.stderr index 702254a0ac4..15c9c9ca4dd 100644 --- a/src/test/ui/regions/regions-nested-fns.stderr +++ b/src/test/ui/regions/regions-nested-fns.stderr @@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen LL | let mut ay = &y; | ^^ | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:54... - --> $DIR/regions-nested-fns.rs:7:54 +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:58... + --> $DIR/regions-nested-fns.rs:7:58 | -LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { - | ______________________________________________________^ +LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { + | __________________________________________________________^ LL | | ay = x; LL | | ay = &y; LL | | ay = z; @@ -19,11 +19,11 @@ note: ...so that reference does not outlive borrowed content | LL | ay = z; | ^ -note: but, the lifetime must be valid for the anonymous lifetime #2 defined on the body at 13:68... - --> $DIR/regions-nested-fns.rs:13:68 +note: but, the lifetime must be valid for the anonymous lifetime #2 defined on the body at 13:72... + --> $DIR/regions-nested-fns.rs:13:72 | -LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | ____________________________________________________________________^ +LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | ________________________________________________________________________^ LL | | if false { return x; } LL | | if false { return ay; } LL | | return z; @@ -39,11 +39,11 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... LL | if false { return x; } | ^ | -note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 13:68... - --> $DIR/regions-nested-fns.rs:13:68 +note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 13:72... + --> $DIR/regions-nested-fns.rs:13:72 | -LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | ____________________________________________________________________^ +LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | ________________________________________________________________________^ LL | | if false { return x; } LL | | if false { return ay; } LL | | return z; diff --git a/src/test/ui/regions/regions-proc-bound-capture.rs b/src/test/ui/regions/regions-proc-bound-capture.rs index f2010dbe62d..0c903b73849 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.rs +++ b/src/test/ui/regions/regions-proc-bound-capture.rs @@ -1,10 +1,10 @@ -fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { +fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { // This is legal, because the region bound on `proc` // states that it captures `x`. Box::new(move|| { *x }) } -fn static_proc(x: &isize) -> Box(isize) + 'static> { +fn static_proc(x: &isize) -> Box(isize) + 'static> { // This is illegal, because the region bound on `proc` is 'static. Box::new(move|| { *x }) //~ ERROR explicit lifetime required in the type of `x` [E0621] } diff --git a/src/test/ui/regions/regions-proc-bound-capture.stderr b/src/test/ui/regions/regions-proc-bound-capture.stderr index aea7347d53c..c53af34456e 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.stderr +++ b/src/test/ui/regions/regions-proc-bound-capture.stderr @@ -1,7 +1,7 @@ error[E0621]: explicit lifetime required in the type of `x` --> $DIR/regions-proc-bound-capture.rs:9:5 | -LL | fn static_proc(x: &isize) -> Box(isize) + 'static> { +LL | fn static_proc(x: &isize) -> Box(isize) + 'static> { | ------ help: add explicit lifetime `'static` to the type of `x`: `&'static isize` LL | // This is illegal, because the region bound on `proc` is 'static. LL | Box::new(move|| { *x }) diff --git a/src/test/ui/regions/regions-steal-closure.rs b/src/test/ui/regions/regions-steal-closure.rs index e6b34510bb5..83e93522c94 100644 --- a/src/test/ui/regions/regions-steal-closure.rs +++ b/src/test/ui/regions/regions-steal-closure.rs @@ -1,10 +1,10 @@ #![feature(fn_traits)] struct ClosureBox<'a> { - cl: Box, + cl: Box, } -fn box_it<'r>(x: Box) -> ClosureBox<'r> { +fn box_it<'r>(x: Box) -> ClosureBox<'r> { ClosureBox {cl: x} } diff --git a/src/test/ui/regions/regions-trait-1.rs b/src/test/ui/regions/regions-trait-1.rs index 72738871936..0da8ac53695 100644 --- a/src/test/ui/regions/regions-trait-1.rs +++ b/src/test/ui/regions/regions-trait-1.rs @@ -19,12 +19,12 @@ impl<'a> GetCtxt for HasCtxt<'a> { } -fn get_v(gc: Box) -> usize { +fn get_v(gc: Box) -> usize { gc.get_ctxt().v } fn main() { let ctxt = Ctxt { v: 22 }; let hc = HasCtxt { c: &ctxt }; - assert_eq!(get_v(box hc as Box), 22); + assert_eq!(get_v(box hc as Box), 22); } diff --git a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr index eccf1b5e8cf..f4b1a89db9a 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr +++ b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/regions-trait-object-subtyping.rs:15:5 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here @@ -12,7 +12,7 @@ LL | x error: lifetime may not live long enough --> $DIR/regions-trait-object-subtyping.rs:22:5 | -LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-trait-object-subtyping.rs b/src/test/ui/regions/regions-trait-object-subtyping.rs index eb262354456..5b36194870e 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.rs +++ b/src/test/ui/regions/regions-trait-object-subtyping.rs @@ -1,23 +1,23 @@ trait Dummy { fn dummy(&self); } -fn foo1<'a:'b,'b>(x: &'a mut (Dummy+'a)) -> &'b mut (Dummy+'b) { +fn foo1<'a:'b,'b>(x: &'a mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) { // Here, we are able to coerce x } -fn foo2<'a:'b,'b>(x: &'b mut (Dummy+'a)) -> &'b mut (Dummy+'b) { +fn foo2<'a:'b,'b>(x: &'b mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) { // Here, we are able to coerce x } -fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { // Without knowing 'a:'b, we can't coerce x //~ ERROR lifetime bound not satisfied //~^ ERROR cannot infer an appropriate lifetime } struct Wrapper(T); -fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { +fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { // We can't coerce because it is packed in `Wrapper` x //~ ERROR mismatched types } diff --git a/src/test/ui/regions/regions-trait-object-subtyping.stderr b/src/test/ui/regions/regions-trait-object-subtyping.stderr index f2d2b37d907..6de92f13840 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.stderr +++ b/src/test/ui/regions/regions-trait-object-subtyping.stderr @@ -7,12 +7,12 @@ LL | x note: lifetime parameter instantiated with the lifetime 'a as defined on the function body at 13:9 --> $DIR/regions-trait-object-subtyping.rs:13:9 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ note: but lifetime parameter must outlive the lifetime 'b as defined on the function body at 13:12 --> $DIR/regions-trait-object-subtyping.rs:13:12 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements @@ -24,7 +24,7 @@ LL | x note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 13:9... --> $DIR/regions-trait-object-subtyping.rs:13:9 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/regions-trait-object-subtyping.rs:15:5 @@ -34,7 +34,7 @@ LL | x note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 13:12... --> $DIR/regions-trait-object-subtyping.rs:13:12 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ = note: ...so that the expression is assignable: expected &'b mut (dyn Dummy + 'b) @@ -51,12 +51,12 @@ LL | x note: the lifetime 'b as defined on the function body at 20:15... --> $DIR/regions-trait-object-subtyping.rs:20:15 | -LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | ^^ note: ...does not necessarily outlive the lifetime 'a as defined on the function body at 20:9 --> $DIR/regions-trait-object-subtyping.rs:20:9 | -LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | ^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-trait-variance.rs b/src/test/ui/regions/regions-trait-variance.rs index 73baa84ec90..9169d457d40 100644 --- a/src/test/ui/regions/regions-trait-variance.rs +++ b/src/test/ui/regions/regions-trait-variance.rs @@ -23,10 +23,10 @@ impl Drop for B { } struct A<'r> { - p: &'r (X+'r) + p: &'r (dyn X + 'r) } -fn make_a(p:&X) -> A { +fn make_a(p: &dyn X) -> A { A{p:p} } diff --git a/src/test/ui/regions/regions-wf-trait-object.rs b/src/test/ui/regions/regions-wf-trait-object.rs index 61bab359f9a..d0053b20234 100644 --- a/src/test/ui/regions/regions-wf-trait-object.rs +++ b/src/test/ui/regions/regions-wf-trait-object.rs @@ -4,7 +4,7 @@ trait TheTrait<'t>: 't { } struct Foo<'a,'b> { - x: Box+'b> //~ ERROR E0478 + x: Box+'b> //~ ERROR E0478 } fn main() { } diff --git a/src/test/ui/regions/regions-wf-trait-object.stderr b/src/test/ui/regions/regions-wf-trait-object.stderr index 3dc1c4dcd22..4e12478c36d 100644 --- a/src/test/ui/regions/regions-wf-trait-object.stderr +++ b/src/test/ui/regions/regions-wf-trait-object.stderr @@ -1,8 +1,8 @@ error[E0478]: lifetime bound not satisfied --> $DIR/regions-wf-trait-object.rs:7:5 | -LL | x: Box+'b> - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | x: Box+'b> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime 'b as defined on the struct at 6:15 --> $DIR/regions-wf-trait-object.rs:6:15 diff --git a/src/test/ui/resolve/issue-23305.rs b/src/test/ui/resolve/issue-23305.rs index af335acd41b..95635e12a63 100644 --- a/src/test/ui/resolve/issue-23305.rs +++ b/src/test/ui/resolve/issue-23305.rs @@ -2,7 +2,7 @@ pub trait ToNbt { fn new(val: T) -> Self; } -impl ToNbt {} +impl dyn ToNbt {} //~^ ERROR cycle detected fn main() {} diff --git a/src/test/ui/resolve/issue-23305.stderr b/src/test/ui/resolve/issue-23305.stderr index 1da56ad05d2..0ed3af81d56 100644 --- a/src/test/ui/resolve/issue-23305.stderr +++ b/src/test/ui/resolve/issue-23305.stderr @@ -1,10 +1,10 @@ -error[E0391]: cycle detected when processing `` - --> $DIR/issue-23305.rs:5:12 +error[E0391]: cycle detected when processing `` + --> $DIR/issue-23305.rs:5:16 | -LL | impl ToNbt {} - | ^^^^ +LL | impl dyn ToNbt {} + | ^^^^ | - = note: ...which again requires processing ``, completing the cycle + = note: ...which again requires processing ``, completing the cycle note: cycle used when collecting item types in top-level module --> $DIR/issue-23305.rs:1:1 | diff --git a/src/test/ui/resolve/issue-33876.rs b/src/test/ui/resolve/issue-33876.rs index dd31fc231cf..e233ec631cc 100644 --- a/src/test/ui/resolve/issue-33876.rs +++ b/src/test/ui/resolve/issue-33876.rs @@ -7,6 +7,6 @@ trait Bar {} impl Bar for Foo {} fn main() { - let any: &Any = &Bar; //~ ERROR expected value, found trait `Bar` + let any: &dyn Any = &Bar; //~ ERROR expected value, found trait `Bar` if any.is::() { println!("u32"); } } diff --git a/src/test/ui/resolve/issue-33876.stderr b/src/test/ui/resolve/issue-33876.stderr index 29a63fdd11f..52308f2a7f0 100644 --- a/src/test/ui/resolve/issue-33876.stderr +++ b/src/test/ui/resolve/issue-33876.stderr @@ -1,8 +1,8 @@ error[E0423]: expected value, found trait `Bar` - --> $DIR/issue-33876.rs:10:22 + --> $DIR/issue-33876.rs:10:26 | -LL | let any: &Any = &Bar; - | ^^^ not a value +LL | let any: &dyn Any = &Bar; + | ^^^ not a value error: aborting due to previous error diff --git a/src/test/ui/resolve/issue-3907-2.rs b/src/test/ui/resolve/issue-3907-2.rs index dc9624698df..46f145e63e1 100644 --- a/src/test/ui/resolve/issue-3907-2.rs +++ b/src/test/ui/resolve/issue-3907-2.rs @@ -2,7 +2,7 @@ extern crate issue_3907; -type Foo = issue_3907::Foo+'static; +type Foo = dyn issue_3907::Foo + 'static; struct S { name: isize diff --git a/src/test/ui/resolve/issue-3907.rs b/src/test/ui/resolve/issue-3907.rs index 87e465489a4..6211de42717 100644 --- a/src/test/ui/resolve/issue-3907.rs +++ b/src/test/ui/resolve/issue-3907.rs @@ -2,7 +2,7 @@ extern crate issue_3907; -type Foo = issue_3907::Foo; +type Foo = dyn issue_3907::Foo; struct S { name: isize diff --git a/src/test/ui/resolve/issue-5035-2.rs b/src/test/ui/resolve/issue-5035-2.rs index f88a2375a43..b831bb4be34 100644 --- a/src/test/ui/resolve/issue-5035-2.rs +++ b/src/test/ui/resolve/issue-5035-2.rs @@ -1,5 +1,5 @@ trait I {} -type K = I+'static; +type K = dyn I + 'static; fn foo(_x: K) {} //~^ ERROR the size for values of type diff --git a/src/test/ui/resolve/issue-5035.rs b/src/test/ui/resolve/issue-5035.rs index c00567a75b7..49fa312f9d2 100644 --- a/src/test/ui/resolve/issue-5035.rs +++ b/src/test/ui/resolve/issue-5035.rs @@ -1,5 +1,5 @@ trait I {} -type K = I; +type K = dyn I; impl K for isize {} //~ ERROR expected trait, found type alias `K` use ImportError; //~ ERROR unresolved import `ImportError` [E0432] diff --git a/src/test/ui/rfc-2093-infer-outlives/self-structs.rs b/src/test/ui/rfc-2093-infer-outlives/self-structs.rs index d2550a99e81..8f2d29d6f17 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-structs.rs +++ b/src/test/ui/rfc-2093-infer-outlives/self-structs.rs @@ -2,7 +2,7 @@ #[rustc_outlives] struct Foo<'a, 'b, T> { //~ ERROR rustc_outlives - field1: Bar<'a, 'b, T> + field1: dyn Bar<'a, 'b, T> } trait Bar<'x, 's, U> diff --git a/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr b/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr index 9ae05dab74d..b32c9743e9e 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr @@ -2,7 +2,7 @@ error: rustc_outlives --> $DIR/self-structs.rs:4:1 | LL | / struct Foo<'a, 'b, T> { -LL | | field1: Bar<'a, 'b, T> +LL | | field1: dyn Bar<'a, 'b, T> LL | | } | |_^ | diff --git a/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs index b0d1fa1a74f..01daf307c00 100644 --- a/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs +++ b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs @@ -9,7 +9,7 @@ trait Foo { type Assoc where Self: Sized; type Assoc2 where T: Display; type Assoc3; - type WithDefault where T: Debug = Iterator; + type WithDefault where T: Debug = dyn Iterator; type NoGenerics; } @@ -19,7 +19,7 @@ impl Foo for Bar { type Assoc = usize; type Assoc2 = Vec; type Assoc3 where T: Iterator = Vec; - type WithDefault<'a, T> = &'a Iterator; + type WithDefault<'a, T> = &'a dyn Iterator; type NoGenerics = ::std::cell::Cell; } diff --git a/src/test/ui/rfc1623.rs b/src/test/ui/rfc1623.rs index 5920446dbc2..ebb4d56af9e 100644 --- a/src/test/ui/rfc1623.rs +++ b/src/test/ui/rfc1623.rs @@ -13,7 +13,7 @@ static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = struct SomeStruct<'x, 'y, 'z: 'x> { foo: &'x Foo<'z>, bar: &'x Bar<'z>, - f: &'y for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Bar<'b>, + f: &'y dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Bar<'b>, } fn id(t: T) -> T { diff --git a/src/test/ui/save-analysis/issue-59134-0.rs b/src/test/ui/save-analysis/issue-59134-0.rs index 3158328b3ff..a0871ca1809 100644 --- a/src/test/ui/save-analysis/issue-59134-0.rs +++ b/src/test/ui/save-analysis/issue-59134-0.rs @@ -4,7 +4,7 @@ pub fn f() { trait Trait {} - impl Trait { + impl dyn Trait { const FLAG: u32 = bogus.field; //~ ERROR cannot find value `bogus` } } diff --git a/src/test/ui/self/arbitrary-self-types-not-object-safe.rs b/src/test/ui/self/arbitrary-self-types-not-object-safe.rs index 2c1fd937a65..7443d888c9e 100644 --- a/src/test/ui/self/arbitrary-self-types-not-object-safe.rs +++ b/src/test/ui/self/arbitrary-self-types-not-object-safe.rs @@ -28,13 +28,13 @@ impl Bar for usize { } fn make_foo() { - let x = Rc::new(5usize) as Rc; + let x = Rc::new(5usize) as Rc; //~^ ERROR E0038 //~| ERROR E0038 } fn make_bar() { - let x = Rc::new(5usize) as Rc; + let x = Rc::new(5usize) as Rc; x.bar(); } diff --git a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr b/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr index dacab1222ab..e45bc2657f1 100644 --- a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr +++ b/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr @@ -1,15 +1,15 @@ error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/arbitrary-self-types-not-object-safe.rs:31:32 | -LL | let x = Rc::new(5usize) as Rc; - | ^^^^^^^ the trait `Foo` cannot be made into an object +LL | let x = Rc::new(5usize) as Rc; + | ^^^^^^^^^^^ the trait `Foo` cannot be made into an object | = note: method `foo`'s receiver cannot be dispatched on error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/arbitrary-self-types-not-object-safe.rs:31:13 | -LL | let x = Rc::new(5usize) as Rc; +LL | let x = Rc::new(5usize) as Rc; | ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object | = note: method `foo`'s receiver cannot be dispatched on diff --git a/src/test/ui/self/arbitrary_self_types_raw_pointer_trait.rs b/src/test/ui/self/arbitrary_self_types_raw_pointer_trait.rs index acbe896eebe..0a9370e6f5a 100644 --- a/src/test/ui/self/arbitrary_self_types_raw_pointer_trait.rs +++ b/src/test/ui/self/arbitrary_self_types_raw_pointer_trait.rs @@ -34,8 +34,8 @@ impl Foo for u32 { } fn main() { - let null_i32 = ptr::null::() as *const Foo; - let null_u32 = ptr::null::() as *const Foo; + let null_i32 = ptr::null::() as *const dyn Foo; + let null_u32 = ptr::null::() as *const dyn Foo; assert_eq!("I'm an i32!", null_i32.foo()); assert_eq!("I'm a u32!", null_u32.foo()); @@ -45,7 +45,7 @@ fn main() { assert_eq!("I'm an i32!", valid_i32_thin.foo()); assert_eq!(5, unsafe { valid_i32_thin.bar() }); assert_eq!(5, unsafe { (&valid_i32_thin as *const *const i32).complicated() }); - let valid_i32_fat = valid_i32_thin as *const Foo; + let valid_i32_fat = valid_i32_thin as *const dyn Foo; assert_eq!("I'm an i32!", valid_i32_fat.foo()); assert_eq!(5, unsafe { valid_i32_fat.bar() }); @@ -54,7 +54,7 @@ fn main() { assert_eq!("I'm a u32!", valid_u32_thin.foo()); assert_eq!(18, unsafe { valid_u32_thin.bar() }); assert_eq!(18, unsafe { (&valid_u32_thin as *const *const u32).complicated() }); - let valid_u32_fat = valid_u32_thin as *const Foo; + let valid_u32_fat = valid_u32_thin as *const dyn Foo; assert_eq!("I'm a u32!", valid_u32_fat.foo()); assert_eq!(18, unsafe { valid_u32_fat.bar() }); diff --git a/src/test/ui/self/explicit-self-objects-uniq.rs b/src/test/ui/self/explicit-self-objects-uniq.rs index f95686cf112..0050bc7124d 100644 --- a/src/test/ui/self/explicit-self-objects-uniq.rs +++ b/src/test/ui/self/explicit-self-objects-uniq.rs @@ -17,6 +17,6 @@ impl Foo for S { pub fn main() { let x = box S { x: 3 }; - let y = x as Box; + let y = x as Box; y.f(); } diff --git a/src/test/ui/self/object-safety-sized-self-by-value-self.rs b/src/test/ui/self/object-safety-sized-self-by-value-self.rs index ae0512666ce..43b1d8b9149 100644 --- a/src/test/ui/self/object-safety-sized-self-by-value-self.rs +++ b/src/test/ui/self/object-safety-sized-self-by-value-self.rs @@ -23,7 +23,7 @@ fn tick1(mut c: C) -> u32 { c.get() } -fn tick2(c: &mut Counter) { +fn tick2(c: &mut dyn Counter) { tick3(c); } diff --git a/src/test/ui/self/object-safety-sized-self-generic-method.rs b/src/test/ui/self/object-safety-sized-self-generic-method.rs index 0b3f6633737..e0b0526a333 100644 --- a/src/test/ui/self/object-safety-sized-self-generic-method.rs +++ b/src/test/ui/self/object-safety-sized-self-generic-method.rs @@ -23,7 +23,7 @@ fn tick1(c: &mut C) { c.with(|i| ()); } -fn tick2(c: &mut Counter) { +fn tick2(c: &mut dyn Counter) { tick3(c); } diff --git a/src/test/ui/self/object-safety-sized-self-return-Self.rs b/src/test/ui/self/object-safety-sized-self-return-Self.rs index e88dba0a4e8..222c7543945 100644 --- a/src/test/ui/self/object-safety-sized-self-return-Self.rs +++ b/src/test/ui/self/object-safety-sized-self-return-Self.rs @@ -23,7 +23,7 @@ fn preticked() -> C { c } -fn tick(c: &mut Counter) { +fn tick(c: &mut dyn Counter) { tick_generic(c); } diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs index db48bdf4c01..6099263ccd0 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs @@ -2,10 +2,10 @@ // Ensure that invoking a closure counts as a unique immutable borrow -type Fn<'a> = Box; +type Fn<'a> = Box; struct Test<'a> { - f: Box + f: Box } fn call(mut f: F) where F: FnMut(Fn) { @@ -47,9 +47,9 @@ fn test6() { } fn test7() { - fn foo(_: F) where F: FnMut(Box, isize) {} + fn foo(_: F) where F: FnMut(Box, isize) {} let s = String::new(); // Capture to make f !Copy - let mut f = move |g: Box, b: isize| { + let mut f = move |g: Box, b: isize| { let _ = s.len(); }; f(Box::new(|a| { diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr index 847f6865624..72f979e8d3c 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -29,7 +29,7 @@ LL | f.f.call_mut(()) error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13 | -LL | let mut f = move |g: Box, b: isize| { +LL | let mut f = move |g: Box, b: isize| { | ----- captured outer variable ... LL | foo(f); diff --git a/src/test/ui/span/borrowck-object-mutability.rs b/src/test/ui/span/borrowck-object-mutability.rs index e672c464535..f5adc2cc141 100644 --- a/src/test/ui/span/borrowck-object-mutability.rs +++ b/src/test/ui/span/borrowck-object-mutability.rs @@ -3,22 +3,22 @@ trait Foo { fn borrowed_mut(&mut self); } -fn borrowed_receiver(x: &Foo) { +fn borrowed_receiver(x: &dyn Foo) { x.borrowed(); x.borrowed_mut(); //~ ERROR cannot borrow } -fn borrowed_mut_receiver(x: &mut Foo) { +fn borrowed_mut_receiver(x: &mut dyn Foo) { x.borrowed(); x.borrowed_mut(); } -fn owned_receiver(x: Box) { +fn owned_receiver(x: Box) { x.borrowed(); x.borrowed_mut(); //~ ERROR cannot borrow } -fn mut_owned_receiver(mut x: Box) { +fn mut_owned_receiver(mut x: Box) { x.borrowed(); x.borrowed_mut(); } diff --git a/src/test/ui/span/borrowck-object-mutability.stderr b/src/test/ui/span/borrowck-object-mutability.stderr index fe6014cd5ad..fe6d05c588f 100644 --- a/src/test/ui/span/borrowck-object-mutability.stderr +++ b/src/test/ui/span/borrowck-object-mutability.stderr @@ -1,8 +1,8 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-object-mutability.rs:8:5 | -LL | fn borrowed_receiver(x: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut dyn Foo` +LL | fn borrowed_receiver(x: &dyn Foo) { + | -------- help: consider changing this to be a mutable reference: `&mut dyn Foo` LL | x.borrowed(); LL | x.borrowed_mut(); | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable @@ -10,7 +10,7 @@ LL | x.borrowed_mut(); error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable --> $DIR/borrowck-object-mutability.rs:18:5 | -LL | fn owned_receiver(x: Box) { +LL | fn owned_receiver(x: Box) { | - help: consider changing this to be mutable: `mut x` LL | x.borrowed(); LL | x.borrowed_mut(); diff --git a/src/test/ui/span/dropck-object-cycle.rs b/src/test/ui/span/dropck-object-cycle.rs index 8dc70ea252b..a26123d5246 100644 --- a/src/test/ui/span/dropck-object-cycle.rs +++ b/src/test/ui/span/dropck-object-cycle.rs @@ -8,7 +8,7 @@ trait Trait<'a> { fn short<'b>(&'b self) -> isize; } -fn object_invoke1<'d>(x: &'d Trait<'d>) -> (isize, isize) { loop { } } +fn object_invoke1<'d>(x: &'d dyn Trait<'d>) -> (isize, isize) { loop { } } trait MakerTrait { fn mk() -> Self; @@ -18,12 +18,12 @@ fn make_val() -> T { MakerTrait::mk() } -impl<'t> MakerTrait for Box+'static> { - fn mk() -> Box+'static> { loop { } } +impl<'t> MakerTrait for Box+'static> { + fn mk() -> Box+'static> { loop { } } } pub fn main() { - let m : Box = make_val(); + let m : Box = make_val(); assert_eq!(object_invoke1(&*m), (4,5)); //~^ ERROR `*m` does not live long enough diff --git a/src/test/ui/span/issue-25199.rs b/src/test/ui/span/issue-25199.rs index ed690443d4d..dbc3b190068 100644 --- a/src/test/ui/span/issue-25199.rs +++ b/src/test/ui/span/issue-25199.rs @@ -34,7 +34,7 @@ impl Drop for VecHolder { struct Container<'a> { v: VecHolder, - d: RefCell>>, + d: RefCell>>, } impl<'a> Container<'a> { diff --git a/src/test/ui/span/issue-26656.rs b/src/test/ui/span/issue-26656.rs index c5a70c87ed8..cde68da1897 100644 --- a/src/test/ui/span/issue-26656.rs +++ b/src/test/ui/span/issue-26656.rs @@ -10,7 +10,7 @@ impl Trigger for () { // Still unsound Zook trait Button { fn push(&self); } -struct Zook { button: B, trigger: Box+'static> } +struct Zook { button: B, trigger: Box+'static> } impl Drop for Zook { fn drop(&mut self) { diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs index 13e651fa56b..e34f84683bb 100644 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs +++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs @@ -11,6 +11,6 @@ fn main() { { let ss: &isize = &id(1); //~^ ERROR temporary value dropped while borrowed - blah = box ss as Box; + blah = box ss as Box; } } diff --git a/src/test/ui/span/regions-close-over-type-parameter-2.rs b/src/test/ui/span/regions-close-over-type-parameter-2.rs index 11187b74c42..29083154b89 100644 --- a/src/test/ui/span/regions-close-over-type-parameter-2.rs +++ b/src/test/ui/span/regions-close-over-type-parameter-2.rs @@ -10,8 +10,8 @@ impl Foo for A { fn get(&self) { } } -fn repeater3<'a,A:'a>(v: A) -> Box { - box v as Box +fn repeater3<'a,A:'a>(v: A) -> Box { + box v as Box } fn main() { diff --git a/src/test/ui/span/send-is-not-static-ensures-scoping.rs b/src/test/ui/span/send-is-not-static-ensures-scoping.rs index ac07420ee36..2aecc2a7e0d 100644 --- a/src/test/ui/span/send-is-not-static-ensures-scoping.rs +++ b/src/test/ui/span/send-is-not-static-ensures-scoping.rs @@ -1,5 +1,5 @@ struct Guard<'a> { - f: Box, + f: Box, } fn scoped<'a, F: Fn() + Send + 'a>(f: F) -> Guard<'a> { diff --git a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs index a3cc53e69e2..78487bd7bb5 100644 --- a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs +++ b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs @@ -4,7 +4,7 @@ pub trait T { type C; } pub struct Foo { - i: Box>, + i: Box>, //~^ ERROR must be specified //~| ERROR wrong number of type arguments } diff --git a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr index 5e333187e3d..d273ec3fca5 100644 --- a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr +++ b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr @@ -1,10 +1,10 @@ error[E0107]: wrong number of type arguments: expected 2, found 4 - --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:28 + --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:32 | -LL | i: Box>, - | ^^^^^ ^^^^^ unexpected type argument - | | - | unexpected type argument +LL | i: Box>, + | ^^^^^ ^^^^^ unexpected type argument + | | + | unexpected type argument error[E0191]: the value of the associated types `A` (from the trait `T`), `C` (from the trait `T`) must be specified --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:12 @@ -15,15 +15,15 @@ LL | type B; LL | type C; | ------- `C` defined here ... -LL | i: Box>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | i: Box>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | associated type `A` must be specified | associated type `C` must be specified help: if you meant to specify the associated types, write | -LL | i: Box>, - | ^^^^^^^^^ ^^^^^^^^^ +LL | i: Box>, + | ^^^^^^^^^ ^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/trait-alias/trait-alias-bounds.rs b/src/test/ui/traits/trait-alias/trait-alias-bounds.rs index 428ce5102ba..b97eb38c5af 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-bounds.rs +++ b/src/test/ui/traits/trait-alias/trait-alias-bounds.rs @@ -17,7 +17,7 @@ struct Foo(PhantomData); #[allow(dead_code)] struct Bar(PhantomData) where T: SendSyncAlias; -impl EmptyAlias {} +impl dyn EmptyAlias {} impl Empty for T {} diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs index afd8400e230..88feb89170d 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs +++ b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs @@ -114,13 +114,13 @@ type _T44 = dyn _4 + Send + Sync + _8; trait ObjL<'l> {} trait _9 = for<'a> ObjL<'a>; trait _10 = for<'b> ObjL<'b>; -type _T50 = _9 + _10; +type _T50 = dyn _9 + _10; //~^ ERROR only auto traits can be used as additional traits in a trait object [E0225] trait ObjT {} trait _11 = ObjT fn(&'a u8)>; trait _12 = ObjT fn(&'b u8)>; -type _T60 = _11 + _12; +type _T60 = dyn _11 + _12; //~^ ERROR only auto traits can be used as additional traits in a trait object [E0225] fn main() {} diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr index eb667c9522c..6df1df86508 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr +++ b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr @@ -430,28 +430,28 @@ LL | type _T44 = dyn _4 + Send + Sync + _8; | trait alias used in trait object type (first use) error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/trait-alias-no-duplicates.rs:117:18 + --> $DIR/trait-alias-no-duplicates.rs:117:22 | LL | trait _9 = for<'a> ObjL<'a>; | ---------------- first non-auto trait LL | trait _10 = for<'b> ObjL<'b>; | ---------------- additional non-auto trait -LL | type _T50 = _9 + _10; - | -- ^^^ trait alias used in trait object type (additional use) - | | - | trait alias used in trait object type (first use) +LL | type _T50 = dyn _9 + _10; + | -- ^^^ trait alias used in trait object type (additional use) + | | + | trait alias used in trait object type (first use) error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/trait-alias-no-duplicates.rs:123:19 + --> $DIR/trait-alias-no-duplicates.rs:123:23 | LL | trait _11 = ObjT fn(&'a u8)>; | ------------------------ first non-auto trait LL | trait _12 = ObjT fn(&'b u8)>; | ------------------------ additional non-auto trait -LL | type _T60 = _11 + _12; - | --- ^^^ trait alias used in trait object type (additional use) - | | - | trait alias used in trait object type (first use) +LL | type _T60 = dyn _11 + _12; + | --- ^^^ trait alias used in trait object type (additional use) + | | + | trait alias used in trait object type (first use) error: aborting due to 27 previous errors diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs b/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs index fd3af6f3a9a..33c9f2f00cf 100644 --- a/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs +++ b/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs @@ -6,6 +6,7 @@ trait Foo { fn foo(_x: Foo + Send) { //~^ ERROR the size for values of type + //~| WARN trait objects without an explicit `dyn` are deprecated } fn main() { } diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr index 5aee1e7e982..250ea4b1c32 100644 --- a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr +++ b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr @@ -1,3 +1,11 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/trait-bounds-not-on-bare-trait.rs:7:12 + | +LL | fn foo(_x: Foo + Send) { + | ^^^^^^^^^^ help: use `dyn`: `dyn Foo + Send` + | + = note: #[warn(bare_trait_objects)] on by default + error[E0277]: the size for values of type `(dyn Foo + std::marker::Send + 'static)` cannot be known at compilation time --> $DIR/trait-bounds-not-on-bare-trait.rs:7:8 | diff --git a/src/test/ui/traits/trait-bounds-sugar.rs b/src/test/ui/traits/trait-bounds-sugar.rs index 0892153c0cf..65b6f6faa42 100644 --- a/src/test/ui/traits/trait-bounds-sugar.rs +++ b/src/test/ui/traits/trait-bounds-sugar.rs @@ -2,17 +2,17 @@ trait Foo {} -fn a(_x: Box) { +fn a(_x: Box) { } -fn b(_x: &'static (Foo+'static)) { +fn b(_x: &'static (dyn Foo + 'static)) { } -fn c(x: Box) { +fn c(x: Box) { a(x); //~ ERROR mismatched types } -fn d(x: &'static (Foo+Sync)) { +fn d(x: &'static (dyn Foo + Sync)) { b(x); } diff --git a/src/test/ui/traits/trait-coercion-generic-bad.rs b/src/test/ui/traits/trait-coercion-generic-bad.rs index 5aa21834148..2e115c732b9 100644 --- a/src/test/ui/traits/trait-coercion-generic-bad.rs +++ b/src/test/ui/traits/trait-coercion-generic-bad.rs @@ -13,7 +13,7 @@ impl Trait<&'static str> for Struct { } fn main() { - let s: Box> = Box::new(Struct { person: "Fred" }); + let s: Box> = Box::new(Struct { person: "Fred" }); //~^ ERROR `Struct: Trait` is not satisfied s.f(1); } diff --git a/src/test/ui/traits/trait-coercion-generic-bad.stderr b/src/test/ui/traits/trait-coercion-generic-bad.stderr index 7f3b46b8ae5..f2710dea095 100644 --- a/src/test/ui/traits/trait-coercion-generic-bad.stderr +++ b/src/test/ui/traits/trait-coercion-generic-bad.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `Struct: Trait` is not satisfied - --> $DIR/trait-coercion-generic-bad.rs:16:32 + --> $DIR/trait-coercion-generic-bad.rs:16:36 | -LL | let s: Box> = Box::new(Struct { person: "Fred" }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `Struct` +LL | let s: Box> = Box::new(Struct { person: "Fred" }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `Struct` | = help: the following implementations were found: > diff --git a/src/test/ui/traits/trait-coercion-generic-regions.rs b/src/test/ui/traits/trait-coercion-generic-regions.rs index 148b7dd5c43..af478df6dfa 100644 --- a/src/test/ui/traits/trait-coercion-generic-regions.rs +++ b/src/test/ui/traits/trait-coercion-generic-regions.rs @@ -15,5 +15,5 @@ impl Trait<&'static str> for Struct { fn main() { let person = "Fred".to_string(); let person: &str = &person; //~ ERROR `person` does not live long enough - let s: Box> = Box::new(Struct { person: person }); + let s: Box> = Box::new(Struct { person: person }); } diff --git a/src/test/ui/traits/trait-coercion-generic-regions.stderr b/src/test/ui/traits/trait-coercion-generic-regions.stderr index 4ee3e4cacc3..d21b48e571d 100644 --- a/src/test/ui/traits/trait-coercion-generic-regions.stderr +++ b/src/test/ui/traits/trait-coercion-generic-regions.stderr @@ -6,7 +6,7 @@ LL | let person: &str = &person; | | | borrowed value does not live long enough | assignment requires that `person` is borrowed for `'static` -LL | let s: Box> = Box::new(Struct { person: person }); +LL | let s: Box> = Box::new(Struct { person: person }); LL | } | - `person` dropped here while still borrowed diff --git a/src/test/ui/traits/trait-impl-1.rs b/src/test/ui/traits/trait-impl-1.rs index 29f58a6a9cb..43b82221835 100644 --- a/src/test/ui/traits/trait-impl-1.rs +++ b/src/test/ui/traits/trait-impl-1.rs @@ -4,7 +4,7 @@ trait T {} -impl<'a> T+'a { +impl<'a> dyn T + 'a { fn foo(&self) {} } diff --git a/src/test/ui/traits/trait-item-privacy.rs b/src/test/ui/traits/trait-item-privacy.rs index dfc8c8f4f6c..d58bbef38c4 100644 --- a/src/test/ui/traits/trait-item-privacy.rs +++ b/src/test/ui/traits/trait-item-privacy.rs @@ -68,7 +68,7 @@ fn check_method() { S.b(); //~ ERROR no method named `b` found for type `S` in the current scope S.c(); // OK // a, b, c are resolved as inherent items, their traits don't need to be in scope - let c = &S as &C; + let c = &S as &dyn C; c.a(); //~ ERROR method `a` is private c.b(); // OK c.c(); // OK @@ -121,10 +121,10 @@ fn check_assoc_ty() { let _: T::C; // OK // Associated types, bindings - let _: assoc_ty::B< + let _: dyn assoc_ty::B< B = u8, // OK >; - let _: C< + let _: dyn C< A = u8, //~ ERROR associated type `A` is private B = u8, // OK C = u8, // OK diff --git a/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs b/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs index 6ba5d28a6c4..85698f19489 100644 --- a/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs +++ b/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs @@ -5,15 +5,15 @@ struct Struct; impl Trait for Struct {} trait Trait {} -type Send1 = Trait + Send; -type Send2 = Trait + Send + Send; +type Send1 = dyn Trait + Send; +type Send2 = dyn Trait + Send + Send; fn main () {} -impl Trait + Send { +impl dyn Trait + Send { fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name `test` } -impl Trait + Send + Send { +impl dyn Trait + Send + Send { fn test(&self) { println!("two"); } } diff --git a/src/test/ui/traits/trait-object-macro-matcher.rs b/src/test/ui/traits/trait-object-macro-matcher.rs index 0f55e2dc4f2..5ec157275a6 100644 --- a/src/test/ui/traits/trait-object-macro-matcher.rs +++ b/src/test/ui/traits/trait-object-macro-matcher.rs @@ -5,7 +5,8 @@ macro_rules! m { } fn main() { - m!(Copy + Send + 'static); //~ ERROR the trait `std::marker::Copy` cannot be made into an object - m!('static + Send); - m!('static +); //~ ERROR at least one non-builtin trait is required for an object type + m!(dyn Copy + Send + 'static); + //~^ ERROR the trait `std::marker::Copy` cannot be made into an object + m!(dyn 'static + Send); + m!(dyn 'static +); //~ ERROR at least one non-builtin trait is required for an object type } diff --git a/src/test/ui/traits/trait-object-macro-matcher.stderr b/src/test/ui/traits/trait-object-macro-matcher.stderr index 57a529ebc57..0b84c3dfcb0 100644 --- a/src/test/ui/traits/trait-object-macro-matcher.stderr +++ b/src/test/ui/traits/trait-object-macro-matcher.stderr @@ -1,14 +1,14 @@ error[E0224]: at least one non-builtin trait is required for an object type - --> $DIR/trait-object-macro-matcher.rs:10:8 + --> $DIR/trait-object-macro-matcher.rs:11:8 | -LL | m!('static +); - | ^^^^^^^^^ +LL | m!(dyn 'static +); + | ^^^^^^^^^^^^^ error[E0038]: the trait `std::marker::Copy` cannot be made into an object --> $DIR/trait-object-macro-matcher.rs:8:8 | -LL | m!(Copy + Send + 'static); - | ^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` cannot be made into an object +LL | m!(dyn Copy + Send + 'static); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/traits/trait-object-safety.rs b/src/test/ui/traits/trait-object-safety.rs index e333bf6bfe5..f43d332d696 100644 --- a/src/test/ui/traits/trait-object-safety.rs +++ b/src/test/ui/traits/trait-object-safety.rs @@ -12,6 +12,6 @@ impl Tr for St { } fn main() { - let _: &Tr = &St; //~ ERROR E0038 + let _: &dyn Tr = &St; //~ ERROR E0038 //~^ ERROR E0038 } diff --git a/src/test/ui/traits/trait-object-safety.stderr b/src/test/ui/traits/trait-object-safety.stderr index a7fe83cb756..68edc178705 100644 --- a/src/test/ui/traits/trait-object-safety.stderr +++ b/src/test/ui/traits/trait-object-safety.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Tr` cannot be made into an object - --> $DIR/trait-object-safety.rs:15:18 + --> $DIR/trait-object-safety.rs:15:22 | -LL | let _: &Tr = &St; - | ^^^ the trait `Tr` cannot be made into an object +LL | let _: &dyn Tr = &St; + | ^^^ the trait `Tr` cannot be made into an object | = note: method `foo` has no receiver = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&dyn Tr>` for `&St` @@ -10,8 +10,8 @@ LL | let _: &Tr = &St; error[E0038]: the trait `Tr` cannot be made into an object --> $DIR/trait-object-safety.rs:15:12 | -LL | let _: &Tr = &St; - | ^^^ the trait `Tr` cannot be made into an object +LL | let _: &dyn Tr = &St; + | ^^^^^^^ the trait `Tr` cannot be made into an object | = note: method `foo` has no receiver diff --git a/src/test/ui/traits/trait-object-vs-lifetime-2.rs b/src/test/ui/traits/trait-object-vs-lifetime-2.rs index 2579a0056f1..4d56fcf11e3 100644 --- a/src/test/ui/traits/trait-object-vs-lifetime-2.rs +++ b/src/test/ui/traits/trait-object-vs-lifetime-2.rs @@ -6,7 +6,7 @@ // `'static` is a lifetime, `'static +` is a type, `'a` is a type fn g() where 'static: 'static, - 'static +: 'static + Copy, + dyn 'static +: 'static + Copy, //~^ ERROR at least one non-builtin trait is required for an object type {} diff --git a/src/test/ui/traits/trait-object-vs-lifetime-2.stderr b/src/test/ui/traits/trait-object-vs-lifetime-2.stderr index 057f587a7b6..24162c920be 100644 --- a/src/test/ui/traits/trait-object-vs-lifetime-2.stderr +++ b/src/test/ui/traits/trait-object-vs-lifetime-2.stderr @@ -1,8 +1,8 @@ error[E0224]: at least one non-builtin trait is required for an object type --> $DIR/trait-object-vs-lifetime-2.rs:9:5 | -LL | 'static +: 'static + Copy, - | ^^^^^^^^^ +LL | dyn 'static +: 'static + Copy, + | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/traits/trait-object-vs-lifetime.rs b/src/test/ui/traits/trait-object-vs-lifetime.rs index 36dec21be05..803b29367c8 100644 --- a/src/test/ui/traits/trait-object-vs-lifetime.rs +++ b/src/test/ui/traits/trait-object-vs-lifetime.rs @@ -6,12 +6,12 @@ struct S<'a, T>(&'a u8, T); fn main() { // `'static` is a lifetime argument, `'static +` is a type argument let _: S<'static, u8>; - let _: S<'static, 'static +>; + let _: S<'static, dyn 'static +>; //~^ at least one non-builtin trait is required for an object type let _: S<'static, 'static>; //~^ ERROR wrong number of lifetime arguments: expected 1, found 2 //~| ERROR wrong number of type arguments: expected 1, found 0 - let _: S<'static +, 'static>; + let _: S; //~^ ERROR lifetime arguments must be declared prior to type arguments //~| ERROR at least one non-builtin trait is required for an object type } diff --git a/src/test/ui/traits/trait-object-vs-lifetime.stderr b/src/test/ui/traits/trait-object-vs-lifetime.stderr index c13d0e3f293..be1af59ed4f 100644 --- a/src/test/ui/traits/trait-object-vs-lifetime.stderr +++ b/src/test/ui/traits/trait-object-vs-lifetime.stderr @@ -1,14 +1,14 @@ error: lifetime arguments must be declared prior to type arguments - --> $DIR/trait-object-vs-lifetime.rs:14:25 + --> $DIR/trait-object-vs-lifetime.rs:14:29 | -LL | let _: S<'static +, 'static>; - | ^^^^^^^ +LL | let _: S; + | ^^^^^^^ error[E0224]: at least one non-builtin trait is required for an object type --> $DIR/trait-object-vs-lifetime.rs:9:23 | -LL | let _: S<'static, 'static +>; - | ^^^^^^^^^ +LL | let _: S<'static, dyn 'static +>; + | ^^^^^^^^^^^^^ error[E0107]: wrong number of lifetime arguments: expected 1, found 2 --> $DIR/trait-object-vs-lifetime.rs:11:23 @@ -25,8 +25,8 @@ LL | let _: S<'static, 'static>; error[E0224]: at least one non-builtin trait is required for an object type --> $DIR/trait-object-vs-lifetime.rs:14:14 | -LL | let _: S<'static +, 'static>; - | ^^^^^^^^^ +LL | let _: S; + | ^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/src/test/ui/traits/trait-test-2.rs b/src/test/ui/traits/trait-test-2.rs index 20d979df4bf..86570f1152e 100644 --- a/src/test/ui/traits/trait-test-2.rs +++ b/src/test/ui/traits/trait-test-2.rs @@ -8,7 +8,7 @@ impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah(&self) {} } fn main() { 10.dup::(); //~ ERROR wrong number of type arguments: expected 0, found 1 10.blah::(); //~ ERROR wrong number of type arguments: expected 1, found 2 - (box 10 as Box).dup(); + (box 10 as Box).dup(); //~^ ERROR E0038 //~| ERROR E0038 } diff --git a/src/test/ui/traits/trait-test-2.stderr b/src/test/ui/traits/trait-test-2.stderr index 0e3446e0d23..5d5251925a1 100644 --- a/src/test/ui/traits/trait-test-2.stderr +++ b/src/test/ui/traits/trait-test-2.stderr @@ -13,8 +13,8 @@ LL | 10.blah::(); error[E0038]: the trait `bar` cannot be made into an object --> $DIR/trait-test-2.rs:11:16 | -LL | (box 10 as Box).dup(); - | ^^^^^^^^ the trait `bar` cannot be made into an object +LL | (box 10 as Box).dup(); + | ^^^^^^^^^^^^ the trait `bar` cannot be made into an object | = note: method `dup` references the `Self` type in its arguments or return type = note: method `blah` has generic type parameters @@ -22,7 +22,7 @@ LL | (box 10 as Box).dup(); error[E0038]: the trait `bar` cannot be made into an object --> $DIR/trait-test-2.rs:11:6 | -LL | (box 10 as Box).dup(); +LL | (box 10 as Box).dup(); | ^^^^^^ the trait `bar` cannot be made into an object | = note: method `dup` references the `Self` type in its arguments or return type diff --git a/src/test/ui/traits/traits-repeated-supertrait-ambig.rs b/src/test/ui/traits/traits-repeated-supertrait-ambig.rs index 5fa7e87aa4b..6aaef8a305b 100644 --- a/src/test/ui/traits/traits-repeated-supertrait-ambig.rs +++ b/src/test/ui/traits/traits-repeated-supertrait-ambig.rs @@ -22,7 +22,7 @@ impl CompareTo for i64 { impl CompareToInts for i64 { } -fn with_obj(c: &CompareToInts) -> bool { +fn with_obj(c: &dyn CompareToInts) -> bool { c.same_as(22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfied } diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs index a5d5b937726..d411807673c 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs @@ -13,8 +13,8 @@ struct T { struct S(str, str) where str: Sized; -fn unsized_local() where for<'a> T: Sized { - let x: T = *(Box::new(T { x: 1 }) as Box>); +fn unsized_local() where for<'a> T: Sized { + let x: T = *(Box::new(T { x: 1 }) as Box>); } fn return_str() -> str where str: Sized { diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr index a9d2634c1ad..fda1d6d70ac 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr @@ -7,10 +7,10 @@ LL | struct S(str, str) where str: Sized; = note: #[warn(trivial_bounds)] on by default warning: Trait bound for<'a> T<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-sized.rs:16:45 + --> $DIR/trivial-bounds-inconsistent-sized.rs:16:49 | -LL | fn unsized_local() where for<'a> T: Sized { - | ^^^^^ +LL | fn unsized_local() where for<'a> T: Sized { + | ^^^^^ warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters --> $DIR/trivial-bounds-inconsistent-sized.rs:20:35 diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs index fdbaec9a5c7..f6538b14d17 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs @@ -52,8 +52,8 @@ struct Dst { struct TwoStrs(str, str) where str: Sized; -fn unsized_local() where for<'a> Dst: Sized { - let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); +fn unsized_local() where for<'a> Dst: Sized { + let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); } fn return_str() -> str where str: Sized { diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr index 744e146f830..a0d638f1714 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr @@ -64,10 +64,10 @@ LL | struct TwoStrs(str, str) where str: Sized; | ^^^^^ warning: Trait bound for<'a> Dst<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:55:47 + --> $DIR/trivial-bounds-inconsistent.rs:55:51 | -LL | fn unsized_local() where for<'a> Dst: Sized { - | ^^^^^ +LL | fn unsized_local() where for<'a> Dst: Sized { + | ^^^^^ warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters --> $DIR/trivial-bounds-inconsistent.rs:59:35 diff --git a/src/test/ui/trivial_casts.rs b/src/test/ui/trivial_casts.rs index c1f5441a36b..dd578e074fd 100644 --- a/src/test/ui/trivial_casts.rs +++ b/src/test/ui/trivial_casts.rs @@ -49,29 +49,29 @@ pub fn main() { // unsize trait let x: &Bar = &Bar; - let _ = x as &Foo; //~ERROR trivial cast: `&Bar` as `&dyn Foo` - let _ = x as *const Foo; //~ERROR trivial cast: `&Bar` as `*const dyn Foo` - let _: &Foo = x; - let _: *const Foo = x; + let _ = x as &dyn Foo; //~ERROR trivial cast: `&Bar` as `&dyn Foo` + let _ = x as *const dyn Foo; //~ERROR trivial cast: `&Bar` as `*const dyn Foo` + let _: &dyn Foo = x; + let _: *const dyn Foo = x; let x: &mut Bar = &mut Bar; - let _ = x as &mut Foo; //~ERROR trivial cast: `&mut Bar` as `&mut dyn Foo` - let _ = x as *mut Foo; //~ERROR trivial cast: `&mut Bar` as `*mut dyn Foo` - let _: &mut Foo = x; - let _: *mut Foo = x; + let _ = x as &mut dyn Foo; //~ERROR trivial cast: `&mut Bar` as `&mut dyn Foo` + let _ = x as *mut dyn Foo; //~ERROR trivial cast: `&mut Bar` as `*mut dyn Foo` + let _: &mut dyn Foo = x; + let _: *mut dyn Foo = x; let x: Box = Box::new(Bar); - let _ = x as Box; //~ERROR `std::boxed::Box` as `std::boxed::Box` + let _ = x as Box; //~ERROR `std::boxed::Box` as `std::boxed::Box` let x: Box = Box::new(Bar); - let _: Box = x; + let _: Box = x; // functions fn baz(_x: i32) {} - let _ = &baz as &Fn(i32); //~ERROR `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` - let _: &Fn(i32) = &baz; + let _ = &baz as &dyn Fn(i32); //~ERROR `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` + let _: &dyn Fn(i32) = &baz; let x = |_x: i32| {}; - let _ = &x as &Fn(i32); //~ERROR trivial cast - let _: &Fn(i32) = &x; + let _ = &x as &dyn Fn(i32); //~ERROR trivial cast + let _: &dyn Fn(i32) = &x; } // subtyping diff --git a/src/test/ui/trivial_casts.stderr b/src/test/ui/trivial_casts.stderr index 524eb7feaaf..8fa44372f0b 100644 --- a/src/test/ui/trivial_casts.stderr +++ b/src/test/ui/trivial_casts.stderr @@ -83,56 +83,56 @@ LL | let _ = x as Box<[u32]>; error: trivial cast: `&Bar` as `&dyn Foo` --> $DIR/trivial_casts.rs:52:13 | -LL | let _ = x as &Foo; - | ^^^^^^^^^ +LL | let _ = x as &dyn Foo; + | ^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&Bar` as `*const dyn Foo` --> $DIR/trivial_casts.rs:53:13 | -LL | let _ = x as *const Foo; - | ^^^^^^^^^^^^^^^ +LL | let _ = x as *const dyn Foo; + | ^^^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&mut Bar` as `&mut dyn Foo` --> $DIR/trivial_casts.rs:58:13 | -LL | let _ = x as &mut Foo; - | ^^^^^^^^^^^^^ +LL | let _ = x as &mut dyn Foo; + | ^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&mut Bar` as `*mut dyn Foo` --> $DIR/trivial_casts.rs:59:13 | -LL | let _ = x as *mut Foo; - | ^^^^^^^^^^^^^ +LL | let _ = x as *mut dyn Foo; + | ^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `std::boxed::Box` as `std::boxed::Box` --> $DIR/trivial_casts.rs:64:13 | -LL | let _ = x as Box; - | ^^^^^^^^^^^^^ +LL | let _ = x as Box; + | ^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` --> $DIR/trivial_casts.rs:70:13 | -LL | let _ = &baz as &Fn(i32); - | ^^^^^^^^^^^^^^^^ +LL | let _ = &baz as &dyn Fn(i32); + | ^^^^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&[closure@$DIR/trivial_casts.rs:72:13: 72:25]` as `&dyn std::ops::Fn(i32)` --> $DIR/trivial_casts.rs:73:13 | -LL | let _ = &x as &Fn(i32); - | ^^^^^^^^^^^^^^ +LL | let _ = &x as &dyn Fn(i32); + | ^^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable diff --git a/src/test/ui/type/type-arg-out-of-scope.rs b/src/test/ui/type/type-arg-out-of-scope.rs index d5b815f6a95..02aad007707 100644 --- a/src/test/ui/type/type-arg-out-of-scope.rs +++ b/src/test/ui/type/type-arg-out-of-scope.rs @@ -1,5 +1,5 @@ // error-pattern:can't use generic parameters from outer function fn foo(x: T) { - fn bar(f: Box T>) { } + fn bar(f: Box T>) { } } fn main() { foo(1); } diff --git a/src/test/ui/type/type-arg-out-of-scope.stderr b/src/test/ui/type/type-arg-out-of-scope.stderr index ea991069c08..0b6283fbc51 100644 --- a/src/test/ui/type/type-arg-out-of-scope.stderr +++ b/src/test/ui/type/type-arg-out-of-scope.stderr @@ -1,20 +1,20 @@ error[E0401]: can't use generic parameters from outer function - --> $DIR/type-arg-out-of-scope.rs:3:25 + --> $DIR/type-arg-out-of-scope.rs:3:29 | LL | fn foo(x: T) { | - type parameter from outer function -LL | fn bar(f: Box T>) { } - | --- ^ use of generic parameter from outer function +LL | fn bar(f: Box T>) { } + | --- ^ use of generic parameter from outer function | | | help: try using a local generic parameter instead: `bar` error[E0401]: can't use generic parameters from outer function - --> $DIR/type-arg-out-of-scope.rs:3:31 + --> $DIR/type-arg-out-of-scope.rs:3:35 | LL | fn foo(x: T) { | - type parameter from outer function -LL | fn bar(f: Box T>) { } - | --- ^ use of generic parameter from outer function +LL | fn bar(f: Box T>) { } + | --- ^ use of generic parameter from outer function | | | help: try using a local generic parameter instead: `bar` diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs index 3e1c876c76b..444453dc694 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs @@ -11,7 +11,7 @@ impl MyAdd for i32 { fn main() { let x: i32 = 5; - let y = x as MyAdd; + let y = x as dyn MyAdd; //~^ ERROR E0038 //~| ERROR cast to unsized type: `i32` as `dyn MyAdd` } diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr index 0beb9e9eb4b..58727ea0fef 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr @@ -1,20 +1,20 @@ error[E0620]: cast to unsized type: `i32` as `dyn MyAdd` --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:13 | -LL | let y = x as MyAdd; - | ^^^^^^^^^^^^^^^ +LL | let y = x as dyn MyAdd; + | ^^^^^^^^^^^^^^^^^^^ | help: consider using a box or reference as appropriate --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:13 | -LL | let y = x as MyAdd; +LL | let y = x as dyn MyAdd; | ^ error[E0038]: the trait `MyAdd` cannot be made into an object --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:18 | -LL | let y = x as MyAdd; - | ^^^^^^^^^^ the trait `MyAdd` cannot be made into an object +LL | let y = x as dyn MyAdd; + | ^^^^^^^^^^^^^^ the trait `MyAdd` cannot be made into an object | = note: method `add` references the `Self` type in its arguments or return type diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self.rs b/src/test/ui/type/type-parameter-defaults-referencing-Self.rs index 721bf960a55..a4c59dced02 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self.rs +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self.rs @@ -7,7 +7,7 @@ trait Foo { fn method(&self); } -fn foo(x: &Foo) { } +fn foo(x: &dyn Foo) { } //~^ ERROR the type parameter `T` must be explicitly specified fn main() { } diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr b/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr index 70093b61f25..0d6ca9d9dcd 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr @@ -1,8 +1,8 @@ error[E0393]: the type parameter `T` must be explicitly specified - --> $DIR/type-parameter-defaults-referencing-Self.rs:10:12 + --> $DIR/type-parameter-defaults-referencing-Self.rs:10:16 | -LL | fn foo(x: &Foo) { } - | ^^^ missing reference to `T` +LL | fn foo(x: &dyn Foo) { } + | ^^^ missing reference to `T` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.rs b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.rs index 77608664362..f466c19e051 100644 --- a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.rs +++ b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.rs @@ -1,7 +1,7 @@ fn foo1, U>(x: T) {} //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] -trait Trait: Copy {} +trait Trait: Copy {} //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] struct MyStruct1>; diff --git a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr index 0242287a3e5..0be1c8ef3bc 100644 --- a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr +++ b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr @@ -7,8 +7,8 @@ LL | fn foo1, U>(x: T) {} error[E0107]: wrong number of type arguments: expected 0, found 1 --> $DIR/typeck-builtin-bound-type-parameters.rs:4:19 | -LL | trait Trait: Copy {} - | ^^^^ unexpected type argument +LL | trait Trait: Copy {} + | ^^^^^^^^ unexpected type argument error[E0107]: wrong number of type arguments: expected 0, found 1 --> $DIR/typeck-builtin-bound-type-parameters.rs:7:26 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.rs b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.rs index 1eb9de778e8..d8b201bf82d 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.rs @@ -10,11 +10,11 @@ trait Foo { } fn main() { - let x: Box; + let x: Box; //~^ ERROR parenthetical notation is only stable when used with `Fn`-family // No errors with these: - let x: Box; - let x: Box; - let x: Box; + let x: Box; + let x: Box; + let x: Box; } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr index 1604aa4a0f7..c23acbcb311 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr @@ -1,8 +1,8 @@ error[E0658]: parenthetical notation is only stable when used with `Fn`-family traits - --> $DIR/unboxed-closure-feature-gate.rs:13:16 + --> $DIR/unboxed-closure-feature-gate.rs:13:20 | -LL | let x: Box; - | ^^^^^^^^^^ +LL | let x: Box; + | ^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add #![feature(unboxed_closures)] to the crate attributes to enable diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs index 044859de6a4..f1c83f0606f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs @@ -15,14 +15,14 @@ fn eq() where A : Eq { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),Output=()>, Foo(isize) >(); + eq::, dyn Foo(isize)>(); // In angle version, we supply something other than the default - eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); + eq::, dyn Foo(isize)>(); //~^ ERROR E0277 // Supply default explicitly. - eq::< Foo<(isize,),(isize,),Output=()>, Foo(isize) >(); + eq::, dyn Foo(isize)>(); } fn main() { } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr index ce90f5b9d24..fd5ef4b9df1 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `dyn Foo<(isize,), isize, Output = ()>: Eq>` is not satisfied --> $DIR/unboxed-closure-sugar-default.rs:21:5 | -LL | eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq>` is not implemented for `dyn Foo<(isize,), isize, Output = ()>` +LL | eq::, dyn Foo(isize)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq>` is not implemented for `dyn Foo<(isize,), isize, Output = ()>` | note: required by `eq` --> $DIR/unboxed-closure-sugar-default.rs:14:1 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs index 95bd391f251..0fc3e23ec73 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs @@ -17,31 +17,31 @@ fn eq>() { } fn test<'a,'b>() { // No errors expected: - eq::< Foo<(),Output=()>, Foo() >(); - eq::< Foo<(isize,),Output=()>, Foo(isize) >(); - eq::< Foo<(isize,usize),Output=()>, Foo(isize,usize) >(); - eq::< Foo<(isize,usize),Output=usize>, Foo(isize,usize) -> usize >(); - eq::< Foo<(&'a isize,&'b usize),Output=usize>, Foo(&'a isize,&'b usize) -> usize >(); + eq::< dyn Foo<(),Output=()>, dyn Foo() >(); + eq::< dyn Foo<(isize,),Output=()>, dyn Foo(isize) >(); + eq::< dyn Foo<(isize,usize),Output=()>, dyn Foo(isize,usize) >(); + eq::< dyn Foo<(isize,usize),Output=usize>, dyn Foo(isize,usize) -> usize >(); + eq::< dyn Foo<(&'a isize,&'b usize),Output=usize>, dyn Foo(&'a isize,&'b usize) -> usize >(); // Test that anonymous regions in `()` form are equivalent // to fresh bound regions, and that we can intermingle // named and anonymous as we choose: - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - for<'x,'y> Foo(&'x isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - for<'x> Foo(&'x isize,&usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - for<'y> Foo(&isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - Foo(&isize,&usize) -> usize >(); + eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + dyn for<'x,'y> Foo(&'x isize,&'y usize) -> usize >(); + eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + dyn for<'x> Foo(&'x isize,&usize) -> usize >(); + eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + dyn for<'y> Foo(&isize,&'y usize) -> usize >(); + eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + dyn Foo(&isize,&usize) -> usize >(); // lifetime elision - eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>, - Foo(&isize) -> &isize >(); + eq::< dyn for<'x> Foo<(&'x isize,), Output=&'x isize>, + dyn Foo(&isize) -> &isize >(); // Errors expected: - eq::< Foo<(),Output=()>, - Foo(char) >(); + eq::< dyn Foo<(),Output=()>, + dyn Foo(char) >(); //~^^ ERROR E0277 } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr index 857a32ca69e..005a86bc217 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr @@ -1,9 +1,9 @@ error[E0277]: the trait bound `dyn Foo<(char,), Output = ()>: Eq>` is not satisfied --> $DIR/unboxed-closure-sugar-equiv.rs:43:5 | -LL | / eq::< Foo<(),Output=()>, -LL | | Foo(char) >(); - | |___________________________________________________________________^ the trait `Eq>` is not implemented for `dyn Foo<(char,), Output = ()>` +LL | / eq::< dyn Foo<(),Output=()>, +LL | | dyn Foo(char) >(); + | |_______________________________________________________________________^ the trait `Eq>` is not implemented for `dyn Foo<(char,), Output = ()>` | note: required by `eq` --> $DIR/unboxed-closure-sugar-equiv.rs:16:1 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs index b61d8b8c8c7..d11d663f172 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs @@ -18,10 +18,10 @@ impl Eq for X { } fn eq>() { } fn main() { - eq::< for<'a> Foo<(&'a isize,), Output=&'a isize>, - Foo(&isize) -> &isize >(); - eq::< for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>, - Foo(&isize) -> (&isize, &isize) >(); + eq::< dyn for<'a> Foo<(&'a isize,), Output=&'a isize>, + dyn Foo(&isize) -> &isize >(); + eq::< dyn for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>, + dyn Foo(&isize) -> (&isize, &isize) >(); - let _: Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier + let _: dyn Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr index 8c3480744fe..9fb9a07166f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr @@ -1,8 +1,8 @@ error[E0106]: missing lifetime specifier - --> $DIR/unboxed-closure-sugar-lifetime-elision.rs:26:35 + --> $DIR/unboxed-closure-sugar-lifetime-elision.rs:26:39 | -LL | let _: Foo(&isize, &usize) -> &usize; - | ^ expected lifetime parameter +LL | let _: dyn Foo(&isize, &usize) -> &usize; + | ^ expected lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.rs index 09927a94019..6d6ed4b568f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.rs @@ -1,6 +1,6 @@ // Test that the `Fn` traits require `()` form without a feature gate. -fn bar1(x: &Fn<(), Output=()>) { +fn bar1(x: &dyn Fn<(), Output=()>) { //~^ ERROR of `Fn`-family traits' type parameters is subject to change } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr index 0901126a3fe..e1ed85d4f46 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr @@ -1,8 +1,8 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead - --> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:3:13 + --> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:3:17 | -LL | fn bar1(x: &Fn<(), Output=()>) { - | ^^^^^^^^^^^^^^^^^ +LL | fn bar1(x: &dyn Fn<(), Output=()>) { + | ^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add #![feature(unboxed_closures)] to the crate attributes to enable diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.rs index 799d9f33e2e..76c928d7b6a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.rs @@ -20,14 +20,14 @@ fn same_type>(a: A, b: B) { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),Output=()>, Foo(isize) >(); + eq::< dyn Foo<(isize,),Output=()>, dyn Foo(isize) >(); // Here we specify 'static explicitly in angle-bracket version. // Parenthesized winds up getting inferred. - eq::< Foo<'static, (isize,),Output=()>, Foo(isize) >(); + eq::< dyn Foo<'static, (isize,),Output=()>, dyn Foo(isize) >(); } -fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { +fn test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize)) { //~^ ERROR wrong number of lifetime arguments: expected 1, found 0 // Here, the omitted lifetimes are expanded to distinct things. same_type(x, y) diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr index 8eed7d58c46..e9d51983a7a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr @@ -1,8 +1,8 @@ error[E0107]: wrong number of lifetime arguments: expected 1, found 0 - --> $DIR/unboxed-closure-sugar-region.rs:30:43 + --> $DIR/unboxed-closure-sugar-region.rs:30:51 | -LL | fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { - | ^^^^^^^^^^ expected 1 lifetime argument +LL | fn test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize)) { + | ^^^^^^^^^^ expected 1 lifetime argument error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs index df0c495a11c..a6c86311b37 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs @@ -2,7 +2,7 @@ trait One { fn foo(&self) -> A; } -fn foo(_: &One()) //~ ERROR associated type `Output` not found for `One<()>` +fn foo(_: &dyn One()) //~ ERROR associated type `Output` not found for `One<()>` {} fn main() { } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr index 304339c89e6..c59082932dd 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `Output` not found for `One<()>` - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs:5:15 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs:5:19 | -LL | fn foo(_: &One()) - | ^^ associated type `Output` not found +LL | fn foo(_: &dyn One()) + | ^^ associated type `Output` not found error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs index 5f5ad7902aa..01c76d64c6b 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs @@ -2,7 +2,7 @@ trait Three { fn dummy(&self) -> (A,B,C); } -fn foo(_: &Three()) +fn foo(_: &dyn Three()) //~^ ERROR wrong number of type arguments //~| ERROR associated type `Output` not found {} diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr index 62b3a254430..6c61e74584a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr @@ -1,14 +1,14 @@ error[E0107]: wrong number of type arguments: expected 3, found 1 - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:12 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16 | -LL | fn foo(_: &Three()) - | ^^^^^^^ expected 3 type arguments +LL | fn foo(_: &dyn Three()) + | ^^^^^^^ expected 3 type arguments error[E0220]: associated type `Output` not found for `Three<(), [type error], [type error]>` - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:17 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:21 | -LL | fn foo(_: &Three()) - | ^^ associated type `Output` not found +LL | fn foo(_: &dyn Three()) + | ^^ associated type `Output` not found error: aborting due to 2 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.rs index 2e87d91f8bd..bc9901c795b 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.rs @@ -2,7 +2,7 @@ trait Zero { fn dummy(&self); } -fn foo(_: Zero()) +fn foo(_: dyn Zero()) //~^ ERROR wrong number of type arguments //~| ERROR associated type `Output` not found for `Zero` {} diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr index b64fc61cc85..b96e2cbc36b 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr @@ -1,14 +1,14 @@ error[E0107]: wrong number of type arguments: expected 0, found 1 - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:15 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:19 | -LL | fn foo(_: Zero()) - | ^^ unexpected type argument +LL | fn foo(_: dyn Zero()) + | ^^ unexpected type argument error[E0220]: associated type `Output` not found for `Zero` - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:15 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:19 | -LL | fn foo(_: Zero()) - | ^^ associated type `Output` not found +LL | fn foo(_: dyn Zero()) + | ^^ associated type `Output` not found error: aborting due to 2 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs index 82dc536bb56..1358ba0f953 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs @@ -9,7 +9,7 @@ fn a() { // iteration, but it still doesn't work. The weird structure with // the `Option` is to avoid giving any useful hints about the `Fn` // kind via the expected type. - let mut factorial: Option u32>> = None; + let mut factorial: Option u32>> = None; let f = |x: u32| -> u32 { let g = factorial.as_ref().unwrap(); @@ -22,7 +22,7 @@ fn a() { } fn b() { - let mut factorial: Option u32 + 'static>> = None; + let mut factorial: Option u32 + 'static>> = None; let f = |x: u32| -> u32 { let g = factorial.as_ref().unwrap(); diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr index 8d39fb026b3..0466887e371 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr @@ -29,8 +29,8 @@ LL | factorial = Some(Box::new(f)); error[E0597]: `factorial` does not live long enough --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:28:17 | -LL | let mut factorial: Option u32 + 'static>> = None; - | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | let mut factorial: Option u32 + 'static>> = None; + | ----------------------------------------- type annotation requires that `factorial` is borrowed for `'static` LL | LL | let f = |x: u32| -> u32 { | --------------- value captured here @@ -43,8 +43,8 @@ LL | } error[E0506]: cannot assign to `factorial` because it is borrowed --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:33:5 | -LL | let mut factorial: Option u32 + 'static>> = None; - | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | let mut factorial: Option u32 + 'static>> = None; + | ----------------------------------------- type annotation requires that `factorial` is borrowed for `'static` LL | LL | let f = |x: u32| -> u32 { | --------------- borrow of `factorial` occurs here diff --git a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.rs b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.rs index 0beead1ad92..6a707b2096d 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.rs @@ -17,14 +17,14 @@ impl YCombinator { } } -impl R, A) -> R> FnMut<(A,)> for YCombinator { +impl R, A) -> R> FnMut<(A,)> for YCombinator { extern "rust-call" fn call_mut(&mut self, (arg,): (A,)) -> R { (self.func)(self, arg) //~^ ERROR cannot borrow `*self` as mutable more than once at a time } } -impl R, A) -> R> FnOnce<(A,)> for YCombinator { +impl R, A) -> R> FnOnce<(A,)> for YCombinator { type Output = R; extern "rust-call" fn call_once(mut self, args: (A,)) -> R { self.call_mut(args) @@ -33,7 +33,7 @@ impl R, A) -> R> FnOnce<(A,)> for YCombinator u32, arg: u32| -> u32 { + let factorial = |recur: &mut dyn FnMut(u32) -> u32, arg: u32| -> u32 { counter += 1; if arg == 0 {1} else {arg * recur(arg-1)} }; diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs index 614f7e49f87..3d049cc5639 100644 --- a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs +++ b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs @@ -7,7 +7,7 @@ fn foo<'_> //~ ERROR cannot be used here trait Meh<'a> {} impl<'a> Meh<'a> for u8 {} -fn meh() -> Box Meh<'_>> //~ ERROR cannot be used here +fn meh() -> Box Meh<'_>> //~ ERROR cannot be used here //~^ ERROR missing lifetime specifier { Box::new(5u8) diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr index 936e3ba55fe..654f4285f65 100644 --- a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr +++ b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr @@ -5,10 +5,10 @@ LL | fn foo<'_> | ^^ `'_` is a reserved lifetime name error[E0637]: `'_` cannot be used here - --> $DIR/underscore-lifetime-binders.rs:10:21 + --> $DIR/underscore-lifetime-binders.rs:10:25 | -LL | fn meh() -> Box Meh<'_>> - | ^^ `'_` is a reserved lifetime name +LL | fn meh() -> Box Meh<'_>> + | ^^ `'_` is a reserved lifetime name error[E0106]: missing lifetime specifier --> $DIR/underscore-lifetime-binders.rs:2:17 @@ -17,10 +17,10 @@ LL | struct Baz<'a>(&'_ &'a u8); | ^^ expected lifetime parameter error[E0106]: missing lifetime specifier - --> $DIR/underscore-lifetime-binders.rs:10:29 + --> $DIR/underscore-lifetime-binders.rs:10:33 | -LL | fn meh() -> Box Meh<'_>> - | ^^ help: consider giving it a 'static lifetime: `'static` +LL | fn meh() -> Box Meh<'_>> + | ^^ help: consider giving it a 'static lifetime: `'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from diff --git a/src/test/ui/unique-object-noncopyable.rs b/src/test/ui/unique-object-noncopyable.rs index 1c467a2421a..dd38a7190aa 100644 --- a/src/test/ui/unique-object-noncopyable.rs +++ b/src/test/ui/unique-object-noncopyable.rs @@ -20,6 +20,6 @@ impl Foo for Bar { fn main() { let x = box Bar { x: 10 }; - let y: Box = x as Box; + let y: Box = x as Box; let _z = y.clone(); //~ ERROR no method named `clone` found } diff --git a/src/test/ui/unsized/unsized-enum2.rs b/src/test/ui/unsized/unsized-enum2.rs index 60bfb5cb640..d589f5ae582 100644 --- a/src/test/ui/unsized/unsized-enum2.rs +++ b/src/test/ui/unsized/unsized-enum2.rs @@ -13,10 +13,10 @@ trait PathHelper2 {} trait PathHelper3 {} trait PathHelper4 {} -struct Path1(PathHelper1); -struct Path2(PathHelper2); -struct Path3(PathHelper3); -struct Path4(PathHelper4); +struct Path1(dyn PathHelper1); +struct Path2(dyn PathHelper2); +struct Path3(dyn PathHelper3); +struct Path4(dyn PathHelper4); enum E { // parameter @@ -50,13 +50,13 @@ enum E { //~^ ERROR the size for values of type // plain trait - VM(Foo), + VM(dyn Foo), //~^ ERROR the size for values of type - VN{x: Bar}, + VN{x: dyn Bar}, //~^ ERROR the size for values of type - VO(isize, FooBar), + VO(isize, dyn FooBar), //~^ ERROR the size for values of type - VP{u: isize, x: BarFoo}, + VP{u: isize, x: dyn BarFoo}, //~^ ERROR the size for values of type // projected diff --git a/src/test/ui/unsized/unsized-enum2.stderr b/src/test/ui/unsized/unsized-enum2.stderr index 9109366e4fc..cdd5747d86b 100644 --- a/src/test/ui/unsized/unsized-enum2.stderr +++ b/src/test/ui/unsized/unsized-enum2.stderr @@ -85,8 +85,8 @@ LL | VH{u: isize, x: [u32]}, error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time --> $DIR/unsized-enum2.rs:53:8 | -LL | VM(Foo), - | ^^^ doesn't have a size known at compile-time +LL | VM(dyn Foo), + | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + 'static)` = note: to learn more, visit @@ -95,8 +95,8 @@ LL | VM(Foo), error[E0277]: the size for values of type `(dyn Bar + 'static)` cannot be known at compilation time --> $DIR/unsized-enum2.rs:55:8 | -LL | VN{x: Bar}, - | ^^^^^^ doesn't have a size known at compile-time +LL | VN{x: dyn Bar}, + | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Bar + 'static)` = note: to learn more, visit @@ -105,8 +105,8 @@ LL | VN{x: Bar}, error[E0277]: the size for values of type `(dyn FooBar + 'static)` cannot be known at compilation time --> $DIR/unsized-enum2.rs:57:15 | -LL | VO(isize, FooBar), - | ^^^^^^ doesn't have a size known at compile-time +LL | VO(isize, dyn FooBar), + | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn FooBar + 'static)` = note: to learn more, visit @@ -115,8 +115,8 @@ LL | VO(isize, FooBar), error[E0277]: the size for values of type `(dyn BarFoo + 'static)` cannot be known at compilation time --> $DIR/unsized-enum2.rs:59:18 | -LL | VP{u: isize, x: BarFoo}, - | ^^^^^^^^^ doesn't have a size known at compile-time +LL | VP{u: isize, x: dyn BarFoo}, + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn BarFoo + 'static)` = note: to learn more, visit diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.rs b/src/test/ui/use/use-after-move-implicity-coerced-object.rs index 2e465ee8962..76487ef1c14 100644 --- a/src/test/ui/use/use-after-move-implicity-coerced-object.rs +++ b/src/test/ui/use/use-after-move-implicity-coerced-object.rs @@ -13,10 +13,10 @@ impl fmt::Display for Number { } struct List { - list: Vec> } + list: Vec> } impl List { - fn push(&mut self, n: Box) { + fn push(&mut self, n: Box) { self.list.push(n); } } diff --git a/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr b/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr index 8b5ecbe56ff..69818aedd15 100644 --- a/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr +++ b/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/variance-contravariant-arg-object.rs:14:5 | -LL | fn get_min_from_max<'min, 'max>(v: Box>) +LL | fn get_min_from_max<'min, 'max>(v: Box>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here @@ -12,7 +12,7 @@ LL | v error: lifetime may not live long enough --> $DIR/variance-contravariant-arg-object.rs:22:5 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here diff --git a/src/test/ui/variance/variance-contravariant-arg-object.rs b/src/test/ui/variance/variance-contravariant-arg-object.rs index 27e5675dcde..947f4cd8b8f 100644 --- a/src/test/ui/variance/variance-contravariant-arg-object.rs +++ b/src/test/ui/variance/variance-contravariant-arg-object.rs @@ -7,15 +7,15 @@ trait Get : 'static { fn get(&self, t: T); } -fn get_min_from_max<'min, 'max>(v: Box>) - -> Box> +fn get_min_from_max<'min, 'max>(v: Box>) + -> Box> where 'max : 'min { v //~ ERROR mismatched types } -fn get_max_from_min<'min, 'max, G>(v: Box>) - -> Box> +fn get_max_from_min<'min, 'max, G>(v: Box>) + -> Box> where 'max : 'min { // Previously OK: diff --git a/src/test/ui/variance/variance-contravariant-arg-object.stderr b/src/test/ui/variance/variance-contravariant-arg-object.stderr index beac05e04a8..263c849e199 100644 --- a/src/test/ui/variance/variance-contravariant-arg-object.stderr +++ b/src/test/ui/variance/variance-contravariant-arg-object.stderr @@ -9,12 +9,12 @@ LL | v note: the lifetime 'min as defined on the function body at 10:21... --> $DIR/variance-contravariant-arg-object.rs:10:21 | -LL | fn get_min_from_max<'min, 'max>(v: Box>) +LL | fn get_min_from_max<'min, 'max>(v: Box>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 10:27 --> $DIR/variance-contravariant-arg-object.rs:10:27 | -LL | fn get_min_from_max<'min, 'max>(v: Box>) +LL | fn get_min_from_max<'min, 'max>(v: Box>) | ^^^^ error[E0308]: mismatched types @@ -28,12 +28,12 @@ LL | v note: the lifetime 'min as defined on the function body at 17:21... --> $DIR/variance-contravariant-arg-object.rs:17:21 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 17:27 --> $DIR/variance-contravariant-arg-object.rs:17:27 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) | ^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-covariant-arg-object.nll.stderr b/src/test/ui/variance/variance-covariant-arg-object.nll.stderr index acf9f2e060c..63ab7fe9651 100644 --- a/src/test/ui/variance/variance-covariant-arg-object.nll.stderr +++ b/src/test/ui/variance/variance-covariant-arg-object.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/variance-covariant-arg-object.rs:15:5 | -LL | fn get_min_from_max<'min, 'max>(v: Box>) +LL | fn get_min_from_max<'min, 'max>(v: Box>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here @@ -12,7 +12,7 @@ LL | v error: lifetime may not live long enough --> $DIR/variance-covariant-arg-object.rs:22:5 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here diff --git a/src/test/ui/variance/variance-covariant-arg-object.rs b/src/test/ui/variance/variance-covariant-arg-object.rs index 4b371841654..7cbf65ae3d9 100644 --- a/src/test/ui/variance/variance-covariant-arg-object.rs +++ b/src/test/ui/variance/variance-covariant-arg-object.rs @@ -7,16 +7,16 @@ trait Get : 'static { fn get(&self) -> T; } -fn get_min_from_max<'min, 'max>(v: Box>) - -> Box> +fn get_min_from_max<'min, 'max>(v: Box>) + -> Box> where 'max : 'min { // Previously OK, now an error as traits are invariant. v //~ ERROR mismatched types } -fn get_max_from_min<'min, 'max, G>(v: Box>) - -> Box> +fn get_max_from_min<'min, 'max, G>(v: Box>) + -> Box> where 'max : 'min { v //~ ERROR mismatched types diff --git a/src/test/ui/variance/variance-covariant-arg-object.stderr b/src/test/ui/variance/variance-covariant-arg-object.stderr index cdcc7a6fd55..94f80c2b657 100644 --- a/src/test/ui/variance/variance-covariant-arg-object.stderr +++ b/src/test/ui/variance/variance-covariant-arg-object.stderr @@ -9,12 +9,12 @@ LL | v note: the lifetime 'min as defined on the function body at 10:21... --> $DIR/variance-covariant-arg-object.rs:10:21 | -LL | fn get_min_from_max<'min, 'max>(v: Box>) +LL | fn get_min_from_max<'min, 'max>(v: Box>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 10:27 --> $DIR/variance-covariant-arg-object.rs:10:27 | -LL | fn get_min_from_max<'min, 'max>(v: Box>) +LL | fn get_min_from_max<'min, 'max>(v: Box>) | ^^^^ error[E0308]: mismatched types @@ -28,12 +28,12 @@ LL | v note: the lifetime 'min as defined on the function body at 18:21... --> $DIR/variance-covariant-arg-object.rs:18:21 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 18:27 --> $DIR/variance-covariant-arg-object.rs:18:27 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) | ^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-invariant-arg-object.nll.stderr b/src/test/ui/variance/variance-invariant-arg-object.nll.stderr index 3c1ee7fc707..fe2f35b63b5 100644 --- a/src/test/ui/variance/variance-invariant-arg-object.nll.stderr +++ b/src/test/ui/variance/variance-invariant-arg-object.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/variance-invariant-arg-object.rs:11:5 | -LL | fn get_min_from_max<'min, 'max>(v: Box>) +LL | fn get_min_from_max<'min, 'max>(v: Box>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here @@ -12,7 +12,7 @@ LL | v error: lifetime may not live long enough --> $DIR/variance-invariant-arg-object.rs:18:5 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here diff --git a/src/test/ui/variance/variance-invariant-arg-object.rs b/src/test/ui/variance/variance-invariant-arg-object.rs index 91f5982e533..886d263c457 100644 --- a/src/test/ui/variance/variance-invariant-arg-object.rs +++ b/src/test/ui/variance/variance-invariant-arg-object.rs @@ -4,15 +4,15 @@ trait Get : 'static { fn get(&self, t: T) -> T; } -fn get_min_from_max<'min, 'max>(v: Box>) - -> Box> +fn get_min_from_max<'min, 'max>(v: Box>) + -> Box> where 'max : 'min { v //~ ERROR mismatched types } -fn get_max_from_min<'min, 'max, G>(v: Box>) - -> Box> +fn get_max_from_min<'min, 'max, G>(v: Box>) + -> Box> where 'max : 'min { v //~ ERROR mismatched types diff --git a/src/test/ui/variance/variance-invariant-arg-object.stderr b/src/test/ui/variance/variance-invariant-arg-object.stderr index e2ee35de1a2..50a8697d439 100644 --- a/src/test/ui/variance/variance-invariant-arg-object.stderr +++ b/src/test/ui/variance/variance-invariant-arg-object.stderr @@ -9,12 +9,12 @@ LL | v note: the lifetime 'min as defined on the function body at 7:21... --> $DIR/variance-invariant-arg-object.rs:7:21 | -LL | fn get_min_from_max<'min, 'max>(v: Box>) +LL | fn get_min_from_max<'min, 'max>(v: Box>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 7:27 --> $DIR/variance-invariant-arg-object.rs:7:27 | -LL | fn get_min_from_max<'min, 'max>(v: Box>) +LL | fn get_min_from_max<'min, 'max>(v: Box>) | ^^^^ error[E0308]: mismatched types @@ -28,12 +28,12 @@ LL | v note: the lifetime 'min as defined on the function body at 14:21... --> $DIR/variance-invariant-arg-object.rs:14:21 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 14:27 --> $DIR/variance-invariant-arg-object.rs:14:27 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) | ^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-object-types.rs b/src/test/ui/variance/variance-object-types.rs index 12af7ae8c5b..14e11f681b1 100644 --- a/src/test/ui/variance/variance-object-types.rs +++ b/src/test/ui/variance/variance-object-types.rs @@ -9,7 +9,7 @@ use std::cell::Cell; // get an invariant result for `'a`. #[rustc_variance] struct Foo<'a> { //~ ERROR [o] - x: Box &'a i32 + 'static> + x: Box &'a i32 + 'static> } fn main() { diff --git a/src/test/ui/variance/variance-object-types.stderr b/src/test/ui/variance/variance-object-types.stderr index be94a727a8d..d97d222e711 100644 --- a/src/test/ui/variance/variance-object-types.stderr +++ b/src/test/ui/variance/variance-object-types.stderr @@ -2,7 +2,7 @@ error[E0208]: [o] --> $DIR/variance-object-types.rs:11:1 | LL | / struct Foo<'a> { -LL | | x: Box &'a i32 + 'static> +LL | | x: Box &'a i32 + 'static> LL | | } | |_^ diff --git a/src/test/ui/variance/variance-trait-object-bound.rs b/src/test/ui/variance/variance-trait-object-bound.rs index ada93b7f6ef..ec3c973bc76 100644 --- a/src/test/ui/variance/variance-trait-object-bound.rs +++ b/src/test/ui/variance/variance-trait-object-bound.rs @@ -12,7 +12,7 @@ trait T { fn foo(&self); } #[rustc_variance] struct TOption<'a> { //~ ERROR [-] - v: Option>, + v: Option>, } fn main() { } diff --git a/src/test/ui/variance/variance-trait-object-bound.stderr b/src/test/ui/variance/variance-trait-object-bound.stderr index 503c087fb4d..fb0fab1950c 100644 --- a/src/test/ui/variance/variance-trait-object-bound.stderr +++ b/src/test/ui/variance/variance-trait-object-bound.stderr @@ -2,7 +2,7 @@ error[E0208]: [-] --> $DIR/variance-trait-object-bound.rs:14:1 | LL | / struct TOption<'a> { -LL | | v: Option>, +LL | | v: Option>, LL | | } | |_^ diff --git a/src/test/ui/variance/variance-types-bounds.rs b/src/test/ui/variance/variance-types-bounds.rs index 5cbda10fbde..d1814dd97a0 100644 --- a/src/test/ui/variance/variance-types-bounds.rs +++ b/src/test/ui/variance/variance-types-bounds.rs @@ -36,8 +36,8 @@ trait Setter { #[rustc_variance] struct TestObject { //~ ERROR [o, o] - n: Box+Send>, - m: Box+Send>, + n: Box+Send>, + m: Box+Send>, } fn main() {} diff --git a/src/test/ui/variance/variance-types-bounds.stderr b/src/test/ui/variance/variance-types-bounds.stderr index 8e3e0515aec..5cffdffc7f2 100644 --- a/src/test/ui/variance/variance-types-bounds.stderr +++ b/src/test/ui/variance/variance-types-bounds.stderr @@ -37,8 +37,8 @@ error[E0208]: [o, o] --> $DIR/variance-types-bounds.rs:38:1 | LL | / struct TestObject { -LL | | n: Box+Send>, -LL | | m: Box+Send>, +LL | | n: Box+Send>, +LL | | m: Box+Send>, LL | | } | |_^ diff --git a/src/test/ui/wf/wf-in-obj-type-static.rs b/src/test/ui/wf/wf-in-obj-type-static.rs index 858a75ab1ab..1ad2fd1edb3 100644 --- a/src/test/ui/wf/wf-in-obj-type-static.rs +++ b/src/test/ui/wf/wf-in-obj-type-static.rs @@ -11,7 +11,7 @@ struct MustBeCopy { struct Foo { // needs T: 'static - x: Object<&'static T> //~ ERROR E0310 + x: dyn Object<&'static T> //~ ERROR E0310 } diff --git a/src/test/ui/wf/wf-in-obj-type-static.stderr b/src/test/ui/wf/wf-in-obj-type-static.stderr index cc06b9243f7..c461da76a25 100644 --- a/src/test/ui/wf/wf-in-obj-type-static.stderr +++ b/src/test/ui/wf/wf-in-obj-type-static.stderr @@ -4,14 +4,14 @@ error[E0310]: the parameter type `T` may not live long enough LL | struct Foo { | - help: consider adding an explicit lifetime bound `T: 'static`... LL | // needs T: 'static -LL | x: Object<&'static T> - | ^^^^^^^^^^^^^^^^^^^^^ +LL | x: dyn Object<&'static T> + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...so that the reference type `&'static T` does not outlive the data it points at --> $DIR/wf-in-obj-type-static.rs:14:5 | -LL | x: Object<&'static T> - | ^^^^^^^^^^^^^^^^^^^^^ +LL | x: dyn Object<&'static T> + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-in-obj-type-trait.rs b/src/test/ui/wf/wf-in-obj-type-trait.rs index fad1da199ea..170fad55f8f 100644 --- a/src/test/ui/wf/wf-in-obj-type-trait.rs +++ b/src/test/ui/wf/wf-in-obj-type-trait.rs @@ -8,7 +8,7 @@ struct MustBeCopy { struct Bar { // needs T: Copy - x: Object> //~ ERROR E0277 + x: dyn Object> //~ ERROR E0277 } fn main() { } diff --git a/src/test/ui/wf/wf-in-obj-type-trait.stderr b/src/test/ui/wf/wf-in-obj-type-trait.stderr index 94b3de78898..2c85dd042e7 100644 --- a/src/test/ui/wf/wf-in-obj-type-trait.stderr +++ b/src/test/ui/wf/wf-in-obj-type-trait.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-obj-type-trait.rs:11:5 | -LL | x: Object> - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` +LL | x: dyn Object> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound note: required by `MustBeCopy` diff --git a/src/test/ui/wf/wf-object-safe.rs b/src/test/ui/wf/wf-object-safe.rs index 08f68f6c004..42e6917551f 100644 --- a/src/test/ui/wf/wf-object-safe.rs +++ b/src/test/ui/wf/wf-object-safe.rs @@ -6,5 +6,5 @@ trait A { } fn main() { - let _x: &A; //~ ERROR E0038 + let _x: &dyn A; //~ ERROR E0038 } diff --git a/src/test/ui/wf/wf-object-safe.stderr b/src/test/ui/wf/wf-object-safe.stderr index 87e8105d4af..3b264ecd580 100644 --- a/src/test/ui/wf/wf-object-safe.stderr +++ b/src/test/ui/wf/wf-object-safe.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `A` cannot be made into an object --> $DIR/wf-object-safe.rs:9:13 | -LL | let _x: &A; - | ^^ the trait `A` cannot be made into an object +LL | let _x: &dyn A; + | ^^^^^^ the trait `A` cannot be made into an object | = note: method `foo` references the `Self` type in its arguments or return type diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs index ac95cbab1f7..85a332e244f 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs @@ -16,7 +16,7 @@ struct Foo<'a,T> { trait Baz { } impl<'a, T> Trait<'a, T> for u32 { - type Out = &'a Baz; //~ ERROR `T` may not live long enough + type Out = &'a dyn Baz; //~ ERROR `T` may not live long enough } fn main() { } diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr index 8649506c870..f1cf514e6b2 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr @@ -17,14 +17,14 @@ error[E0309]: the parameter type `T` may not live long enough | LL | impl<'a, T> Trait<'a, T> for u32 { | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | type Out = &'a Baz; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | type Out = &'a dyn Baz; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...so that the reference type `&'a (dyn Baz + 'a)` does not outlive the data it points at --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 | -LL | type Out = &'a Baz; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | type Out = &'a dyn Baz; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/where-clauses/where-lifetime-resolution.rs b/src/test/ui/where-clauses/where-lifetime-resolution.rs index 4c46a77ae29..0d426386768 100644 --- a/src/test/ui/where-clauses/where-lifetime-resolution.rs +++ b/src/test/ui/where-clauses/where-lifetime-resolution.rs @@ -2,10 +2,10 @@ trait Trait1<'a> {} trait Trait2<'a, 'b> {} fn f() where - for<'a> Trait1<'a>: Trait1<'a>, // OK - (for<'a> Trait1<'a>): Trait1<'a>, + for<'a> dyn Trait1<'a>: Trait1<'a>, // OK + (dyn for<'a> Trait1<'a>): Trait1<'a>, //~^ ERROR use of undeclared lifetime name `'a` - for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, //~^ ERROR use of undeclared lifetime name `'b` //~| ERROR nested quantification of lifetimes {} diff --git a/src/test/ui/where-clauses/where-lifetime-resolution.stderr b/src/test/ui/where-clauses/where-lifetime-resolution.stderr index babf8efc23f..0081ae07163 100644 --- a/src/test/ui/where-clauses/where-lifetime-resolution.stderr +++ b/src/test/ui/where-clauses/where-lifetime-resolution.stderr @@ -1,20 +1,20 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/where-lifetime-resolution.rs:6:34 + --> $DIR/where-lifetime-resolution.rs:6:38 | -LL | (for<'a> Trait1<'a>): Trait1<'a>, - | ^^ undeclared lifetime +LL | (dyn for<'a> Trait1<'a>): Trait1<'a>, + | ^^ undeclared lifetime error[E0316]: nested quantification of lifetimes - --> $DIR/where-lifetime-resolution.rs:8:13 + --> $DIR/where-lifetime-resolution.rs:8:17 | -LL | for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/where-lifetime-resolution.rs:8:48 + --> $DIR/where-lifetime-resolution.rs:8:52 | -LL | for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, - | ^^ undeclared lifetime +LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + | ^^ undeclared lifetime error: aborting due to 3 previous errors From f19f4545b1674e6d16b9ec81a2358d615bb6a786 Mon Sep 17 00:00:00 2001 From: memoryruins Date: Tue, 28 May 2019 14:47:21 -0400 Subject: [PATCH 52/65] Update run-pass test suite to use dyn --- src/test/run-pass/alignment-gep-tup-like-1.rs | 4 +-- ...ciated-types-doubleendediterator-object.rs | 2 +- .../associated-types-eq-obj.rs | 2 +- ...ociated-types-projection-in-object-type.rs | 6 ++-- .../autoderef-method-on-trait.rs | 2 +- .../borrowck/borrowck-trait-lifetime.rs | 4 +-- .../run-pass/cast-rfc0401-vtable-kinds.rs | 10 +++--- src/test/run-pass/cast-rfc0401.rs | 4 +-- .../close-over-big-then-small-data.rs | 4 +-- src/test/run-pass/codegen-object-shim.rs | 2 +- .../run-pass/coerce/coerce-expect-unsized.rs | 18 +++++----- .../run-pass/consts/const-trait-to-trait.rs | 8 ++--- src/test/run-pass/deriving/deriving-show.rs | 2 +- .../run-pass/drop/drop-struct-as-object.rs | 2 +- .../dst-coerce-custom.rs | 2 +- .../dynamically-sized-types/dst-coerce-rc.rs | 8 ++--- .../dynamically-sized-types/dst-coercions.rs | 12 +++---- .../dst-field-align.rs | 8 ++--- .../dynamically-sized-types/dst-index.rs | 6 ++-- .../dynamically-sized-types/dst-raw.rs | 12 +++---- .../dst-trait-tuple.rs | 22 ++++++------ .../dynamically-sized-types/dst-trait.rs | 22 ++++++------ .../extern/extern-types-trait-impl.rs | 2 +- src/test/run-pass/fat-ptr-cast.rs | 2 +- .../closure-expected-type/issue-38714.rs | 2 +- src/test/run-pass/generics/generic-object.rs | 2 +- src/test/run-pass/hashmap-memory.rs | 2 +- .../hrtb-binder-levels-in-object-types.rs | 2 +- .../hrtb-debruijn-object-types-in-closures.rs | 2 +- .../hrtb-fn-like-trait-object.rs | 2 +- .../higher-rank-trait-bounds/hrtb-parse.rs | 4 +-- .../hrtb-precedence-of-plus.rs | 2 +- .../hrtb-resolve-lifetime.rs | 2 +- .../hrtb-trait-object-paren-notation.rs | 2 +- .../hrtb-trait-object-passed-to-closure.rs | 2 +- src/test/run-pass/ifmt.rs | 2 +- src/test/run-pass/issues/issue-10802.rs | 8 ++--- src/test/run-pass/issues/issue-11205.rs | 36 +++++++++---------- src/test/run-pass/issues/issue-11267.rs | 2 +- src/test/run-pass/issues/issue-11677.rs | 4 +-- src/test/run-pass/issues/issue-11709.rs | 2 +- src/test/run-pass/issues/issue-12744.rs | 2 +- src/test/run-pass/issues/issue-13507-2.rs | 2 +- src/test/run-pass/issues/issue-13808.rs | 2 +- src/test/run-pass/issues/issue-14399.rs | 2 +- src/test/run-pass/issues/issue-14589.rs | 6 ++-- src/test/run-pass/issues/issue-14821.rs | 8 ++--- src/test/run-pass/issues/issue-14919.rs | 2 +- src/test/run-pass/issues/issue-14958.rs | 12 +++---- src/test/run-pass/issues/issue-15155.rs | 8 ++--- src/test/run-pass/issues/issue-15763.rs | 8 ++--- src/test/run-pass/issues/issue-16739.rs | 6 ++-- src/test/run-pass/issues/issue-16922.rs | 2 +- src/test/run-pass/issues/issue-17322.rs | 4 +-- src/test/run-pass/issues/issue-17351.rs | 2 +- src/test/run-pass/issues/issue-17771.rs | 6 ++-- src/test/run-pass/issues/issue-17897.rs | 2 +- .../run-pass/issues/issue-20055-box-trait.rs | 2 +- src/test/run-pass/issues/issue-20575.rs | 2 +- src/test/run-pass/issues/issue-20676.rs | 2 +- src/test/run-pass/issues/issue-20953.rs | 4 +-- src/test/run-pass/issues/issue-21058.rs | 2 +- src/test/run-pass/issues/issue-21361.rs | 4 +-- src/test/run-pass/issues/issue-21655.rs | 2 +- src/test/run-pass/issues/issue-2190-1.rs | 4 +-- src/test/run-pass/issues/issue-22346.rs | 2 +- src/test/run-pass/issues/issue-2288.rs | 4 +-- src/test/run-pass/issues/issue-23261.rs | 4 +-- src/test/run-pass/issues/issue-23485.rs | 2 +- src/test/run-pass/issues/issue-24010.rs | 2 +- src/test/run-pass/issues/issue-24086.rs | 4 +-- src/test/run-pass/issues/issue-25339.rs | 2 +- src/test/run-pass/issues/issue-25515.rs | 2 +- .../issues/issue-25549-multiple-drop.rs | 2 +- src/test/run-pass/issues/issue-25757.rs | 2 +- src/test/run-pass/issues/issue-26641.rs | 2 +- src/test/run-pass/issues/issue-26709.rs | 2 +- src/test/run-pass/issues/issue-26802.rs | 2 +- src/test/run-pass/issues/issue-26805.rs | 2 +- src/test/run-pass/issues/issue-26905.rs | 2 +- src/test/run-pass/issues/issue-27268.rs | 2 +- src/test/run-pass/issues/issue-2734.rs | 4 +-- src/test/run-pass/issues/issue-2735.rs | 4 +-- src/test/run-pass/issues/issue-27890.rs | 4 +-- src/test/run-pass/issues/issue-2935.rs | 2 +- src/test/run-pass/issues/issue-3052.rs | 2 +- src/test/run-pass/issues/issue-30530.rs | 4 +-- src/test/run-pass/issues/issue-30615.rs | 2 +- src/test/run-pass/issues/issue-32389.rs | 2 +- src/test/run-pass/issues/issue-33387.rs | 8 ++--- src/test/run-pass/issues/issue-33461.rs | 2 +- src/test/run-pass/issues/issue-34503.rs | 2 +- src/test/run-pass/issues/issue-35815.rs | 2 +- src/test/run-pass/issues/issue-36260.rs | 2 +- .../issues/issue-36786-resolve-call.rs | 2 +- src/test/run-pass/issues/issue-3702.rs | 2 +- src/test/run-pass/issues/issue-3794.rs | 4 +-- src/test/run-pass/issues/issue-39292.rs | 2 +- src/test/run-pass/issues/issue-39823.rs | 8 ++--- src/test/run-pass/issues/issue-41053.rs | 4 +-- src/test/run-pass/issues/issue-41744.rs | 2 +- src/test/run-pass/issues/issue-42210.rs | 4 +-- src/test/run-pass/issues/issue-43132.rs | 2 +- src/test/run-pass/issues/issue-4333.rs | 2 +- src/test/run-pass/issues/issue-47638.rs | 4 +-- ...e-5008-borrowed-traitobject-method-call.rs | 4 +-- src/test/run-pass/issues/issue-5192.rs | 6 ++-- src/test/run-pass/issues/issue-5666.rs | 2 +- src/test/run-pass/issues/issue-5708.rs | 10 +++--- src/test/run-pass/issues/issue-5988.rs | 2 +- src/test/run-pass/issues/issue-6128.rs | 2 +- src/test/run-pass/issues/issue-6157.rs | 4 +-- src/test/run-pass/issues/issue-6318.rs | 4 +-- src/test/run-pass/issues/issue-7563.rs | 2 +- src/test/run-pass/issues/issue-7911.rs | 12 +++---- src/test/run-pass/issues/issue-8248.rs | 4 +-- src/test/run-pass/issues/issue-8249.rs | 4 +-- src/test/run-pass/issues/issue-9129.rs | 4 +-- .../issue-9394-inherited-trait-calls.rs | 2 +- src/test/run-pass/issues/issue-9951.rs | 10 +++--- src/test/run-pass/last-use-in-cap-clause.rs | 2 +- .../run-pass/macros/colorful-write-macros.rs | 4 +-- .../run-pass/macros/type-macros-simple.rs | 2 +- ...thod-argument-inference-associated-type.rs | 4 +-- src/test/run-pass/mir/mir_codegen_calls.rs | 8 ++--- .../run-pass/mir/mir_codegen_critical_edge.rs | 2 +- src/test/run-pass/mir/mir_coercions.rs | 10 +++--- src/test/run-pass/mir/mir_raw_fat_ptr.rs | 6 ++-- src/test/run-pass/new-box.rs | 6 ++-- src/test/run-pass/newlambdas-ret-infer.rs | 2 +- src/test/run-pass/newlambdas-ret-infer2.rs | 2 +- ...ject-lifetime-default-default-to-static.rs | 12 +++---- .../object-lifetime-default-from-rptr-box.rs | 10 +++--- .../object-lifetime-default-from-rptr-mut.rs | 12 +++---- .../object-lifetime-default-from-rptr.rs | 16 ++++----- src/test/run-pass/object-method-numbering.rs | 2 +- .../objects-coerce-freeze-borrored.rs | 6 ++-- ...owned-object-borrowed-method-headerless.rs | 8 ++--- .../objects-owned-object-owned-method.rs | 2 +- .../overloaded-calls-object-one-arg.rs | 2 +- .../overloaded-calls-object-two-args.rs | 2 +- .../overloaded-calls-object-zero-args.rs | 2 +- src/test/run-pass/panics/panic-safe.rs | 2 +- src/test/run-pass/privacy/privacy-ns.rs | 12 +++---- src/test/run-pass/raw-fat-ptr.rs | 4 +-- .../regions-bound-lists-feature-gate.rs | 2 +- ...-close-over-type-parameter-successfully.rs | 4 +-- .../run-pass/regions/regions-copy-closure.rs | 4 +-- .../regions/regions-debruijn-of-object.rs | 4 +-- .../regions-early-bound-trait-param.rs | 18 +++++----- .../regions/regions-fn-subtyping-2.rs | 4 +-- .../run-pass/regions/regions-fn-subtyping.rs | 8 ++--- ...regions-infer-region-in-fn-but-not-type.rs | 2 +- .../regions-lifetime-nonfree-late-bound.rs | 8 ++--- ...ions-on-closures-to-inference-variables.rs | 2 +- .../regions/regions-static-closure.rs | 4 +-- .../regions/regions-trait-object-1.rs | 4 +-- src/test/run-pass/string-box-error.rs | 8 ++--- .../class-cast-to-trait-cross-crate-2.rs | 4 +-- .../class-cast-to-trait-multiple-types.rs | 2 +- .../structs-enums/class-cast-to-trait.rs | 2 +- .../structs-enums/class-separate-impl.rs | 4 +-- .../structs-enums/enum-null-pointer-opt.rs | 6 ++-- ...object-lifetime-default-from-ref-struct.rs | 22 ++++++------ ...bject-lifetime-default-from-rptr-struct.rs | 10 +++--- src/test/run-pass/traits/auto-traits.rs | 2 +- .../traits/impl-inherent-prefer-over-trait.rs | 4 +-- .../infer-from-object-trait-issue-26952.rs | 2 +- .../traits/kindck-owned-trait-contains-1.rs | 4 +-- .../traits/object-one-type-two-traits.rs | 10 +++--- .../traits/parameterized-trait-with-bounds.rs | 10 +++--- .../run-pass/traits/trait-bounds-basic.rs | 8 ++--- .../run-pass/traits/trait-bounds-in-arc.rs | 22 ++++++------ .../trait-bounds-on-structs-and-enums.rs | 4 +-- .../run-pass/traits/trait-coercion-generic.rs | 4 +-- src/test/run-pass/traits/trait-coercion.rs | 6 ++-- src/test/run-pass/traits/trait-impl-2.rs | 2 +- src/test/run-pass/traits/trait-impl.rs | 6 ++-- ...ritance-cast-without-call-to-supertrait.rs | 4 +-- .../run-pass/traits/trait-inheritance-cast.rs | 4 +-- .../run-pass/traits/trait-object-exclusion.rs | 2 +- .../run-pass/traits/trait-object-generics.rs | 4 +-- .../traits/trait-object-lifetime-first.rs | 4 +-- .../trait-object-with-lifetime-bound.rs | 4 +-- .../traits/trait-region-pointer-simple.rs | 2 +- .../traits-impl-object-overlap-issue-23853.rs | 2 +- .../run-pass/traits/traits-issue-26339.rs | 2 +- .../traits/traits-repeated-supertrait.rs | 2 +- src/test/run-pass/traits/ufcs-trait-object.rs | 2 +- src/test/run-pass/trivial_casts.rs | 14 ++++---- src/test/run-pass/type-id-higher-rank-2.rs | 6 ++-- src/test/run-pass/type-id-higher-rank.rs | 18 +++++----- .../run-pass/type-infer-generalize-ty-var.rs | 8 ++--- .../unboxed-closures-blanket-fn-mut.rs | 2 +- .../unboxed-closures-blanket-fn.rs | 2 +- .../unboxed-closures-boxed.rs | 4 +-- ...ed-closures-call-sugar-object-autoderef.rs | 2 +- .../unboxed-closures-call-sugar-object.rs | 2 +- .../unboxed-closures-extern-fn-hr.rs | 2 +- ...fer-arg-types-from-expected-object-type.rs | 2 +- .../unboxed-closures-infer-recursive-fn.rs | 8 ++--- .../unboxed-closures-manual-impl.rs | 2 +- .../unboxed-closures-monomorphization.rs | 2 +- .../unboxed-closures-prelude.rs | 4 +-- .../unboxed-closures-sugar-object.rs | 2 +- .../run-pass/unique/unique-object-move.rs | 2 +- src/test/run-pass/unsized2.rs | 16 ++++----- .../wf-bound-region-in-object-type.rs | 2 +- 208 files changed, 502 insertions(+), 502 deletions(-) diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index badd095d0ae..7e6ee60e519 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -22,11 +22,11 @@ impl Invokable for Invoker { } } -fn f(a: A, b: u16) -> Box+'static> { +fn f(a: A, b: u16) -> Box+'static> { box Invoker { a: a, b: b, - } as (Box+'static>) + } as (Box+'static>) } pub fn main() { diff --git a/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs b/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs index 5f86888aef0..96ba2ee3b62 100644 --- a/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs +++ b/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs @@ -1,7 +1,7 @@ // run-pass #![feature(box_syntax)] -fn pairwise_sub(mut t: Box>) -> isize { +fn pairwise_sub(mut t: Box>) -> isize { let mut result = 0; loop { let front = t.next(); diff --git a/src/test/run-pass/associated-types/associated-types-eq-obj.rs b/src/test/run-pass/associated-types/associated-types-eq-obj.rs index 0f3dfe338a3..c202c376c5f 100644 --- a/src/test/run-pass/associated-types/associated-types-eq-obj.rs +++ b/src/test/run-pass/associated-types/associated-types-eq-obj.rs @@ -15,7 +15,7 @@ impl Foo for char { fn boo(&self) -> Bar { Bar } } -fn baz(x: &Foo) -> Bar { +fn baz(x: &dyn Foo) -> Bar { x.boo() } diff --git a/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs b/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs index 0dc32f2fd94..eec95a141f5 100644 --- a/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs +++ b/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs @@ -19,7 +19,7 @@ pub trait Subscriber { pub trait Publisher<'a> { type Output; - fn subscribe(&mut self, _: Box + 'a>); + fn subscribe(&mut self, _: Box + 'a>); } pub trait Processor<'a> : Subscriber + Publisher<'a> { } @@ -27,12 +27,12 @@ pub trait Processor<'a> : Subscriber + Publisher<'a> { } impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { } struct MyStruct<'a> { - sub: Box + 'a> + sub: Box + 'a> } impl<'a> Publisher<'a> for MyStruct<'a> { type Output = u64; - fn subscribe(&mut self, t : Box + 'a>) { + fn subscribe(&mut self, t : Box + 'a>) { self.sub = t; } } diff --git a/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs b/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs index 0a54db7f5cd..fadb0784e75 100644 --- a/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs @@ -11,6 +11,6 @@ impl double for usize { } pub fn main() { - let x: Box<_> = box (box 3usize as Box); + let x: Box<_> = box (box 3usize as Box); assert_eq!(x.double(), 6); } diff --git a/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs b/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs index 9721b08233e..8a6dfe76d60 100644 --- a/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs +++ b/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs @@ -12,7 +12,7 @@ use std::marker; fn main() { trait T { fn foo(&self) {} } - fn f<'a, V: T>(v: &'a V) -> &'a T { - v as &'a T + fn f<'a, V: T>(v: &'a V) -> &'a dyn T { + v as &'a dyn T } } diff --git a/src/test/run-pass/cast-rfc0401-vtable-kinds.rs b/src/test/run-pass/cast-rfc0401-vtable-kinds.rs index e53ab791922..a27dd9eef52 100644 --- a/src/test/run-pass/cast-rfc0401-vtable-kinds.rs +++ b/src/test/run-pass/cast-rfc0401-vtable-kinds.rs @@ -15,9 +15,9 @@ impl Foo for () {} impl Foo for u32 { fn foo(&self, _: u32) -> u32 { self+43 } } impl Bar for () {} -unsafe fn round_trip_and_call<'a>(t: *const (Foo+'a)) -> u32 { - let foo_e : *const Foo = t as *const _; - let r_1 = foo_e as *mut Foo; +unsafe fn round_trip_and_call<'a>(t: *const (dyn Foo+'a)) -> u32 { + let foo_e : *const dyn Foo = t as *const _; + let r_1 = foo_e as *mut dyn Foo; (&*r_1).foo(0) } @@ -38,8 +38,8 @@ fn tuple_i32_to_u32(u: *const (i32, T)) -> *const (u32, T) { fn main() { let x = 4u32; - let y : &Foo = &x; - let fl = unsafe { round_trip_and_call(y as *const Foo) }; + let y : &dyn Foo = &x; + let fl = unsafe { round_trip_and_call(y as *const dyn Foo) }; assert_eq!(fl, (43+4)); let s = FooS([0,1,2]); diff --git a/src/test/run-pass/cast-rfc0401.rs b/src/test/run-pass/cast-rfc0401.rs index 324860e53e1..017b63c7374 100644 --- a/src/test/run-pass/cast-rfc0401.rs +++ b/src/test/run-pass/cast-rfc0401.rs @@ -25,8 +25,8 @@ fn main() // coercion-cast let mut it = vec![137].into_iter(); let itr: &mut vec::IntoIter = &mut it; - assert_eq!((itr as &mut Iterator).next(), Some(137)); - assert_eq!((itr as &mut Iterator).next(), None); + assert_eq!((itr as &mut dyn Iterator).next(), Some(137)); + assert_eq!((itr as &mut dyn Iterator).next(), None); assert_eq!(Some(4u32) as Option, Some(4u32)); assert_eq!((1u32,2u32) as (u32,u32), (1,2)); diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index 2ae0b6c7d3d..0eead0194ef 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -24,11 +24,11 @@ impl Invokable for Invoker { } } -fn f(a: A, b: u16) -> Box+'static> { +fn f(a: A, b: u16) -> Box+'static> { box Invoker { a: a, b: b, - } as (Box+'static>) + } as (Box+'static>) } pub fn main() { diff --git a/src/test/run-pass/codegen-object-shim.rs b/src/test/run-pass/codegen-object-shim.rs index 4e2d7ac6086..26f53a9c182 100644 --- a/src/test/run-pass/codegen-object-shim.rs +++ b/src/test/run-pass/codegen-object-shim.rs @@ -1,4 +1,4 @@ fn main() { - assert_eq!((ToString::to_string as fn(&(ToString+'static)) -> String)(&"foo"), + assert_eq!((ToString::to_string as fn(&(dyn ToString+'static)) -> String)(&"foo"), String::from("foo")); } diff --git a/src/test/run-pass/coerce/coerce-expect-unsized.rs b/src/test/run-pass/coerce/coerce-expect-unsized.rs index a7e80afbf76..b44aa6ab377 100644 --- a/src/test/run-pass/coerce/coerce-expect-unsized.rs +++ b/src/test/run-pass/coerce/coerce-expect-unsized.rs @@ -12,16 +12,16 @@ pub fn main() { let _: Box<[isize]> = Box::new({ [1, 2, 3] }); let _: Box<[isize]> = Box::new(if true { [1, 2, 3] } else { [1, 3, 4] }); let _: Box<[isize]> = Box::new(match true { true => [1, 2, 3], false => [1, 3, 4] }); - let _: Box _> = Box::new({ |x| (x as u8) }); - let _: Box = Box::new(if true { false } else { true }); - let _: Box = Box::new(match true { true => 'a', false => 'b' }); + let _: Box _> = Box::new({ |x| (x as u8) }); + let _: Box = Box::new(if true { false } else { true }); + let _: Box = Box::new(match true { true => 'a', false => 'b' }); let _: &[isize] = &{ [1, 2, 3] }; let _: &[isize] = &if true { [1, 2, 3] } else { [1, 3, 4] }; let _: &[isize] = &match true { true => [1, 2, 3], false => [1, 3, 4] }; - let _: &Fn(isize) -> _ = &{ |x| (x as u8) }; - let _: &Debug = &if true { false } else { true }; - let _: &Debug = &match true { true => 'a', false => 'b' }; + let _: &dyn Fn(isize) -> _ = &{ |x| (x as u8) }; + let _: &dyn Debug = &if true { false } else { true }; + let _: &dyn Debug = &match true { true => 'a', false => 'b' }; let _: &str = &{ String::new() }; let _: &str = &if true { String::from("...") } else { 5.to_string() }; @@ -31,12 +31,12 @@ pub fn main() { }; let _: Box<[isize]> = Box::new([1, 2, 3]); - let _: Box _> = Box::new(|x| (x as u8)); + let _: Box _> = Box::new(|x| (x as u8)); let _: Rc> = Rc::new(RefCell::new([1, 2, 3])); - let _: Rc _>> = Rc::new(RefCell::new(|x| (x as u8))); + let _: Rc _>> = Rc::new(RefCell::new(|x| (x as u8))); - let _: Vec _>> = vec![ + let _: Vec _>> = vec![ Box::new(|x| (x as u8)), Box::new(|x| (x as i16 as u8)), ]; diff --git a/src/test/run-pass/consts/const-trait-to-trait.rs b/src/test/run-pass/consts/const-trait-to-trait.rs index a324d73a3a9..12a2999d79d 100644 --- a/src/test/run-pass/consts/const-trait-to-trait.rs +++ b/src/test/run-pass/consts/const-trait-to-trait.rs @@ -8,7 +8,7 @@ struct Bar; impl Trait for Bar {} fn main() { - let x: &[&Trait] = &[{ &Bar }]; + let x: &[&dyn Trait] = &[{ &Bar }]; } // Issue #25748 - the cast causes an &Encoding -> &Encoding coercion: @@ -16,9 +16,9 @@ pub struct UTF8Encoding; pub const UTF_8: &'static UTF8Encoding = &UTF8Encoding; pub trait Encoding {} impl Encoding for UTF8Encoding {} -pub fn f() -> &'static Encoding { UTF_8 as &'static Encoding } +pub fn f() -> &'static dyn Encoding { UTF_8 as &'static dyn Encoding } // Root of the problem: &Trait -> &Trait coercions: -const FOO: &'static Trait = &Bar; -const BAR: &'static Trait = FOO; +const FOO: &'static dyn Trait = &Bar; +const BAR: &'static dyn Trait = FOO; fn foo() { let _x = BAR; } diff --git a/src/test/run-pass/deriving/deriving-show.rs b/src/test/run-pass/deriving/deriving-show.rs index 98c1f3ac027..eb3a8948fc8 100644 --- a/src/test/run-pass/deriving/deriving-show.rs +++ b/src/test/run-pass/deriving/deriving-show.rs @@ -17,7 +17,7 @@ enum Enum { } #[derive(Debug)] -struct Pointers(*const Send, *mut Sync); +struct Pointers(*const dyn Send, *mut dyn Sync); macro_rules! t { ($x:expr, $expected:expr) => { diff --git a/src/test/run-pass/drop/drop-struct-as-object.rs b/src/test/run-pass/drop/drop-struct-as-object.rs index 307b3f1d6dc..1bc3b4c157c 100644 --- a/src/test/run-pass/drop/drop-struct-as-object.rs +++ b/src/test/run-pass/drop/drop-struct-as-object.rs @@ -30,7 +30,7 @@ impl Drop for Cat { pub fn main() { { let x = box Cat {name: 22}; - let nyan: Box = x as Box; + let nyan: Box = x as Box; } unsafe { assert_eq!(value, 22); diff --git a/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs b/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs index 35927bde027..24d83eb5343 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs @@ -36,7 +36,7 @@ fn main() { // Trait objects. let a: Bar = Bar { x: &42 }; - let b: Bar = a; + let b: Bar = a; unsafe { assert_eq!((*b.x).get(), 42); } diff --git a/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs b/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs index bbd0b1f8be1..683fa6850fd 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs @@ -26,17 +26,17 @@ fn main() { assert_eq!(b[2], 3); let a: Rc = Rc::new(42); - let b: Rc = a.clone(); + let b: Rc = a.clone(); assert_eq!(b.get(), 42); let c: Weak = Rc::downgrade(&a); - let d: Weak = c.clone(); + let d: Weak = c.clone(); let _c = b.clone(); let a: Rc> = Rc::new(RefCell::new(42)); - let b: Rc> = a.clone(); + let b: Rc> = a.clone(); assert_eq!(b.borrow().get(), 42); // FIXME - let c: Weak> = Rc::downgrade(&a) as Weak<_>; + let c: Weak> = Rc::downgrade(&a) as Weak<_>; } diff --git a/src/test/run-pass/dynamically-sized-types/dst-coercions.rs b/src/test/run-pass/dynamically-sized-types/dst-coercions.rs index 06c2892b69e..66688e93fb8 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-coercions.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-coercions.rs @@ -9,20 +9,20 @@ trait T { fn dummy(&self) { } } impl T for S {} pub fn main() { - let x: &T = &S; + let x: &dyn T = &S; // Test we can convert from &-ptr to *-ptr of trait objects - let x: *const T = &S; + let x: *const dyn T = &S; // Test we can convert from &-ptr to *-ptr of struct pointer (not DST) let x: *const S = &S; // As above, but mut - let x: &mut T = &mut S; - let x: *mut T = &mut S; + let x: &mut dyn T = &mut S; + let x: *mut dyn T = &mut S; let x: *mut S = &mut S; // Test we can change the mutability from mut to const. - let x: &T = &mut S; - let x: *const T = &mut S; + let x: &dyn T = &mut S; + let x: *const dyn T = &mut S; } diff --git a/src/test/run-pass/dynamically-sized-types/dst-field-align.rs b/src/test/run-pass/dynamically-sized-types/dst-field-align.rs index 9c81f5652d1..6c338e99912 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-field-align.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-field-align.rs @@ -26,7 +26,7 @@ fn main() { // Test that zero-offset works properly let b : Baz = Baz { a: 7 }; assert_eq!(b.a.get(), 7); - let b : &Baz = &b; + let b : &Baz = &b; assert_eq!(b.a.get(), 7); // Test that the field is aligned properly @@ -34,7 +34,7 @@ fn main() { assert_eq!(f.b.get(), 11); let ptr1 : *const u8 = &f.b as *const _ as *const u8; - let f : &Foo = &f; + let f : &Foo = &f; let ptr2 : *const u8 = &f.b as *const _ as *const u8; assert_eq!(f.b.get(), 11); @@ -44,13 +44,13 @@ fn main() { // Test that nested DSTs work properly let f : Foo> = Foo { a: 0, b: Foo { a: 1, b: 17 }}; assert_eq!(f.b.b.get(), 17); - let f : &Foo> = &f; + let f : &Foo> = &f; assert_eq!(f.b.b.get(), 17); // Test that get the pointer via destructuring works let f : Foo = Foo { a: 0, b: 11 }; - let f : &Foo = &f; + let f : &Foo = &f; let &Foo { a: _, b: ref bar } = f; assert_eq!(bar.get(), 11); diff --git a/src/test/run-pass/dynamically-sized-types/dst-index.rs b/src/test/run-pass/dynamically-sized-types/dst-index.rs index 0728599f323..980d99a6d6c 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-index.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-index.rs @@ -19,11 +19,11 @@ impl Index for S { struct T; impl Index for T { - type Output = Debug + 'static; + type Output = dyn Debug + 'static; - fn index<'a>(&'a self, idx: usize) -> &'a (Debug + 'static) { + fn index<'a>(&'a self, idx: usize) -> &'a (dyn Debug + 'static) { static X: usize = 42; - &X as &(Debug + 'static) + &X as &(dyn Debug + 'static) } } diff --git a/src/test/run-pass/dynamically-sized-types/dst-raw.rs b/src/test/run-pass/dynamically-sized-types/dst-raw.rs index 949adbbefce..0893b02e74e 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-raw.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-raw.rs @@ -24,7 +24,7 @@ struct Foo { pub fn main() { // raw trait object let x = A { f: 42 }; - let z: *const Trait = &x; + let z: *const dyn Trait = &x; let r = unsafe { (&*z).foo() }; @@ -32,7 +32,7 @@ pub fn main() { // raw DST struct let p = Foo {f: A { f: 42 }}; - let o: *const Foo = &p; + let o: *const Foo = &p; let r = unsafe { (&*o).f.foo() }; @@ -40,7 +40,7 @@ pub fn main() { // raw DST tuple let p = (A { f: 42 },); - let o: *const (Trait,) = &p; + let o: *const (dyn Trait,) = &p; let r = unsafe { (&*o).0.foo() }; @@ -84,21 +84,21 @@ pub fn main() { // all of the above with *mut let mut x = A { f: 42 }; - let z: *mut Trait = &mut x; + let z: *mut dyn Trait = &mut x; let r = unsafe { (&*z).foo() }; assert_eq!(r, 42); let mut p = Foo {f: A { f: 42 }}; - let o: *mut Foo = &mut p; + let o: *mut Foo = &mut p; let r = unsafe { (&*o).f.foo() }; assert_eq!(r, 42); let mut p = (A { f: 42 },); - let o: *mut (Trait,) = &mut p; + let o: *mut (dyn Trait,) = &mut p; let r = unsafe { (&*o).0.foo() }; diff --git a/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs b/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs index ca88605ee3a..70bcc3de07d 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs @@ -38,7 +38,7 @@ impl ToBar for Bar1 { } // x is a fat pointer -fn foo(x: &Fat) { +fn foo(x: &Fat) { assert_eq!(x.0, 5); assert_eq!(x.1, "some str"); assert_eq!(x.2.to_bar(), Bar); @@ -49,12 +49,12 @@ fn foo(x: &Fat) { assert_eq!(y.to_val(), 42); } -fn bar(x: &ToBar) { +fn bar(x: &dyn ToBar) { assert_eq!(x.to_bar(), Bar); assert_eq!(x.to_val(), 42); } -fn baz(x: &Fat>) { +fn baz(x: &Fat>) { assert_eq!(x.0, 5); assert_eq!(x.1, "some str"); assert_eq!((x.2).0, 8); @@ -73,20 +73,20 @@ pub fn main() { foo(&f1); let f2 = &f1; foo(f2); - let f3: &Fat = f2; + let f3: &Fat = f2; foo(f3); - let f4: &Fat = &f1; + let f4: &Fat = &f1; foo(f4); - let f5: &Fat = &(5, "some str", Bar1 {f :42}); + let f5: &Fat = &(5, "some str", Bar1 {f :42}); foo(f5); // Zero size object. - let f6: &Fat = &(5, "some str", Bar); + let f6: &Fat = &(5, "some str", Bar); assert_eq!(f6.2.to_bar(), Bar); // &* // - let f7: Box = Box::new(Bar1 {f :42}); + let f7: Box = Box::new(Bar1 {f :42}); bar(&*f7); // Deep nesting @@ -94,10 +94,10 @@ pub fn main() { baz(&f1); let f2 = &f1; baz(f2); - let f3: &Fat> = f2; + let f3: &Fat> = f2; baz(f3); - let f4: &Fat> = &f1; + let f4: &Fat> = &f1; baz(f4); - let f5: &Fat> = &(5, "some str", (8, "deep str", Bar1 {f :42})); + let f5: &Fat> = &(5, "some str", (8, "deep str", Bar1 {f :42})); baz(f5); } diff --git a/src/test/run-pass/dynamically-sized-types/dst-trait.rs b/src/test/run-pass/dynamically-sized-types/dst-trait.rs index 9a9bd12d50f..ec6bc72192d 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-trait.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-trait.rs @@ -38,7 +38,7 @@ impl ToBar for Bar1 { } // x is a fat pointer -fn foo(x: &Fat) { +fn foo(x: &Fat) { assert_eq!(x.f1, 5); assert_eq!(x.f2, "some str"); assert_eq!(x.ptr.to_bar(), Bar); @@ -49,12 +49,12 @@ fn foo(x: &Fat) { assert_eq!(y.to_val(), 42); } -fn bar(x: &ToBar) { +fn bar(x: &dyn ToBar) { assert_eq!(x.to_bar(), Bar); assert_eq!(x.to_val(), 42); } -fn baz(x: &Fat>) { +fn baz(x: &Fat>) { assert_eq!(x.f1, 5); assert_eq!(x.f2, "some str"); assert_eq!(x.ptr.f1, 8); @@ -73,20 +73,20 @@ pub fn main() { foo(&f1); let f2 = &f1; foo(f2); - let f3: &Fat = f2; + let f3: &Fat = f2; foo(f3); - let f4: &Fat = &f1; + let f4: &Fat = &f1; foo(f4); - let f5: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + let f5: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; foo(f5); // Zero size object. - let f6: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar }; + let f6: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar }; assert_eq!(f6.ptr.to_bar(), Bar); // &* // - let f7: Box = Box::new(Bar1 {f :42}); + let f7: Box = Box::new(Bar1 {f :42}); bar(&*f7); // Deep nesting @@ -95,11 +95,11 @@ pub fn main() { baz(&f1); let f2 = &f1; baz(f2); - let f3: &Fat> = f2; + let f3: &Fat> = f2; baz(f3); - let f4: &Fat> = &f1; + let f4: &Fat> = &f1; baz(f4); - let f5: &Fat> = + let f5: &Fat> = &Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: Bar1 {f :42}} }; baz(f5); } diff --git a/src/test/run-pass/extern/extern-types-trait-impl.rs b/src/test/run-pass/extern/extern-types-trait-impl.rs index ac4c70a71ce..6cce6c723c5 100644 --- a/src/test/run-pass/extern/extern-types-trait-impl.rs +++ b/src/test/run-pass/extern/extern-types-trait-impl.rs @@ -18,7 +18,7 @@ impl Foo for A { fn assert_foo() { } -fn use_foo(x: &Foo) { +fn use_foo(x: &dyn Foo) { x.foo(); } diff --git a/src/test/run-pass/fat-ptr-cast.rs b/src/test/run-pass/fat-ptr-cast.rs index 367b57d5ea0..1943abe9e14 100644 --- a/src/test/run-pass/fat-ptr-cast.rs +++ b/src/test/run-pass/fat-ptr-cast.rs @@ -25,7 +25,7 @@ fn main() { assert_eq!(a as usize, b as *const () as usize); // And conversion to a void pointer/address for trait objects too. - let a: *mut Foo = &mut Bar; + let a: *mut dyn Foo = &mut Bar; let b = a as *mut (); let c = a as *const () as usize; let d = unsafe { diff --git a/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs b/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs index 96b7a66d075..e97785b5cac 100644 --- a/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs +++ b/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs @@ -5,7 +5,7 @@ struct UsizeRef<'a> { a: &'a usize } -type RefTo = Box Fn(&'r Vec) -> UsizeRef<'r>>; +type RefTo = Box Fn(&'r Vec) -> UsizeRef<'r>>; fn ref_to<'a>(vec: &'a Vec) -> UsizeRef<'a> { UsizeRef{ a: &vec[0]} diff --git a/src/test/run-pass/generics/generic-object.rs b/src/test/run-pass/generics/generic-object.rs index 054425989c3..870ff980ec6 100644 --- a/src/test/run-pass/generics/generic-object.rs +++ b/src/test/run-pass/generics/generic-object.rs @@ -17,6 +17,6 @@ impl Foo for S { pub fn main() { let x = box S { x: 1 }; - let y = x as Box>; + let y = x as Box>; assert_eq!(y.get(), 1); } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 364661e565e..987a3e414f5 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -19,7 +19,7 @@ mod map_reduce { use std::str; use std::thread; - pub type putter<'a> = Box; + pub type putter<'a> = Box; pub type mapper = extern fn(String, putter); diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs index 1591d616cac..cc766c0605c 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs @@ -19,7 +19,7 @@ struct Tcx<'tcx> { impl<'tcx> Typer<'tcx> for Tcx<'tcx> { } -fn g<'tcx>(typer: &Typer<'tcx>) { +fn g<'tcx>(typer: &dyn Typer<'tcx>) { } fn check_static_type<'x>(tcx: &Tcx<'x>) { diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs index 09152970fdc..8431226a3ec 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs @@ -7,7 +7,7 @@ trait Typer<'tcx> { fn dummy(&self) { } } -fn g(_: F) where F: FnOnce(&Typer) {} +fn g(_: F) where F: FnOnce(&dyn Typer) {} fn h() { g(|typer| typer.dummy()) diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs index 7ef8ea046b8..ff84ad9d298 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs @@ -6,7 +6,7 @@ trait FnLike { fn call(&self, arg: A) -> R; } -type FnObject<'b> = for<'a> FnLike<&'a isize, &'a isize> + 'b; +type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b; struct Identity; diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs index 3fb0b3290eb..1fab9758c5c 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs @@ -24,8 +24,8 @@ fn foo01 Get<&'a i32, &'a i32>>(t: T) // Parse HRTB with explicit `for` in various sorts of types: -fn foo10(t: Box Get>) { } -fn foo11(t: Box Fn(i32) -> i32>) { } +fn foo10(t: Box Get>) { } +fn foo11(t: Box Fn(i32) -> i32>) { } fn foo20(t: for<'a> fn(i32) -> i32) { } fn foo21(t: for<'a> unsafe fn(i32) -> i32) { } diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs index 5fda4b826e0..6834c392d4e 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs @@ -6,7 +6,7 @@ // 'static` and not `Fn(isize) -> (isize + 'static)`. The latter would // cause a compilation error. Issue #18772. -fn adder(y: isize) -> Box isize + 'static> { +fn adder(y: isize) -> Box isize + 'static> { Box::new(move |x| y + x) } diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs index 917f6f96118..b97fdf4df50 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs @@ -8,7 +8,7 @@ trait FnLike { fn call(&self, arg: A) -> R; } -type FnObject<'b> = for<'a> FnLike<&'a isize, &'a isize> + 'b; +type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b; fn main() { } diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs index 0ed8f7ee52a..d8c726cdd71 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs @@ -5,7 +5,7 @@ trait FnLike { fn call(&self, arg: A) -> R; } -type FnObject<'b> = for<'a> FnLike<(&'a i32,), &'a i32> + 'b; +type FnObject<'b> = dyn for<'a> FnLike<(&'a i32,), &'a i32> + 'b; struct Identity; diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs index 4cb9242f0ed..41ebb3f5a14 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs @@ -17,7 +17,7 @@ struct NoAnn<'ast> { impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> { } -fn foo<'ast, G>(f: Option<&'ast usize>, g: G) where G: FnOnce(&PrinterSupport) { +fn foo<'ast, G>(f: Option<&'ast usize>, g: G) where G: FnOnce(&dyn PrinterSupport) { let annotation = NoAnn { f: f }; g(&annotation) } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 8c17b01e2bd..6660f393f7d 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -93,7 +93,7 @@ pub fn main() { t!(format!("{:#4}", C), "☃123"); t!(format!("{:b}", D), "aa☃bb"); - let a: &fmt::Debug = &1; + let a: &dyn fmt::Debug = &1; t!(format!("{:?}", a), "1"); diff --git a/src/test/run-pass/issues/issue-10802.rs b/src/test/run-pass/issues/issue-10802.rs index 8872eae6f8b..f1d6b37a684 100644 --- a/src/test/run-pass/issues/issue-10802.rs +++ b/src/test/run-pass/issues/issue-10802.rs @@ -24,9 +24,9 @@ trait MyTrait { fn dummy(&self) { } } impl MyTrait for Box {} impl MyTrait for Box {} -struct Whatever { w: Box } +struct Whatever { w: Box } impl Whatever { - fn new(w: Box) -> Whatever { + fn new(w: Box) -> Whatever { Whatever { w: w } } } @@ -34,13 +34,13 @@ impl Whatever { fn main() { { let f: Box<_> = box DroppableStruct; - let _a = Whatever::new(box f as Box); + let _a = Whatever::new(box f as Box); } assert!(unsafe { DROPPED }); unsafe { DROPPED = false; } { let f: Box<_> = box DroppableEnum::DroppableVariant1; - let _a = Whatever::new(box f as Box); + let _a = Whatever::new(box f as Box); } assert!(unsafe { DROPPED }); } diff --git a/src/test/run-pass/issues/issue-11205.rs b/src/test/run-pass/issues/issue-11205.rs index b628bf60196..ce0951eafdd 100644 --- a/src/test/run-pass/issues/issue-11205.rs +++ b/src/test/run-pass/issues/issue-11205.rs @@ -5,44 +5,44 @@ trait Foo { fn dummy(&self) { } } impl Foo for isize {} -fn foo(_: [&Foo; 2]) {} -fn foos(_: &[&Foo]) {} +fn foo(_: [&dyn Foo; 2]) {} +fn foos(_: &[&dyn Foo]) {} fn foog(_: &[T], _: &[T]) {} -fn bar(_: [Box; 2]) {} -fn bars(_: &[Box]) {} +fn bar(_: [Box; 2]) {} +fn bars(_: &[Box]) {} fn main() { - let x: [&Foo; 2] = [&1, &2]; + let x: [&dyn Foo; 2] = [&1, &2]; foo(x); foo([&1, &2]); let r = &1; - let x: [&Foo; 2] = [r; 2]; + let x: [&dyn Foo; 2] = [r; 2]; foo(x); foo([&1; 2]); - let x: &[&Foo] = &[&1, &2]; + let x: &[&dyn Foo] = &[&1, &2]; foos(x); foos(&[&1, &2]); - let x: &[&Foo] = &[&1, &2]; + let x: &[&dyn Foo] = &[&1, &2]; let r = &1; foog(x, &[r]); - let x: [Box; 2] = [Box::new(1), Box::new(2)]; + let x: [Box; 2] = [Box::new(1), Box::new(2)]; bar(x); bar([Box::new(1), Box::new(2)]); - let x: &[Box] = &[Box::new(1), Box::new(2)]; + let x: &[Box] = &[Box::new(1), Box::new(2)]; bars(x); bars(&[Box::new(1), Box::new(2)]); - let x: &[Box] = &[Box::new(1), Box::new(2)]; + let x: &[Box] = &[Box::new(1), Box::new(2)]; foog(x, &[Box::new(1)]); struct T<'a> { - t: [&'a (Foo+'a); 2] + t: [&'a (dyn Foo+'a); 2] } let _n = T { t: [&1, &2] @@ -51,34 +51,34 @@ fn main() { let _n = T { t: [r; 2] }; - let x: [&Foo; 2] = [&1, &2]; + let x: [&dyn Foo; 2] = [&1, &2]; let _n = T { t: x }; struct F<'b> { - t: &'b [&'b (Foo+'b)] + t: &'b [&'b (dyn Foo+'b)] } let _n = F { t: &[&1, &2] }; let r = &1; - let r: [&Foo; 2] = [r; 2]; + let r: [&dyn Foo; 2] = [r; 2]; let _n = F { t: &r }; - let x: [&Foo; 2] = [&1, &2]; + let x: [&dyn Foo; 2] = [&1, &2]; let _n = F { t: &x }; struct M<'a> { - t: &'a [Box] + t: &'a [Box] } let _n = M { t: &[Box::new(1), Box::new(2)] }; - let x: [Box; 2] = [Box::new(1), Box::new(2)]; + let x: [Box; 2] = [Box::new(1), Box::new(2)]; let _n = M { t: &x }; diff --git a/src/test/run-pass/issues/issue-11267.rs b/src/test/run-pass/issues/issue-11267.rs index 1aaeaa62ad0..848ed6ac7a8 100644 --- a/src/test/run-pass/issues/issue-11267.rs +++ b/src/test/run-pass/issues/issue-11267.rs @@ -10,7 +10,7 @@ impl T for Empty { fn next(&mut self) -> Option { None } } -fn do_something_with(a : &mut T) { +fn do_something_with(a : &mut dyn T) { println!("{:?}", a.next()) } diff --git a/src/test/run-pass/issues/issue-11677.rs b/src/test/run-pass/issues/issue-11677.rs index 5dabecc48f9..be18c736f14 100644 --- a/src/test/run-pass/issues/issue-11677.rs +++ b/src/test/run-pass/issues/issue-11677.rs @@ -11,8 +11,8 @@ trait X { fn dummy(&self) -> T { panic!() } } -struct S {f: Box+'static>, - g: Box+'static>} +struct S {f: Box+'static>, + g: Box+'static>} struct F; impl X for F { diff --git a/src/test/run-pass/issues/issue-11709.rs b/src/test/run-pass/issues/issue-11709.rs index f191a203f03..cb5e3dff3b3 100644 --- a/src/test/run-pass/issues/issue-11709.rs +++ b/src/test/run-pass/issues/issue-11709.rs @@ -9,7 +9,7 @@ struct S {x:()} -fn test(slot: &mut Option Box>>) -> () { +fn test(slot: &mut Option Box>>) -> () { let a = slot.take(); let _a = match a { // `{let .. a(); }` would break diff --git a/src/test/run-pass/issues/issue-12744.rs b/src/test/run-pass/issues/issue-12744.rs index d02620ee1a4..e2756ec970c 100644 --- a/src/test/run-pass/issues/issue-12744.rs +++ b/src/test/run-pass/issues/issue-12744.rs @@ -1,5 +1,5 @@ // run-pass fn main() { - fn test() -> Box { Box::new(1) } + fn test() -> Box { Box::new(1) } println!("{:?}", test()) } diff --git a/src/test/run-pass/issues/issue-13507-2.rs b/src/test/run-pass/issues/issue-13507-2.rs index ce920a3ccab..63f3589c6cc 100644 --- a/src/test/run-pass/issues/issue-13507-2.rs +++ b/src/test/run-pass/issues/issue-13507-2.rs @@ -23,7 +23,7 @@ pub fn type_ids() -> Vec { TypeId::of::(), TypeId::of::(), TypeId::of::(), - TypeId::of::(), + TypeId::of::(), TypeId::of::(), TypeId::of::() ] diff --git a/src/test/run-pass/issues/issue-13808.rs b/src/test/run-pass/issues/issue-13808.rs index d1b94c71864..9f9db067bf4 100644 --- a/src/test/run-pass/issues/issue-13808.rs +++ b/src/test/run-pass/issues/issue-13808.rs @@ -4,7 +4,7 @@ // pretty-expanded FIXME #23616 struct Foo<'a> { - listener: Box, + listener: Box, } impl<'a> Foo<'a> { diff --git a/src/test/run-pass/issues/issue-14399.rs b/src/test/run-pass/issues/issue-14399.rs index 1b57856e955..6bf8a589959 100644 --- a/src/test/run-pass/issues/issue-14399.rs +++ b/src/test/run-pass/issues/issue-14399.rs @@ -16,5 +16,5 @@ impl A for B1 {} fn main() { let v: Box<_> = box B1; - let _c: Box = v.clone(); + let _c: Box = v.clone(); } diff --git a/src/test/run-pass/issues/issue-14589.rs b/src/test/run-pass/issues/issue-14589.rs index d495602dff7..5d8aab2ce74 100644 --- a/src/test/run-pass/issues/issue-14589.rs +++ b/src/test/run-pass/issues/issue-14589.rs @@ -5,9 +5,9 @@ // pretty-expanded FIXME #23616 fn main() { - send::>(Box::new(Output(0))); - Test::>::foo(Box::new(Output(0))); - Test::>::new().send(Box::new(Output(0))); + send::>(Box::new(Output(0))); + Test::>::foo(Box::new(Output(0))); + Test::>::new().send(Box::new(Output(0))); } fn send(_: T) {} diff --git a/src/test/run-pass/issues/issue-14821.rs b/src/test/run-pass/issues/issue-14821.rs index 5ac0d0df0d7..00b2e3607fc 100644 --- a/src/test/run-pass/issues/issue-14821.rs +++ b/src/test/run-pass/issues/issue-14821.rs @@ -6,16 +6,16 @@ struct Meow; impl SomeTrait for Meow {} struct Foo<'a> { - x: &'a SomeTrait, - y: &'a SomeTrait, + x: &'a dyn SomeTrait, + y: &'a dyn SomeTrait, } impl<'a> Foo<'a> { - pub fn new<'b>(x: &'b SomeTrait, y: &'b SomeTrait) -> Foo<'b> { Foo { x: x, y: y } } + pub fn new<'b>(x: &'b dyn SomeTrait, y: &'b dyn SomeTrait) -> Foo<'b> { Foo { x: x, y: y } } } fn main() { let r = Meow; let s = Meow; - let q = Foo::new(&r as &SomeTrait, &s as &SomeTrait); + let q = Foo::new(&r as &dyn SomeTrait, &s as &dyn SomeTrait); } diff --git a/src/test/run-pass/issues/issue-14919.rs b/src/test/run-pass/issues/issue-14919.rs index c6ccb7575bb..94361543354 100644 --- a/src/test/run-pass/issues/issue-14919.rs +++ b/src/test/run-pass/issues/issue-14919.rs @@ -9,7 +9,7 @@ trait Matcher { struct CharPredMatcher<'a, 'b> { str: &'a str, - pred: Box bool + 'b>, + pred: Box bool + 'b>, } impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> { diff --git a/src/test/run-pass/issues/issue-14958.rs b/src/test/run-pass/issues/issue-14958.rs index 17f7f159fd2..a12564ca9c0 100644 --- a/src/test/run-pass/issues/issue-14958.rs +++ b/src/test/run-pass/issues/issue-14958.rs @@ -7,17 +7,17 @@ trait Foo { fn dummy(&self) { }} struct Bar; -impl<'a> std::ops::Fn<(&'a (Foo+'a),)> for Bar { - extern "rust-call" fn call(&self, _: (&'a Foo,)) {} +impl<'a> std::ops::Fn<(&'a (dyn Foo+'a),)> for Bar { + extern "rust-call" fn call(&self, _: (&'a dyn Foo,)) {} } -impl<'a> std::ops::FnMut<(&'a (Foo+'a),)> for Bar { - extern "rust-call" fn call_mut(&mut self, a: (&'a Foo,)) { self.call(a) } +impl<'a> std::ops::FnMut<(&'a (dyn Foo+'a),)> for Bar { + extern "rust-call" fn call_mut(&mut self, a: (&'a dyn Foo,)) { self.call(a) } } -impl<'a> std::ops::FnOnce<(&'a (Foo+'a),)> for Bar { +impl<'a> std::ops::FnOnce<(&'a (dyn Foo+'a),)> for Bar { type Output = (); - extern "rust-call" fn call_once(self, a: (&'a Foo,)) { self.call(a) } + extern "rust-call" fn call_once(self, a: (&'a dyn Foo,)) { self.call(a) } } struct Baz; diff --git a/src/test/run-pass/issues/issue-15155.rs b/src/test/run-pass/issues/issue-15155.rs index 3e513a3d5ec..7b137b4af56 100644 --- a/src/test/run-pass/issues/issue-15155.rs +++ b/src/test/run-pass/issues/issue-15155.rs @@ -4,18 +4,18 @@ trait IndirectTraitWithSend: TraitWithSend {} // Check struct instantiation (Box will only have Send if TraitWithSend has Send) #[allow(dead_code)] -struct Blah { x: Box } +struct Blah { x: Box } impl TraitWithSend for Blah {} // Struct instantiation 2-levels deep #[allow(dead_code)] -struct IndirectBlah { x: Box } +struct IndirectBlah { x: Box } impl TraitWithSend for IndirectBlah {} impl IndirectTraitWithSend for IndirectBlah {} fn test_trait() { println!("got here!") } fn main() { - test_trait::(); - test_trait::(); + test_trait::(); + test_trait::(); } diff --git a/src/test/run-pass/issues/issue-15763.rs b/src/test/run-pass/issues/issue-15763.rs index 4438d1f2cec..9ceffff2e38 100644 --- a/src/test/run-pass/issues/issue-15763.rs +++ b/src/test/run-pass/issues/issue-15763.rs @@ -78,12 +78,12 @@ fn main() { assert_eq!(cc().unwrap(), 3); assert_eq!(dd().unwrap(), 3); - let i = box 32isize as Box; + let i = box 32isize as Box; assert_eq!(i.aaa(), 3); - let i = box 32isize as Box; + let i = box 32isize as Box; assert_eq!(i.bbb(), 3); - let i = box 32isize as Box; + let i = box 32isize as Box; assert_eq!(i.ccc().unwrap(), 3); - let i = box 32isize as Box; + let i = box 32isize as Box; assert_eq!(i.ddd().unwrap(), 3); } diff --git a/src/test/run-pass/issues/issue-16739.rs b/src/test/run-pass/issues/issue-16739.rs index 6868eae6ea4..54ad8fd076e 100644 --- a/src/test/run-pass/issues/issue-16739.rs +++ b/src/test/run-pass/issues/issue-16739.rs @@ -39,12 +39,12 @@ impl FnOnce<(u32,u32)> for Foo { } fn main() { - let mut f = box Foo { foo: 42 } as Box u32>; + let mut f = box Foo { foo: 42 } as Box u32>; assert_eq!(f.call_mut(()), 42); - let mut f = box Foo { foo: 40 } as Box u32>; + let mut f = box Foo { foo: 40 } as Box u32>; assert_eq!(f.call_mut((2,)), 42); - let mut f = box Foo { foo: 40 } as Box u32>; + let mut f = box Foo { foo: 40 } as Box u32>; assert_eq!(f.call_mut((1, 1)), 42); } diff --git a/src/test/run-pass/issues/issue-16922.rs b/src/test/run-pass/issues/issue-16922.rs index 82a3943e9ef..c3c6ff30488 100644 --- a/src/test/run-pass/issues/issue-16922.rs +++ b/src/test/run-pass/issues/issue-16922.rs @@ -7,5 +7,5 @@ fn foo(_: &u8) { } fn main() { - let _ = &foo as &Any; + let _ = &foo as &dyn Any; } diff --git a/src/test/run-pass/issues/issue-17322.rs b/src/test/run-pass/issues/issue-17322.rs index 79b6a5ae533..20a8d136124 100644 --- a/src/test/run-pass/issues/issue-17322.rs +++ b/src/test/run-pass/issues/issue-17322.rs @@ -5,11 +5,11 @@ use std::io::{self, Write}; -fn f(wr: &mut Write) { +fn f(wr: &mut dyn Write) { wr.write_all(b"hello").ok().expect("failed"); } fn main() { - let mut wr = box io::stdout() as Box; + let mut wr = box io::stdout() as Box; f(&mut wr); } diff --git a/src/test/run-pass/issues/issue-17351.rs b/src/test/run-pass/issues/issue-17351.rs index f51f0b3ca01..62f6bcf15e3 100644 --- a/src/test/run-pass/issues/issue-17351.rs +++ b/src/test/run-pass/issues/issue-17351.rs @@ -6,5 +6,5 @@ impl Str for str {} impl<'a, S: ?Sized> Str for &'a S where S: Str {} fn main() { - let _: &Str = &"x"; + let _: &dyn Str = &"x"; } diff --git a/src/test/run-pass/issues/issue-17771.rs b/src/test/run-pass/issues/issue-17771.rs index 7eea5ce6589..2f6464668c2 100644 --- a/src/test/run-pass/issues/issue-17771.rs +++ b/src/test/run-pass/issues/issue-17771.rs @@ -4,13 +4,13 @@ trait Aaa { fn dummy(&self) { } } -impl<'a> Aaa for &'a mut (Aaa + 'a) {} +impl<'a> Aaa for &'a mut (dyn Aaa + 'a) {} struct Bar<'a> { - writer: &'a mut (Aaa + 'a), + writer: &'a mut (dyn Aaa + 'a), } -fn baz(_: &mut Aaa) { +fn baz(_: &mut dyn Aaa) { } fn foo<'a>(mut bar: Bar<'a>) { diff --git a/src/test/run-pass/issues/issue-17897.rs b/src/test/run-pass/issues/issue-17897.rs index 291bd3f1718..6873c7ccb7f 100644 --- a/src/test/run-pass/issues/issue-17897.rs +++ b/src/test/run-pass/issues/issue-17897.rs @@ -1,5 +1,5 @@ // run-pass -fn action(mut cb: Box usize>) -> usize { +fn action(mut cb: Box usize>) -> usize { cb(1) } diff --git a/src/test/run-pass/issues/issue-20055-box-trait.rs b/src/test/run-pass/issues/issue-20055-box-trait.rs index cb7b5a638fc..772cd9d7eda 100644 --- a/src/test/run-pass/issues/issue-20055-box-trait.rs +++ b/src/test/run-pass/issues/issue-20055-box-trait.rs @@ -22,7 +22,7 @@ pub fn foo(box_1: fn () -> Box<[i8; 1]>, box_4: fn () -> Box<[i8; 4]>, ) { println!("Hello World 1"); - let _: Box = match 3 { + let _: Box = match 3 { 1 => box_1(), 2 => box_2(), 3 => box_3(), diff --git a/src/test/run-pass/issues/issue-20575.rs b/src/test/run-pass/issues/issue-20575.rs index 95273edcf7e..0ca67d9dc71 100644 --- a/src/test/run-pass/issues/issue-20575.rs +++ b/src/test/run-pass/issues/issue-20575.rs @@ -4,7 +4,7 @@ // pretty-expanded FIXME #23616 fn main() { - let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; + let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; let _: Option> = functions.iter().map(|f| (*f)()).collect(); } diff --git a/src/test/run-pass/issues/issue-20676.rs b/src/test/run-pass/issues/issue-20676.rs index 27bbff09a00..2bc5034960a 100644 --- a/src/test/run-pass/issues/issue-20676.rs +++ b/src/test/run-pass/issues/issue-20676.rs @@ -7,6 +7,6 @@ use std::fmt; fn main() { - let a: &fmt::Debug = &1; + let a: &dyn fmt::Debug = &1; format!("{:?}", a); } diff --git a/src/test/run-pass/issues/issue-20953.rs b/src/test/run-pass/issues/issue-20953.rs index f5c743d0d82..4ec7e3195eb 100644 --- a/src/test/run-pass/issues/issue-20953.rs +++ b/src/test/run-pass/issues/issue-20953.rs @@ -2,11 +2,11 @@ #![allow(unused_mut)] #![allow(unused_variables)] fn main() { - let mut shrinker: Box> = Box::new(vec![1].into_iter()); + let mut shrinker: Box> = Box::new(vec![1].into_iter()); println!("{:?}", shrinker.next()); for v in shrinker { assert!(false); } - let mut shrinker: &mut Iterator = &mut vec![1].into_iter(); + let mut shrinker: &mut dyn Iterator = &mut vec![1].into_iter(); println!("{:?}", shrinker.next()); for v in shrinker { assert!(false); } } diff --git a/src/test/run-pass/issues/issue-21058.rs b/src/test/run-pass/issues/issue-21058.rs index e0cf26f7034..0483e62fd21 100644 --- a/src/test/run-pass/issues/issue-21058.rs +++ b/src/test/run-pass/issues/issue-21058.rs @@ -13,7 +13,7 @@ fn main() { // str std::intrinsics::type_name::(), // Trait - std::intrinsics::type_name::(), + std::intrinsics::type_name::(), // Newtype std::intrinsics::type_name::(), // DST diff --git a/src/test/run-pass/issues/issue-21361.rs b/src/test/run-pass/issues/issue-21361.rs index 5297a4a7b29..c970e77abb7 100644 --- a/src/test/run-pass/issues/issue-21361.rs +++ b/src/test/run-pass/issues/issue-21361.rs @@ -2,10 +2,10 @@ fn main() { let v = vec![1, 2, 3]; - let boxed: Box> = Box::new(v.into_iter()); + let boxed: Box> = Box::new(v.into_iter()); assert_eq!(boxed.max(), Some(3)); let v = vec![1, 2, 3]; - let boxed: &mut Iterator = &mut v.into_iter(); + let boxed: &mut dyn Iterator = &mut v.into_iter(); assert_eq!(boxed.max(), Some(3)); } diff --git a/src/test/run-pass/issues/issue-21655.rs b/src/test/run-pass/issues/issue-21655.rs index cddd48349f9..d1cd4ec7b8a 100644 --- a/src/test/run-pass/issues/issue-21655.rs +++ b/src/test/run-pass/issues/issue-21655.rs @@ -1,6 +1,6 @@ // run-pass -fn test(it: &mut Iterator) { +fn test(it: &mut dyn Iterator) { for x in it { assert_eq!(x, 1) } diff --git a/src/test/run-pass/issues/issue-2190-1.rs b/src/test/run-pass/issues/issue-2190-1.rs index 34a80ab0051..e67a924b9ee 100644 --- a/src/test/run-pass/issues/issue-2190-1.rs +++ b/src/test/run-pass/issues/issue-2190-1.rs @@ -9,11 +9,11 @@ use std::thread::Builder; static generations: usize = 1024+256+128+49; -fn spawn(mut f: Box) { +fn spawn(mut f: Box) { Builder::new().stack_size(32 * 1024).spawn(move|| f()); } -fn child_no(x: usize) -> Box { +fn child_no(x: usize) -> Box { Box::new(move|| { if x < generations { spawn(child_no(x+1)); diff --git a/src/test/run-pass/issues/issue-22346.rs b/src/test/run-pass/issues/issue-22346.rs index b728911e541..5f6d9dcc9ae 100644 --- a/src/test/run-pass/issues/issue-22346.rs +++ b/src/test/run-pass/issues/issue-22346.rs @@ -3,7 +3,7 @@ // pretty-expanded FIXME #23616 // This used to cause an ICE because the retslot for the "return" had the wrong type -fn testcase<'a>() -> Box + 'a> { +fn testcase<'a>() -> Box + 'a> { return Box::new((0..3).map(|i| { return i; })); } diff --git a/src/test/run-pass/issues/issue-2288.rs b/src/test/run-pass/issues/issue-2288.rs index 963e7e62c7f..c74e53fca60 100644 --- a/src/test/run-pass/issues/issue-2288.rs +++ b/src/test/run-pass/issues/issue-2288.rs @@ -23,13 +23,13 @@ fn foo(b: A) -> foo { } } -fn f(x: Box>, a: A) { +fn f(x: Box>, a: A) { x.chowder(a); } pub fn main() { let c = foo(42); - let d: Box> = box c as Box>; + let d: Box> = box c as Box>; f(d, c.x); } diff --git a/src/test/run-pass/issues/issue-23261.rs b/src/test/run-pass/issues/issue-23261.rs index 0b34653a345..e21f86351ee 100644 --- a/src/test/run-pass/issues/issue-23261.rs +++ b/src/test/run-pass/issues/issue-23261.rs @@ -41,7 +41,7 @@ fn check_both(val: &Foo<[u8]>) { } } -fn check_trait_obj(val: &Foo) { +fn check_trait_obj(val: &Foo) { match *val { Foo { a, ref inner } => { assert_eq!(a, 32); @@ -56,6 +56,6 @@ fn main() { check_dst_val(foo); check_both(foo); - let foo: &Foo = &Foo { a: 32, inner: 32 }; + let foo: &Foo = &Foo { a: 32, inner: 32 }; check_trait_obj(foo); } diff --git a/src/test/run-pass/issues/issue-23485.rs b/src/test/run-pass/issues/issue-23485.rs index a55846f40df..1dd3d9293bc 100644 --- a/src/test/run-pass/issues/issue-23485.rs +++ b/src/test/run-pass/issues/issue-23485.rs @@ -45,6 +45,6 @@ impl Iterator for Counter { } fn main() { - let mut x: Box> = Box::new(Counter { value: 22 }); + let mut x: Box> = Box::new(Counter { value: 22 }); assert_eq!(x.next().unwrap().value, 22); } diff --git a/src/test/run-pass/issues/issue-24010.rs b/src/test/run-pass/issues/issue-24010.rs index 1f68d47d97b..264e1ee22cd 100644 --- a/src/test/run-pass/issues/issue-24010.rs +++ b/src/test/run-pass/issues/issue-24010.rs @@ -2,7 +2,7 @@ trait Foo: Fn(i32) -> i32 + Send {} impl i32 + Send> Foo for T {} -fn wants_foo(f: Box) -> i32 { +fn wants_foo(f: Box) -> i32 { f(42) } diff --git a/src/test/run-pass/issues/issue-24086.rs b/src/test/run-pass/issues/issue-24086.rs index 86fa5a6f368..54622afbcfc 100644 --- a/src/test/run-pass/issues/issue-24086.rs +++ b/src/test/run-pass/issues/issue-24086.rs @@ -7,8 +7,8 @@ pub struct Registry<'a> { } pub struct Listener<'a> { - pub announce: Option>, - pub remove: Option>, + pub announce: Option>, + pub remove: Option>, } impl<'a> Drop for Registry<'a> { diff --git a/src/test/run-pass/issues/issue-25339.rs b/src/test/run-pass/issues/issue-25339.rs index 602f458e4cf..6f8ec700951 100644 --- a/src/test/run-pass/issues/issue-25339.rs +++ b/src/test/run-pass/issues/issue-25339.rs @@ -12,7 +12,7 @@ pub trait Routing { pub trait ToRouting { type Input; - type Routing : ?Sized = Routing; + type Routing : ?Sized = dyn Routing; fn to_routing(self) -> Self::Routing; } diff --git a/src/test/run-pass/issues/issue-25515.rs b/src/test/run-pass/issues/issue-25515.rs index 75af16d8dda..e7b9ea3acfc 100644 --- a/src/test/run-pass/issues/issue-25515.rs +++ b/src/test/run-pass/issues/issue-25515.rs @@ -13,7 +13,7 @@ fn main() { let mut drops = 0; { - let _: Rc = Rc::new(Foo(&mut drops)); + let _: Rc = Rc::new(Foo(&mut drops)); } assert_eq!(1, drops); diff --git a/src/test/run-pass/issues/issue-25549-multiple-drop.rs b/src/test/run-pass/issues/issue-25549-multiple-drop.rs index db9261f6ef4..25a2da707dc 100644 --- a/src/test/run-pass/issues/issue-25549-multiple-drop.rs +++ b/src/test/run-pass/issues/issue-25549-multiple-drop.rs @@ -25,7 +25,7 @@ fn main() { drops = 0; { - let y = &Holder(Foo(&mut drops)) as &Holder; + let y = &Holder(Foo(&mut drops)) as &Holder; // this used to cause an extra drop of the Foo instance let x = &y.0; } diff --git a/src/test/run-pass/issues/issue-25757.rs b/src/test/run-pass/issues/issue-25757.rs index caade6defdd..ec1864d7deb 100644 --- a/src/test/run-pass/issues/issue-25757.rs +++ b/src/test/run-pass/issues/issue-25757.rs @@ -9,7 +9,7 @@ impl Foo { } } -const FUNC: &'static Fn(&mut Foo) -> () = &Foo::x; +const FUNC: &'static dyn Fn(&mut Foo) -> () = &Foo::x; fn main() { let mut foo = Foo { a: 137 }; diff --git a/src/test/run-pass/issues/issue-26641.rs b/src/test/run-pass/issues/issue-26641.rs index 297b1d689a6..4b6f2c2b3bc 100644 --- a/src/test/run-pass/issues/issue-26641.rs +++ b/src/test/run-pass/issues/issue-26641.rs @@ -1,5 +1,5 @@ // run-pass -struct Parser<'a>(Box); +struct Parser<'a>(Box); fn main() { let _x = Parser(Box::new(|_|{})); diff --git a/src/test/run-pass/issues/issue-26709.rs b/src/test/run-pass/issues/issue-26709.rs index 84cd2137367..281ae13399d 100644 --- a/src/test/run-pass/issues/issue-26709.rs +++ b/src/test/run-pass/issues/issue-26709.rs @@ -11,7 +11,7 @@ fn main() { let mut x = 0; { let wrapper = Box::new(Wrapper(&mut x, 123)); - let _: Box> = wrapper; + let _: Box> = wrapper; } assert_eq!(432, x) } diff --git a/src/test/run-pass/issues/issue-26802.rs b/src/test/run-pass/issues/issue-26802.rs index c4aa70d5022..307a6716098 100644 --- a/src/test/run-pass/issues/issue-26802.rs +++ b/src/test/run-pass/issues/issue-26802.rs @@ -5,7 +5,7 @@ trait Foo<'a> { pub struct FooBar; impl Foo<'static> for FooBar {} -fn test(foobar: FooBar) -> Box> { +fn test(foobar: FooBar) -> Box> { Box::new(foobar) } diff --git a/src/test/run-pass/issues/issue-26805.rs b/src/test/run-pass/issues/issue-26805.rs index 950d98315d0..bcf8a673191 100644 --- a/src/test/run-pass/issues/issue-26805.rs +++ b/src/test/run-pass/issues/issue-26805.rs @@ -2,5 +2,5 @@ struct NonOrd; fn main() { - let _: Box> = Box::new(vec![NonOrd].into_iter()); + let _: Box> = Box::new(vec![NonOrd].into_iter()); } diff --git a/src/test/run-pass/issues/issue-26905.rs b/src/test/run-pass/issues/issue-26905.rs index 2f500d1c0d1..2d5827f476b 100644 --- a/src/test/run-pass/issues/issue-26905.rs +++ b/src/test/run-pass/issues/issue-26905.rs @@ -17,5 +17,5 @@ fn main() { let data = [1, 2, 3]; let iter = data.iter(); let x = MyRc { _ptr: &iter, _boo: PhantomData }; - let _y: MyRc> = x; + let _y: MyRc> = x; } diff --git a/src/test/run-pass/issues/issue-27268.rs b/src/test/run-pass/issues/issue-27268.rs index fccea452fbc..161e2d4d204 100644 --- a/src/test/run-pass/issues/issue-27268.rs +++ b/src/test/run-pass/issues/issue-27268.rs @@ -1,4 +1,4 @@ // run-pass fn main() { - const _C: &'static Fn() = &||{}; + const _C: &'static dyn Fn() = &||{}; } diff --git a/src/test/run-pass/issues/issue-2734.rs b/src/test/run-pass/issues/issue-2734.rs index fcb224e2d04..d449f6449aa 100644 --- a/src/test/run-pass/issues/issue-2734.rs +++ b/src/test/run-pass/issues/issue-2734.rs @@ -11,8 +11,8 @@ trait hax { } impl hax for A { } -fn perform_hax(x: Box) -> Box { - box x as Box +fn perform_hax(x: Box) -> Box { + box x as Box } fn deadcode() { diff --git a/src/test/run-pass/issues/issue-2735.rs b/src/test/run-pass/issues/issue-2735.rs index c48bedf14f7..794c7d4edaa 100644 --- a/src/test/run-pass/issues/issue-2735.rs +++ b/src/test/run-pass/issues/issue-2735.rs @@ -11,8 +11,8 @@ trait hax { } impl hax for A { } -fn perform_hax(x: Box) -> Box { - box x as Box +fn perform_hax(x: Box) -> Box { + box x as Box } fn deadcode() { diff --git a/src/test/run-pass/issues/issue-27890.rs b/src/test/run-pass/issues/issue-27890.rs index 0f6a932e4b8..9f85473380f 100644 --- a/src/test/run-pass/issues/issue-27890.rs +++ b/src/test/run-pass/issues/issue-27890.rs @@ -1,6 +1,6 @@ // run-pass -static PLUS_ONE: &'static (Fn(i32) -> i32 + Sync) = (&|x: i32| { x + 1 }) - as &'static (Fn(i32) -> i32 + Sync); +static PLUS_ONE: &'static (dyn Fn(i32) -> i32 + Sync) = (&|x: i32| { x + 1 }) + as &'static (dyn Fn(i32) -> i32 + Sync); fn main() { assert_eq!(PLUS_ONE(2), 3); diff --git a/src/test/run-pass/issues/issue-2935.rs b/src/test/run-pass/issues/issue-2935.rs index 58ade32b250..11641ca7380 100644 --- a/src/test/run-pass/issues/issue-2935.rs +++ b/src/test/run-pass/issues/issue-2935.rs @@ -20,7 +20,7 @@ pub fn main() { // let y = box ({a: 4}); // let z = box ({a: 4} as it); // let z = box ({a: true} as it); - let z: Box<_> = box (box true as Box); + let z: Box<_> = box (box true as Box); // x.f(); // y.f(); // (*z).f(); diff --git a/src/test/run-pass/issues/issue-3052.rs b/src/test/run-pass/issues/issue-3052.rs index 927102981e7..ee2456da3e2 100644 --- a/src/test/run-pass/issues/issue-3052.rs +++ b/src/test/run-pass/issues/issue-3052.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // pretty-expanded FIXME #23616 -type Connection = Box) + 'static>; +type Connection = Box) + 'static>; fn f() -> Option { let mock_connection: Connection = Box::new(|_| {}); diff --git a/src/test/run-pass/issues/issue-30530.rs b/src/test/run-pass/issues/issue-30530.rs index 0ae270200a6..e837fc81721 100644 --- a/src/test/run-pass/issues/issue-30530.rs +++ b/src/test/run-pass/issues/issue-30530.rs @@ -8,7 +8,7 @@ pub enum Handler { Default, #[allow(dead_code)] - Custom(*mut Box), + Custom(*mut Box), } fn main() { @@ -16,7 +16,7 @@ fn main() { } #[inline(never)] -pub fn take(h: Handler, f: Box) -> Box { +pub fn take(h: Handler, f: Box) -> Box { unsafe { match h { Handler::Custom(ptr) => *Box::from_raw(ptr), diff --git a/src/test/run-pass/issues/issue-30615.rs b/src/test/run-pass/issues/issue-30615.rs index 236a181fc1d..c718449d84e 100644 --- a/src/test/run-pass/issues/issue-30615.rs +++ b/src/test/run-pass/issues/issue-30615.rs @@ -1,5 +1,5 @@ // run-pass fn main() { - &0u8 as *const u8 as *const PartialEq; + &0u8 as *const u8 as *const dyn PartialEq; &[0u8] as *const [u8; 1] as *const [u8]; } diff --git a/src/test/run-pass/issues/issue-32389.rs b/src/test/run-pass/issues/issue-32389.rs index 6824c66cb37..cc94cc819d6 100644 --- a/src/test/run-pass/issues/issue-32389.rs +++ b/src/test/run-pass/issues/issue-32389.rs @@ -2,7 +2,7 @@ fn foo() -> T { loop {} } fn test() { - let ref mut a: &mut FnMut((i8,), i16) = foo(); + let ref mut a: &mut dyn FnMut((i8,), i16) = foo(); a((0,), 0); } diff --git a/src/test/run-pass/issues/issue-33387.rs b/src/test/run-pass/issues/issue-33387.rs index 792ff95200a..499fa7c1f27 100644 --- a/src/test/run-pass/issues/issue-33387.rs +++ b/src/test/run-pass/issues/issue-33387.rs @@ -15,18 +15,18 @@ impl Foo for [u8; 2] { struct Bar(T); -fn unsize_fat_ptr<'a>(x: &'a Bar) -> &'a Bar { +fn unsize_fat_ptr<'a>(x: &'a Bar) -> &'a Bar { x } -fn unsize_nested_fat_ptr(x: Arc) -> Arc { +fn unsize_nested_fat_ptr(x: Arc) -> Arc { x } fn main() { - let x: Box> = Box::new(Bar([1,2])); + let x: Box> = Box::new(Bar([1,2])); assert_eq!(unsize_fat_ptr(&*x).0.get(), [1, 2]); - let x: Arc = Arc::new([3, 4]); + let x: Arc = Arc::new([3, 4]); assert_eq!(unsize_nested_fat_ptr(x).get(), [3, 4]); } diff --git a/src/test/run-pass/issues/issue-33461.rs b/src/test/run-pass/issues/issue-33461.rs index 9c6c5bfe78c..4e01d4d3061 100644 --- a/src/test/run-pass/issues/issue-33461.rs +++ b/src/test/run-pass/issues/issue-33461.rs @@ -24,5 +24,5 @@ impl Shape

for TheType { fn main() { let ball = TheType { t: PhantomData }; - let handle: &Shape<()> = &ball; + let handle: &dyn Shape<()> = &ball; } diff --git a/src/test/run-pass/issues/issue-34503.rs b/src/test/run-pass/issues/issue-34503.rs index 1fb4b8759bd..26e7358408f 100644 --- a/src/test/run-pass/issues/issue-34503.rs +++ b/src/test/run-pass/issues/issue-34503.rs @@ -7,5 +7,5 @@ fn main() { where Option: Ord { *x < *x } } impl Foo for () {} - let _ = &() as &Foo; + let _ = &() as &dyn Foo; } diff --git a/src/test/run-pass/issues/issue-35815.rs b/src/test/run-pass/issues/issue-35815.rs index 70e0ed9f7ce..05fd1b15d43 100644 --- a/src/test/run-pass/issues/issue-35815.rs +++ b/src/test/run-pass/issues/issue-35815.rs @@ -10,6 +10,6 @@ struct Foo { fn main() { let foo: &Foo = &Foo { a: 1, b: false, c: 2i32 }; - let foo_unsized: &Foo = foo; + let foo_unsized: &Foo = foo; assert_eq!(mem::size_of_val(foo), mem::size_of_val(foo_unsized)); } diff --git a/src/test/run-pass/issues/issue-36260.rs b/src/test/run-pass/issues/issue-36260.rs index 728dd5ec8d0..d96dc80ea71 100644 --- a/src/test/run-pass/issues/issue-36260.rs +++ b/src/test/run-pass/issues/issue-36260.rs @@ -2,7 +2,7 @@ // Make sure this compiles without getting a linker error because of missing // drop-glue because the collector missed adding drop-glue for the closure: -fn create_fn() -> Box { +fn create_fn() -> Box { let text = String::new(); Box::new(move || { let _ = &text; }) diff --git a/src/test/run-pass/issues/issue-36786-resolve-call.rs b/src/test/run-pass/issues/issue-36786-resolve-call.rs index 38461db544f..e5341ba7dbe 100644 --- a/src/test/run-pass/issues/issue-36786-resolve-call.rs +++ b/src/test/run-pass/issues/issue-36786-resolve-call.rs @@ -3,6 +3,6 @@ // correctly fn main() { - let x : Vec> = vec![Box::new(|| ())]; + let x : Vec> = vec![Box::new(|| ())]; x[0]() } diff --git a/src/test/run-pass/issues/issue-3702.rs b/src/test/run-pass/issues/issue-3702.rs index 1420dff063c..f48d549b3eb 100644 --- a/src/test/run-pass/issues/issue-3702.rs +++ b/src/test/run-pass/issues/issue-3702.rs @@ -6,7 +6,7 @@ pub fn main() { fn to_string(&self) -> String; } - fn to_string(t: Box) { + fn to_string(t: Box) { println!("{}", (*t).to_string()); } diff --git a/src/test/run-pass/issues/issue-3794.rs b/src/test/run-pass/issues/issue-3794.rs index d6af65f787d..408d8d866d8 100644 --- a/src/test/run-pass/issues/issue-3794.rs +++ b/src/test/run-pass/issues/issue-3794.rs @@ -16,7 +16,7 @@ impl T for S { } } -fn print_t(t: &T) { +fn print_t(t: &dyn T) { t.print(); } @@ -27,6 +27,6 @@ fn print_s(s: &S) { pub fn main() { let s: Box = box S { s: 5 }; print_s(&*s); - let t: Box = s as Box; + let t: Box = s as Box; print_t(&*t); } diff --git a/src/test/run-pass/issues/issue-39292.rs b/src/test/run-pass/issues/issue-39292.rs index 0b8139dd795..968cf08916f 100644 --- a/src/test/run-pass/issues/issue-39292.rs +++ b/src/test/run-pass/issues/issue-39292.rs @@ -13,5 +13,5 @@ trait Bar: for<'a> Foo<&'a ()> { } impl Bar for () {} fn main() { - (&() as &Bar).print(); // Segfault + (&() as &dyn Bar).print(); // Segfault } diff --git a/src/test/run-pass/issues/issue-39823.rs b/src/test/run-pass/issues/issue-39823.rs index 0dfa8a75c4f..148cf527e7c 100644 --- a/src/test/run-pass/issues/issue-39823.rs +++ b/src/test/run-pass/issues/issue-39823.rs @@ -11,15 +11,15 @@ struct LocalC(u32); struct LocalG(T); fn main() { - let virtual_localc : &Fn(_) -> LocalC = &LocalC; + let virtual_localc : &dyn Fn(_) -> LocalC = &LocalC; assert_eq!(virtual_localc(1), LocalC(1)); - let virtual_localg : &Fn(_) -> LocalG = &LocalG; + let virtual_localg : &dyn Fn(_) -> LocalG = &LocalG; assert_eq!(virtual_localg(1), LocalG(1)); - let virtual_remotec : &Fn(_) -> RemoteC = &RemoteC; + let virtual_remotec : &dyn Fn(_) -> RemoteC = &RemoteC; assert_eq!(virtual_remotec(1), RemoteC(1)); - let virtual_remoteg : &Fn(_) -> RemoteG = &RemoteG; + let virtual_remoteg : &dyn Fn(_) -> RemoteG = &RemoteG; assert_eq!(virtual_remoteg(1), RemoteG(1)); } diff --git a/src/test/run-pass/issues/issue-41053.rs b/src/test/run-pass/issues/issue-41053.rs index cd7a0a22623..967edfd4415 100644 --- a/src/test/run-pass/issues/issue-41053.rs +++ b/src/test/run-pass/issues/issue-41053.rs @@ -6,8 +6,8 @@ pub trait Trait { fn foo(&self) {} } pub struct Foo; impl Iterator for Foo { - type Item = Box; - fn next(&mut self) -> Option> { + type Item = Box; + fn next(&mut self) -> Option> { extern crate issue_41053; impl ::Trait for issue_41053::Test { fn foo(&self) {} diff --git a/src/test/run-pass/issues/issue-41744.rs b/src/test/run-pass/issues/issue-41744.rs index edc4354b253..dcdd1c21ee5 100644 --- a/src/test/run-pass/issues/issue-41744.rs +++ b/src/test/run-pass/issues/issue-41744.rs @@ -3,5 +3,5 @@ trait Tc {} impl Tc for bool {} fn main() { - let _: &[&Tc] = &[&true]; + let _: &[&dyn Tc] = &[&true]; } diff --git a/src/test/run-pass/issues/issue-42210.rs b/src/test/run-pass/issues/issue-42210.rs index cf4a698f516..318e3099f98 100644 --- a/src/test/run-pass/issues/issue-42210.rs +++ b/src/test/run-pass/issues/issue-42210.rs @@ -12,9 +12,9 @@ struct Bar; trait Baz { } -impl Foo for (Bar, Baz) { } +impl Foo for (Bar, dyn Baz) { } fn main() { - <(Bar, Baz) as Foo>::foo() + <(Bar, dyn Baz) as Foo>::foo() } diff --git a/src/test/run-pass/issues/issue-43132.rs b/src/test/run-pass/issues/issue-43132.rs index 726a86142f6..c886f4b0a2d 100644 --- a/src/test/run-pass/issues/issue-43132.rs +++ b/src/test/run-pass/issues/issue-43132.rs @@ -6,7 +6,7 @@ fn main() { fn foo() { let b = mk::< - Forward<(Box>,)>, + Forward<(Box>,)>, >(); b.map_err(|_| ()).join(); } diff --git a/src/test/run-pass/issues/issue-4333.rs b/src/test/run-pass/issues/issue-4333.rs index ae9f4c8bdb5..3df319b683f 100644 --- a/src/test/run-pass/issues/issue-4333.rs +++ b/src/test/run-pass/issues/issue-4333.rs @@ -5,6 +5,6 @@ use std::io; pub fn main() { - let stdout = &mut io::stdout() as &mut io::Write; + let stdout = &mut io::stdout() as &mut dyn io::Write; stdout.write(b"Hello!"); } diff --git a/src/test/run-pass/issues/issue-47638.rs b/src/test/run-pass/issues/issue-47638.rs index 357364ee612..a1ed3c36544 100644 --- a/src/test/run-pass/issues/issue-47638.rs +++ b/src/test/run-pass/issues/issue-47638.rs @@ -1,10 +1,10 @@ // run-pass #![allow(unused_variables)] -fn id<'c, 'b>(f: &'c &'b Fn(&i32)) -> &'c &'b Fn(&'static i32) { +fn id<'c, 'b>(f: &'c &'b dyn Fn(&i32)) -> &'c &'b dyn Fn(&'static i32) { f } fn main() { - let f: &Fn(&i32) = &|x| {}; + let f: &dyn Fn(&i32) = &|x| {}; id(&f); } diff --git a/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs b/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs index 457fca3fedf..fc869ae4fec 100644 --- a/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs +++ b/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs @@ -23,12 +23,12 @@ impl Debuggable for Thing { fn debug_name(&self) -> String { self.name.clone() } } -fn print_name(x: &Debuggable) +fn print_name(x: &dyn Debuggable) { println!("debug_name = {}", x.debug_name()); } pub fn main() { let thing = Thing::new(); - print_name(&thing as &Debuggable); + print_name(&thing as &dyn Debuggable); } diff --git a/src/test/run-pass/issues/issue-5192.rs b/src/test/run-pass/issues/issue-5192.rs index 74d8d861a7d..5a83d1c2ff9 100644 --- a/src/test/run-pass/issues/issue-5192.rs +++ b/src/test/run-pass/issues/issue-5192.rs @@ -24,12 +24,12 @@ impl EventLoop for UvEventLoop { } pub struct Scheduler { - event_loop: Box, + event_loop: Box, } impl Scheduler { - pub fn new(event_loop: Box) -> Scheduler { + pub fn new(event_loop: Box) -> Scheduler { Scheduler { event_loop: event_loop, } @@ -37,5 +37,5 @@ impl Scheduler { } pub fn main() { - let _sched = Scheduler::new(box UvEventLoop::new() as Box); + let _sched = Scheduler::new(box UvEventLoop::new() as Box); } diff --git a/src/test/run-pass/issues/issue-5666.rs b/src/test/run-pass/issues/issue-5666.rs index bf919ed5b10..aa513277830 100644 --- a/src/test/run-pass/issues/issue-5666.rs +++ b/src/test/run-pass/issues/issue-5666.rs @@ -19,7 +19,7 @@ impl Barks for Dog { pub fn main() { let snoopy = box Dog{name: "snoopy".to_string()}; let bubbles = box Dog{name: "bubbles".to_string()}; - let barker = [snoopy as Box, bubbles as Box]; + let barker = [snoopy as Box, bubbles as Box]; for pup in &barker { println!("{}", pup.bark()); diff --git a/src/test/run-pass/issues/issue-5708.rs b/src/test/run-pass/issues/issue-5708.rs index d3a2858873c..6fe9943d368 100644 --- a/src/test/run-pass/issues/issue-5708.rs +++ b/src/test/run-pass/issues/issue-5708.rs @@ -21,11 +21,11 @@ impl Inner for isize { } struct Outer<'a> { - inner: &'a (Inner+'a) + inner: &'a (dyn Inner+'a) } impl<'a> Outer<'a> { - fn new(inner: &Inner) -> Outer { + fn new(inner: &dyn Inner) -> Outer { Outer { inner: inner } @@ -34,7 +34,7 @@ impl<'a> Outer<'a> { pub fn main() { let inner: isize = 5; - let outer = Outer::new(&inner as &Inner); + let outer = Outer::new(&inner as &dyn Inner); outer.inner.print(); } @@ -45,11 +45,11 @@ pub trait MyTrait { } pub struct MyContainer<'a, T:'a> { - foos: Vec<&'a (MyTrait+'a)> , + foos: Vec<&'a (dyn MyTrait+'a)> , } impl<'a, T> MyContainer<'a, T> { - pub fn add (&mut self, foo: &'a MyTrait) { + pub fn add (&mut self, foo: &'a dyn MyTrait) { self.foos.push(foo); } } diff --git a/src/test/run-pass/issues/issue-5988.rs b/src/test/run-pass/issues/issue-5988.rs index db77ca4375f..303fb4fbc94 100644 --- a/src/test/run-pass/issues/issue-5988.rs +++ b/src/test/run-pass/issues/issue-5988.rs @@ -19,6 +19,6 @@ impl T for A { fn main() { let a = A; - let br = &a as &B; + let br = &a as &dyn B; br.f(); } diff --git a/src/test/run-pass/issues/issue-6128.rs b/src/test/run-pass/issues/issue-6128.rs index f23a317c6ba..8859fbe6afb 100644 --- a/src/test/run-pass/issues/issue-6128.rs +++ b/src/test/run-pass/issues/issue-6128.rs @@ -20,5 +20,5 @@ impl Graph for HashMap { pub fn main() { let g : Box> = box HashMap::new(); - let _g2 : Box> = g as Box>; + let _g2 : Box> = g as Box>; } diff --git a/src/test/run-pass/issues/issue-6157.rs b/src/test/run-pass/issues/issue-6157.rs index 354797cb2a7..b7a44ed8623 100644 --- a/src/test/run-pass/issues/issue-6157.rs +++ b/src/test/run-pass/issues/issue-6157.rs @@ -9,7 +9,7 @@ impl OpInt for F where F: FnMut(isize, isize) -> isize { } } -fn squarei<'a>(x: isize, op: &'a mut OpInt) -> isize { op.call(x, x) } +fn squarei<'a>(x: isize, op: &'a mut dyn OpInt) -> isize { op.call(x, x) } fn muli(x:isize, y:isize) -> isize { x * y } @@ -17,7 +17,7 @@ pub fn main() { let mut f = |x, y| muli(x, y); { let g = &mut f; - let h = g as &mut OpInt; + let h = g as &mut dyn OpInt; squarei(3, h); } } diff --git a/src/test/run-pass/issues/issue-6318.rs b/src/test/run-pass/issues/issue-6318.rs index d416048265f..d8bd83f0dc6 100644 --- a/src/test/run-pass/issues/issue-6318.rs +++ b/src/test/run-pass/issues/issue-6318.rs @@ -4,7 +4,7 @@ #![feature(box_syntax)] pub enum Thing { - A(Box) + A(Box) } pub trait Foo { @@ -16,7 +16,7 @@ pub struct Struct; impl Foo for Struct {} pub fn main() { - match Thing::A(box Struct as Box) { + match Thing::A(box Struct as Box) { Thing::A(_a) => 0, }; } diff --git a/src/test/run-pass/issues/issue-7563.rs b/src/test/run-pass/issues/issue-7563.rs index 820fffd1056..c62405554b4 100644 --- a/src/test/run-pass/issues/issue-7563.rs +++ b/src/test/run-pass/issues/issue-7563.rs @@ -16,7 +16,7 @@ struct B<'a> { b: isize, pa: &'a A } } impl<'a> B<'a> { - fn get_pa(&self) -> &'a IDummy { self.pa as &'a IDummy } + fn get_pa(&self) -> &'a dyn IDummy { self.pa as &'a dyn IDummy } } pub fn main() { diff --git a/src/test/run-pass/issues/issue-7911.rs b/src/test/run-pass/issues/issue-7911.rs index cb7e009d074..de833324bd2 100644 --- a/src/test/run-pass/issues/issue-7911.rs +++ b/src/test/run-pass/issues/issue-7911.rs @@ -12,18 +12,18 @@ struct Foo { bar: Bar } impl FooBar for Bar {} trait Test { - fn get_immut(&self) -> &FooBar; - fn get_mut(&mut self) -> &mut FooBar; + fn get_immut(&self) -> &dyn FooBar; + fn get_mut(&mut self) -> &mut dyn FooBar; } macro_rules! generate_test { ($type_:path, $slf:ident, $field:expr) => ( impl Test for $type_ { - fn get_immut(&$slf) -> &FooBar { - &$field as &FooBar + fn get_immut(&$slf) -> &dyn FooBar { + &$field as &dyn FooBar } - fn get_mut(&mut $slf) -> &mut FooBar { - &mut $field as &mut FooBar + fn get_mut(&mut $slf) -> &mut dyn FooBar { + &mut $field as &mut dyn FooBar } } )} diff --git a/src/test/run-pass/issues/issue-8248.rs b/src/test/run-pass/issues/issue-8248.rs index 239c432e457..31a305c31be 100644 --- a/src/test/run-pass/issues/issue-8248.rs +++ b/src/test/run-pass/issues/issue-8248.rs @@ -7,9 +7,9 @@ trait A { struct B; impl A for B {} -fn foo(_: &mut A) {} +fn foo(_: &mut dyn A) {} pub fn main() { let mut b = B; - foo(&mut b as &mut A); + foo(&mut b as &mut dyn A); } diff --git a/src/test/run-pass/issues/issue-8249.rs b/src/test/run-pass/issues/issue-8249.rs index db49f354a39..d09dff3a697 100644 --- a/src/test/run-pass/issues/issue-8249.rs +++ b/src/test/run-pass/issues/issue-8249.rs @@ -9,10 +9,10 @@ struct B; impl A for B {} struct C<'a> { - foo: &'a mut (A+'a), + foo: &'a mut (dyn A+'a), } -fn foo(a: &mut A) { +fn foo(a: &mut dyn A) { C{ foo: a }; } diff --git a/src/test/run-pass/issues/issue-9129.rs b/src/test/run-pass/issues/issue-9129.rs index c81b9b1a10d..3d87e1c2037 100644 --- a/src/test/run-pass/issues/issue-9129.rs +++ b/src/test/run-pass/issues/issue-9129.rs @@ -20,7 +20,7 @@ fn Ident_new() -> Ident { Ident {name: 0x6789ABCD } } -pub fn light_fuse(fld: Box) { +pub fn light_fuse(fld: Box) { int3!(); let f = || { int3!(); @@ -30,6 +30,6 @@ pub fn light_fuse(fld: Box) { } pub fn main() { - let b = box S as Box; + let b = box S as Box; light_fuse(b); } diff --git a/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs b/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs index c4c95aa1aae..cc0dd4fc14a 100644 --- a/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs +++ b/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs @@ -52,7 +52,7 @@ impl Super for X { pub fn main() { let n = X; - let s = &n as &Super; + let s = &n as &dyn Super; assert_eq!(s.bar(),"super bar".to_string()); assert_eq!(s.foo(),"base foo".to_string()); assert_eq!(s.foo1(),"base foo1".to_string()); diff --git a/src/test/run-pass/issues/issue-9951.rs b/src/test/run-pass/issues/issue-9951.rs index 4e14bdbd734..2698a3b17c6 100644 --- a/src/test/run-pass/issues/issue-9951.rs +++ b/src/test/run-pass/issues/issue-9951.rs @@ -11,11 +11,11 @@ impl Bar for u8 { } fn main() { - let (a, b) = (&5u8 as &Bar, &9u8 as &Bar); - let (c, d): (&Bar, &Bar) = (a, b); + let (a, b) = (&5u8 as &dyn Bar, &9u8 as &dyn Bar); + let (c, d): (&dyn Bar, &dyn Bar) = (a, b); - let (a, b) = (Box::new(5u8) as Box, Box::new(9u8) as Box); - let (c, d): (&Bar, &Bar) = (&*a, &*b); + let (a, b) = (Box::new(5u8) as Box, Box::new(9u8) as Box); + let (c, d): (&dyn Bar, &dyn Bar) = (&*a, &*b); - let (c, d): (&Bar, &Bar) = (&5, &9); + let (c, d): (&dyn Bar, &dyn Bar) = (&5, &9); } diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index b77f7b5d782..42dc6a4b06e 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -3,7 +3,7 @@ struct A { a: Box } -fn foo() -> Box isize + 'static> { +fn foo() -> Box isize + 'static> { let k: Box<_> = Box::new(22); let _u = A {a: k.clone()}; let result = || 22; diff --git a/src/test/run-pass/macros/colorful-write-macros.rs b/src/test/run-pass/macros/colorful-write-macros.rs index aba4383c734..eb1872cc7f0 100644 --- a/src/test/run-pass/macros/colorful-write-macros.rs +++ b/src/test/run-pass/macros/colorful-write-macros.rs @@ -4,7 +4,7 @@ use std::io::Write; use std::fmt; struct Foo<'a> { - writer: &'a mut (Write+'a), + writer: &'a mut (dyn Write+'a), other: &'a str, } @@ -22,7 +22,7 @@ fn borrowing_writer_from_struct_and_formatting_struct_field(foo: Foo) { fn main() { let mut w = Vec::new(); - write!(&mut w as &mut Write, "").unwrap(); + write!(&mut w as &mut dyn Write, "").unwrap(); write!(&mut w, "").unwrap(); // should coerce println!("ok"); diff --git a/src/test/run-pass/macros/type-macros-simple.rs b/src/test/run-pass/macros/type-macros-simple.rs index 579b485a2a5..dd3ad2ef0ac 100644 --- a/src/test/run-pass/macros/type-macros-simple.rs +++ b/src/test/run-pass/macros/type-macros-simple.rs @@ -16,7 +16,7 @@ fn issue_36540() { let x: m!() = m!(); std::cell::Cell::::new(m!()); - impl std::ops::Index for Trait<(m!(), T)> + impl std::ops::Index for dyn Trait<(m!(), T)> where T: Trait { type Output = m!(); diff --git a/src/test/run-pass/methods/method-argument-inference-associated-type.rs b/src/test/run-pass/methods/method-argument-inference-associated-type.rs index b5ba1f94556..acd4a8465b0 100644 --- a/src/test/run-pass/methods/method-argument-inference-associated-type.rs +++ b/src/test/run-pass/methods/method-argument-inference-associated-type.rs @@ -10,13 +10,13 @@ pub trait Service { pub struct S(T); impl Service for ClientMap { - type Request = S>; + type Request = S>; fn call(&self, _req: Self::Request) {} } impl Service for ClientMap2 { - type Request = (Box,); + type Request = (Box,); fn call(&self, _req: Self::Request) {} } diff --git a/src/test/run-pass/mir/mir_codegen_calls.rs b/src/test/run-pass/mir/mir_codegen_calls.rs index 075d266d34d..fc0db03e3a9 100644 --- a/src/test/run-pass/mir/mir_codegen_calls.rs +++ b/src/test/run-pass/mir/mir_codegen_calls.rs @@ -42,7 +42,7 @@ fn test4(x: &Foo, a: isize) -> isize { x.extension_method(a) } -fn test5(x: &Bar, a: isize) -> isize { +fn test5(x: &dyn Bar, a: isize) -> isize { // Test calling method on trait object x.extension_method(a) } @@ -88,11 +88,11 @@ fn test_closure(f: &F, x: i32, y: i32) -> i32 f(x, y) } -fn test_fn_object(f: &Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { +fn test_fn_object(f: &dyn Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { f(x, y) } -fn test_fn_impl(f: &&Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { +fn test_fn_impl(f: &&dyn Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { // This call goes through the Fn implementation for &Fn provided in // core::ops::impls. It expands to a static Fn::call() that calls the // Fn::call() implementation of the object shim underneath. @@ -174,7 +174,7 @@ fn main() { let closure = |x: i32, y: i32| { r*(x + (y*2)) }; assert_eq!(test_fn_const_call(&closure), 294); assert_eq!(test_closure(&closure, 100, 1), 306); - let function_object = &closure as &Fn(i32, i32) -> i32; + let function_object = &closure as &dyn Fn(i32, i32) -> i32; assert_eq!(test_fn_object(function_object, 100, 2), 312); assert_eq!(test_fn_impl(&function_object, 100, 3), 318); assert_eq!(test_fn_direct_call(&closure, 100, 4), 324); diff --git a/src/test/run-pass/mir/mir_codegen_critical_edge.rs b/src/test/run-pass/mir/mir_codegen_critical_edge.rs index 03b111e93dd..5c1f1c3b701 100644 --- a/src/test/run-pass/mir/mir_codegen_critical_edge.rs +++ b/src/test/run-pass/mir/mir_codegen_critical_edge.rs @@ -37,7 +37,7 @@ where A: Iterator, B: Iterator } // Make sure we actually codegen a version of the function -pub fn do_stuff(mut f: Foo>, Box>>) { +pub fn do_stuff(mut f: Foo>, Box>>) { let _x = f.next(); } diff --git a/src/test/run-pass/mir/mir_coercions.rs b/src/test/run-pass/mir/mir_coercions.rs index b673345db70..f3dcc6b85fd 100644 --- a/src/test/run-pass/mir/mir_coercions.rs +++ b/src/test/run-pass/mir/mir_coercions.rs @@ -4,12 +4,12 @@ use std::ops::CoerceUnsized; use std::marker::Unsize; -fn identity_coercion(x: &(Fn(u32)->u32 + Send)) -> &Fn(u32)->u32 { +fn identity_coercion(x: &(dyn Fn(u32)->u32 + Send)) -> &dyn Fn(u32)->u32 { x } fn fn_coercions(f: &fn(u32) -> u32) -> (unsafe fn(u32) -> u32, - &(Fn(u32) -> u32+Send)) + &(dyn Fn(u32) -> u32+Send)) { (*f, f) } @@ -35,8 +35,8 @@ fn coerce_triv_ptr_wrapper(p: TrivPtrWrapper<[u8; 3]>) -> TrivPtrWrapper<[u8]> { p } -fn coerce_fat_ptr_wrapper(p: PtrWrapper u32+Send>) - -> PtrWrapper u32> { +fn coerce_fat_ptr_wrapper(p: PtrWrapper u32+Send>) + -> PtrWrapper u32> { p } @@ -65,7 +65,7 @@ fn main() { let z = coerce_fat_ptr_wrapper(PtrWrapper(2,3,(),&square_local)); assert_eq!((z.3)(6), 36); - let z: PtrWrapper u32> = + let z: PtrWrapper u32> = coerce_ptr_wrapper_poly(PtrWrapper(2,3,(),&square_local)); assert_eq!((z.3)(6), 36); } diff --git a/src/test/run-pass/mir/mir_raw_fat_ptr.rs b/src/test/run-pass/mir/mir_raw_fat_ptr.rs index 328c8c502cb..6583852aa9b 100644 --- a/src/test/run-pass/mir/mir_raw_fat_ptr.rs +++ b/src/test/run-pass/mir/mir_raw_fat_ptr.rs @@ -63,7 +63,7 @@ fn compare_au8(a: *const [u8], b: *const [u8]) -> ComparisonResults { } } -fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults { +fn compare_foo<'a>(a: *const (dyn Foo+'a), b: *const (dyn Foo+'a)) -> ComparisonResults { ComparisonResults { lt: a < b, le: a <= b, @@ -74,7 +74,7 @@ fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults } } -fn simple_eq<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> bool { +fn simple_eq<'a>(a: *const (dyn Foo+'a), b: *const (dyn Foo+'a)) -> bool { let result = a == b; result } @@ -128,7 +128,7 @@ fn main() { let u32_ = (4u32, 5u32); // check ordering for ptrs - let buf: &mut [*const Foo] = &mut [ + let buf: &mut [*const dyn Foo] = &mut [ &u8_, &u8_.0, &u32_, &u32_.0, ]; diff --git a/src/test/run-pass/new-box.rs b/src/test/run-pass/new-box.rs index b35c5445a44..5539518c370 100644 --- a/src/test/run-pass/new-box.rs +++ b/src/test/run-pass/new-box.rs @@ -18,13 +18,13 @@ impl Trait for Struct { } } -fn g(x: Box) { +fn g(x: Box) { x.printme(); - let y: &Trait = &*x; + let y: &dyn Trait = &*x; y.printme(); } fn main() { f(box 1234); - g(box Struct as Box); + g(box Struct as Box); } diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index 969868486e6..79c9f7dc011 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -4,7 +4,7 @@ // pretty-expanded FIXME #23616 -fn unique() -> Box { return Box::new(|| ()); } +fn unique() -> Box { return Box::new(|| ()); } pub fn main() { } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index 676b3507c57..104f5be7767 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -4,7 +4,7 @@ // pretty-expanded FIXME #23616 -fn unique() -> Box { Box::new(|| ()) } +fn unique() -> Box { Box::new(|| ()) } pub fn main() { } diff --git a/src/test/run-pass/object-lifetime-default-default-to-static.rs b/src/test/run-pass/object-lifetime-default-default-to-static.rs index cf836c1a7de..cd61dea0378 100644 --- a/src/test/run-pass/object-lifetime-default-default-to-static.rs +++ b/src/test/run-pass/object-lifetime-default-default-to-static.rs @@ -10,23 +10,23 @@ trait Test { } struct SomeStruct { - t: Box, - u: Box, + t: Box, + u: Box, } -fn a(t: Box, mut ss: SomeStruct) { +fn a(t: Box, mut ss: SomeStruct) { ss.t = t; } -fn b(t: Box, mut ss: SomeStruct) { +fn b(t: Box, mut ss: SomeStruct) { ss.t = t; } -fn c(t: Box, mut ss: SomeStruct) { +fn c(t: Box, mut ss: SomeStruct) { ss.u = t; } -fn d(t: Box, mut ss: SomeStruct) { +fn d(t: Box, mut ss: SomeStruct) { ss.u = t; } diff --git a/src/test/run-pass/object-lifetime-default-from-rptr-box.rs b/src/test/run-pass/object-lifetime-default-from-rptr-box.rs index 3f69c927488..9212f2802c0 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr-box.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr-box.rs @@ -10,21 +10,21 @@ trait Test { } struct SomeStruct<'a> { - t: &'a Box, - u: &'a Box, + t: &'a Box, + u: &'a Box, } -fn a<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { +fn a<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { +fn b<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { ss.u = t; } // see also compile-fail/object-lifetime-default-from-rptr-box-error.rs -fn d<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { +fn d<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { ss.u = t; } diff --git a/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs b/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs index dc9e292f0de..061f3a116fc 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs @@ -10,23 +10,23 @@ trait Test { } struct SomeStruct<'a> { - t: &'a mut Test, - u: &'a mut (Test+'a), + t: &'a mut dyn Test, + u: &'a mut (dyn Test+'a), } -fn a<'a>(t: &'a mut Test, mut ss: SomeStruct<'a>) { +fn a<'a>(t: &'a mut dyn Test, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: &'a mut Test, mut ss: SomeStruct<'a>) { +fn b<'a>(t: &'a mut dyn Test, mut ss: SomeStruct<'a>) { ss.u = t; } -fn c<'a>(t: &'a mut (Test+'a), mut ss: SomeStruct<'a>) { +fn c<'a>(t: &'a mut (dyn Test+'a), mut ss: SomeStruct<'a>) { ss.t = t; } -fn d<'a>(t: &'a mut (Test+'a), mut ss: SomeStruct<'a>) { +fn d<'a>(t: &'a mut (dyn Test+'a), mut ss: SomeStruct<'a>) { ss.u = t; } diff --git a/src/test/run-pass/object-lifetime-default-from-rptr.rs b/src/test/run-pass/object-lifetime-default-from-rptr.rs index 061f71b9ae6..cfa4af0d7a5 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr.rs @@ -12,30 +12,30 @@ trait Test { } struct SomeStruct<'a> { - t: &'a Test, - u: &'a (Test+'a), + t: &'a dyn Test, + u: &'a (dyn Test+'a), } -fn a<'a>(t: &'a Test, mut ss: SomeStruct<'a>) { +fn a<'a>(t: &'a dyn Test, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: &'a Test, mut ss: SomeStruct<'a>) { +fn b<'a>(t: &'a dyn Test, mut ss: SomeStruct<'a>) { ss.u = t; } -fn c<'a>(t: &'a (Test+'a), mut ss: SomeStruct<'a>) { +fn c<'a>(t: &'a (dyn Test+'a), mut ss: SomeStruct<'a>) { ss.t = t; } -fn d<'a>(t: &'a (Test+'a), mut ss: SomeStruct<'a>) { +fn d<'a>(t: &'a (dyn Test+'a), mut ss: SomeStruct<'a>) { ss.u = t; } -fn e<'a>(_: &'a (Display+'static)) {} +fn e<'a>(_: &'a (dyn Display+'static)) {} fn main() { // Inside a function body, we can just infer both // lifetimes, to allow &'tmp (Display+'static). - e(&0 as &Display); + e(&0 as &dyn Display); } diff --git a/src/test/run-pass/object-method-numbering.rs b/src/test/run-pass/object-method-numbering.rs index 455af78c7a0..7f24ab2cbb5 100644 --- a/src/test/run-pass/object-method-numbering.rs +++ b/src/test/run-pass/object-method-numbering.rs @@ -21,7 +21,7 @@ impl SomeTrait for i32 { fn main() { let x = 22; - let x1: &SomeTrait = &x; + let x1: &dyn SomeTrait = &x; let y = get_int(x1); assert_eq!(x, y); } diff --git a/src/test/run-pass/objects-coerce-freeze-borrored.rs b/src/test/run-pass/objects-coerce-freeze-borrored.rs index 872b9d3e916..47196f108c0 100644 --- a/src/test/run-pass/objects-coerce-freeze-borrored.rs +++ b/src/test/run-pass/objects-coerce-freeze-borrored.rs @@ -17,7 +17,7 @@ impl Foo for usize { } } -fn do_it_mut(obj: &mut Foo) { +fn do_it_mut(obj: &mut dyn Foo) { let x = obj.bar(); let y = obj.foo(); assert_eq!(x, y); @@ -25,14 +25,14 @@ fn do_it_mut(obj: &mut Foo) { do_it_imm(obj, y); } -fn do_it_imm(obj: &Foo, v: usize) { +fn do_it_imm(obj: &dyn Foo, v: usize) { let y = obj.foo(); assert_eq!(v, y); } pub fn main() { let mut x: usize = 22; - let obj = &mut x as &mut Foo; + let obj = &mut x as &mut dyn Foo; do_it_mut(obj); do_it_imm(obj, 23); do_it_mut(obj); diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs index a96772bfb63..58327237494 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs @@ -20,10 +20,10 @@ impl FooTrait for BarStruct { } pub fn main() { - let foos: Vec> = vec![ - box BarStruct{ x: 0 } as Box, - box BarStruct{ x: 1 } as Box, - box BarStruct{ x: 2 } as Box + let foos: Vec> = vec![ + box BarStruct{ x: 0 } as Box, + box BarStruct{ x: 1 } as Box, + box BarStruct{ x: 2 } as Box ]; for i in 0..foos.len() { diff --git a/src/test/run-pass/objects-owned-object-owned-method.rs b/src/test/run-pass/objects-owned-object-owned-method.rs index 6ca5233b198..69984fbb62f 100644 --- a/src/test/run-pass/objects-owned-object-owned-method.rs +++ b/src/test/run-pass/objects-owned-object-owned-method.rs @@ -19,6 +19,6 @@ impl FooTrait for BarStruct { } pub fn main() { - let foo = box BarStruct{ x: 22 } as Box; + let foo = box BarStruct{ x: 22 } as Box; assert_eq!(22, foo.foo()); } diff --git a/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs b/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs index ff484418c1d..1afab9a1ffb 100644 --- a/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs +++ b/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs @@ -3,7 +3,7 @@ // This is a bit tricky due to rust-call ABI. -fn foo(f: &mut FnMut(isize) -> isize) -> isize { +fn foo(f: &mut dyn FnMut(isize) -> isize) -> isize { f(22) } diff --git a/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs b/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs index 0d0136bc29a..38087bc8710 100644 --- a/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs +++ b/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs @@ -3,7 +3,7 @@ // This is a bit tricky due to rust-call ABI. -fn foo(f: &mut FnMut(isize, isize) -> isize) -> isize { +fn foo(f: &mut dyn FnMut(isize, isize) -> isize) -> isize { f(1, 2) } diff --git a/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs b/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs index bbea6a909c8..9a7bfaa9bf4 100644 --- a/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs +++ b/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs @@ -3,7 +3,7 @@ // This is a bit tricky due to rust-call ABI. -fn foo(f: &mut FnMut() -> isize) -> isize { +fn foo(f: &mut dyn FnMut() -> isize) -> isize { f() } diff --git a/src/test/run-pass/panics/panic-safe.rs b/src/test/run-pass/panics/panic-safe.rs index 3798a4fc5cb..9867cc56406 100644 --- a/src/test/run-pass/panics/panic-safe.rs +++ b/src/test/run-pass/panics/panic-safe.rs @@ -33,7 +33,7 @@ fn main() { assert::>(); trait Trait: UnwindSafe {} - assert::>(); + assert::>(); fn bar() { assert::>(); diff --git a/src/test/run-pass/privacy/privacy-ns.rs b/src/test/run-pass/privacy/privacy-ns.rs index b1b03eae5db..c32e3f17880 100644 --- a/src/test/run-pass/privacy/privacy-ns.rs +++ b/src/test/run-pass/privacy/privacy-ns.rs @@ -28,19 +28,19 @@ fn test_unused1() { fn test_single1() { use foo1::Bar; - let _x: Box; + let _x: Box; } fn test_list1() { use foo1::{Bar,Baz}; - let _x: Box; + let _x: Box; } fn test_glob1() { use foo1::*; - let _x: Box; + let _x: Box; } // private type, public value @@ -93,21 +93,21 @@ fn test_single3() { use foo3::Bar; Bar(); - let _x: Box; + let _x: Box; } fn test_list3() { use foo3::{Bar,Baz}; Bar(); - let _x: Box; + let _x: Box; } fn test_glob3() { use foo3::*; Bar(); - let _x: Box; + let _x: Box; } fn main() { diff --git a/src/test/run-pass/raw-fat-ptr.rs b/src/test/run-pass/raw-fat-ptr.rs index df69db1cc9a..511a35b25a3 100644 --- a/src/test/run-pass/raw-fat-ptr.rs +++ b/src/test/run-pass/raw-fat-ptr.rs @@ -78,7 +78,7 @@ fn main() { let mut u32_ = (4u32, 5u32); // check ordering for ptrs - let buf: &mut [*const Foo] = &mut [ + let buf: &mut [*const dyn Foo] = &mut [ &u8_, &u8_.0, &u32_, &u32_.0, ]; @@ -90,7 +90,7 @@ fn main() { assert_inorder(buf); // check ordering for mut ptrs - let buf: &mut [*mut Foo] = &mut [ + let buf: &mut [*mut dyn Foo] = &mut [ &mut u8_, &mut u8_.0, &mut u32_, &mut u32_.0, ]; diff --git a/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs b/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs index 204f4f8130d..3815498f86f 100644 --- a/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs +++ b/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs @@ -9,7 +9,7 @@ trait Foo { fn dummy(&self) { } } -fn foo<'a>(x: Box) { +fn foo<'a>(x: Box) { } fn bar<'a, T: 'a>() { diff --git a/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs b/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs index 85c9c64c643..4b47ed8c6ae 100644 --- a/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs +++ b/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs @@ -12,8 +12,8 @@ impl<'a> SomeTrait for &'a isize { } } -fn make_object<'a,A:SomeTrait+'a>(v: A) -> Box { - box v as Box +fn make_object<'a,A:SomeTrait+'a>(v: A) -> Box { + box v as Box } fn main() { diff --git a/src/test/run-pass/regions/regions-copy-closure.rs b/src/test/run-pass/regions/regions-copy-closure.rs index 6545ddf72c7..43640079777 100644 --- a/src/test/run-pass/regions/regions-copy-closure.rs +++ b/src/test/run-pass/regions/regions-copy-closure.rs @@ -2,10 +2,10 @@ #![allow(non_camel_case_types)] struct closure_box<'a> { - cl: Box, + cl: Box, } -fn box_it<'a>(x: Box) -> closure_box<'a> { +fn box_it<'a>(x: Box) -> closure_box<'a> { closure_box {cl: x} } diff --git a/src/test/run-pass/regions/regions-debruijn-of-object.rs b/src/test/run-pass/regions/regions-debruijn-of-object.rs index 24c0cf53317..0b5510489fb 100644 --- a/src/test/run-pass/regions/regions-debruijn-of-object.rs +++ b/src/test/run-pass/regions/regions-debruijn-of-object.rs @@ -13,9 +13,9 @@ trait AstConv<'tcx> { fn tcx<'a>(&'a self) -> &'a ctxt<'tcx>; } -fn foo(conv: &AstConv) { } +fn foo(conv: &dyn AstConv) { } -fn bar<'tcx>(conv: &AstConv<'tcx>) { +fn bar<'tcx>(conv: &dyn AstConv<'tcx>) { foo(conv) } diff --git a/src/test/run-pass/regions/regions-early-bound-trait-param.rs b/src/test/run-pass/regions/regions-early-bound-trait-param.rs index c71e47db22d..cc2bde78d85 100644 --- a/src/test/run-pass/regions/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions/regions-early-bound-trait-param.rs @@ -15,14 +15,14 @@ fn poly_invoke<'c, T: Trait<'c>>(x: &'c T) -> (isize, isize) { (l,s) } -fn object_invoke1<'d>(x: &'d Trait<'d>) -> (isize, isize) { +fn object_invoke1<'d>(x: &'d dyn Trait<'d>) -> (isize, isize) { let l = x.long(); let s = x.short(); (l,s) } struct Struct1<'e> { - f: &'e (Trait<'e>+'e) + f: &'e (dyn Trait<'e>+'e) } fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (isize,isize) { @@ -32,10 +32,10 @@ fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (isize,isize) { } struct Struct2<'h, 'i:'h> { - f: &'h (Trait<'i>+'h) + f: &'h (dyn Trait<'i>+'h) } -fn object_invoke2<'j, 'k>(x: &'k Trait<'j>) -> isize { +fn object_invoke2<'j, 'k>(x: &'k dyn Trait<'j>) -> isize { x.short() } @@ -70,10 +70,10 @@ impl<'s> Trait<'s> for (isize,isize) { } } -impl<'t> MakerTrait for Box+'static> { - fn mk() -> Box+'static> { +impl<'t> MakerTrait for Box+'static> { + fn mk() -> Box+'static> { let tup: Box<(isize, isize)> = box (4,5); - tup as Box + tup as Box } } @@ -105,7 +105,7 @@ impl<'t> RefMakerTrait<'t> for List<'t> { pub fn main() { let t = (2,3); - let o = &t as &Trait; + let o = &t as &dyn Trait; let s1 = Struct1 { f: o }; let s2 = Struct2 { f: o }; assert_eq!(poly_invoke(&t), (2,3)); @@ -114,7 +114,7 @@ pub fn main() { assert_eq!(object_invoke2(&t), 3); assert_eq!(field_invoke2(&s2), 3); - let m : Box = make_val(); + let m : Box = make_val(); // assert_eq!(object_invoke1(&*m), (4,5)); // ~~~~~~~~~~~~~~~~~~~ // this call yields a compilation error; see compile-fail/dropck-object-cycle.rs diff --git a/src/test/run-pass/regions/regions-fn-subtyping-2.rs b/src/test/run-pass/regions/regions-fn-subtyping-2.rs index cbd88ebde0d..83949ddba3d 100644 --- a/src/test/run-pass/regions/regions-fn-subtyping-2.rs +++ b/src/test/run-pass/regions/regions-fn-subtyping-2.rs @@ -7,13 +7,13 @@ // that `x` is in. // pretty-expanded FIXME #23616 -fn has_same_region(f: Box FnMut(&'a isize, Box)>) { +fn has_same_region(f: Box FnMut(&'a isize, Box)>) { // `f` should be the type that `wants_same_region` wants, but // right now the compiler complains that it isn't. wants_same_region(f); } -fn wants_same_region(_f: Box FnMut(&'b isize, Box)>) { +fn wants_same_region(_f: Box FnMut(&'b isize, Box)>) { } pub fn main() { diff --git a/src/test/run-pass/regions/regions-fn-subtyping.rs b/src/test/run-pass/regions/regions-fn-subtyping.rs index a1da966659a..9570359c69e 100644 --- a/src/test/run-pass/regions/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions/regions-fn-subtyping.rs @@ -8,21 +8,21 @@ #![allow(unused_variables)] // Should pass region checking. -fn ok(f: Box) { +fn ok(f: Box) { // Here, g is a function that can accept a usize pointer with // lifetime r, and f is a function that can accept a usize pointer // with any lifetime. The assignment g = f should be OK (i.e., // f's type should be a subtype of g's type), because f can be // used in any context that expects g's type. But this currently // fails. - let mut g: Box FnMut(&'r usize)> = Box::new(|x| { }); + let mut g: Box FnMut(&'r usize)> = Box::new(|x| { }); g = f; } // This version is the same as above, except that here, g's type is // inferred. -fn ok_inferred(f: Box) { - let mut g: Box FnMut(&'r usize)> = Box::new(|_| {}); +fn ok_inferred(f: Box) { + let mut g: Box FnMut(&'r usize)> = Box::new(|_| {}); g = f; } diff --git a/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs b/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs index dff36e6d183..6aa5d8217a4 100644 --- a/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs +++ b/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs @@ -8,7 +8,7 @@ // contains region pointers // pretty-expanded FIXME #23616 -struct foo(Box); +struct foo(Box); fn take_foo(x: T) {} diff --git a/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs b/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs index 189f6172029..c8106f32c65 100644 --- a/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs +++ b/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs @@ -19,15 +19,15 @@ pub fn main() { fn explicit() { - fn test(_x: Option>) where F: FnMut(Box FnMut(&'a isize)>) {} - test(Some(box |_f: Box FnMut(&'a isize)>| {})); + fn test(_x: Option>) where F: FnMut(Box FnMut(&'a isize)>) {} + test(Some(box |_f: Box FnMut(&'a isize)>| {})); } // The code below is shorthand for the code above (and more likely // to represent what one encounters in practice). fn implicit() { - fn test(_x: Option>) where F: FnMut(Box< FnMut(& isize)>) {} - test(Some(box |_f: Box< FnMut(& isize)>| {})); + fn test(_x: Option>) where F: FnMut(Box) {} + test(Some(box |_f: Box| {})); } explicit(); diff --git a/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs b/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs index f26ef85ef72..aec05161c1a 100644 --- a/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs +++ b/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs @@ -44,7 +44,7 @@ impl<'a,'tcx> Foo<'a,'tcx> { fn elaborate_bounds( &mut self, - mut mk_cand: Box FnMut(&mut Foo<'b, 'tcx>) -> isize>) + mut mk_cand: Box FnMut(&mut Foo<'b, 'tcx>) -> isize>) -> isize { mk_cand(self) diff --git a/src/test/run-pass/regions/regions-static-closure.rs b/src/test/run-pass/regions/regions-static-closure.rs index 6d00f7501ca..09cd5622032 100644 --- a/src/test/run-pass/regions/regions-static-closure.rs +++ b/src/test/run-pass/regions/regions-static-closure.rs @@ -2,10 +2,10 @@ #![allow(non_camel_case_types)] struct closure_box<'a> { - cl: Box, + cl: Box, } -fn box_it<'a>(x: Box) -> closure_box<'a> { +fn box_it<'a>(x: Box) -> closure_box<'a> { closure_box {cl: x} } diff --git a/src/test/run-pass/regions/regions-trait-object-1.rs b/src/test/run-pass/regions/regions-trait-object-1.rs index 242142588ea..679bf4dd811 100644 --- a/src/test/run-pass/regions/regions-trait-object-1.rs +++ b/src/test/run-pass/regions/regions-trait-object-1.rs @@ -21,10 +21,10 @@ impl<'d> M for P<'d> { fn n(&self) -> u8 { *self.g } } -fn extension<'e>(x: &'e E<'e>) -> Box { +fn extension<'e>(x: &'e E<'e>) -> Box { loop { let p = P { g: x.m() }; - return Box::new(p) as Box; + return Box::new(p) as Box; } } diff --git a/src/test/run-pass/string-box-error.rs b/src/test/run-pass/string-box-error.rs index debbe665a89..944157d0b20 100644 --- a/src/test/run-pass/string-box-error.rs +++ b/src/test/run-pass/string-box-error.rs @@ -4,8 +4,8 @@ use std::error::Error; fn main() { - let _err1: Box = From::from("test".to_string()); - let _err2: Box = From::from("test".to_string()); - let _err3: Box = From::from("test"); - let _err4: Box = From::from("test"); + let _err1: Box = From::from("test".to_string()); + let _err2: Box = From::from("test".to_string()); + let _err3: Box = From::from("test"); + let _err4: Box = From::from("test"); } diff --git a/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs index cb4a67f609d..bf1ba8a643f 100644 --- a/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs @@ -8,13 +8,13 @@ extern crate cci_class_cast; use std::string::ToString; use cci_class_cast::kitty::cat; -fn print_out(thing: Box, expected: String) { +fn print_out(thing: Box, expected: String) { let actual = (*thing).to_string(); println!("{}", actual); assert_eq!(actual.to_string(), expected); } pub fn main() { - let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; + let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; print_out(nyan, "nyan".to_string()); } diff --git a/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs index 5ce6538fcb3..55975cbdb53 100644 --- a/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs +++ b/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs @@ -79,7 +79,7 @@ fn cat(in_x: usize, in_y: isize, in_name: String) -> cat { } -fn annoy_neighbors(critter: &mut noisy) { +fn annoy_neighbors(critter: &mut dyn noisy) { for _i in 0_usize..10 { critter.speak(); } } diff --git a/src/test/run-pass/structs-enums/class-cast-to-trait.rs b/src/test/run-pass/structs-enums/class-cast-to-trait.rs index 7fa60da6e57..1019bb30015 100644 --- a/src/test/run-pass/structs-enums/class-cast-to-trait.rs +++ b/src/test/run-pass/structs-enums/class-cast-to-trait.rs @@ -55,6 +55,6 @@ fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { pub fn main() { let mut nyan = cat(0, 2, "nyan".to_string()); - let mut nyan: &mut noisy = &mut nyan; + let mut nyan: &mut dyn noisy = &mut nyan; nyan.speak(); } diff --git a/src/test/run-pass/structs-enums/class-separate-impl.rs b/src/test/run-pass/structs-enums/class-separate-impl.rs index 2b10a46e8e2..947690b51f4 100644 --- a/src/test/run-pass/structs-enums/class-separate-impl.rs +++ b/src/test/run-pass/structs-enums/class-separate-impl.rs @@ -53,13 +53,13 @@ impl fmt::Display for cat { } } -fn print_out(thing: Box, expected: String) { +fn print_out(thing: Box, expected: String) { let actual = (*thing).to_string(); println!("{}", actual); assert_eq!(actual.to_string(), expected); } pub fn main() { - let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; + let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; print_out(nyan, "nyan".to_string()); } diff --git a/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs b/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs index 5e3b5942a82..87629665bc2 100644 --- a/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs +++ b/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs @@ -22,9 +22,9 @@ fn main() { assert_eq!(size_of::<&mut [isize]>(), size_of::>()); // Traits - Box / &Trait / &mut Trait - assert_eq!(size_of::>(), size_of::>>()); - assert_eq!(size_of::<&Trait>(), size_of::>()); - assert_eq!(size_of::<&mut Trait>(), size_of::>()); + assert_eq!(size_of::>(), size_of::>>()); + assert_eq!(size_of::<&dyn Trait>(), size_of::>()); + assert_eq!(size_of::<&mut dyn Trait>(), size_of::>()); // Pointers - Box assert_eq!(size_of::>(), size_of::>>()); diff --git a/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs b/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs index 0a48725cbe4..e1a865fa503 100644 --- a/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs +++ b/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs @@ -22,37 +22,37 @@ struct Ref2<'a,'b,T:'a+'b+?Sized> { } struct SomeStruct<'a> { - t: Ref<'a,Test>, - u: Ref<'a,Test+'a>, + t: Ref<'a, dyn Test>, + u: Ref<'a, dyn Test+'a>, } -fn a<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) { +fn a<'a>(t: Ref<'a, dyn Test>, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) { +fn b<'a>(t: Ref<'a, dyn Test>, mut ss: SomeStruct<'a>) { ss.u = t; } -fn c<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) { +fn c<'a>(t: Ref<'a, dyn Test+'a>, mut ss: SomeStruct<'a>) { ss.t = t; } -fn d<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) { +fn d<'a>(t: Ref<'a, dyn Test+'a>, mut ss: SomeStruct<'a>) { ss.u = t; } -fn e<'a>(_: Ref<'a, Display+'static>) {} -fn g<'a, 'b>(_: Ref2<'a, 'b, Display+'static>) {} +fn e<'a>(_: Ref<'a, dyn Display+'static>) {} +fn g<'a, 'b>(_: Ref2<'a, 'b, dyn Display+'static>) {} fn main() { // Inside a function body, we can just infer all // lifetimes, to allow Ref<'tmp, Display+'static> // and Ref2<'tmp, 'tmp, Display+'static>. - let x = &0 as &(Display+'static); - let r: Ref = Ref { r: x }; - let r2: Ref2 = Ref2 { a: x, b: x }; + let x = &0 as &(dyn Display+'static); + let r: Ref = Ref { r: x }; + let r2: Ref2 = Ref2 { a: x, b: x }; e(r); g(r2); } diff --git a/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs b/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs index 48ee5a2ed54..1fc52ead48e 100644 --- a/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs +++ b/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs @@ -11,25 +11,25 @@ trait Test { } struct SomeStruct<'a> { - t: &'a MyBox, - u: &'a MyBox, + t: &'a MyBox, + u: &'a MyBox, } struct MyBox { b: Box } -fn a<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { +fn a<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { +fn b<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { ss.u = t; } // see also compile-fail/object-lifetime-default-from-rptr-box-error.rs -fn d<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { +fn d<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { ss.u = t; } diff --git a/src/test/run-pass/traits/auto-traits.rs b/src/test/run-pass/traits/auto-traits.rs index 7702725e640..c495b97b25b 100644 --- a/src/test/run-pass/traits/auto-traits.rs +++ b/src/test/run-pass/traits/auto-traits.rs @@ -27,5 +27,5 @@ fn main() { take_auto_unsafe(AutoBool(true)); /// Auto traits are allowed in trait object bounds. - let _: &(Send + Auto) = &0; + let _: &(dyn Send + Auto) = &0; } diff --git a/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs b/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs index 140dcaf6a27..82760788897 100644 --- a/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs +++ b/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs @@ -11,7 +11,7 @@ impl Foo { fn bar(&self) {} } -impl Trait { +impl dyn Trait { fn baz(_: &Foo) {} } @@ -26,5 +26,5 @@ fn main() { // Should work even if Trait::baz doesn't exist. // N.B: `::bar` would be ambiguous. - ::baz(&Foo); + ::baz(&Foo); } diff --git a/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs b/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs index 1deb17e00da..ed258dbb24c 100644 --- a/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs +++ b/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs @@ -14,7 +14,7 @@ trait Trait { fn foo(&self); } struct Type { a: PhantomData } -fn as_trait(t: &Type) -> &Trait { loop { } } +fn as_trait(t: &Type) -> &dyn Trait { loop { } } fn want+?Sized>(t: &T) { } diff --git a/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs b/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs index f7a58c6f926..23b91f924b5 100644 --- a/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs @@ -12,8 +12,8 @@ impl repeat for Box { } } -fn repeater(v: Box) -> Box+'static> { - box v as Box+'static> // No +fn repeater(v: Box) -> Box+'static> { + box v as Box+'static> // No } pub fn main() { diff --git a/src/test/run-pass/traits/object-one-type-two-traits.rs b/src/test/run-pass/traits/object-one-type-two-traits.rs index 12e4a34a233..b92a2ab7b4b 100644 --- a/src/test/run-pass/traits/object-one-type-two-traits.rs +++ b/src/test/run-pass/traits/object-one-type-two-traits.rs @@ -10,24 +10,24 @@ use std::any::Any; trait Wrap { fn get(&self) -> isize; - fn wrap(self: Box) -> Box; + fn wrap(self: Box) -> Box; } impl Wrap for isize { fn get(&self) -> isize { *self } - fn wrap(self: Box) -> Box { - self as Box + fn wrap(self: Box) -> Box { + self as Box } } -fn is(x: &Any) -> bool { +fn is(x: &dyn Any) -> bool { x.is::() } fn main() { - let x = box 22isize as Box; + let x = box 22isize as Box; println!("x={}", x.get()); let y = x.wrap(); } diff --git a/src/test/run-pass/traits/parameterized-trait-with-bounds.rs b/src/test/run-pass/traits/parameterized-trait-with-bounds.rs index b1339b207eb..832d4f6c89f 100644 --- a/src/test/run-pass/traits/parameterized-trait-with-bounds.rs +++ b/src/test/run-pass/traits/parameterized-trait-with-bounds.rs @@ -12,10 +12,10 @@ mod foo { pub trait D<'a, T> { fn get(self) -> &'a T; } } -fn foo1(_: &(A + Send)) {} -fn foo2(_: Box + Send + Sync>) {} -fn foo3(_: Box + 'static>) {} -fn foo4<'a, T>(_: Box + 'static + Send>) {} -fn foo5<'a, T>(_: Box + 'static + Send>) {} +fn foo1(_: &(dyn A + Send)) {} +fn foo2(_: Box + Send + Sync>) {} +fn foo3(_: Box + 'static>) {} +fn foo4<'a, T>(_: Box + 'static + Send>) {} +fn foo5<'a, T>(_: Box + 'static + Send>) {} pub fn main() {} diff --git a/src/test/run-pass/traits/trait-bounds-basic.rs b/src/test/run-pass/traits/trait-bounds-basic.rs index af6392e5658..8c8a7eb7d9d 100644 --- a/src/test/run-pass/traits/trait-bounds-basic.rs +++ b/src/test/run-pass/traits/trait-bounds-basic.rs @@ -7,18 +7,18 @@ trait Foo { } -fn b(_x: Box) { +fn b(_x: Box) { } -fn c(x: Box) { +fn c(x: Box) { e(x); } -fn d(x: Box) { +fn d(x: Box) { e(x); } -fn e(x: Box) { +fn e(x: Box) { e(x); } diff --git a/src/test/run-pass/traits/trait-bounds-in-arc.rs b/src/test/run-pass/traits/trait-bounds-in-arc.rs index 82bdcdcf7c5..a45d834297e 100644 --- a/src/test/run-pass/traits/trait-bounds-in-arc.rs +++ b/src/test/run-pass/traits/trait-bounds-in-arc.rs @@ -12,7 +12,7 @@ use std::sync::mpsc::channel; use std::thread; trait Pet { - fn name(&self, blk: Box); + fn name(&self, blk: Box); fn num_legs(&self) -> usize; fn of_good_pedigree(&self) -> bool; } @@ -34,19 +34,19 @@ struct Goldfyshe { } impl Pet for Catte { - fn name(&self, mut blk: Box) { blk(&self.name) } + fn name(&self, mut blk: Box) { blk(&self.name) } fn num_legs(&self) -> usize { 4 } fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 } } impl Pet for Dogge { - fn name(&self, mut blk: Box) { blk(&self.name) } + fn name(&self, mut blk: Box) { blk(&self.name) } fn num_legs(&self) -> usize { 4 } fn of_good_pedigree(&self) -> bool { self.bark_decibels < 70 || self.tricks_known > 20 } } impl Pet for Goldfyshe { - fn name(&self, mut blk: Box) { blk(&self.name) } + fn name(&self, mut blk: Box) { blk(&self.name) } fn num_legs(&self) -> usize { 0 } fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 } } @@ -67,10 +67,10 @@ pub fn main() { swim_speed: 998, name: "alec_guinness".to_string(), }; - let arc = Arc::new(vec![box catte as Box, - box dogge1 as Box, - box fishe as Box, - box dogge2 as Box]); + let arc = Arc::new(vec![box catte as Box, + box dogge1 as Box, + box fishe as Box, + box dogge2 as Box]); let (tx1, rx1) = channel(); let arc1 = arc.clone(); let t1 = thread::spawn(move|| { check_legs(arc1); tx1.send(()); }); @@ -88,21 +88,21 @@ pub fn main() { t3.join(); } -fn check_legs(arc: Arc>>) { +fn check_legs(arc: Arc>>) { let mut legs = 0; for pet in arc.iter() { legs += pet.num_legs(); } assert!(legs == 12); } -fn check_names(arc: Arc>>) { +fn check_names(arc: Arc>>) { for pet in arc.iter() { pet.name(Box::new(|name| { assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8); })) } } -fn check_pedigree(arc: Arc>>) { +fn check_pedigree(arc: Arc>>) { for pet in arc.iter() { assert!(pet.of_good_pedigree()); } diff --git a/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs b/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs index 18b25b852d1..4dc4fecc91f 100644 --- a/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs +++ b/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs @@ -7,11 +7,11 @@ trait U {} trait T { fn get(self) -> X; } trait S2 { - fn m(x: Box+'static>) {} + fn m(x: Box+'static>) {} } struct St { - f: Box+'static>, + f: Box+'static>, } impl St { diff --git a/src/test/run-pass/traits/trait-coercion-generic.rs b/src/test/run-pass/traits/trait-coercion-generic.rs index 5d1b442afcc..bf4dda49519 100644 --- a/src/test/run-pass/traits/trait-coercion-generic.rs +++ b/src/test/run-pass/traits/trait-coercion-generic.rs @@ -18,8 +18,8 @@ impl Trait<&'static str> for Struct { pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: Box> = Box::new(a); + let b: Box> = Box::new(a); b.f("Mary"); - let c: &Trait<&'static str> = &a; + let c: &dyn Trait<&'static str> = &a; c.f("Joe"); } diff --git a/src/test/run-pass/traits/trait-coercion.rs b/src/test/run-pass/traits/trait-coercion.rs index 1a40b81c89f..cba33af1f1a 100644 --- a/src/test/run-pass/traits/trait-coercion.rs +++ b/src/test/run-pass/traits/trait-coercion.rs @@ -22,13 +22,13 @@ impl Trait for Struct { } } -fn foo(mut a: Box) {} +fn foo(mut a: Box) {} pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: Box = Box::new(a); + let b: Box = Box::new(a); b.f(); - let c: &Trait = &a; + let c: &dyn Trait = &a; c.f(); let out = io::stdout(); diff --git a/src/test/run-pass/traits/trait-impl-2.rs b/src/test/run-pass/traits/trait-impl-2.rs index b28d74a7b35..804ffec12c2 100644 --- a/src/test/run-pass/traits/trait-impl-2.rs +++ b/src/test/run-pass/traits/trait-impl-2.rs @@ -11,7 +11,7 @@ pub mod Foo { } mod Bar { - impl<'a> ::Foo::Trait+'a { + impl<'a> dyn (::Foo::Trait) + 'a { fn bar(&self) { self.foo() } } } diff --git a/src/test/run-pass/traits/trait-impl.rs b/src/test/run-pass/traits/trait-impl.rs index 6b22ac08bb8..14796ce19c8 100644 --- a/src/test/run-pass/traits/trait-impl.rs +++ b/src/test/run-pass/traits/trait-impl.rs @@ -12,7 +12,7 @@ trait T { fn t(&self) {} } -impl<'a> T+'a { +impl<'a> dyn T+'a { fn foo(&self) { unsafe { COUNT *= 2; } } @@ -27,7 +27,7 @@ struct Foo; impl<'a> Bar<'a> for Foo {} fn main() { - let x: &T = &42; + let x: &dyn T = &42; x.foo(); T::foo(x); @@ -36,6 +36,6 @@ fn main() { unsafe { assert_eq!(COUNT, 12); } // Cross-crait case - let x: &Bar = &Foo; + let x: &dyn Bar = &Foo; x.bar(); } diff --git a/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs b/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs index c0b5db63bd4..25159c1adb6 100644 --- a/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs +++ b/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs @@ -26,8 +26,8 @@ impl Bar for A { pub fn main() { let a = &A { x: 3 }; - let afoo = a as &Foo; - let abar = a as &Bar; + let afoo = a as &dyn Foo; + let abar = a as &dyn Bar; assert_eq!(afoo.f(), 10); assert_eq!(abar.g(), 20); } diff --git a/src/test/run-pass/traits/trait-inheritance-cast.rs b/src/test/run-pass/traits/trait-inheritance-cast.rs index 38e5c79e9e0..9070b9d1f56 100644 --- a/src/test/run-pass/traits/trait-inheritance-cast.rs +++ b/src/test/run-pass/traits/trait-inheritance-cast.rs @@ -25,8 +25,8 @@ impl Bar for A { pub fn main() { let a = &A { x: 3 }; - let afoo = a as &Foo; - let abar = a as &Bar; + let afoo = a as &dyn Foo; + let abar = a as &dyn Bar; assert_eq!(afoo.f(), 10); assert_eq!(abar.g(), 20); assert_eq!(abar.f(), 10); diff --git a/src/test/run-pass/traits/trait-object-exclusion.rs b/src/test/run-pass/traits/trait-object-exclusion.rs index 248804d144a..0b8b0e2f5ef 100644 --- a/src/test/run-pass/traits/trait-object-exclusion.rs +++ b/src/test/run-pass/traits/trait-object-exclusion.rs @@ -4,7 +4,7 @@ trait Future: 'static { // Future::forget in vtables, otherwise there's an infinite type // recursion through as Future>::forget. fn forget(self) where Self: Sized { - Box::new(Map(self)) as Box; + Box::new(Map(self)) as Box; } } diff --git a/src/test/run-pass/traits/trait-object-generics.rs b/src/test/run-pass/traits/trait-object-generics.rs index 168bffa0e48..c18754302b7 100644 --- a/src/test/run-pass/traits/trait-object-generics.rs +++ b/src/test/run-pass/traits/trait-object-generics.rs @@ -16,7 +16,7 @@ pub struct Impl { * task failed at 'index out of bounds: the len is 1 but the index is 1', * src/librustc/middle/subst.rs:58 */ - t: Box+'static> + t: Box+'static> } impl Impl { @@ -38,6 +38,6 @@ impl Trait for () { } pub fn main() { - let a = box () as Box>; + let a = box () as Box>; assert_eq!(a.method(Type::Constant((1, 2))), 0); } diff --git a/src/test/run-pass/traits/trait-object-lifetime-first.rs b/src/test/run-pass/traits/trait-object-lifetime-first.rs index e95a652057d..33757cb7c0a 100644 --- a/src/test/run-pass/traits/trait-object-lifetime-first.rs +++ b/src/test/run-pass/traits/trait-object-lifetime-first.rs @@ -4,8 +4,8 @@ use std::fmt::Display; static BYTE: u8 = 33; fn main() { - let x: &('static + Display) = &BYTE; - let y: Box<'static + Display> = Box::new(BYTE); + let x: &(dyn 'static + Display) = &BYTE; + let y: Box = Box::new(BYTE); let xstr = format!("{}", x); let ystr = format!("{}", y); assert_eq!(xstr, "33"); diff --git a/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs b/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs index 9060380db17..05aab5e3b08 100644 --- a/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs +++ b/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs @@ -20,10 +20,10 @@ impl<'d> M for P<'d> { fn n(&self) -> u8 { *self.g } } -fn extension<'e>(x: &'e E<'e>) -> Box { +fn extension<'e>(x: &'e E<'e>) -> Box { loop { let p = P { g: x.m() }; - return Box::new(p) as Box; + return Box::new(p) as Box; } } diff --git a/src/test/run-pass/traits/trait-region-pointer-simple.rs b/src/test/run-pass/traits/trait-region-pointer-simple.rs index 6584182d38a..0456ca93115 100644 --- a/src/test/run-pass/traits/trait-region-pointer-simple.rs +++ b/src/test/run-pass/traits/trait-region-pointer-simple.rs @@ -16,6 +16,6 @@ impl Foo for A { pub fn main() { let a = A { x: 3 }; - let b = (&a) as &Foo; + let b = (&a) as &dyn Foo; assert_eq!(b.f(), 3); } diff --git a/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs b/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs index c9745e06d8f..e490967b690 100644 --- a/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs +++ b/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs @@ -14,5 +14,5 @@ impl Foo for T { } fn want_foo() { } fn main() { - want_foo::(); + want_foo::(); } diff --git a/src/test/run-pass/traits/traits-issue-26339.rs b/src/test/run-pass/traits/traits-issue-26339.rs index 0f831be2485..bedd87cc4cc 100644 --- a/src/test/run-pass/traits/traits-issue-26339.rs +++ b/src/test/run-pass/traits/traits-issue-26339.rs @@ -25,7 +25,7 @@ impl PartialEq for Aimpl { impl A for Aimpl { } fn main() { - let a = &Aimpl as &A; + let a = &Aimpl as &dyn A; assert!(*a == Foo); } diff --git a/src/test/run-pass/traits/traits-repeated-supertrait.rs b/src/test/run-pass/traits/traits-repeated-supertrait.rs index c8318bdf154..391d19c4385 100644 --- a/src/test/run-pass/traits/traits-repeated-supertrait.rs +++ b/src/test/run-pass/traits/traits-repeated-supertrait.rs @@ -22,7 +22,7 @@ impl CompareTo for i64 { impl CompareToInts for i64 { } -fn with_obj(c: &CompareToInts) -> bool { +fn with_obj(c: &dyn CompareToInts) -> bool { c.same_as(22_i64) && c.same_as(22_u64) } diff --git a/src/test/run-pass/traits/ufcs-trait-object.rs b/src/test/run-pass/traits/ufcs-trait-object.rs index abe164a5720..700488c22d6 100644 --- a/src/test/run-pass/traits/ufcs-trait-object.rs +++ b/src/test/run-pass/traits/ufcs-trait-object.rs @@ -12,6 +12,6 @@ impl Foo for i32 { } fn main() { - let a: &Foo = &22; + let a: &dyn Foo = &22; assert_eq!(Foo::test(a), 22); } diff --git a/src/test/run-pass/trivial_casts.rs b/src/test/run-pass/trivial_casts.rs index bc56d0158d4..f06b0708290 100644 --- a/src/test/run-pass/trivial_casts.rs +++ b/src/test/run-pass/trivial_casts.rs @@ -36,21 +36,21 @@ pub fn main() { // unsize trait let x: &Bar = &Bar; - let _ = x as &Foo; - let _ = x as *const Foo; + let _ = x as &dyn Foo; + let _ = x as *const dyn Foo; let x: &mut Bar = &mut Bar; - let _ = x as &mut Foo; - let _ = x as *mut Foo; + let _ = x as &mut dyn Foo; + let _ = x as *mut dyn Foo; let x: Box = Box::new(Bar); - let _ = x as Box; + let _ = x as Box; // functions fn baz(_x: i32) {} - let _ = &baz as &Fn(i32); + let _ = &baz as &dyn Fn(i32); let x = |_x: i32| {}; - let _ = &x as &Fn(i32); + let _ = &x as &dyn Fn(i32); } // subtyping diff --git a/src/test/run-pass/type-id-higher-rank-2.rs b/src/test/run-pass/type-id-higher-rank-2.rs index d9280cf97f9..469bc8ed7e1 100644 --- a/src/test/run-pass/type-id-higher-rank-2.rs +++ b/src/test/run-pass/type-id-higher-rank-2.rs @@ -7,7 +7,7 @@ struct Foo<'a>(&'a str); fn good(s: &String) -> Foo { Foo(s) } fn bad1(s: String) -> Option<&'static str> { - let a: Box = Box::new(good as fn(&String) -> Foo); + let a: Box = Box::new(good as fn(&String) -> Foo); a.downcast_ref:: Foo<'static>>().map(|f| f(&s).0) } @@ -20,8 +20,8 @@ impl<'a> AsStr<'a, 'a> for String { } fn bad2(s: String) -> Option<&'static str> { - let a: Box = Box::new(Box::new(s) as Box AsStr<'a, 'a>>); - a.downcast_ref:: AsStr<'a, 'static>>>().map(|x| x.get()) + let a: Box = Box::new(Box::new(s) as Box AsStr<'a, 'a>>); + a.downcast_ref:: AsStr<'a, 'static>>>().map(|x| x.get()) } fn main() { diff --git a/src/test/run-pass/type-id-higher-rank.rs b/src/test/run-pass/type-id-higher-rank.rs index 55d70e31b16..b98dff0d72b 100644 --- a/src/test/run-pass/type-id-higher-rank.rs +++ b/src/test/run-pass/type-id-higher-rank.rs @@ -26,9 +26,9 @@ fn main() { assert!(e != f); // Make sure lifetime parameters of items are not ignored. - let g = TypeId::of:: fn(&'a Trait<'a>) -> Struct<'a>>(); - let h = TypeId::of:: fn(&'a Trait<'a>) -> Struct<'static>>(); - let i = TypeId::of:: fn(&'a Trait<'b>) -> Struct<'b>>(); + let g = TypeId::of:: fn(&'a dyn Trait<'a>) -> Struct<'a>>(); + let h = TypeId::of:: fn(&'a dyn Trait<'a>) -> Struct<'static>>(); + let i = TypeId::of:: fn(&'a dyn Trait<'b>) -> Struct<'b>>(); assert!(g != h); assert!(g != i); assert!(h != i); @@ -40,10 +40,10 @@ fn main() { } // Boxed unboxed closures { - let a = TypeId::of::>(); - let b = TypeId::of:: Fn(&'static isize, &'a isize)>>(); - let c = TypeId::of:: Fn(&'a isize, &'b isize)>>(); - let d = TypeId::of:: Fn(&'b isize, &'a isize)>>(); + let a = TypeId::of::>(); + let b = TypeId::of:: Fn(&'static isize, &'a isize)>>(); + let c = TypeId::of:: Fn(&'a isize, &'b isize)>>(); + let d = TypeId::of:: Fn(&'b isize, &'a isize)>>(); assert!(a != b); assert!(a != c); assert!(a != d); @@ -52,8 +52,8 @@ fn main() { assert_eq!(c, d); // Make sure De Bruijn indices are handled correctly - let e = TypeId::of:: Fn(Box &'a isize>)>>(); - let f = TypeId::of:: Fn(&'a isize) -> &'a isize>)>>(); + let e = TypeId::of:: Fn(Box &'a isize>)>>(); + let f = TypeId::of:: Fn(&'a isize) -> &'a isize>)>>(); assert!(e != f); } // Raw unboxed closures diff --git a/src/test/run-pass/type-infer-generalize-ty-var.rs b/src/test/run-pass/type-infer-generalize-ty-var.rs index 244a72c80fa..6298156452e 100644 --- a/src/test/run-pass/type-infer-generalize-ty-var.rs +++ b/src/test/run-pass/type-infer-generalize-ty-var.rs @@ -23,8 +23,8 @@ trait Get { fn get(&self) -> &T; } -impl Get for Wrap { - fn get(&self) -> &(MyShow + 'static) { +impl Get for Wrap { + fn get(&self) -> &(dyn MyShow + 'static) { static x: usize = 42; &x } @@ -38,9 +38,9 @@ impl Get for Wrap { } trait MyShow { fn dummy(&self) { } } -impl<'a> MyShow for &'a (MyShow + 'a) { } +impl<'a> MyShow for &'a (dyn MyShow + 'a) { } impl MyShow for usize { } -fn constrain<'a>(rc: RefCell<&'a (MyShow + 'a)>) { } +fn constrain<'a>(rc: RefCell<&'a (dyn MyShow + 'a)>) { } fn main() { let mut collection: Wrap<_> = WrapNone; diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs index 08a9796ea29..a1001673506 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs @@ -8,7 +8,7 @@ fn a i32>(mut f: F) -> i32 { f() } -fn b(f: &mut FnMut() -> i32) -> i32 { +fn b(f: &mut dyn FnMut() -> i32) -> i32 { a(f) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs index 76ad40b8f3d..ca1d31ca544 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs @@ -8,7 +8,7 @@ fn a i32>(f: F) -> i32 { f() } -fn b(f: &Fn() -> i32) -> i32 { +fn b(f: &dyn Fn() -> i32) -> i32 { a(f) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs index 6d55fe997b0..b2596e49aa7 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs @@ -3,9 +3,9 @@ use std::ops::FnMut; - fn make_adder(x: i32) -> Boxi32+'static> { + fn make_adder(x: i32) -> Boxi32+'static> { (box move |y: i32| -> i32 { x + y }) as - Boxi32+'static> + Boxi32+'static> } pub fn main() { diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs index 22fc148c352..d47ceea0f4f 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs @@ -3,7 +3,7 @@ use std::ops::FnMut; -fn make_adder(x: isize) -> Boxisize + 'static> { +fn make_adder(x: isize) -> Boxisize + 'static> { Box::new(move |y| { x + y }) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs index 91311fba2e8..f77733d106d 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs @@ -1,7 +1,7 @@ // run-pass use std::ops::FnMut; -fn make_adder(x: isize) -> Boxisize + 'static> { +fn make_adder(x: isize) -> Boxisize + 'static> { Box::new(move |y| { x + y }) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs index 0fd23a2d796..3ee1aeb109b 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs @@ -7,7 +7,7 @@ fn call_itisize>(f: &F, x: isize) -> isize { (*f)(&x) } -fn call_it_boxed(f: &Fn(&isize) -> isize, x: isize) -> isize { +fn call_it_boxed(f: &dyn Fn(&isize) -> isize, x: isize) -> isize { f(&x) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs index 4f23f85b649..d2eaee30410 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs @@ -12,7 +12,7 @@ impl ToPrimitive for isize {} impl ToPrimitive for i32 {} impl ToPrimitive for usize {} -fn doit(val: T, f: &Fn(T)) { f(val) } +fn doit(val: T, f: &dyn Fn(T)) { f(val) } pub fn main() { doit(0, &|x /*: isize*/ | { x.to_int(); }); diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs index 72d658f393b..86834f49407 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs @@ -20,23 +20,23 @@ impl YCombinator { } } -impl R, A) -> R> Fn<(A,)> for YCombinator { +impl R, A) -> R> Fn<(A,)> for YCombinator { extern "rust-call" fn call(&self, (arg,): (A,)) -> R { (self.func)(self, arg) } } -impl R, A) -> R> FnMut<(A,)> for YCombinator { +impl R, A) -> R> FnMut<(A,)> for YCombinator { extern "rust-call" fn call_mut(&mut self, args: (A,)) -> R { self.call(args) } } -impl R, A) -> R> FnOnce<(A,)> for YCombinator { +impl R, A) -> R> FnOnce<(A,)> for YCombinator { type Output = R; extern "rust-call" fn call_once(self, args: (A,)) -> R { self.call(args) } } fn main() { - let factorial = |recur: &Fn(u32) -> u32, arg: u32| -> u32 { + let factorial = |recur: &dyn Fn(u32) -> u32, arg: u32| -> u32 { if arg == 0 {1} else {arg * recur(arg-1)} }; let factorial: YCombinator<_,u32,u32> = YCombinator::new(factorial); diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs index 5c7aafdc573..df60b42ab12 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs @@ -19,7 +19,7 @@ fn call_iti32>(mut f: F, x: i32) -> i32 { f(x) + 3 } -fn call_box(f: &mut FnMut(i32) -> i32, x: i32) -> i32 { +fn call_box(f: &mut dyn FnMut(i32) -> i32, x: i32) -> i32 { f(x) + 3 } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs index 092224b7934..2df360d4a30 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs @@ -3,7 +3,7 @@ // monomorphize correctly (issue #16791) fn main(){ - fn bar<'a, T:Clone+'a> (t: T) -> BoxT + 'a> { + fn bar<'a, T:Clone+'a> (t: T) -> BoxT + 'a> { Box::new(move || t.clone()) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs index 7e53c4d9eb6..89a273b7a43 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs @@ -4,10 +4,10 @@ // pretty-expanded FIXME #23616 fn main() { - let task: Box isize> = Box::new(|x| x); + let task: Box isize> = Box::new(|x| x); task(0); - let mut task: Box isize> = Box::new(|x| x); + let mut task: Box isize> = Box::new(|x| x); task(0); call(|x| x, 22); diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs index 45ab5df94b2..1ca25517c3c 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs @@ -19,7 +19,7 @@ impl Getter for Identity { } fn main() { - let x: &Getter<(i32,), (i32,)> = &Identity; + let x: &dyn Getter<(i32,), (i32,)> = &Identity; let (y,) = x.get((22,)); assert_eq!(y, 22); } diff --git a/src/test/run-pass/unique/unique-object-move.rs b/src/test/run-pass/unique/unique-object-move.rs index 4bd3764fa15..84e8cdb32b8 100644 --- a/src/test/run-pass/unique/unique-object-move.rs +++ b/src/test/run-pass/unique/unique-object-move.rs @@ -15,6 +15,6 @@ pub struct UvEventLoop { impl EventLoop for UvEventLoop { } pub fn main() { - let loop_: Box = box UvEventLoop { uvio: 0 } as Box; + let loop_: Box = box UvEventLoop { uvio: 0 } as Box; let _loop2_ = loop_; } diff --git a/src/test/run-pass/unsized2.rs b/src/test/run-pass/unsized2.rs index c3eae299b86..c9a8b2e7c66 100644 --- a/src/test/run-pass/unsized2.rs +++ b/src/test/run-pass/unsized2.rs @@ -60,26 +60,26 @@ fn f7(x: &X) { trait T4 { fn dummy(&self) { } - fn m1(&self, x: &T4, y: X); - fn m2(&self, x: &T5, y: X); + fn m1(&self, x: &dyn T4, y: X); + fn m2(&self, x: &dyn T5, y: X); } trait T5 { fn dummy(&self) { } // not an error (for now) - fn m1(&self, x: &T4); - fn m2(&self, x: &T5); + fn m1(&self, x: &dyn T4); + fn m2(&self, x: &dyn T5); } trait T6 { fn dummy(&self) { } - fn m1(&self, x: &T4); - fn m2(&self, x: &T5); + fn m1(&self, x: &dyn T4); + fn m2(&self, x: &dyn T5); } trait T7 { fn dummy(&self) { } // not an error (for now) - fn m1(&self, x: &T4); - fn m2(&self, x: &T5); + fn m1(&self, x: &dyn T4); + fn m2(&self, x: &dyn T5); } // The last field in a struct may be unsized diff --git a/src/test/run-pass/wf-bound-region-in-object-type.rs b/src/test/run-pass/wf-bound-region-in-object-type.rs index d81059ca6a8..6814e2baab5 100644 --- a/src/test/run-pass/wf-bound-region-in-object-type.rs +++ b/src/test/run-pass/wf-bound-region-in-object-type.rs @@ -12,7 +12,7 @@ pub struct Context<'tcx> { pub type Cmd<'a> = &'a isize; pub type DecodeInlinedItem<'a> = - Box FnMut(Cmd, &Context<'tcx>) -> Result<&'tcx isize, ()> + 'a>; + Box FnMut(Cmd, &Context<'tcx>) -> Result<&'tcx isize, ()> + 'a>; fn foo(d: DecodeInlinedItem) { } From fd347a8735b94d2320c0caff4c860d3501d53b31 Mon Sep 17 00:00:00 2001 From: memoryruins Date: Tue, 28 May 2019 14:47:46 -0400 Subject: [PATCH 53/65] Update the rest of the test suites to use dyn --- src/test/compile-fail/issue-23595-1.rs | 2 +- src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/compile-fail/issue-23595-1.rs b/src/test/compile-fail/issue-23595-1.rs index b8a0c4846ab..2912c4ead7a 100644 --- a/src/test/compile-fail/issue-23595-1.rs +++ b/src/test/compile-fail/issue-23595-1.rs @@ -5,7 +5,7 @@ use std::ops::{Index}; trait Hierarchy { type Value; type ChildKey; - type Children = Index; + type Children = dyn Index; //~^ ERROR: the value of the associated types `Value` (from the trait `Hierarchy`), `ChildKey` fn data(&self) -> Option<(Self::Value, Self::Children)>; diff --git a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs index 659de9cf6d5..2e2a77b92ca 100644 --- a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs @@ -62,7 +62,7 @@ fn make_x() -> P { /// Iterate over exprs of depth up to `depth`. The goal is to explore all "interesting" /// combinations of expression nesting. For example, we explore combinations using `if`, but not /// `while` or `match`, since those should print and parse in much the same way as `if`. -fn iter_exprs(depth: usize, f: &mut FnMut(P)) { +fn iter_exprs(depth: usize, f: &mut dyn FnMut(P)) { if depth == 0 { f(make_x()); return; From 83660b62734c4f966c536b60864bb51fac696f6c Mon Sep 17 00:00:00 2001 From: memoryruins Date: Tue, 28 May 2019 14:48:04 -0400 Subject: [PATCH 54/65] Update libstd doctests to use dyn --- src/libstd/error.rs | 18 +++++++++--------- src/libstd/fs.rs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libstd/error.rs b/src/libstd/error.rs index aeb822fa99e..c8978a94fcd 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -94,7 +94,7 @@ pub trait Error: Debug + Display { /// "I'm the superhero of errors" /// } /// - /// fn cause(&self) -> Option<&Error> { + /// fn cause(&self) -> Option<&dyn Error> { /// Some(&self.side) /// } /// } @@ -244,7 +244,7 @@ impl<'a, E: Error + 'a> From for Box { /// /// let an_error = AnError; /// assert!(0 == mem::size_of_val(&an_error)); - /// let a_boxed_error = Box::::from(an_error); + /// let a_boxed_error = Box::::from(an_error); /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` fn from(err: E) -> Box { @@ -287,7 +287,7 @@ impl<'a, E: Error + Send + Sync + 'a> From for Box::from(an_error); + /// let a_boxed_error = Box::::from(an_error); /// assert!( /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` @@ -309,7 +309,7 @@ impl From for Box { /// use std::mem; /// /// let a_string_error = "a string error".to_string(); - /// let a_boxed_error = Box::::from(a_string_error); + /// let a_boxed_error = Box::::from(a_string_error); /// assert!( /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` @@ -344,7 +344,7 @@ impl From for Box { /// use std::mem; /// /// let a_string_error = "a string error".to_string(); - /// let a_boxed_error = Box::::from(a_string_error); + /// let a_boxed_error = Box::::from(a_string_error); /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` fn from(str_err: String) -> Box { @@ -367,7 +367,7 @@ impl<'a> From<&str> for Box { /// use std::mem; /// /// let a_str_error = "a str error"; - /// let a_boxed_error = Box::::from(a_str_error); + /// let a_boxed_error = Box::::from(a_str_error); /// assert!( /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` @@ -389,7 +389,7 @@ impl From<&str> for Box { /// use std::mem; /// /// let a_str_error = "a str error"; - /// let a_boxed_error = Box::::from(a_str_error); + /// let a_boxed_error = Box::::from(a_str_error); /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` fn from(err: &str) -> Box { @@ -412,7 +412,7 @@ impl<'a, 'b> From> for Box { /// use std::borrow::Cow; /// /// let a_cow_str_error = Cow::from("a str error"); - /// let a_boxed_error = Box::::from(a_cow_str_error); + /// let a_boxed_error = Box::::from(a_cow_str_error); /// assert!( /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` @@ -436,7 +436,7 @@ impl<'a> From> for Box { /// use std::borrow::Cow; /// /// let a_cow_str_error = Cow::from("a str error"); - /// let a_boxed_error = Box::::from(a_cow_str_error); + /// let a_boxed_error = Box::::from(a_cow_str_error); /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` fn from(err: Cow<'a, str>) -> Box { diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 616b5eb836f..d41b3a3a123 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1976,7 +1976,7 @@ pub fn remove_dir_all>(path: P) -> io::Result<()> { /// use std::path::Path; /// /// // one possible implementation of walking a directory only visiting files -/// fn visit_dirs(dir: &Path, cb: &Fn(&DirEntry)) -> io::Result<()> { +/// fn visit_dirs(dir: &Path, cb: &dyn Fn(&DirEntry)) -> io::Result<()> { /// if dir.is_dir() { /// for entry in fs::read_dir(dir)? { /// let entry = entry?; From 41aaf7bc468759b4775b28fc039ff07c538d4ccb Mon Sep 17 00:00:00 2001 From: David Wood Date: Tue, 14 May 2019 21:34:43 +0100 Subject: [PATCH 55/65] Fix ICE with struct ctors and const generics. This commit fixes a ICE where struct constructors were resulting in an ICE with const generics. Previously, a `match` in `type_of` did not have an arm for the `DefKind::Ctor` resolutions and therefore would assume that the type did not have generics. --- src/librustc/hir/mod.rs | 7 ++ src/librustc_typeck/collect.rs | 98 +++++++++---------- .../cannot-infer-type-for-const-param.rs | 5 +- .../cannot-infer-type-for-const-param.stderr | 21 +--- .../issue-60818-struct-constructors.rs | 10 ++ .../issue-60818-struct-constructors.stderr | 6 ++ 6 files changed, 74 insertions(+), 73 deletions(-) create mode 100644 src/test/ui/const-generics/issue-60818-struct-constructors.rs create mode 100644 src/test/ui/const-generics/issue-60818-struct-constructors.stderr diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 1a6f5d3733e..f03a8ddc908 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -425,6 +425,13 @@ impl GenericArg { GenericArg::Const(c) => c.value.hir_id, } } + + pub fn is_const(&self) -> bool { + match self { + GenericArg::Const(_) => true, + _ => false, + } + } } #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 00990a5c5b5..3806fd0998b 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -27,7 +27,7 @@ use rustc::ty::subst::{Subst, InternalSubsts}; use rustc::ty::util::Discr; use rustc::ty::util::IntTypeExt; use rustc::ty::subst::UnpackedKind; -use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt}; +use rustc::ty::{self, AdtKind, DefIdTree, ToPolyTraitRef, Ty, TyCtxt}; use rustc::ty::{ReprOptions, ToPredicate}; use rustc::util::captures::Captures; use rustc::util::nodemap::FxHashMap; @@ -1349,65 +1349,61 @@ pub fn checked_type_of<'a, 'tcx>( match path { QPath::Resolved(_, ref path) => { - let mut arg_index = 0; - let mut found_const = false; - for seg in &path.segments { - if let Some(generic_args) = &seg.args { - let args = &generic_args.args; - for arg in args { - if let GenericArg::Const(ct) = arg { - if ct.value.hir_id == hir_id { - found_const = true; - break; - } - arg_index += 1; - } - } - } - } - // Sanity check to make sure everything is as expected. - if !found_const { - if !fail { - return None; - } - bug!("no arg matching AnonConst in path") - } - match path.res { - // We've encountered an `AnonConst` in some path, so we need to - // figure out which generic parameter it corresponds to and return - // the relevant type. - Res::Def(DefKind::Struct, def_id) - | Res::Def(DefKind::Union, def_id) - | Res::Def(DefKind::Enum, def_id) - | Res::Def(DefKind::Fn, def_id) => { - let generics = tcx.generics_of(def_id); - let mut param_index = 0; - for param in &generics.params { - if let ty::GenericParamDefKind::Const = param.kind { - if param_index == arg_index { - return Some(tcx.type_of(param.def_id)); - } - param_index += 1; - } - } - // This is no generic parameter associated with the arg. This is - // probably from an extra arg where one is not needed. - return Some(tcx.types.err); - } - Res::Err => tcx.types.err, - x => { + let arg_index = path.segments.iter() + .filter_map(|seg| seg.args.as_ref()) + .map(|generic_args| generic_args.args.as_ref()) + .find_map(|args| { + args.iter() + .filter(|arg| arg.is_const()) + .enumerate() + .filter(|(_, arg)| arg.id() == hir_id) + .map(|(index, _)| index) + .next() + }) + .or_else(|| { if !fail { - return None; + None + } else { + bug!("no arg matching AnonConst in path") } + })?; + + // We've encountered an `AnonConst` in some path, so we need to + // figure out which generic parameter it corresponds to and return + // the relevant type. + let generics = match path.res { + Res::Def(DefKind::Ctor(..), def_id) => + tcx.generics_of(tcx.parent(def_id).unwrap()), + Res::Def(_, def_id) => + tcx.generics_of(def_id), + Res::Err => + return Some(tcx.types.err), + _ if !fail => + return None, + x => { tcx.sess.delay_span_bug( DUMMY_SP, &format!( "unexpected const parent path def {:?}", x ), ); - tcx.types.err + return Some(tcx.types.err); } - } + }; + + generics.params.iter() + .filter(|param| { + if let ty::GenericParamDefKind::Const = param.kind { + true + } else { + false + } + }) + .nth(arg_index) + .map(|param| tcx.type_of(param.def_id)) + // This is no generic parameter associated with the arg. This is + // probably from an extra arg where one is not needed. + .unwrap_or(tcx.types.err) } x => { if !fail { diff --git a/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs index 26496ec4a90..f592e486be9 100644 --- a/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs +++ b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs @@ -1,8 +1,9 @@ +// compile-pass #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash -// We should probably be able to infer the types here. However, this test is checking that we don't -// get an ICE in this case. It may be modified later to not be an error. +// This test confirms that the types can be inferred correctly for this example with const +// generics. Previously this would ICE, and more recently error. struct Foo(pub [u8; NUM_BYTES]); diff --git a/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr b/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr index fb151648f2f..52907bbb677 100644 --- a/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr +++ b/src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr @@ -1,25 +1,6 @@ warning: the feature `const_generics` is incomplete and may cause the compiler to crash - --> $DIR/cannot-infer-type-for-const-param.rs:1:12 + --> $DIR/cannot-infer-type-for-const-param.rs:2:12 | LL | #![feature(const_generics)] | ^^^^^^^^^^^^^^ -error[E0282]: type annotations needed - --> $DIR/cannot-infer-type-for-const-param.rs:10:19 - | -LL | let _ = Foo::<3>([1, 2, 3]); - | ^ cannot infer type for `{integer}` - -error[E0308]: mismatched types - --> $DIR/cannot-infer-type-for-const-param.rs:10:22 - | -LL | let _ = Foo::<3>([1, 2, 3]); - | ^^^^^^^^^ expected `3`, found `3usize` - | - = note: expected type `[u8; _]` - found type `[u8; 3]` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0282, E0308. -For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/const-generics/issue-60818-struct-constructors.rs b/src/test/ui/const-generics/issue-60818-struct-constructors.rs new file mode 100644 index 00000000000..0b4aeae7a4a --- /dev/null +++ b/src/test/ui/const-generics/issue-60818-struct-constructors.rs @@ -0,0 +1,10 @@ +// compile-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +struct Generic; + +fn main() { + let _ = Generic::<0>; +} diff --git a/src/test/ui/const-generics/issue-60818-struct-constructors.stderr b/src/test/ui/const-generics/issue-60818-struct-constructors.stderr new file mode 100644 index 00000000000..4b8f50b9b02 --- /dev/null +++ b/src/test/ui/const-generics/issue-60818-struct-constructors.stderr @@ -0,0 +1,6 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-60818-struct-constructors.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + From 1529067a046b079c1348ead39199e9c491a5f472 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 29 May 2019 10:00:13 +0200 Subject: [PATCH 56/65] split libcore::mem into multiple files --- src/libcore/mem.rs | 1406 ------------------------------ src/libcore/mem/manually_drop.rs | 146 ++++ src/libcore/mem/maybe_uninit.rs | 519 +++++++++++ src/libcore/mem/mod.rs | 752 ++++++++++++++++ 4 files changed, 1417 insertions(+), 1406 deletions(-) delete mode 100644 src/libcore/mem.rs create mode 100644 src/libcore/mem/manually_drop.rs create mode 100644 src/libcore/mem/maybe_uninit.rs create mode 100644 src/libcore/mem/mod.rs diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs deleted file mode 100644 index 40f4354213b..00000000000 --- a/src/libcore/mem.rs +++ /dev/null @@ -1,1406 +0,0 @@ -//! Basic functions for dealing with memory. -//! -//! This module contains functions for querying the size and alignment of -//! types, initializing and manipulating memory. - -#![stable(feature = "rust1", since = "1.0.0")] - -use crate::clone; -use crate::cmp; -use crate::fmt; -use crate::hash; -use crate::intrinsics; -use crate::marker::{Copy, PhantomData, Sized}; -use crate::ptr; -use crate::ops::{Deref, DerefMut}; - -#[stable(feature = "rust1", since = "1.0.0")] -#[doc(inline)] -pub use crate::intrinsics::transmute; - -/// Takes ownership and "forgets" about the value **without running its destructor**. -/// -/// Any resources the value manages, such as heap memory or a file handle, will linger -/// forever in an unreachable state. However, it does not guarantee that pointers -/// to this memory will remain valid. -/// -/// * If you want to leak memory, see [`Box::leak`][leak]. -/// * If you want to obtain a raw pointer to the memory, see [`Box::into_raw`][into_raw]. -/// * If you want to dispose of a value properly, running its destructor, see -/// [`mem::drop`][drop]. -/// -/// # Safety -/// -/// `forget` is not marked as `unsafe`, because Rust's safety guarantees -/// do not include a guarantee that destructors will always run. For example, -/// a program can create a reference cycle using [`Rc`][rc], or call -/// [`process::exit`][exit] to exit without running destructors. Thus, allowing -/// `mem::forget` from safe code does not fundamentally change Rust's safety -/// guarantees. -/// -/// That said, leaking resources such as memory or I/O objects is usually undesirable, -/// so `forget` is only recommended for specialized use cases like those shown below. -/// -/// Because forgetting a value is allowed, any `unsafe` code you write must -/// allow for this possibility. You cannot return a value and expect that the -/// caller will necessarily run the value's destructor. -/// -/// [rc]: ../../std/rc/struct.Rc.html -/// [exit]: ../../std/process/fn.exit.html -/// -/// # Examples -/// -/// Leak an I/O object, never closing the file: -/// -/// ```no_run -/// use std::mem; -/// use std::fs::File; -/// -/// let file = File::open("foo.txt").unwrap(); -/// mem::forget(file); -/// ``` -/// -/// The practical use cases for `forget` are rather specialized and mainly come -/// up in unsafe or FFI code. -/// -/// [drop]: fn.drop.html -/// [uninit]: fn.uninitialized.html -/// [clone]: ../clone/trait.Clone.html -/// [swap]: fn.swap.html -/// [box]: ../../std/boxed/struct.Box.html -/// [leak]: ../../std/boxed/struct.Box.html#method.leak -/// [into_raw]: ../../std/boxed/struct.Box.html#method.into_raw -/// [ub]: ../../reference/behavior-considered-undefined.html -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -pub fn forget(t: T) { - ManuallyDrop::new(t); -} - -/// Like [`forget`], but also accepts unsized values. -/// -/// This function is just a shim intended to be removed when the `unsized_locals` feature gets -/// stabilized. -/// -/// [`forget`]: fn.forget.html -#[inline] -#[unstable(feature = "forget_unsized", issue = "0")] -pub fn forget_unsized(t: T) { - unsafe { intrinsics::forget(t) } -} - -/// Returns the size of a type in bytes. -/// -/// More specifically, this is the offset in bytes between successive elements -/// in an array with that item type including alignment padding. Thus, for any -/// type `T` and length `n`, `[T; n]` has a size of `n * size_of::()`. -/// -/// In general, the size of a type is not stable across compilations, but -/// specific types such as primitives are. -/// -/// The following table gives the size for primitives. -/// -/// Type | size_of::\() -/// ---- | --------------- -/// () | 0 -/// bool | 1 -/// u8 | 1 -/// u16 | 2 -/// u32 | 4 -/// u64 | 8 -/// u128 | 16 -/// i8 | 1 -/// i16 | 2 -/// i32 | 4 -/// i64 | 8 -/// i128 | 16 -/// f32 | 4 -/// f64 | 8 -/// char | 4 -/// -/// Furthermore, `usize` and `isize` have the same size. -/// -/// The types `*const T`, `&T`, `Box`, `Option<&T>`, and `Option>` all have -/// the same size. If `T` is Sized, all of those types have the same size as `usize`. -/// -/// The mutability of a pointer does not change its size. As such, `&T` and `&mut T` -/// have the same size. Likewise for `*const T` and `*mut T`. -/// -/// # Size of `#[repr(C)]` items -/// -/// The `C` representation for items has a defined layout. With this layout, -/// the size of items is also stable as long as all fields have a stable size. -/// -/// ## Size of Structs -/// -/// For `structs`, the size is determined by the following algorithm. -/// -/// For each field in the struct ordered by declaration order: -/// -/// 1. Add the size of the field. -/// 2. Round up the current size to the nearest multiple of the next field's [alignment]. -/// -/// Finally, round the size of the struct to the nearest multiple of its [alignment]. -/// The alignment of the struct is usually the largest alignment of all its -/// fields; this can be changed with the use of `repr(align(N))`. -/// -/// Unlike `C`, zero sized structs are not rounded up to one byte in size. -/// -/// ## Size of Enums -/// -/// Enums that carry no data other than the discriminant have the same size as C enums -/// on the platform they are compiled for. -/// -/// ## Size of Unions -/// -/// The size of a union is the size of its largest field. -/// -/// Unlike `C`, zero sized unions are not rounded up to one byte in size. -/// -/// # Examples -/// -/// ``` -/// use std::mem; -/// -/// // Some primitives -/// assert_eq!(4, mem::size_of::()); -/// assert_eq!(8, mem::size_of::()); -/// assert_eq!(0, mem::size_of::<()>()); -/// -/// // Some arrays -/// assert_eq!(8, mem::size_of::<[i32; 2]>()); -/// assert_eq!(12, mem::size_of::<[i32; 3]>()); -/// assert_eq!(0, mem::size_of::<[i32; 0]>()); -/// -/// -/// // Pointer size equality -/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::<*const i32>()); -/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::>()); -/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::>()); -/// assert_eq!(mem::size_of::>(), mem::size_of::>>()); -/// ``` -/// -/// Using `#[repr(C)]`. -/// -/// ``` -/// use std::mem; -/// -/// #[repr(C)] -/// struct FieldStruct { -/// first: u8, -/// second: u16, -/// third: u8 -/// } -/// -/// // The size of the first field is 1, so add 1 to the size. Size is 1. -/// // The alignment of the second field is 2, so add 1 to the size for padding. Size is 2. -/// // The size of the second field is 2, so add 2 to the size. Size is 4. -/// // The alignment of the third field is 1, so add 0 to the size for padding. Size is 4. -/// // The size of the third field is 1, so add 1 to the size. Size is 5. -/// // Finally, the alignment of the struct is 2 (because the largest alignment amongst its -/// // fields is 2), so add 1 to the size for padding. Size is 6. -/// assert_eq!(6, mem::size_of::()); -/// -/// #[repr(C)] -/// struct TupleStruct(u8, u16, u8); -/// -/// // Tuple structs follow the same rules. -/// assert_eq!(6, mem::size_of::()); -/// -/// // Note that reordering the fields can lower the size. We can remove both padding bytes -/// // by putting `third` before `second`. -/// #[repr(C)] -/// struct FieldStructOptimized { -/// first: u8, -/// third: u8, -/// second: u16 -/// } -/// -/// assert_eq!(4, mem::size_of::()); -/// -/// // Union size is the size of the largest field. -/// #[repr(C)] -/// union ExampleUnion { -/// smaller: u8, -/// larger: u16 -/// } -/// -/// assert_eq!(2, mem::size_of::()); -/// ``` -/// -/// [alignment]: ./fn.align_of.html -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_promotable] -pub const fn size_of() -> usize { - intrinsics::size_of::() -} - -/// Returns the size of the pointed-to value in bytes. -/// -/// This is usually the same as `size_of::()`. However, when `T` *has* no -/// statically-known size, e.g., a slice [`[T]`][slice] or a [trait object], -/// then `size_of_val` can be used to get the dynamically-known size. -/// -/// [slice]: ../../std/primitive.slice.html -/// [trait object]: ../../book/ch17-02-trait-objects.html -/// -/// # Examples -/// -/// ``` -/// use std::mem; -/// -/// assert_eq!(4, mem::size_of_val(&5i32)); -/// -/// let x: [u8; 13] = [0; 13]; -/// let y: &[u8] = &x; -/// assert_eq!(13, mem::size_of_val(y)); -/// ``` -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -pub fn size_of_val(val: &T) -> usize { - unsafe { intrinsics::size_of_val(val) } -} - -/// Returns the [ABI]-required minimum alignment of a type. -/// -/// Every reference to a value of the type `T` must be a multiple of this number. -/// -/// This is the alignment used for struct fields. It may be smaller than the preferred alignment. -/// -/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface -/// -/// # Examples -/// -/// ``` -/// # #![allow(deprecated)] -/// use std::mem; -/// -/// assert_eq!(4, mem::min_align_of::()); -/// ``` -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_deprecated(reason = "use `align_of` instead", since = "1.2.0")] -pub fn min_align_of() -> usize { - intrinsics::min_align_of::() -} - -/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. -/// -/// Every reference to a value of the type `T` must be a multiple of this number. -/// -/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface -/// -/// # Examples -/// -/// ``` -/// # #![allow(deprecated)] -/// use std::mem; -/// -/// assert_eq!(4, mem::min_align_of_val(&5i32)); -/// ``` -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_deprecated(reason = "use `align_of_val` instead", since = "1.2.0")] -pub fn min_align_of_val(val: &T) -> usize { - unsafe { intrinsics::min_align_of_val(val) } -} - -/// Returns the [ABI]-required minimum alignment of a type. -/// -/// Every reference to a value of the type `T` must be a multiple of this number. -/// -/// This is the alignment used for struct fields. It may be smaller than the preferred alignment. -/// -/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface -/// -/// # Examples -/// -/// ``` -/// use std::mem; -/// -/// assert_eq!(4, mem::align_of::()); -/// ``` -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_promotable] -pub const fn align_of() -> usize { - intrinsics::min_align_of::() -} - -/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. -/// -/// Every reference to a value of the type `T` must be a multiple of this number. -/// -/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface -/// -/// # Examples -/// -/// ``` -/// use std::mem; -/// -/// assert_eq!(4, mem::align_of_val(&5i32)); -/// ``` -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -pub fn align_of_val(val: &T) -> usize { - unsafe { intrinsics::min_align_of_val(val) } -} - -/// Returns `true` if dropping values of type `T` matters. -/// -/// This is purely an optimization hint, and may be implemented conservatively: -/// it may return `true` for types that don't actually need to be dropped. -/// As such always returning `true` would be a valid implementation of -/// this function. However if this function actually returns `false`, then you -/// can be certain dropping `T` has no side effect. -/// -/// Low level implementations of things like collections, which need to manually -/// drop their data, should use this function to avoid unnecessarily -/// trying to drop all their contents when they are destroyed. This might not -/// make a difference in release builds (where a loop that has no side-effects -/// is easily detected and eliminated), but is often a big win for debug builds. -/// -/// Note that `ptr::drop_in_place` already performs this check, so if your workload -/// can be reduced to some small number of drop_in_place calls, using this is -/// unnecessary. In particular note that you can drop_in_place a slice, and that -/// will do a single needs_drop check for all the values. -/// -/// Types like Vec therefore just `drop_in_place(&mut self[..])` without using -/// needs_drop explicitly. Types like HashMap, on the other hand, have to drop -/// values one at a time and should use this API. -/// -/// -/// # Examples -/// -/// Here's an example of how a collection might make use of needs_drop: -/// -/// ``` -/// use std::{mem, ptr}; -/// -/// pub struct MyCollection { -/// # data: [T; 1], -/// /* ... */ -/// } -/// # impl MyCollection { -/// # fn iter_mut(&mut self) -> &mut [T] { &mut self.data } -/// # fn free_buffer(&mut self) {} -/// # } -/// -/// impl Drop for MyCollection { -/// fn drop(&mut self) { -/// unsafe { -/// // drop the data -/// if mem::needs_drop::() { -/// for x in self.iter_mut() { -/// ptr::drop_in_place(x); -/// } -/// } -/// self.free_buffer(); -/// } -/// } -/// } -/// ``` -#[inline] -#[stable(feature = "needs_drop", since = "1.21.0")] -pub const fn needs_drop() -> bool { - intrinsics::needs_drop::() -} - -/// Creates a value whose bytes are all zero. -/// -/// This has the same effect as [`MaybeUninit::zeroed().assume_init()`][zeroed]. -/// It is useful for FFI sometimes, but should generally be avoided. -/// -/// There is no guarantee that an all-zero byte-pattern represents a valid value of -/// some type `T`. For example, the all-zero byte-pattern is not a valid value -/// for reference types (`&T` and `&mut T`). Using `zeroed` on such types -/// causes immediate [undefined behavior][ub] because [the Rust compiler assumes][inv] -/// that there always is a valid value in a variable it considers initialized. -/// -/// [zeroed]: union.MaybeUninit.html#method.zeroed -/// [ub]: ../../reference/behavior-considered-undefined.html -/// [inv]: union.MaybeUninit.html#initialization-invariant -/// -/// # Examples -/// -/// Correct usage of this function: initializing an integer with zero. -/// -/// ``` -/// use std::mem; -/// -/// let x: i32 = unsafe { mem::zeroed() }; -/// assert_eq!(0, x); -/// ``` -/// -/// *Incorrect* usage of this function: initializing a reference with zero. -/// -/// ```no_run -/// use std::mem; -/// -/// let _x: &i32 = unsafe { mem::zeroed() }; // Undefined behavior! -/// ``` -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -pub unsafe fn zeroed() -> T { - intrinsics::panic_if_uninhabited::(); - intrinsics::init() -} - -/// Bypasses Rust's normal memory-initialization checks by pretending to -/// produce a value of type `T`, while doing nothing at all. -/// -/// **This functon is deprecated.** Use [`MaybeUninit`] instead. -/// -/// The reason for deprecation is that the function basically cannot be used -/// correctly: [the Rust compiler assumes][inv] that values are properly initialized. -/// As a consequence, calling e.g. `mem::uninitialized::()` causes immediate -/// undefined behavior for returning a `bool` that is not definitely either `true` -/// or `false`. Worse, truly uninitialized memory like what gets returned here -/// is special in that the compiler knows that it does not have a fixed value. -/// This makes it undefined behavior to have uninitialized data in a variable even -/// if that variable has an integer type. -/// (Notice that the rules around uninitialized integers are not finalized yet, but -/// until they are, it is advisable to avoid them.) -/// -/// [`MaybeUninit`]: union.MaybeUninit.html -/// [inv]: union.MaybeUninit.html#initialization-invariant -#[inline] -#[rustc_deprecated(since = "1.38.0", reason = "use `mem::MaybeUninit` instead")] -#[stable(feature = "rust1", since = "1.0.0")] -pub unsafe fn uninitialized() -> T { - intrinsics::panic_if_uninhabited::(); - intrinsics::uninit() -} - -/// Swaps the values at two mutable locations, without deinitializing either one. -/// -/// # Examples -/// -/// ``` -/// use std::mem; -/// -/// let mut x = 5; -/// let mut y = 42; -/// -/// mem::swap(&mut x, &mut y); -/// -/// assert_eq!(42, x); -/// assert_eq!(5, y); -/// ``` -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -pub fn swap(x: &mut T, y: &mut T) { - unsafe { - ptr::swap_nonoverlapping_one(x, y); - } -} - -/// Moves `src` into the referenced `dest`, returning the previous `dest` value. -/// -/// Neither value is dropped. -/// -/// # Examples -/// -/// A simple example: -/// -/// ``` -/// use std::mem; -/// -/// let mut v: Vec = vec![1, 2]; -/// -/// let old_v = mem::replace(&mut v, vec![3, 4, 5]); -/// assert_eq!(vec![1, 2], old_v); -/// assert_eq!(vec![3, 4, 5], v); -/// ``` -/// -/// `replace` allows consumption of a struct field by replacing it with another value. -/// Without `replace` you can run into issues like these: -/// -/// ```compile_fail,E0507 -/// struct Buffer { buf: Vec } -/// -/// impl Buffer { -/// fn get_and_reset(&mut self) -> Vec { -/// // error: cannot move out of dereference of `&mut`-pointer -/// let buf = self.buf; -/// self.buf = Vec::new(); -/// buf -/// } -/// } -/// ``` -/// -/// Note that `T` does not necessarily implement [`Clone`], so it can't even clone and reset -/// `self.buf`. But `replace` can be used to disassociate the original value of `self.buf` from -/// `self`, allowing it to be returned: -/// -/// ``` -/// # #![allow(dead_code)] -/// use std::mem; -/// -/// # struct Buffer { buf: Vec } -/// impl Buffer { -/// fn get_and_reset(&mut self) -> Vec { -/// mem::replace(&mut self.buf, Vec::new()) -/// } -/// } -/// ``` -/// -/// [`Clone`]: ../../std/clone/trait.Clone.html -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -pub fn replace(dest: &mut T, mut src: T) -> T { - swap(dest, &mut src); - src -} - -/// Disposes of a value. -/// -/// This does call the argument's implementation of [`Drop`][drop]. -/// -/// This effectively does nothing for types which implement `Copy`, e.g. -/// integers. Such values are copied and _then_ moved into the function, so the -/// value persists after this function call. -/// -/// This function is not magic; it is literally defined as -/// -/// ``` -/// pub fn drop(_x: T) { } -/// ``` -/// -/// Because `_x` is moved into the function, it is automatically dropped before -/// the function returns. -/// -/// [drop]: ../ops/trait.Drop.html -/// -/// # Examples -/// -/// Basic usage: -/// -/// ``` -/// let v = vec![1, 2, 3]; -/// -/// drop(v); // explicitly drop the vector -/// ``` -/// -/// Since [`RefCell`] enforces the borrow rules at runtime, `drop` can -/// release a [`RefCell`] borrow: -/// -/// ``` -/// use std::cell::RefCell; -/// -/// let x = RefCell::new(1); -/// -/// let mut mutable_borrow = x.borrow_mut(); -/// *mutable_borrow = 1; -/// -/// drop(mutable_borrow); // relinquish the mutable borrow on this slot -/// -/// let borrow = x.borrow(); -/// println!("{}", *borrow); -/// ``` -/// -/// Integers and other types implementing [`Copy`] are unaffected by `drop`. -/// -/// ``` -/// #[derive(Copy, Clone)] -/// struct Foo(u8); -/// -/// let x = 1; -/// let y = Foo(2); -/// drop(x); // a copy of `x` is moved and dropped -/// drop(y); // a copy of `y` is moved and dropped -/// -/// println!("x: {}, y: {}", x, y.0); // still available -/// ``` -/// -/// [`RefCell`]: ../../std/cell/struct.RefCell.html -/// [`Copy`]: ../../std/marker/trait.Copy.html -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -pub fn drop(_x: T) { } - -/// Interprets `src` as having type `&U`, and then reads `src` without moving -/// the contained value. -/// -/// This function will unsafely assume the pointer `src` is valid for -/// [`size_of::`][size_of] bytes by transmuting `&T` to `&U` and then reading -/// the `&U`. It will also unsafely create a copy of the contained value instead of -/// moving out of `src`. -/// -/// It is not a compile-time error if `T` and `U` have different sizes, but it -/// is highly encouraged to only invoke this function where `T` and `U` have the -/// same size. This function triggers [undefined behavior][ub] if `U` is larger than -/// `T`. -/// -/// [ub]: ../../reference/behavior-considered-undefined.html -/// [size_of]: fn.size_of.html -/// -/// # Examples -/// -/// ``` -/// use std::mem; -/// -/// #[repr(packed)] -/// struct Foo { -/// bar: u8, -/// } -/// -/// let foo_slice = [10u8]; -/// -/// unsafe { -/// // Copy the data from 'foo_slice' and treat it as a 'Foo' -/// let mut foo_struct: Foo = mem::transmute_copy(&foo_slice); -/// assert_eq!(foo_struct.bar, 10); -/// -/// // Modify the copied data -/// foo_struct.bar = 20; -/// assert_eq!(foo_struct.bar, 20); -/// } -/// -/// // The contents of 'foo_slice' should not have changed -/// assert_eq!(foo_slice, [10]); -/// ``` -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -pub unsafe fn transmute_copy(src: &T) -> U { - ptr::read_unaligned(src as *const T as *const U) -} - -/// Opaque type representing the discriminant of an enum. -/// -/// See the [`discriminant`] function in this module for more information. -/// -/// [`discriminant`]: fn.discriminant.html -#[stable(feature = "discriminant_value", since = "1.21.0")] -pub struct Discriminant(u64, PhantomData T>); - -// N.B. These trait implementations cannot be derived because we don't want any bounds on T. - -#[stable(feature = "discriminant_value", since = "1.21.0")] -impl Copy for Discriminant {} - -#[stable(feature = "discriminant_value", since = "1.21.0")] -impl clone::Clone for Discriminant { - fn clone(&self) -> Self { - *self - } -} - -#[stable(feature = "discriminant_value", since = "1.21.0")] -impl cmp::PartialEq for Discriminant { - fn eq(&self, rhs: &Self) -> bool { - self.0 == rhs.0 - } -} - -#[stable(feature = "discriminant_value", since = "1.21.0")] -impl cmp::Eq for Discriminant {} - -#[stable(feature = "discriminant_value", since = "1.21.0")] -impl hash::Hash for Discriminant { - fn hash(&self, state: &mut H) { - self.0.hash(state); - } -} - -#[stable(feature = "discriminant_value", since = "1.21.0")] -impl fmt::Debug for Discriminant { - fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt.debug_tuple("Discriminant") - .field(&self.0) - .finish() - } -} - -/// Returns a value uniquely identifying the enum variant in `v`. -/// -/// If `T` is not an enum, calling this function will not result in undefined behavior, but the -/// return value is unspecified. -/// -/// # Stability -/// -/// The discriminant of an enum variant may change if the enum definition changes. A discriminant -/// of some variant will not change between compilations with the same compiler. -/// -/// # Examples -/// -/// This can be used to compare enums that carry data, while disregarding -/// the actual data: -/// -/// ``` -/// use std::mem; -/// -/// enum Foo { A(&'static str), B(i32), C(i32) } -/// -/// assert!(mem::discriminant(&Foo::A("bar")) == mem::discriminant(&Foo::A("baz"))); -/// assert!(mem::discriminant(&Foo::B(1)) == mem::discriminant(&Foo::B(2))); -/// assert!(mem::discriminant(&Foo::B(3)) != mem::discriminant(&Foo::C(3))); -/// ``` -#[stable(feature = "discriminant_value", since = "1.21.0")] -pub fn discriminant(v: &T) -> Discriminant { - unsafe { - Discriminant(intrinsics::discriminant_value(v), PhantomData) - } -} - -/// A wrapper to inhibit compiler from automatically calling `T`’s destructor. -/// -/// This wrapper is 0-cost. -/// -/// `ManuallyDrop` is subject to the same layout optimizations as `T`. -/// As a consequence, it has *no effect* on the assumptions that the compiler makes -/// about all values being initialized at their type. In particular, initializing -/// a `ManuallyDrop<&mut T>` with [`mem::zeroed`] is undefined behavior. -/// If you need to handle uninitialized data, use [`MaybeUninit`] instead. -/// -/// # Examples -/// -/// This wrapper helps with explicitly documenting the drop order dependencies between fields of -/// the type: -/// -/// ```rust -/// use std::mem::ManuallyDrop; -/// struct Peach; -/// struct Banana; -/// struct Melon; -/// struct FruitBox { -/// // Immediately clear there’s something non-trivial going on with these fields. -/// peach: ManuallyDrop, -/// melon: Melon, // Field that’s independent of the other two. -/// banana: ManuallyDrop, -/// } -/// -/// impl Drop for FruitBox { -/// fn drop(&mut self) { -/// unsafe { -/// // Explicit ordering in which field destructors are run specified in the intuitive -/// // location – the destructor of the structure containing the fields. -/// // Moreover, one can now reorder fields within the struct however much they want. -/// ManuallyDrop::drop(&mut self.peach); -/// ManuallyDrop::drop(&mut self.banana); -/// } -/// // After destructor for `FruitBox` runs (this function), the destructor for Melon gets -/// // invoked in the usual manner, as it is not wrapped in `ManuallyDrop`. -/// } -/// } -/// ``` -/// -/// [`mem::zeroed`]: fn.zeroed.html -/// [`MaybeUninit`]: union.MaybeUninit.html -#[stable(feature = "manually_drop", since = "1.20.0")] -#[lang = "manually_drop"] -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[repr(transparent)] -pub struct ManuallyDrop { - value: T, -} - -impl ManuallyDrop { - /// Wrap a value to be manually dropped. - /// - /// # Examples - /// - /// ```rust - /// use std::mem::ManuallyDrop; - /// ManuallyDrop::new(Box::new(())); - /// ``` - #[stable(feature = "manually_drop", since = "1.20.0")] - #[inline(always)] - pub const fn new(value: T) -> ManuallyDrop { - ManuallyDrop { value } - } - - /// Extracts the value from the `ManuallyDrop` container. - /// - /// This allows the value to be dropped again. - /// - /// # Examples - /// - /// ```rust - /// use std::mem::ManuallyDrop; - /// let x = ManuallyDrop::new(Box::new(())); - /// let _: Box<()> = ManuallyDrop::into_inner(x); // This drops the `Box`. - /// ``` - #[stable(feature = "manually_drop", since = "1.20.0")] - #[inline(always)] - pub const fn into_inner(slot: ManuallyDrop) -> T { - slot.value - } - - /// Takes the contained value out. - /// - /// This method is primarily intended for moving out values in drop. - /// Instead of using [`ManuallyDrop::drop`] to manually drop the value, - /// you can use this method to take the value and use it however desired. - /// `Drop` will be invoked on the returned value following normal end-of-scope rules. - /// - /// If you have ownership of the container, you can use [`ManuallyDrop::into_inner`] instead. - /// - /// # Safety - /// - /// This function semantically moves out the contained value without preventing further usage. - /// It is up to the user of this method to ensure that this container is not used again. - /// - /// [`ManuallyDrop::drop`]: #method.drop - /// [`ManuallyDrop::into_inner`]: #method.into_inner - #[must_use = "if you don't need the value, you can use `ManuallyDrop::drop` instead"] - #[unstable(feature = "manually_drop_take", issue = "55422")] - #[inline] - pub unsafe fn take(slot: &mut ManuallyDrop) -> T { - ManuallyDrop::into_inner(ptr::read(slot)) - } -} - -impl ManuallyDrop { - /// Manually drops the contained value. - /// - /// If you have ownership of the value, you can use [`ManuallyDrop::into_inner`] instead. - /// - /// # Safety - /// - /// This function runs the destructor of the contained value and thus the wrapped value - /// now represents uninitialized data. It is up to the user of this method to ensure the - /// uninitialized data is not actually used. - /// - /// [`ManuallyDrop::into_inner`]: #method.into_inner - #[stable(feature = "manually_drop", since = "1.20.0")] - #[inline] - pub unsafe fn drop(slot: &mut ManuallyDrop) { - ptr::drop_in_place(&mut slot.value) - } -} - -#[stable(feature = "manually_drop", since = "1.20.0")] -impl Deref for ManuallyDrop { - type Target = T; - #[inline(always)] - fn deref(&self) -> &T { - &self.value - } -} - -#[stable(feature = "manually_drop", since = "1.20.0")] -impl DerefMut for ManuallyDrop { - #[inline(always)] - fn deref_mut(&mut self) -> &mut T { - &mut self.value - } -} - -/// A wrapper type to construct uninitialized instances of `T`. -/// -/// # Initialization invariant -/// -/// The compiler, in general, assumes that variables are properly initialized -/// at their respective type. For example, a variable of reference type must -/// be aligned and non-NULL. This is an invariant that must *always* be upheld, -/// even in unsafe code. As a consequence, zero-initializing a variable of reference -/// type causes instantaneous [undefined behavior][ub], no matter whether that reference -/// ever gets used to access memory: -/// -/// ```rust,no_run -/// use std::mem::{self, MaybeUninit}; -/// -/// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior! -/// // The equivalent code with `MaybeUninit<&i32>`: -/// let x: &i32 = unsafe { MaybeUninit::zeroed().assume_init() }; // undefined behavior! -/// ``` -/// -/// This is exploited by the compiler for various optimizations, such as eliding -/// run-time checks and optimizing `enum` layout. -/// -/// Similarly, entirely uninitialized memory may have any content, while a `bool` must -/// always be `true` or `false`. Hence, creating an uninitialized `bool` is undefined behavior: -/// -/// ```rust,no_run -/// use std::mem::{self, MaybeUninit}; -/// -/// let b: bool = unsafe { mem::uninitialized() }; // undefined behavior! -/// // The equivalent code with `MaybeUninit`: -/// let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! -/// ``` -/// -/// Moreover, uninitialized memory is special in that the compiler knows that -/// it does not have a fixed value. This makes it undefined behavior to have -/// uninitialized data in a variable even if that variable has an integer type, -/// which otherwise can hold any *fixed* bit pattern: -/// -/// ```rust,no_run -/// use std::mem::{self, MaybeUninit}; -/// -/// let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior! -/// // The equivalent code with `MaybeUninit`: -/// let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! -/// ``` -/// (Notice that the rules around uninitialized integers are not finalized yet, but -/// until they are, it is advisable to avoid them.) -/// -/// On top of that, remember that most types have additional invariants beyond merely -/// being considered initialized at the type level. For example, a `1`-initialized [`Vec`] -/// is considered initialized because the only requirement the compiler knows about it -/// is that the data pointer must be non-null. Creating such a `Vec` does not cause -/// *immediate* undefined behavior, but will cause undefined behavior with most -/// safe operations (including dropping it). -/// -/// [`Vec`]: ../../std/vec/struct.Vec.html -/// -/// # Examples -/// -/// `MaybeUninit` serves to enable unsafe code to deal with uninitialized data. -/// It is a signal to the compiler indicating that the data here might *not* -/// be initialized: -/// -/// ```rust -/// use std::mem::MaybeUninit; -/// -/// // Create an explicitly uninitialized reference. The compiler knows that data inside -/// // a `MaybeUninit` may be invalid, and hence this is not UB: -/// let mut x = MaybeUninit::<&i32>::uninit(); -/// // Set it to a valid value. -/// unsafe { x.as_mut_ptr().write(&0); } -/// // Extract the initialized data -- this is only allowed *after* properly -/// // initializing `x`! -/// let x = unsafe { x.assume_init() }; -/// ``` -/// -/// The compiler then knows to not make any incorrect assumptions or optimizations on this code. -/// -/// You can think of `MaybeUninit` as being a bit like `Option` but without -/// any of the run-time tracking and without any of the safety checks. -/// -/// ## out-pointers -/// -/// You can use `MaybeUninit` to implement "out-pointers": instead of returning data -/// from a function, pass it a pointer to some (uninitialized) memory to put the -/// result into. This can be useful when it is important for the caller to control -/// how the memory the result is stored in gets allocated, and you want to avoid -/// unnecessary moves. -/// -/// ``` -/// use std::mem::MaybeUninit; -/// -/// unsafe fn make_vec(out: *mut Vec) { -/// // `write` does not drop the old contents, which is important. -/// out.write(vec![1, 2, 3]); -/// } -/// -/// let mut v = MaybeUninit::uninit(); -/// unsafe { make_vec(v.as_mut_ptr()); } -/// // Now we know `v` is initialized! This also makes sure the vector gets -/// // properly dropped. -/// let v = unsafe { v.assume_init() }; -/// assert_eq!(&v, &[1, 2, 3]); -/// ``` -/// -/// ## Initializing an array element-by-element -/// -/// `MaybeUninit` can be used to initialize a large array element-by-element: -/// -/// ``` -/// use std::mem::{self, MaybeUninit}; -/// use std::ptr; -/// -/// let data = { -/// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is -/// // safe because the type we are claiming to have initialized here is a -/// // bunch of `MaybeUninit`s, which do not require initialization. -/// let mut data: [MaybeUninit>; 1000] = unsafe { -/// MaybeUninit::uninit().assume_init() -/// }; -/// -/// // Dropping a `MaybeUninit` does nothing, so if there is a panic during this loop, -/// // we have a memory leak, but there is no memory safety issue. -/// for elem in &mut data[..] { -/// unsafe { ptr::write(elem.as_mut_ptr(), vec![42]); } -/// } -/// -/// // Everything is initialized. Transmute the array to the -/// // initialized type. -/// unsafe { mem::transmute::<_, [Vec; 1000]>(data) } -/// }; -/// -/// assert_eq!(&data[0], &[42]); -/// ``` -/// -/// You can also work with partially initialized arrays, which could -/// be found in low-level datastructures. -/// -/// ``` -/// use std::mem::MaybeUninit; -/// use std::ptr; -/// -/// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is -/// // safe because the type we are claiming to have initialized here is a -/// // bunch of `MaybeUninit`s, which do not require initialization. -/// let mut data: [MaybeUninit; 1000] = unsafe { MaybeUninit::uninit().assume_init() }; -/// // Count the number of elements we have assigned. -/// let mut data_len: usize = 0; -/// -/// for elem in &mut data[0..500] { -/// unsafe { ptr::write(elem.as_mut_ptr(), String::from("hello")); } -/// data_len += 1; -/// } -/// -/// // For each item in the array, drop if we allocated it. -/// for elem in &mut data[0..data_len] { -/// unsafe { ptr::drop_in_place(elem.as_mut_ptr()); } -/// } -/// ``` -/// -/// ## Initializing a struct field-by-field -/// -/// There is currently no supported way to create a raw pointer or reference -/// to a field of a struct inside `MaybeUninit`. That means it is not possible -/// to create a struct by calling `MaybeUninit::uninit::()` and then writing -/// to its fields. -/// -/// [ub]: ../../reference/behavior-considered-undefined.html -/// -/// # Layout -/// -/// `MaybeUninit` is guaranteed to have the same size and alignment as `T`: -/// -/// ```rust -/// use std::mem::{MaybeUninit, size_of, align_of}; -/// assert_eq!(size_of::>(), size_of::()); -/// assert_eq!(align_of::>(), align_of::()); -/// ``` -/// -/// However remember that a type *containing* a `MaybeUninit` is not necessarily the same -/// layout; Rust does not in general guarantee that the fields of a `Foo` have the same order as -/// a `Foo` even if `T` and `U` have the same size and alignment. Furthermore because any bit -/// value is valid for a `MaybeUninit` the compiler can't apply non-zero/niche-filling -/// optimizations, potentially resulting in a larger size: -/// -/// ```rust -/// # use std::mem::{MaybeUninit, size_of}; -/// assert_eq!(size_of::>(), 1); -/// assert_eq!(size_of::>>(), 2); -/// ``` -#[allow(missing_debug_implementations)] -#[stable(feature = "maybe_uninit", since = "1.36.0")] -#[derive(Copy)] -pub union MaybeUninit { - uninit: (), - value: ManuallyDrop, -} - -#[stable(feature = "maybe_uninit", since = "1.36.0")] -impl Clone for MaybeUninit { - #[inline(always)] - fn clone(&self) -> Self { - // Not calling `T::clone()`, we cannot know if we are initialized enough for that. - *self - } -} - -impl MaybeUninit { - /// Creates a new `MaybeUninit` initialized with the given value. - /// It is safe to call [`assume_init`] on the return value of this function. - /// - /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. - /// It is your responsibility to make sure `T` gets dropped if it got initialized. - /// - /// [`assume_init`]: #method.assume_init - #[stable(feature = "maybe_uninit", since = "1.36.0")] - #[inline(always)] - pub const fn new(val: T) -> MaybeUninit { - MaybeUninit { value: ManuallyDrop::new(val) } - } - - /// Creates a new `MaybeUninit` in an uninitialized state. - /// - /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. - /// It is your responsibility to make sure `T` gets dropped if it got initialized. - /// - /// See the [type-level documentation][type] for some examples. - /// - /// [type]: union.MaybeUninit.html - #[stable(feature = "maybe_uninit", since = "1.36.0")] - #[inline(always)] - pub const fn uninit() -> MaybeUninit { - MaybeUninit { uninit: () } - } - - /// Creates a new `MaybeUninit` in an uninitialized state, with the memory being - /// filled with `0` bytes. It depends on `T` whether that already makes for - /// proper initialization. For example, `MaybeUninit::zeroed()` is initialized, - /// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not - /// be null. - /// - /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. - /// It is your responsibility to make sure `T` gets dropped if it got initialized. - /// - /// # Example - /// - /// Correct usage of this function: initializing a struct with zero, where all - /// fields of the struct can hold the bit-pattern 0 as a valid value. - /// - /// ```rust - /// use std::mem::MaybeUninit; - /// - /// let x = MaybeUninit::<(u8, bool)>::zeroed(); - /// let x = unsafe { x.assume_init() }; - /// assert_eq!(x, (0, false)); - /// ``` - /// - /// *Incorrect* usage of this function: initializing a struct with zero, where some fields - /// cannot hold 0 as a valid value. - /// - /// ```rust,no_run - /// use std::mem::MaybeUninit; - /// - /// enum NotZero { One = 1, Two = 2 }; - /// - /// let x = MaybeUninit::<(u8, NotZero)>::zeroed(); - /// let x = unsafe { x.assume_init() }; - /// // Inside a pair, we create a `NotZero` that does not have a valid discriminant. - /// // This is undefined behavior. - /// ``` - #[stable(feature = "maybe_uninit", since = "1.36.0")] - #[inline] - pub fn zeroed() -> MaybeUninit { - let mut u = MaybeUninit::::uninit(); - unsafe { - u.as_mut_ptr().write_bytes(0u8, 1); - } - u - } - - /// Sets the value of the `MaybeUninit`. This overwrites any previous value - /// without dropping it, so be careful not to use this twice unless you want to - /// skip running the destructor. For your convenience, this also returns a mutable - /// reference to the (now safely initialized) contents of `self`. - #[unstable(feature = "maybe_uninit_extra", issue = "53491")] - #[inline(always)] - pub fn write(&mut self, val: T) -> &mut T { - unsafe { - self.value = ManuallyDrop::new(val); - self.get_mut() - } - } - - /// Gets a pointer to the contained value. Reading from this pointer or turning it - /// into a reference is undefined behavior unless the `MaybeUninit` is initialized. - /// Writing to memory that this pointer (non-transitively) points to is undefined behavior - /// (except inside an `UnsafeCell`). - /// - /// # Examples - /// - /// Correct usage of this method: - /// - /// ```rust - /// use std::mem::MaybeUninit; - /// - /// let mut x = MaybeUninit::>::uninit(); - /// unsafe { x.as_mut_ptr().write(vec![0,1,2]); } - /// // Create a reference into the `MaybeUninit`. This is okay because we initialized it. - /// let x_vec = unsafe { &*x.as_ptr() }; - /// assert_eq!(x_vec.len(), 3); - /// ``` - /// - /// *Incorrect* usage of this method: - /// - /// ```rust,no_run - /// use std::mem::MaybeUninit; - /// - /// let x = MaybeUninit::>::uninit(); - /// let x_vec = unsafe { &*x.as_ptr() }; - /// // We have created a reference to an uninitialized vector! This is undefined behavior. - /// ``` - /// - /// (Notice that the rules around references to uninitialized data are not finalized yet, but - /// until they are, it is advisable to avoid them.) - #[stable(feature = "maybe_uninit", since = "1.36.0")] - #[inline(always)] - pub fn as_ptr(&self) -> *const T { - unsafe { &*self.value as *const T } - } - - /// Gets a mutable pointer to the contained value. Reading from this pointer or turning it - /// into a reference is undefined behavior unless the `MaybeUninit` is initialized. - /// - /// # Examples - /// - /// Correct usage of this method: - /// - /// ```rust - /// use std::mem::MaybeUninit; - /// - /// let mut x = MaybeUninit::>::uninit(); - /// unsafe { x.as_mut_ptr().write(vec![0,1,2]); } - /// // Create a reference into the `MaybeUninit>`. - /// // This is okay because we initialized it. - /// let x_vec = unsafe { &mut *x.as_mut_ptr() }; - /// x_vec.push(3); - /// assert_eq!(x_vec.len(), 4); - /// ``` - /// - /// *Incorrect* usage of this method: - /// - /// ```rust,no_run - /// use std::mem::MaybeUninit; - /// - /// let mut x = MaybeUninit::>::uninit(); - /// let x_vec = unsafe { &mut *x.as_mut_ptr() }; - /// // We have created a reference to an uninitialized vector! This is undefined behavior. - /// ``` - /// - /// (Notice that the rules around references to uninitialized data are not finalized yet, but - /// until they are, it is advisable to avoid them.) - #[stable(feature = "maybe_uninit", since = "1.36.0")] - #[inline(always)] - pub fn as_mut_ptr(&mut self) -> *mut T { - unsafe { &mut *self.value as *mut T } - } - - /// Extracts the value from the `MaybeUninit` container. This is a great way - /// to ensure that the data will get dropped, because the resulting `T` is - /// subject to the usual drop handling. - /// - /// # Safety - /// - /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized - /// state. Calling this when the content is not yet fully initialized causes immediate undefined - /// behavior. The [type-level documentation][inv] contains more information about - /// this initialization invariant. - /// - /// [inv]: #initialization-invariant - /// - /// # Examples - /// - /// Correct usage of this method: - /// - /// ```rust - /// use std::mem::MaybeUninit; - /// - /// let mut x = MaybeUninit::::uninit(); - /// unsafe { x.as_mut_ptr().write(true); } - /// let x_init = unsafe { x.assume_init() }; - /// assert_eq!(x_init, true); - /// ``` - /// - /// *Incorrect* usage of this method: - /// - /// ```rust,no_run - /// use std::mem::MaybeUninit; - /// - /// let x = MaybeUninit::>::uninit(); - /// let x_init = unsafe { x.assume_init() }; - /// // `x` had not been initialized yet, so this last line caused undefined behavior. - /// ``` - #[stable(feature = "maybe_uninit", since = "1.36.0")] - #[inline(always)] - pub unsafe fn assume_init(self) -> T { - intrinsics::panic_if_uninhabited::(); - ManuallyDrop::into_inner(self.value) - } - - /// Reads the value from the `MaybeUninit` container. The resulting `T` is subject - /// to the usual drop handling. - /// - /// Whenever possible, it is preferrable to use [`assume_init`] instead, which - /// prevents duplicating the content of the `MaybeUninit`. - /// - /// # Safety - /// - /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized - /// state. Calling this when the content is not yet fully initialized causes undefined - /// behavior. The [type-level documentation][inv] contains more information about - /// this initialization invariant. - /// - /// Moreover, this leaves a copy of the same data behind in the `MaybeUninit`. When using - /// multiple copies of the data (by calling `read` multiple times, or first - /// calling `read` and then [`assume_init`]), it is your responsibility - /// to ensure that that data may indeed be duplicated. - /// - /// [inv]: #initialization-invariant - /// [`assume_init`]: #method.assume_init - /// - /// # Examples - /// - /// Correct usage of this method: - /// - /// ```rust - /// #![feature(maybe_uninit_extra)] - /// use std::mem::MaybeUninit; - /// - /// let mut x = MaybeUninit::::uninit(); - /// x.write(13); - /// let x1 = unsafe { x.read() }; - /// // `u32` is `Copy`, so we may read multiple times. - /// let x2 = unsafe { x.read() }; - /// assert_eq!(x1, x2); - /// - /// let mut x = MaybeUninit::>>::uninit(); - /// x.write(None); - /// let x1 = unsafe { x.read() }; - /// // Duplicating a `None` value is okay, so we may read multiple times. - /// let x2 = unsafe { x.read() }; - /// assert_eq!(x1, x2); - /// ``` - /// - /// *Incorrect* usage of this method: - /// - /// ```rust,no_run - /// #![feature(maybe_uninit_extra)] - /// use std::mem::MaybeUninit; - /// - /// let mut x = MaybeUninit::>>::uninit(); - /// x.write(Some(vec![0,1,2])); - /// let x1 = unsafe { x.read() }; - /// let x2 = unsafe { x.read() }; - /// // We now created two copies of the same vector, leading to a double-free when - /// // they both get dropped! - /// ``` - #[unstable(feature = "maybe_uninit_extra", issue = "53491")] - #[inline(always)] - pub unsafe fn read(&self) -> T { - intrinsics::panic_if_uninhabited::(); - self.as_ptr().read() - } - - /// Gets a reference to the contained value. - /// - /// # Safety - /// - /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized - /// state. Calling this when the content is not yet fully initialized causes undefined - /// behavior. - #[unstable(feature = "maybe_uninit_ref", issue = "53491")] - #[inline(always)] - pub unsafe fn get_ref(&self) -> &T { - &*self.value - } - - /// Gets a mutable reference to the contained value. - /// - /// # Safety - /// - /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized - /// state. Calling this when the content is not yet fully initialized causes undefined - /// behavior. - // FIXME(#53491): We currently rely on the above being incorrect, i.e., we have references - // to uninitialized data (e.g., in `libcore/fmt/float.rs`). We should make - // a final decision about the rules before stabilization. - #[unstable(feature = "maybe_uninit_ref", issue = "53491")] - #[inline(always)] - pub unsafe fn get_mut(&mut self) -> &mut T { - &mut *self.value - } - - /// Gets a pointer to the first element of the array. - #[unstable(feature = "maybe_uninit_slice", issue = "53491")] - #[inline(always)] - pub fn first_ptr(this: &[MaybeUninit]) -> *const T { - this as *const [MaybeUninit] as *const T - } - - /// Gets a mutable pointer to the first element of the array. - #[unstable(feature = "maybe_uninit_slice", issue = "53491")] - #[inline(always)] - pub fn first_ptr_mut(this: &mut [MaybeUninit]) -> *mut T { - this as *mut [MaybeUninit] as *mut T - } -} diff --git a/src/libcore/mem/manually_drop.rs b/src/libcore/mem/manually_drop.rs new file mode 100644 index 00000000000..3ad1223e331 --- /dev/null +++ b/src/libcore/mem/manually_drop.rs @@ -0,0 +1,146 @@ +use crate::ptr; +use crate::ops::{Deref, DerefMut}; + +/// A wrapper to inhibit compiler from automatically calling `T`’s destructor. +/// +/// This wrapper is 0-cost. +/// +/// `ManuallyDrop` is subject to the same layout optimizations as `T`. +/// As a consequence, it has *no effect* on the assumptions that the compiler makes +/// about all values being initialized at their type. In particular, initializing +/// a `ManuallyDrop<&mut T>` with [`mem::zeroed`] is undefined behavior. +/// If you need to handle uninitialized data, use [`MaybeUninit`] instead. +/// +/// # Examples +/// +/// This wrapper helps with explicitly documenting the drop order dependencies between fields of +/// the type: +/// +/// ```rust +/// use std::mem::ManuallyDrop; +/// struct Peach; +/// struct Banana; +/// struct Melon; +/// struct FruitBox { +/// // Immediately clear there’s something non-trivial going on with these fields. +/// peach: ManuallyDrop, +/// melon: Melon, // Field that’s independent of the other two. +/// banana: ManuallyDrop, +/// } +/// +/// impl Drop for FruitBox { +/// fn drop(&mut self) { +/// unsafe { +/// // Explicit ordering in which field destructors are run specified in the intuitive +/// // location – the destructor of the structure containing the fields. +/// // Moreover, one can now reorder fields within the struct however much they want. +/// ManuallyDrop::drop(&mut self.peach); +/// ManuallyDrop::drop(&mut self.banana); +/// } +/// // After destructor for `FruitBox` runs (this function), the destructor for Melon gets +/// // invoked in the usual manner, as it is not wrapped in `ManuallyDrop`. +/// } +/// } +/// ``` +/// +/// [`mem::zeroed`]: fn.zeroed.html +/// [`MaybeUninit`]: union.MaybeUninit.html +#[stable(feature = "manually_drop", since = "1.20.0")] +#[lang = "manually_drop"] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[repr(transparent)] +pub struct ManuallyDrop { + value: T, +} + +impl ManuallyDrop { + /// Wrap a value to be manually dropped. + /// + /// # Examples + /// + /// ```rust + /// use std::mem::ManuallyDrop; + /// ManuallyDrop::new(Box::new(())); + /// ``` + #[stable(feature = "manually_drop", since = "1.20.0")] + #[inline(always)] + pub const fn new(value: T) -> ManuallyDrop { + ManuallyDrop { value } + } + + /// Extracts the value from the `ManuallyDrop` container. + /// + /// This allows the value to be dropped again. + /// + /// # Examples + /// + /// ```rust + /// use std::mem::ManuallyDrop; + /// let x = ManuallyDrop::new(Box::new(())); + /// let _: Box<()> = ManuallyDrop::into_inner(x); // This drops the `Box`. + /// ``` + #[stable(feature = "manually_drop", since = "1.20.0")] + #[inline(always)] + pub const fn into_inner(slot: ManuallyDrop) -> T { + slot.value + } + + /// Takes the contained value out. + /// + /// This method is primarily intended for moving out values in drop. + /// Instead of using [`ManuallyDrop::drop`] to manually drop the value, + /// you can use this method to take the value and use it however desired. + /// `Drop` will be invoked on the returned value following normal end-of-scope rules. + /// + /// If you have ownership of the container, you can use [`ManuallyDrop::into_inner`] instead. + /// + /// # Safety + /// + /// This function semantically moves out the contained value without preventing further usage. + /// It is up to the user of this method to ensure that this container is not used again. + /// + /// [`ManuallyDrop::drop`]: #method.drop + /// [`ManuallyDrop::into_inner`]: #method.into_inner + #[must_use = "if you don't need the value, you can use `ManuallyDrop::drop` instead"] + #[unstable(feature = "manually_drop_take", issue = "55422")] + #[inline] + pub unsafe fn take(slot: &mut ManuallyDrop) -> T { + ManuallyDrop::into_inner(ptr::read(slot)) + } +} + +impl ManuallyDrop { + /// Manually drops the contained value. + /// + /// If you have ownership of the value, you can use [`ManuallyDrop::into_inner`] instead. + /// + /// # Safety + /// + /// This function runs the destructor of the contained value and thus the wrapped value + /// now represents uninitialized data. It is up to the user of this method to ensure the + /// uninitialized data is not actually used. + /// + /// [`ManuallyDrop::into_inner`]: #method.into_inner + #[stable(feature = "manually_drop", since = "1.20.0")] + #[inline] + pub unsafe fn drop(slot: &mut ManuallyDrop) { + ptr::drop_in_place(&mut slot.value) + } +} + +#[stable(feature = "manually_drop", since = "1.20.0")] +impl Deref for ManuallyDrop { + type Target = T; + #[inline(always)] + fn deref(&self) -> &T { + &self.value + } +} + +#[stable(feature = "manually_drop", since = "1.20.0")] +impl DerefMut for ManuallyDrop { + #[inline(always)] + fn deref_mut(&mut self) -> &mut T { + &mut self.value + } +} diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs new file mode 100644 index 00000000000..eeff9d0303a --- /dev/null +++ b/src/libcore/mem/maybe_uninit.rs @@ -0,0 +1,519 @@ +use crate::intrinsics; +use crate::mem::ManuallyDrop; + +/// A wrapper type to construct uninitialized instances of `T`. +/// +/// # Initialization invariant +/// +/// The compiler, in general, assumes that variables are properly initialized +/// at their respective type. For example, a variable of reference type must +/// be aligned and non-NULL. This is an invariant that must *always* be upheld, +/// even in unsafe code. As a consequence, zero-initializing a variable of reference +/// type causes instantaneous [undefined behavior][ub], no matter whether that reference +/// ever gets used to access memory: +/// +/// ```rust,no_run +/// use std::mem::{self, MaybeUninit}; +/// +/// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior! +/// // The equivalent code with `MaybeUninit<&i32>`: +/// let x: &i32 = unsafe { MaybeUninit::zeroed().assume_init() }; // undefined behavior! +/// ``` +/// +/// This is exploited by the compiler for various optimizations, such as eliding +/// run-time checks and optimizing `enum` layout. +/// +/// Similarly, entirely uninitialized memory may have any content, while a `bool` must +/// always be `true` or `false`. Hence, creating an uninitialized `bool` is undefined behavior: +/// +/// ```rust,no_run +/// use std::mem::{self, MaybeUninit}; +/// +/// let b: bool = unsafe { mem::uninitialized() }; // undefined behavior! +/// // The equivalent code with `MaybeUninit`: +/// let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! +/// ``` +/// +/// Moreover, uninitialized memory is special in that the compiler knows that +/// it does not have a fixed value. This makes it undefined behavior to have +/// uninitialized data in a variable even if that variable has an integer type, +/// which otherwise can hold any *fixed* bit pattern: +/// +/// ```rust,no_run +/// use std::mem::{self, MaybeUninit}; +/// +/// let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior! +/// // The equivalent code with `MaybeUninit`: +/// let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! +/// ``` +/// (Notice that the rules around uninitialized integers are not finalized yet, but +/// until they are, it is advisable to avoid them.) +/// +/// On top of that, remember that most types have additional invariants beyond merely +/// being considered initialized at the type level. For example, a `1`-initialized [`Vec`] +/// is considered initialized because the only requirement the compiler knows about it +/// is that the data pointer must be non-null. Creating such a `Vec` does not cause +/// *immediate* undefined behavior, but will cause undefined behavior with most +/// safe operations (including dropping it). +/// +/// [`Vec`]: ../../std/vec/struct.Vec.html +/// +/// # Examples +/// +/// `MaybeUninit` serves to enable unsafe code to deal with uninitialized data. +/// It is a signal to the compiler indicating that the data here might *not* +/// be initialized: +/// +/// ```rust +/// use std::mem::MaybeUninit; +/// +/// // Create an explicitly uninitialized reference. The compiler knows that data inside +/// // a `MaybeUninit` may be invalid, and hence this is not UB: +/// let mut x = MaybeUninit::<&i32>::uninit(); +/// // Set it to a valid value. +/// unsafe { x.as_mut_ptr().write(&0); } +/// // Extract the initialized data -- this is only allowed *after* properly +/// // initializing `x`! +/// let x = unsafe { x.assume_init() }; +/// ``` +/// +/// The compiler then knows to not make any incorrect assumptions or optimizations on this code. +/// +/// You can think of `MaybeUninit` as being a bit like `Option` but without +/// any of the run-time tracking and without any of the safety checks. +/// +/// ## out-pointers +/// +/// You can use `MaybeUninit` to implement "out-pointers": instead of returning data +/// from a function, pass it a pointer to some (uninitialized) memory to put the +/// result into. This can be useful when it is important for the caller to control +/// how the memory the result is stored in gets allocated, and you want to avoid +/// unnecessary moves. +/// +/// ``` +/// use std::mem::MaybeUninit; +/// +/// unsafe fn make_vec(out: *mut Vec) { +/// // `write` does not drop the old contents, which is important. +/// out.write(vec![1, 2, 3]); +/// } +/// +/// let mut v = MaybeUninit::uninit(); +/// unsafe { make_vec(v.as_mut_ptr()); } +/// // Now we know `v` is initialized! This also makes sure the vector gets +/// // properly dropped. +/// let v = unsafe { v.assume_init() }; +/// assert_eq!(&v, &[1, 2, 3]); +/// ``` +/// +/// ## Initializing an array element-by-element +/// +/// `MaybeUninit` can be used to initialize a large array element-by-element: +/// +/// ``` +/// use std::mem::{self, MaybeUninit}; +/// use std::ptr; +/// +/// let data = { +/// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is +/// // safe because the type we are claiming to have initialized here is a +/// // bunch of `MaybeUninit`s, which do not require initialization. +/// let mut data: [MaybeUninit>; 1000] = unsafe { +/// MaybeUninit::uninit().assume_init() +/// }; +/// +/// // Dropping a `MaybeUninit` does nothing, so if there is a panic during this loop, +/// // we have a memory leak, but there is no memory safety issue. +/// for elem in &mut data[..] { +/// unsafe { ptr::write(elem.as_mut_ptr(), vec![42]); } +/// } +/// +/// // Everything is initialized. Transmute the array to the +/// // initialized type. +/// unsafe { mem::transmute::<_, [Vec; 1000]>(data) } +/// }; +/// +/// assert_eq!(&data[0], &[42]); +/// ``` +/// +/// You can also work with partially initialized arrays, which could +/// be found in low-level datastructures. +/// +/// ``` +/// use std::mem::MaybeUninit; +/// use std::ptr; +/// +/// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is +/// // safe because the type we are claiming to have initialized here is a +/// // bunch of `MaybeUninit`s, which do not require initialization. +/// let mut data: [MaybeUninit; 1000] = unsafe { MaybeUninit::uninit().assume_init() }; +/// // Count the number of elements we have assigned. +/// let mut data_len: usize = 0; +/// +/// for elem in &mut data[0..500] { +/// unsafe { ptr::write(elem.as_mut_ptr(), String::from("hello")); } +/// data_len += 1; +/// } +/// +/// // For each item in the array, drop if we allocated it. +/// for elem in &mut data[0..data_len] { +/// unsafe { ptr::drop_in_place(elem.as_mut_ptr()); } +/// } +/// ``` +/// +/// ## Initializing a struct field-by-field +/// +/// There is currently no supported way to create a raw pointer or reference +/// to a field of a struct inside `MaybeUninit`. That means it is not possible +/// to create a struct by calling `MaybeUninit::uninit::()` and then writing +/// to its fields. +/// +/// [ub]: ../../reference/behavior-considered-undefined.html +/// +/// # Layout +/// +/// `MaybeUninit` is guaranteed to have the same size and alignment as `T`: +/// +/// ```rust +/// use std::mem::{MaybeUninit, size_of, align_of}; +/// assert_eq!(size_of::>(), size_of::()); +/// assert_eq!(align_of::>(), align_of::()); +/// ``` +/// +/// However remember that a type *containing* a `MaybeUninit` is not necessarily the same +/// layout; Rust does not in general guarantee that the fields of a `Foo` have the same order as +/// a `Foo` even if `T` and `U` have the same size and alignment. Furthermore because any bit +/// value is valid for a `MaybeUninit` the compiler can't apply non-zero/niche-filling +/// optimizations, potentially resulting in a larger size: +/// +/// ```rust +/// # use std::mem::{MaybeUninit, size_of}; +/// assert_eq!(size_of::>(), 1); +/// assert_eq!(size_of::>>(), 2); +/// ``` +#[allow(missing_debug_implementations)] +#[stable(feature = "maybe_uninit", since = "1.36.0")] +#[derive(Copy)] +pub union MaybeUninit { + uninit: (), + value: ManuallyDrop, +} + +#[stable(feature = "maybe_uninit", since = "1.36.0")] +impl Clone for MaybeUninit { + #[inline(always)] + fn clone(&self) -> Self { + // Not calling `T::clone()`, we cannot know if we are initialized enough for that. + *self + } +} + +impl MaybeUninit { + /// Creates a new `MaybeUninit` initialized with the given value. + /// It is safe to call [`assume_init`] on the return value of this function. + /// + /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. + /// It is your responsibility to make sure `T` gets dropped if it got initialized. + /// + /// [`assume_init`]: #method.assume_init + #[stable(feature = "maybe_uninit", since = "1.36.0")] + #[inline(always)] + pub const fn new(val: T) -> MaybeUninit { + MaybeUninit { value: ManuallyDrop::new(val) } + } + + /// Creates a new `MaybeUninit` in an uninitialized state. + /// + /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. + /// It is your responsibility to make sure `T` gets dropped if it got initialized. + /// + /// See the [type-level documentation][type] for some examples. + /// + /// [type]: union.MaybeUninit.html + #[stable(feature = "maybe_uninit", since = "1.36.0")] + #[inline(always)] + pub const fn uninit() -> MaybeUninit { + MaybeUninit { uninit: () } + } + + /// Creates a new `MaybeUninit` in an uninitialized state, with the memory being + /// filled with `0` bytes. It depends on `T` whether that already makes for + /// proper initialization. For example, `MaybeUninit::zeroed()` is initialized, + /// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not + /// be null. + /// + /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. + /// It is your responsibility to make sure `T` gets dropped if it got initialized. + /// + /// # Example + /// + /// Correct usage of this function: initializing a struct with zero, where all + /// fields of the struct can hold the bit-pattern 0 as a valid value. + /// + /// ```rust + /// use std::mem::MaybeUninit; + /// + /// let x = MaybeUninit::<(u8, bool)>::zeroed(); + /// let x = unsafe { x.assume_init() }; + /// assert_eq!(x, (0, false)); + /// ``` + /// + /// *Incorrect* usage of this function: initializing a struct with zero, where some fields + /// cannot hold 0 as a valid value. + /// + /// ```rust,no_run + /// use std::mem::MaybeUninit; + /// + /// enum NotZero { One = 1, Two = 2 }; + /// + /// let x = MaybeUninit::<(u8, NotZero)>::zeroed(); + /// let x = unsafe { x.assume_init() }; + /// // Inside a pair, we create a `NotZero` that does not have a valid discriminant. + /// // This is undefined behavior. + /// ``` + #[stable(feature = "maybe_uninit", since = "1.36.0")] + #[inline] + pub fn zeroed() -> MaybeUninit { + let mut u = MaybeUninit::::uninit(); + unsafe { + u.as_mut_ptr().write_bytes(0u8, 1); + } + u + } + + /// Sets the value of the `MaybeUninit`. This overwrites any previous value + /// without dropping it, so be careful not to use this twice unless you want to + /// skip running the destructor. For your convenience, this also returns a mutable + /// reference to the (now safely initialized) contents of `self`. + #[unstable(feature = "maybe_uninit_extra", issue = "53491")] + #[inline(always)] + pub fn write(&mut self, val: T) -> &mut T { + unsafe { + self.value = ManuallyDrop::new(val); + self.get_mut() + } + } + + /// Gets a pointer to the contained value. Reading from this pointer or turning it + /// into a reference is undefined behavior unless the `MaybeUninit` is initialized. + /// Writing to memory that this pointer (non-transitively) points to is undefined behavior + /// (except inside an `UnsafeCell`). + /// + /// # Examples + /// + /// Correct usage of this method: + /// + /// ```rust + /// use std::mem::MaybeUninit; + /// + /// let mut x = MaybeUninit::>::uninit(); + /// unsafe { x.as_mut_ptr().write(vec![0,1,2]); } + /// // Create a reference into the `MaybeUninit`. This is okay because we initialized it. + /// let x_vec = unsafe { &*x.as_ptr() }; + /// assert_eq!(x_vec.len(), 3); + /// ``` + /// + /// *Incorrect* usage of this method: + /// + /// ```rust,no_run + /// use std::mem::MaybeUninit; + /// + /// let x = MaybeUninit::>::uninit(); + /// let x_vec = unsafe { &*x.as_ptr() }; + /// // We have created a reference to an uninitialized vector! This is undefined behavior. + /// ``` + /// + /// (Notice that the rules around references to uninitialized data are not finalized yet, but + /// until they are, it is advisable to avoid them.) + #[stable(feature = "maybe_uninit", since = "1.36.0")] + #[inline(always)] + pub fn as_ptr(&self) -> *const T { + unsafe { &*self.value as *const T } + } + + /// Gets a mutable pointer to the contained value. Reading from this pointer or turning it + /// into a reference is undefined behavior unless the `MaybeUninit` is initialized. + /// + /// # Examples + /// + /// Correct usage of this method: + /// + /// ```rust + /// use std::mem::MaybeUninit; + /// + /// let mut x = MaybeUninit::>::uninit(); + /// unsafe { x.as_mut_ptr().write(vec![0,1,2]); } + /// // Create a reference into the `MaybeUninit>`. + /// // This is okay because we initialized it. + /// let x_vec = unsafe { &mut *x.as_mut_ptr() }; + /// x_vec.push(3); + /// assert_eq!(x_vec.len(), 4); + /// ``` + /// + /// *Incorrect* usage of this method: + /// + /// ```rust,no_run + /// use std::mem::MaybeUninit; + /// + /// let mut x = MaybeUninit::>::uninit(); + /// let x_vec = unsafe { &mut *x.as_mut_ptr() }; + /// // We have created a reference to an uninitialized vector! This is undefined behavior. + /// ``` + /// + /// (Notice that the rules around references to uninitialized data are not finalized yet, but + /// until they are, it is advisable to avoid them.) + #[stable(feature = "maybe_uninit", since = "1.36.0")] + #[inline(always)] + pub fn as_mut_ptr(&mut self) -> *mut T { + unsafe { &mut *self.value as *mut T } + } + + /// Extracts the value from the `MaybeUninit` container. This is a great way + /// to ensure that the data will get dropped, because the resulting `T` is + /// subject to the usual drop handling. + /// + /// # Safety + /// + /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized + /// state. Calling this when the content is not yet fully initialized causes immediate undefined + /// behavior. The [type-level documentation][inv] contains more information about + /// this initialization invariant. + /// + /// [inv]: #initialization-invariant + /// + /// # Examples + /// + /// Correct usage of this method: + /// + /// ```rust + /// use std::mem::MaybeUninit; + /// + /// let mut x = MaybeUninit::::uninit(); + /// unsafe { x.as_mut_ptr().write(true); } + /// let x_init = unsafe { x.assume_init() }; + /// assert_eq!(x_init, true); + /// ``` + /// + /// *Incorrect* usage of this method: + /// + /// ```rust,no_run + /// use std::mem::MaybeUninit; + /// + /// let x = MaybeUninit::>::uninit(); + /// let x_init = unsafe { x.assume_init() }; + /// // `x` had not been initialized yet, so this last line caused undefined behavior. + /// ``` + #[stable(feature = "maybe_uninit", since = "1.36.0")] + #[inline(always)] + pub unsafe fn assume_init(self) -> T { + intrinsics::panic_if_uninhabited::(); + ManuallyDrop::into_inner(self.value) + } + + /// Reads the value from the `MaybeUninit` container. The resulting `T` is subject + /// to the usual drop handling. + /// + /// Whenever possible, it is preferrable to use [`assume_init`] instead, which + /// prevents duplicating the content of the `MaybeUninit`. + /// + /// # Safety + /// + /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized + /// state. Calling this when the content is not yet fully initialized causes undefined + /// behavior. The [type-level documentation][inv] contains more information about + /// this initialization invariant. + /// + /// Moreover, this leaves a copy of the same data behind in the `MaybeUninit`. When using + /// multiple copies of the data (by calling `read` multiple times, or first + /// calling `read` and then [`assume_init`]), it is your responsibility + /// to ensure that that data may indeed be duplicated. + /// + /// [inv]: #initialization-invariant + /// [`assume_init`]: #method.assume_init + /// + /// # Examples + /// + /// Correct usage of this method: + /// + /// ```rust + /// #![feature(maybe_uninit_extra)] + /// use std::mem::MaybeUninit; + /// + /// let mut x = MaybeUninit::::uninit(); + /// x.write(13); + /// let x1 = unsafe { x.read() }; + /// // `u32` is `Copy`, so we may read multiple times. + /// let x2 = unsafe { x.read() }; + /// assert_eq!(x1, x2); + /// + /// let mut x = MaybeUninit::>>::uninit(); + /// x.write(None); + /// let x1 = unsafe { x.read() }; + /// // Duplicating a `None` value is okay, so we may read multiple times. + /// let x2 = unsafe { x.read() }; + /// assert_eq!(x1, x2); + /// ``` + /// + /// *Incorrect* usage of this method: + /// + /// ```rust,no_run + /// #![feature(maybe_uninit_extra)] + /// use std::mem::MaybeUninit; + /// + /// let mut x = MaybeUninit::>>::uninit(); + /// x.write(Some(vec![0,1,2])); + /// let x1 = unsafe { x.read() }; + /// let x2 = unsafe { x.read() }; + /// // We now created two copies of the same vector, leading to a double-free when + /// // they both get dropped! + /// ``` + #[unstable(feature = "maybe_uninit_extra", issue = "53491")] + #[inline(always)] + pub unsafe fn read(&self) -> T { + intrinsics::panic_if_uninhabited::(); + self.as_ptr().read() + } + + /// Gets a reference to the contained value. + /// + /// # Safety + /// + /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized + /// state. Calling this when the content is not yet fully initialized causes undefined + /// behavior. + #[unstable(feature = "maybe_uninit_ref", issue = "53491")] + #[inline(always)] + pub unsafe fn get_ref(&self) -> &T { + &*self.value + } + + /// Gets a mutable reference to the contained value. + /// + /// # Safety + /// + /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized + /// state. Calling this when the content is not yet fully initialized causes undefined + /// behavior. + // FIXME(#53491): We currently rely on the above being incorrect, i.e., we have references + // to uninitialized data (e.g., in `libcore/fmt/float.rs`). We should make + // a final decision about the rules before stabilization. + #[unstable(feature = "maybe_uninit_ref", issue = "53491")] + #[inline(always)] + pub unsafe fn get_mut(&mut self) -> &mut T { + &mut *self.value + } + + /// Gets a pointer to the first element of the array. + #[unstable(feature = "maybe_uninit_slice", issue = "53491")] + #[inline(always)] + pub fn first_ptr(this: &[MaybeUninit]) -> *const T { + this as *const [MaybeUninit] as *const T + } + + /// Gets a mutable pointer to the first element of the array. + #[unstable(feature = "maybe_uninit_slice", issue = "53491")] + #[inline(always)] + pub fn first_ptr_mut(this: &mut [MaybeUninit]) -> *mut T { + this as *mut [MaybeUninit] as *mut T + } +} diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs new file mode 100644 index 00000000000..91449f09936 --- /dev/null +++ b/src/libcore/mem/mod.rs @@ -0,0 +1,752 @@ +//! Basic functions for dealing with memory. +//! +//! This module contains functions for querying the size and alignment of +//! types, initializing and manipulating memory. + +#![stable(feature = "rust1", since = "1.0.0")] + +use crate::clone; +use crate::cmp; +use crate::fmt; +use crate::hash; +use crate::intrinsics; +use crate::marker::{Copy, PhantomData, Sized}; +use crate::ptr; + +mod manually_drop; +#[stable(feature = "manually_drop", since = "1.20.0")] +pub use manually_drop::ManuallyDrop; + +mod maybe_uninit; +#[stable(feature = "maybe_uninit", since = "1.36.0")] +pub use maybe_uninit::MaybeUninit; + +#[stable(feature = "rust1", since = "1.0.0")] +#[doc(inline)] +pub use crate::intrinsics::transmute; + +/// Takes ownership and "forgets" about the value **without running its destructor**. +/// +/// Any resources the value manages, such as heap memory or a file handle, will linger +/// forever in an unreachable state. However, it does not guarantee that pointers +/// to this memory will remain valid. +/// +/// * If you want to leak memory, see [`Box::leak`][leak]. +/// * If you want to obtain a raw pointer to the memory, see [`Box::into_raw`][into_raw]. +/// * If you want to dispose of a value properly, running its destructor, see +/// [`mem::drop`][drop]. +/// +/// # Safety +/// +/// `forget` is not marked as `unsafe`, because Rust's safety guarantees +/// do not include a guarantee that destructors will always run. For example, +/// a program can create a reference cycle using [`Rc`][rc], or call +/// [`process::exit`][exit] to exit without running destructors. Thus, allowing +/// `mem::forget` from safe code does not fundamentally change Rust's safety +/// guarantees. +/// +/// That said, leaking resources such as memory or I/O objects is usually undesirable, +/// so `forget` is only recommended for specialized use cases like those shown below. +/// +/// Because forgetting a value is allowed, any `unsafe` code you write must +/// allow for this possibility. You cannot return a value and expect that the +/// caller will necessarily run the value's destructor. +/// +/// [rc]: ../../std/rc/struct.Rc.html +/// [exit]: ../../std/process/fn.exit.html +/// +/// # Examples +/// +/// Leak an I/O object, never closing the file: +/// +/// ```no_run +/// use std::mem; +/// use std::fs::File; +/// +/// let file = File::open("foo.txt").unwrap(); +/// mem::forget(file); +/// ``` +/// +/// The practical use cases for `forget` are rather specialized and mainly come +/// up in unsafe or FFI code. +/// +/// [drop]: fn.drop.html +/// [uninit]: fn.uninitialized.html +/// [clone]: ../clone/trait.Clone.html +/// [swap]: fn.swap.html +/// [box]: ../../std/boxed/struct.Box.html +/// [leak]: ../../std/boxed/struct.Box.html#method.leak +/// [into_raw]: ../../std/boxed/struct.Box.html#method.into_raw +/// [ub]: ../../reference/behavior-considered-undefined.html +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +pub fn forget(t: T) { + ManuallyDrop::new(t); +} + +/// Like [`forget`], but also accepts unsized values. +/// +/// This function is just a shim intended to be removed when the `unsized_locals` feature gets +/// stabilized. +/// +/// [`forget`]: fn.forget.html +#[inline] +#[unstable(feature = "forget_unsized", issue = "0")] +pub fn forget_unsized(t: T) { + unsafe { intrinsics::forget(t) } +} + +/// Returns the size of a type in bytes. +/// +/// More specifically, this is the offset in bytes between successive elements +/// in an array with that item type including alignment padding. Thus, for any +/// type `T` and length `n`, `[T; n]` has a size of `n * size_of::()`. +/// +/// In general, the size of a type is not stable across compilations, but +/// specific types such as primitives are. +/// +/// The following table gives the size for primitives. +/// +/// Type | size_of::\() +/// ---- | --------------- +/// () | 0 +/// bool | 1 +/// u8 | 1 +/// u16 | 2 +/// u32 | 4 +/// u64 | 8 +/// u128 | 16 +/// i8 | 1 +/// i16 | 2 +/// i32 | 4 +/// i64 | 8 +/// i128 | 16 +/// f32 | 4 +/// f64 | 8 +/// char | 4 +/// +/// Furthermore, `usize` and `isize` have the same size. +/// +/// The types `*const T`, `&T`, `Box`, `Option<&T>`, and `Option>` all have +/// the same size. If `T` is Sized, all of those types have the same size as `usize`. +/// +/// The mutability of a pointer does not change its size. As such, `&T` and `&mut T` +/// have the same size. Likewise for `*const T` and `*mut T`. +/// +/// # Size of `#[repr(C)]` items +/// +/// The `C` representation for items has a defined layout. With this layout, +/// the size of items is also stable as long as all fields have a stable size. +/// +/// ## Size of Structs +/// +/// For `structs`, the size is determined by the following algorithm. +/// +/// For each field in the struct ordered by declaration order: +/// +/// 1. Add the size of the field. +/// 2. Round up the current size to the nearest multiple of the next field's [alignment]. +/// +/// Finally, round the size of the struct to the nearest multiple of its [alignment]. +/// The alignment of the struct is usually the largest alignment of all its +/// fields; this can be changed with the use of `repr(align(N))`. +/// +/// Unlike `C`, zero sized structs are not rounded up to one byte in size. +/// +/// ## Size of Enums +/// +/// Enums that carry no data other than the discriminant have the same size as C enums +/// on the platform they are compiled for. +/// +/// ## Size of Unions +/// +/// The size of a union is the size of its largest field. +/// +/// Unlike `C`, zero sized unions are not rounded up to one byte in size. +/// +/// # Examples +/// +/// ``` +/// use std::mem; +/// +/// // Some primitives +/// assert_eq!(4, mem::size_of::()); +/// assert_eq!(8, mem::size_of::()); +/// assert_eq!(0, mem::size_of::<()>()); +/// +/// // Some arrays +/// assert_eq!(8, mem::size_of::<[i32; 2]>()); +/// assert_eq!(12, mem::size_of::<[i32; 3]>()); +/// assert_eq!(0, mem::size_of::<[i32; 0]>()); +/// +/// +/// // Pointer size equality +/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::<*const i32>()); +/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::>()); +/// assert_eq!(mem::size_of::<&i32>(), mem::size_of::>()); +/// assert_eq!(mem::size_of::>(), mem::size_of::>>()); +/// ``` +/// +/// Using `#[repr(C)]`. +/// +/// ``` +/// use std::mem; +/// +/// #[repr(C)] +/// struct FieldStruct { +/// first: u8, +/// second: u16, +/// third: u8 +/// } +/// +/// // The size of the first field is 1, so add 1 to the size. Size is 1. +/// // The alignment of the second field is 2, so add 1 to the size for padding. Size is 2. +/// // The size of the second field is 2, so add 2 to the size. Size is 4. +/// // The alignment of the third field is 1, so add 0 to the size for padding. Size is 4. +/// // The size of the third field is 1, so add 1 to the size. Size is 5. +/// // Finally, the alignment of the struct is 2 (because the largest alignment amongst its +/// // fields is 2), so add 1 to the size for padding. Size is 6. +/// assert_eq!(6, mem::size_of::()); +/// +/// #[repr(C)] +/// struct TupleStruct(u8, u16, u8); +/// +/// // Tuple structs follow the same rules. +/// assert_eq!(6, mem::size_of::()); +/// +/// // Note that reordering the fields can lower the size. We can remove both padding bytes +/// // by putting `third` before `second`. +/// #[repr(C)] +/// struct FieldStructOptimized { +/// first: u8, +/// third: u8, +/// second: u16 +/// } +/// +/// assert_eq!(4, mem::size_of::()); +/// +/// // Union size is the size of the largest field. +/// #[repr(C)] +/// union ExampleUnion { +/// smaller: u8, +/// larger: u16 +/// } +/// +/// assert_eq!(2, mem::size_of::()); +/// ``` +/// +/// [alignment]: ./fn.align_of.html +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_promotable] +pub const fn size_of() -> usize { + intrinsics::size_of::() +} + +/// Returns the size of the pointed-to value in bytes. +/// +/// This is usually the same as `size_of::()`. However, when `T` *has* no +/// statically-known size, e.g., a slice [`[T]`][slice] or a [trait object], +/// then `size_of_val` can be used to get the dynamically-known size. +/// +/// [slice]: ../../std/primitive.slice.html +/// [trait object]: ../../book/ch17-02-trait-objects.html +/// +/// # Examples +/// +/// ``` +/// use std::mem; +/// +/// assert_eq!(4, mem::size_of_val(&5i32)); +/// +/// let x: [u8; 13] = [0; 13]; +/// let y: &[u8] = &x; +/// assert_eq!(13, mem::size_of_val(y)); +/// ``` +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +pub fn size_of_val(val: &T) -> usize { + unsafe { intrinsics::size_of_val(val) } +} + +/// Returns the [ABI]-required minimum alignment of a type. +/// +/// Every reference to a value of the type `T` must be a multiple of this number. +/// +/// This is the alignment used for struct fields. It may be smaller than the preferred alignment. +/// +/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface +/// +/// # Examples +/// +/// ``` +/// # #![allow(deprecated)] +/// use std::mem; +/// +/// assert_eq!(4, mem::min_align_of::()); +/// ``` +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_deprecated(reason = "use `align_of` instead", since = "1.2.0")] +pub fn min_align_of() -> usize { + intrinsics::min_align_of::() +} + +/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. +/// +/// Every reference to a value of the type `T` must be a multiple of this number. +/// +/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface +/// +/// # Examples +/// +/// ``` +/// # #![allow(deprecated)] +/// use std::mem; +/// +/// assert_eq!(4, mem::min_align_of_val(&5i32)); +/// ``` +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_deprecated(reason = "use `align_of_val` instead", since = "1.2.0")] +pub fn min_align_of_val(val: &T) -> usize { + unsafe { intrinsics::min_align_of_val(val) } +} + +/// Returns the [ABI]-required minimum alignment of a type. +/// +/// Every reference to a value of the type `T` must be a multiple of this number. +/// +/// This is the alignment used for struct fields. It may be smaller than the preferred alignment. +/// +/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface +/// +/// # Examples +/// +/// ``` +/// use std::mem; +/// +/// assert_eq!(4, mem::align_of::()); +/// ``` +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_promotable] +pub const fn align_of() -> usize { + intrinsics::min_align_of::() +} + +/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. +/// +/// Every reference to a value of the type `T` must be a multiple of this number. +/// +/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface +/// +/// # Examples +/// +/// ``` +/// use std::mem; +/// +/// assert_eq!(4, mem::align_of_val(&5i32)); +/// ``` +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +pub fn align_of_val(val: &T) -> usize { + unsafe { intrinsics::min_align_of_val(val) } +} + +/// Returns `true` if dropping values of type `T` matters. +/// +/// This is purely an optimization hint, and may be implemented conservatively: +/// it may return `true` for types that don't actually need to be dropped. +/// As such always returning `true` would be a valid implementation of +/// this function. However if this function actually returns `false`, then you +/// can be certain dropping `T` has no side effect. +/// +/// Low level implementations of things like collections, which need to manually +/// drop their data, should use this function to avoid unnecessarily +/// trying to drop all their contents when they are destroyed. This might not +/// make a difference in release builds (where a loop that has no side-effects +/// is easily detected and eliminated), but is often a big win for debug builds. +/// +/// Note that `ptr::drop_in_place` already performs this check, so if your workload +/// can be reduced to some small number of drop_in_place calls, using this is +/// unnecessary. In particular note that you can drop_in_place a slice, and that +/// will do a single needs_drop check for all the values. +/// +/// Types like Vec therefore just `drop_in_place(&mut self[..])` without using +/// needs_drop explicitly. Types like HashMap, on the other hand, have to drop +/// values one at a time and should use this API. +/// +/// +/// # Examples +/// +/// Here's an example of how a collection might make use of needs_drop: +/// +/// ``` +/// use std::{mem, ptr}; +/// +/// pub struct MyCollection { +/// # data: [T; 1], +/// /* ... */ +/// } +/// # impl MyCollection { +/// # fn iter_mut(&mut self) -> &mut [T] { &mut self.data } +/// # fn free_buffer(&mut self) {} +/// # } +/// +/// impl Drop for MyCollection { +/// fn drop(&mut self) { +/// unsafe { +/// // drop the data +/// if mem::needs_drop::() { +/// for x in self.iter_mut() { +/// ptr::drop_in_place(x); +/// } +/// } +/// self.free_buffer(); +/// } +/// } +/// } +/// ``` +#[inline] +#[stable(feature = "needs_drop", since = "1.21.0")] +pub const fn needs_drop() -> bool { + intrinsics::needs_drop::() +} + +/// Creates a value whose bytes are all zero. +/// +/// This has the same effect as [`MaybeUninit::zeroed().assume_init()`][zeroed]. +/// It is useful for FFI sometimes, but should generally be avoided. +/// +/// There is no guarantee that an all-zero byte-pattern represents a valid value of +/// some type `T`. For example, the all-zero byte-pattern is not a valid value +/// for reference types (`&T` and `&mut T`). Using `zeroed` on such types +/// causes immediate [undefined behavior][ub] because [the Rust compiler assumes][inv] +/// that there always is a valid value in a variable it considers initialized. +/// +/// [zeroed]: union.MaybeUninit.html#method.zeroed +/// [ub]: ../../reference/behavior-considered-undefined.html +/// [inv]: union.MaybeUninit.html#initialization-invariant +/// +/// # Examples +/// +/// Correct usage of this function: initializing an integer with zero. +/// +/// ``` +/// use std::mem; +/// +/// let x: i32 = unsafe { mem::zeroed() }; +/// assert_eq!(0, x); +/// ``` +/// +/// *Incorrect* usage of this function: initializing a reference with zero. +/// +/// ```no_run +/// use std::mem; +/// +/// let _x: &i32 = unsafe { mem::zeroed() }; // Undefined behavior! +/// ``` +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +pub unsafe fn zeroed() -> T { + intrinsics::panic_if_uninhabited::(); + intrinsics::init() +} + +/// Bypasses Rust's normal memory-initialization checks by pretending to +/// produce a value of type `T`, while doing nothing at all. +/// +/// **This functon is deprecated.** Use [`MaybeUninit`] instead. +/// +/// The reason for deprecation is that the function basically cannot be used +/// correctly: [the Rust compiler assumes][inv] that values are properly initialized. +/// As a consequence, calling e.g. `mem::uninitialized::()` causes immediate +/// undefined behavior for returning a `bool` that is not definitely either `true` +/// or `false`. Worse, truly uninitialized memory like what gets returned here +/// is special in that the compiler knows that it does not have a fixed value. +/// This makes it undefined behavior to have uninitialized data in a variable even +/// if that variable has an integer type. +/// (Notice that the rules around uninitialized integers are not finalized yet, but +/// until they are, it is advisable to avoid them.) +/// +/// [`MaybeUninit`]: union.MaybeUninit.html +/// [inv]: union.MaybeUninit.html#initialization-invariant +#[inline] +#[rustc_deprecated(since = "1.38.0", reason = "use `mem::MaybeUninit` instead")] +#[stable(feature = "rust1", since = "1.0.0")] +pub unsafe fn uninitialized() -> T { + intrinsics::panic_if_uninhabited::(); + intrinsics::uninit() +} + +/// Swaps the values at two mutable locations, without deinitializing either one. +/// +/// # Examples +/// +/// ``` +/// use std::mem; +/// +/// let mut x = 5; +/// let mut y = 42; +/// +/// mem::swap(&mut x, &mut y); +/// +/// assert_eq!(42, x); +/// assert_eq!(5, y); +/// ``` +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +pub fn swap(x: &mut T, y: &mut T) { + unsafe { + ptr::swap_nonoverlapping_one(x, y); + } +} + +/// Moves `src` into the referenced `dest`, returning the previous `dest` value. +/// +/// Neither value is dropped. +/// +/// # Examples +/// +/// A simple example: +/// +/// ``` +/// use std::mem; +/// +/// let mut v: Vec = vec![1, 2]; +/// +/// let old_v = mem::replace(&mut v, vec![3, 4, 5]); +/// assert_eq!(vec![1, 2], old_v); +/// assert_eq!(vec![3, 4, 5], v); +/// ``` +/// +/// `replace` allows consumption of a struct field by replacing it with another value. +/// Without `replace` you can run into issues like these: +/// +/// ```compile_fail,E0507 +/// struct Buffer { buf: Vec } +/// +/// impl Buffer { +/// fn get_and_reset(&mut self) -> Vec { +/// // error: cannot move out of dereference of `&mut`-pointer +/// let buf = self.buf; +/// self.buf = Vec::new(); +/// buf +/// } +/// } +/// ``` +/// +/// Note that `T` does not necessarily implement [`Clone`], so it can't even clone and reset +/// `self.buf`. But `replace` can be used to disassociate the original value of `self.buf` from +/// `self`, allowing it to be returned: +/// +/// ``` +/// # #![allow(dead_code)] +/// use std::mem; +/// +/// # struct Buffer { buf: Vec } +/// impl Buffer { +/// fn get_and_reset(&mut self) -> Vec { +/// mem::replace(&mut self.buf, Vec::new()) +/// } +/// } +/// ``` +/// +/// [`Clone`]: ../../std/clone/trait.Clone.html +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +pub fn replace(dest: &mut T, mut src: T) -> T { + swap(dest, &mut src); + src +} + +/// Disposes of a value. +/// +/// This does call the argument's implementation of [`Drop`][drop]. +/// +/// This effectively does nothing for types which implement `Copy`, e.g. +/// integers. Such values are copied and _then_ moved into the function, so the +/// value persists after this function call. +/// +/// This function is not magic; it is literally defined as +/// +/// ``` +/// pub fn drop(_x: T) { } +/// ``` +/// +/// Because `_x` is moved into the function, it is automatically dropped before +/// the function returns. +/// +/// [drop]: ../ops/trait.Drop.html +/// +/// # Examples +/// +/// Basic usage: +/// +/// ``` +/// let v = vec![1, 2, 3]; +/// +/// drop(v); // explicitly drop the vector +/// ``` +/// +/// Since [`RefCell`] enforces the borrow rules at runtime, `drop` can +/// release a [`RefCell`] borrow: +/// +/// ``` +/// use std::cell::RefCell; +/// +/// let x = RefCell::new(1); +/// +/// let mut mutable_borrow = x.borrow_mut(); +/// *mutable_borrow = 1; +/// +/// drop(mutable_borrow); // relinquish the mutable borrow on this slot +/// +/// let borrow = x.borrow(); +/// println!("{}", *borrow); +/// ``` +/// +/// Integers and other types implementing [`Copy`] are unaffected by `drop`. +/// +/// ``` +/// #[derive(Copy, Clone)] +/// struct Foo(u8); +/// +/// let x = 1; +/// let y = Foo(2); +/// drop(x); // a copy of `x` is moved and dropped +/// drop(y); // a copy of `y` is moved and dropped +/// +/// println!("x: {}, y: {}", x, y.0); // still available +/// ``` +/// +/// [`RefCell`]: ../../std/cell/struct.RefCell.html +/// [`Copy`]: ../../std/marker/trait.Copy.html +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +pub fn drop(_x: T) { } + +/// Interprets `src` as having type `&U`, and then reads `src` without moving +/// the contained value. +/// +/// This function will unsafely assume the pointer `src` is valid for +/// [`size_of::`][size_of] bytes by transmuting `&T` to `&U` and then reading +/// the `&U`. It will also unsafely create a copy of the contained value instead of +/// moving out of `src`. +/// +/// It is not a compile-time error if `T` and `U` have different sizes, but it +/// is highly encouraged to only invoke this function where `T` and `U` have the +/// same size. This function triggers [undefined behavior][ub] if `U` is larger than +/// `T`. +/// +/// [ub]: ../../reference/behavior-considered-undefined.html +/// [size_of]: fn.size_of.html +/// +/// # Examples +/// +/// ``` +/// use std::mem; +/// +/// #[repr(packed)] +/// struct Foo { +/// bar: u8, +/// } +/// +/// let foo_slice = [10u8]; +/// +/// unsafe { +/// // Copy the data from 'foo_slice' and treat it as a 'Foo' +/// let mut foo_struct: Foo = mem::transmute_copy(&foo_slice); +/// assert_eq!(foo_struct.bar, 10); +/// +/// // Modify the copied data +/// foo_struct.bar = 20; +/// assert_eq!(foo_struct.bar, 20); +/// } +/// +/// // The contents of 'foo_slice' should not have changed +/// assert_eq!(foo_slice, [10]); +/// ``` +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +pub unsafe fn transmute_copy(src: &T) -> U { + ptr::read_unaligned(src as *const T as *const U) +} + +/// Opaque type representing the discriminant of an enum. +/// +/// See the [`discriminant`] function in this module for more information. +/// +/// [`discriminant`]: fn.discriminant.html +#[stable(feature = "discriminant_value", since = "1.21.0")] +pub struct Discriminant(u64, PhantomData T>); + +// N.B. These trait implementations cannot be derived because we don't want any bounds on T. + +#[stable(feature = "discriminant_value", since = "1.21.0")] +impl Copy for Discriminant {} + +#[stable(feature = "discriminant_value", since = "1.21.0")] +impl clone::Clone for Discriminant { + fn clone(&self) -> Self { + *self + } +} + +#[stable(feature = "discriminant_value", since = "1.21.0")] +impl cmp::PartialEq for Discriminant { + fn eq(&self, rhs: &Self) -> bool { + self.0 == rhs.0 + } +} + +#[stable(feature = "discriminant_value", since = "1.21.0")] +impl cmp::Eq for Discriminant {} + +#[stable(feature = "discriminant_value", since = "1.21.0")] +impl hash::Hash for Discriminant { + fn hash(&self, state: &mut H) { + self.0.hash(state); + } +} + +#[stable(feature = "discriminant_value", since = "1.21.0")] +impl fmt::Debug for Discriminant { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt.debug_tuple("Discriminant") + .field(&self.0) + .finish() + } +} + +/// Returns a value uniquely identifying the enum variant in `v`. +/// +/// If `T` is not an enum, calling this function will not result in undefined behavior, but the +/// return value is unspecified. +/// +/// # Stability +/// +/// The discriminant of an enum variant may change if the enum definition changes. A discriminant +/// of some variant will not change between compilations with the same compiler. +/// +/// # Examples +/// +/// This can be used to compare enums that carry data, while disregarding +/// the actual data: +/// +/// ``` +/// use std::mem; +/// +/// enum Foo { A(&'static str), B(i32), C(i32) } +/// +/// assert!(mem::discriminant(&Foo::A("bar")) == mem::discriminant(&Foo::A("baz"))); +/// assert!(mem::discriminant(&Foo::B(1)) == mem::discriminant(&Foo::B(2))); +/// assert!(mem::discriminant(&Foo::B(3)) != mem::discriminant(&Foo::C(3))); +/// ``` +#[stable(feature = "discriminant_value", since = "1.21.0")] +pub fn discriminant(v: &T) -> Discriminant { + unsafe { + Discriminant(intrinsics::discriminant_value(v), PhantomData) + } +} From 3f3087bb7f78426d033e95c3d2dcecce8878d02e Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 29 May 2019 12:12:09 +0200 Subject: [PATCH 57/65] Simplify Set1::insert. --- src/librustc/middle/resolve_lifetime.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 736b4633b38..593a09b6866 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -170,16 +170,11 @@ pub enum Set1 { impl Set1 { pub fn insert(&mut self, value: T) { - if let Set1::Empty = *self { - *self = Set1::One(value); - return; - } - if let Set1::One(ref old) = *self { - if *old == value { - return; - } - } - *self = Set1::Many; + *self = match self { + Set1::Empty => Set1::One(value), + Set1::One(old) if *old == value => return, + _ => Set1::Many, + }; } } From d0b37744904fb73244f36c69c8898eef2c4b566f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 29 May 2019 12:28:45 +0200 Subject: [PATCH 58/65] bless you --- src/test/ui/consts/const-size_of-cycle.stderr | 2 +- src/test/ui/type_length_limit.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/consts/const-size_of-cycle.stderr b/src/test/ui/consts/const-size_of-cycle.stderr index 3762f5e3d6a..113ec292396 100644 --- a/src/test/ui/consts/const-size_of-cycle.stderr +++ b/src/test/ui/consts/const-size_of-cycle.stderr @@ -5,7 +5,7 @@ LL | bytes: [u8; std::mem::size_of::()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...which requires const-evaluating `Foo::bytes::{{constant}}#0`... - --> $SRC_DIR/libcore/mem.rs:LL:COL + --> $SRC_DIR/libcore/mem/mod.rs:LL:COL | LL | intrinsics::size_of::() | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/type_length_limit.stderr b/src/test/ui/type_length_limit.stderr index 9d07c86356b..7e308f107ba 100644 --- a/src/test/ui/type_length_limit.stderr +++ b/src/test/ui/type_length_limit.stderr @@ -1,5 +1,5 @@ error: reached the type-length limit while instantiating `std::mem::drop::>` - --> $SRC_DIR/libcore/mem.rs:LL:COL + --> $SRC_DIR/libcore/mem/mod.rs:LL:COL | LL | pub fn drop(_x: T) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ From a19a9e9194a03add87cd10aacfe518a61487cf0d Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 29 May 2019 14:32:38 +0200 Subject: [PATCH 59/65] Make run-make PGO tests work on MSVC. --- src/test/run-make-fulldeps/pgo-gen-lto/Makefile | 12 +++++++++++- .../pgo-gen-no-imp-symbols/Makefile | 12 +++++++++++- src/test/run-make-fulldeps/pgo-gen/Makefile | 12 +++++++++++- src/test/run-make-fulldeps/pgo-use/Makefile | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/test/run-make-fulldeps/pgo-gen-lto/Makefile b/src/test/run-make-fulldeps/pgo-gen-lto/Makefile index 48181bcbdc6..56f31434ade 100644 --- a/src/test/run-make-fulldeps/pgo-gen-lto/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen-lto/Makefile @@ -2,7 +2,17 @@ -include ../tools.mk +COMPILE_FLAGS=-Copt-level=3 -Clto=fat -Z pgo-gen="$(TMPDIR)" + +# LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC: +# https://github.com/rust-lang/rust/issues/61002 +# +# Things work fine with -Cpanic=abort though. +ifdef IS_MSVC +COMPILE_FLAGS+= -Cpanic=abort +endif + all: - $(RUSTC) -Copt-level=3 -Clto=fat -Z pgo-gen="$(TMPDIR)" test.rs + $(RUSTC) $(COMPILE_FLAGS) test.rs $(call RUN,test) || exit 1 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1) diff --git a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile index 20977edb88e..bb86160d2df 100644 --- a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile @@ -2,8 +2,18 @@ -include ../tools.mk +COMPILE_FLAGS=-O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)" + +# LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC: +# https://github.com/rust-lang/rust/issues/61002 +# +# Things work fine with -Cpanic=abort though. +ifdef IS_MSVC +COMPILE_FLAGS+= -Cpanic=abort +endif + all: - $(RUSTC) -O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)" --emit=llvm-ir test.rs + $(RUSTC) $(COMPILE_FLAGS) --emit=llvm-ir test.rs # We expect symbols starting with "__llvm_profile_". $(CGREP) "__llvm_profile_" < $(TMPDIR)/test.ll # We do NOT expect the "__imp_" version of these symbols. diff --git a/src/test/run-make-fulldeps/pgo-gen/Makefile b/src/test/run-make-fulldeps/pgo-gen/Makefile index ce44c10a7c2..f0ab3b7d13d 100644 --- a/src/test/run-make-fulldeps/pgo-gen/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen/Makefile @@ -2,7 +2,17 @@ -include ../tools.mk +COMPILE_FLAGS=-g -Z pgo-gen="$(TMPDIR)" + +# LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC: +# https://github.com/rust-lang/rust/issues/61002 +# +# Things work fine with -Cpanic=abort though. +ifdef IS_MSVC +COMPILE_FLAGS+= -Cpanic=abort +endif + all: - $(RUSTC) -g -Z pgo-gen="$(TMPDIR)" test.rs + $(RUSTC) $(COMPILE_FLAGS) test.rs $(call RUN,test) || exit 1 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1) diff --git a/src/test/run-make-fulldeps/pgo-use/Makefile b/src/test/run-make-fulldeps/pgo-use/Makefile index ababd45d33e..72c3c34ee37 100644 --- a/src/test/run-make-fulldeps/pgo-use/Makefile +++ b/src/test/run-make-fulldeps/pgo-use/Makefile @@ -16,7 +16,7 @@ COMMON_FLAGS=-Copt-level=s -Ccodegen-units=1 # LLVM doesn't support instrumenting binaries that use SEH: -# https://bugs.llvm.org/show_bug.cgi?id=41279 +# https://github.com/rust-lang/rust/issues/61002 # # Things work fine with -Cpanic=abort though. ifdef IS_MSVC From 3eda151086c3fe5ad49c7c3f5e68e9bf9b938de8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 28 May 2019 13:20:43 -0700 Subject: [PATCH 60/65] Update all s3 URLs used on CI with subdomains Ensure that they're all forwards-compatible with AWS updates happening next year by ensuring the bucket name shows up in the domain name. Closes #61168 --- .azure-pipelines/auto.yml | 12 +++++------ .azure-pipelines/steps/install-clang.yml | 2 +- .azure-pipelines/steps/install-sccache.yml | 4 ++-- .../steps/install-windows-build-deps.yml | 2 +- appveyor.yml | 20 +++++++++---------- src/ci/docker/armhf-gnu/Dockerfile | 2 +- .../dist-various-1/install-mips-musl.sh | 2 +- .../dist-various-1/install-mipsel-musl.sh | 2 +- .../dist-various-2/build-wasi-toolchain.sh | 2 +- .../docker/dist-x86_64-linux/build-openssl.sh | 2 +- .../build-netbsd-toolchain.sh | 2 +- src/ci/docker/scripts/emscripten.sh | 2 +- src/ci/docker/scripts/freebsd-toolchain.sh | 2 +- src/ci/docker/scripts/sccache.sh | 2 +- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.azure-pipelines/auto.yml b/.azure-pipelines/auto.yml index 4cdf8423c08..c824c918280 100644 --- a/.azure-pipelines/auto.yml +++ b/.azure-pipelines/auto.yml @@ -274,7 +274,7 @@ jobs: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu SCRIPT: make ci-subset-1 - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 # FIXME(#59637) @@ -284,14 +284,14 @@ jobs: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu SCRIPT: make ci-subset-2 - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 x86_64-mingw-1: MSYS_BITS: 64 SCRIPT: make ci-subset-1 RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 # FIXME(#59637) @@ -301,7 +301,7 @@ jobs: MSYS_BITS: 64 SCRIPT: make ci-subset-2 RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 @@ -328,7 +328,7 @@ jobs: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-full-tools SCRIPT: python x.py dist - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 DIST_REQUIRE_ALL_TOOLS: 1 @@ -337,7 +337,7 @@ jobs: MSYS_BITS: 64 SCRIPT: python x.py dist RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-full-tools - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 DIST_REQUIRE_ALL_TOOLS: 1 diff --git a/.azure-pipelines/steps/install-clang.yml b/.azure-pipelines/steps/install-clang.yml index 26a223282cd..e1a6ea510d0 100644 --- a/.azure-pipelines/steps/install-clang.yml +++ b/.azure-pipelines/steps/install-clang.yml @@ -27,7 +27,7 @@ steps: # Original downloaded here came from # http://releases.llvm.org/7.0.0/LLVM-7.0.0-win64.exe - script: | - powershell -Command "iwr -outf %TEMP%\LLVM-7.0.0-win64.exe https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/LLVM-7.0.0-win64.exe" + powershell -Command "iwr -outf %TEMP%\LLVM-7.0.0-win64.exe https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/LLVM-7.0.0-win64.exe" set CLANG_DIR=%CD%\citools\clang-rust %TEMP%\LLVM-7.0.0-win64.exe /S /NCRC /D=%CLANG_DIR% set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --set llvm.clang-cl=%CLANG_DIR%\bin\clang-cl.exe diff --git a/.azure-pipelines/steps/install-sccache.yml b/.azure-pipelines/steps/install-sccache.yml index 39f58002a73..7622f716cc8 100644 --- a/.azure-pipelines/steps/install-sccache.yml +++ b/.azure-pipelines/steps/install-sccache.yml @@ -2,14 +2,14 @@ steps: - bash: | set -e - curl -fo /usr/local/bin/sccache https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-04-02-sccache-x86_64-apple-darwin + curl -fo /usr/local/bin/sccache https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-02-sccache-x86_64-apple-darwin chmod +x /usr/local/bin/sccache displayName: Install sccache (OSX) condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) - script: | md sccache - powershell -Command "iwr -outf sccache\sccache.exe https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-04-26-sccache-x86_64-pc-windows-msvc" + powershell -Command "iwr -outf sccache\sccache.exe https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-26-sccache-x86_64-pc-windows-msvc" echo ##vso[task.prependpath]%CD%\sccache displayName: Install sccache (Windows) condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) diff --git a/.azure-pipelines/steps/install-windows-build-deps.yml b/.azure-pipelines/steps/install-windows-build-deps.yml index 037c8daa2a8..d79ebe973ba 100644 --- a/.azure-pipelines/steps/install-windows-build-deps.yml +++ b/.azure-pipelines/steps/install-windows-build-deps.yml @@ -81,7 +81,7 @@ steps: # Note that this is originally from the github releases patch of Ninja - script: | md ninja - powershell -Command "iwr -outf 2017-03-15-ninja-win.zip https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-15-ninja-win.zip" + powershell -Command "iwr -outf 2017-03-15-ninja-win.zip https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2017-03-15-ninja-win.zip" 7z x -oninja 2017-03-15-ninja-win.zip del 2017-03-15-ninja-win.zip set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --enable-ninja diff --git a/appveyor.yml b/appveyor.yml index 6dc33f30c7e..cd9011730aa 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -59,7 +59,7 @@ environment: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu SCRIPT: make ci-subset-1 - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 # FIXME(#59637) @@ -69,14 +69,14 @@ environment: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu SCRIPT: make ci-subset-2 - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 - CI_JOB_NAME: x86_64-mingw MSYS_BITS: 64 SCRIPT: python x.py test RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 # FIXME(#59637) @@ -106,7 +106,7 @@ environment: MSYS_BITS: 32 RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-full-tools --enable-profiler SCRIPT: python x.py dist - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: i686-6.3.0-release-posix-dwarf-rt_v5-rev2.7z MINGW_DIR: mingw32 DIST_REQUIRE_ALL_TOOLS: 1 @@ -115,7 +115,7 @@ environment: MSYS_BITS: 64 SCRIPT: python x.py dist RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-full-tools --enable-profiler - MINGW_URL: https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror + MINGW_URL: https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror MINGW_ARCHIVE: x86_64-6.3.0-release-posix-seh-rt_v5-rev2.7z MINGW_DIR: mingw64 DIST_REQUIRE_ALL_TOOLS: 1 @@ -159,7 +159,7 @@ install: # # Original downloaded here came from # http://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe - - if NOT defined MINGW_URL appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/LLVM-8.0.0-win64.exe + - if NOT defined MINGW_URL appveyor-retry appveyor DownloadFile https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/LLVM-8.0.0-win64.exe - if NOT defined MINGW_URL .\LLVM-8.0.0-win64.exe /S /NCRC /D=C:\clang-rust - if NOT defined MINGW_URL set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --set llvm.clang-cl=C:\clang-rust\bin\clang-cl.exe @@ -191,25 +191,25 @@ install: - set PATH=C:\Python27;%PATH% # Download and install sccache - - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-04-26-sccache-x86_64-pc-windows-msvc + - appveyor-retry appveyor DownloadFile https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-26-sccache-x86_64-pc-windows-msvc - mv 2018-04-26-sccache-x86_64-pc-windows-msvc sccache.exe - set PATH=%PATH%;%CD% # Download and install ninja # # Note that this is originally from the github releases patch of Ninja - - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-15-ninja-win.zip + - appveyor-retry appveyor DownloadFile https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2017-03-15-ninja-win.zip - 7z x 2017-03-15-ninja-win.zip - set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --enable-ninja # - set PATH=%PATH%;%CD% -- this already happens above for sccache # Install InnoSetup to get `iscc` used to produce installers - - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-08-22-is.exe + - appveyor-retry appveyor DownloadFile https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2017-08-22-is.exe - 2017-08-22-is.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- - set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH% # Help debug some handle issues on AppVeyor - - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-05-15-Handle.zip + - appveyor-retry appveyor DownloadFile https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2017-05-15-Handle.zip - mkdir handle - 7z x -ohandle 2017-05-15-Handle.zip - set PATH=%PATH%;%CD%\handle diff --git a/src/ci/docker/armhf-gnu/Dockerfile b/src/ci/docker/armhf-gnu/Dockerfile index e4c2097f970..235920833f8 100644 --- a/src/ci/docker/armhf-gnu/Dockerfile +++ b/src/ci/docker/armhf-gnu/Dockerfile @@ -72,7 +72,7 @@ RUN arm-linux-gnueabihf-gcc addentropy.c -o rootfs/addentropy -static # TODO: What is this?! # Source of the file: https://github.com/vfdev-5/qemu-rpi2-vexpress/raw/master/vexpress-v2p-ca15-tc1.dtb -RUN curl -O https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/vexpress-v2p-ca15-tc1.dtb +RUN curl -O https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/vexpress-v2p-ca15-tc1.dtb COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh diff --git a/src/ci/docker/dist-various-1/install-mips-musl.sh b/src/ci/docker/dist-various-1/install-mips-musl.sh index 8d05a046959..60a96e3b8e9 100755 --- a/src/ci/docker/dist-various-1/install-mips-musl.sh +++ b/src/ci/docker/dist-various-1/install-mips-musl.sh @@ -5,7 +5,7 @@ mkdir /usr/local/mips-linux-musl # originally from # https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/ # OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2 -URL="https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror" +URL="https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror" FILE="OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz2" curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mips-linux-musl --strip-components=2 diff --git a/src/ci/docker/dist-various-1/install-mipsel-musl.sh b/src/ci/docker/dist-various-1/install-mipsel-musl.sh index 2c414744bf4..9ae41218ee4 100755 --- a/src/ci/docker/dist-various-1/install-mipsel-musl.sh +++ b/src/ci/docker/dist-various-1/install-mipsel-musl.sh @@ -5,7 +5,7 @@ mkdir /usr/local/mipsel-linux-musl # Note that this originally came from: # https://downloads.openwrt.org/snapshots/trunk/malta/generic/ # OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 -URL="https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc" +URL="https://rust-lang-ci2.s3.amazonaws.com/libc" FILE="OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2" curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mipsel-linux-musl --strip-components=2 diff --git a/src/ci/docker/dist-various-2/build-wasi-toolchain.sh b/src/ci/docker/dist-various-2/build-wasi-toolchain.sh index 98d6df043ba..7bf8946c4f1 100755 --- a/src/ci/docker/dist-various-2/build-wasi-toolchain.sh +++ b/src/ci/docker/dist-various-2/build-wasi-toolchain.sh @@ -5,7 +5,7 @@ set -ex # Originally from https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz -curl https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/clang%2Bllvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | \ +curl https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/clang%2Bllvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | \ tar xJf - export PATH=`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH diff --git a/src/ci/docker/dist-x86_64-linux/build-openssl.sh b/src/ci/docker/dist-x86_64-linux/build-openssl.sh index 7e391e21d13..13dae616905 100755 --- a/src/ci/docker/dist-x86_64-linux/build-openssl.sh +++ b/src/ci/docker/dist-x86_64-linux/build-openssl.sh @@ -4,7 +4,7 @@ set -ex source shared.sh VERSION=1.0.2k -URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/openssl-$VERSION.tar.gz +URL=https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/openssl-$VERSION.tar.gz curl $URL | tar xzf - diff --git a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh index b5377c64b1f..2e9b9dcc234 100755 --- a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh +++ b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh @@ -25,7 +25,7 @@ cd netbsd mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot -URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror +URL=https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror # Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/source/sets/*.tgz curl $URL/2018-03-01-netbsd-src.tgz | tar xzf - diff --git a/src/ci/docker/scripts/emscripten.sh b/src/ci/docker/scripts/emscripten.sh index d3b1cded6f5..47196e89396 100644 --- a/src/ci/docker/scripts/emscripten.sh +++ b/src/ci/docker/scripts/emscripten.sh @@ -18,7 +18,7 @@ exit 1 } cd / -curl -fL https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ +curl -fL https://mozilla-games.s3.amazonaws.com/emscripten/releases/emsdk-portable.tar.gz | \ tar -xz cd /emsdk-portable diff --git a/src/ci/docker/scripts/freebsd-toolchain.sh b/src/ci/docker/scripts/freebsd-toolchain.sh index b1ac490a878..8cef69d9c26 100755 --- a/src/ci/docker/scripts/freebsd-toolchain.sh +++ b/src/ci/docker/scripts/freebsd-toolchain.sh @@ -59,7 +59,7 @@ done # Originally downloaded from: # https://download.freebsd.org/ftp/releases/${freebsd_arch}/${freebsd_version}-RELEASE/base.txz -URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2019-04-04-freebsd-${freebsd_arch}-${freebsd_version}-RELEASE-base.txz +URL=https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2019-04-04-freebsd-${freebsd_arch}-${freebsd_version}-RELEASE-base.txz curl "$URL" | tar xJf - -C "$sysroot" --wildcards "${files_to_extract[@]}" # Fix up absolute symlinks from the system image. This can be removed diff --git a/src/ci/docker/scripts/sccache.sh b/src/ci/docker/scripts/sccache.sh index 4c03419894e..194de3c339f 100644 --- a/src/ci/docker/scripts/sccache.sh +++ b/src/ci/docker/scripts/sccache.sh @@ -1,6 +1,6 @@ set -ex curl -fo /usr/local/bin/sccache \ - https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-04-02-sccache-x86_64-unknown-linux-musl + https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/2018-04-02-sccache-x86_64-unknown-linux-musl chmod +x /usr/local/bin/sccache From ed8a4d5bc1abd12695dba6c1c7d4f42d553aa3f1 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Mon, 13 May 2019 17:18:21 -0400 Subject: [PATCH 61/65] upgrade rustdoc's `pulldown-cmark` to 0.5.2 Fixes #60482. --- Cargo.lock | 25 +++++++------------------ src/librustdoc/Cargo.toml | 2 +- src/librustdoc/html/markdown.rs | 10 +++++----- src/test/rustdoc/issue-60482.rs | 9 +++++++++ 4 files changed, 22 insertions(+), 24 deletions(-) create mode 100644 src/test/rustdoc/issue-60482.rs diff --git a/Cargo.lock b/Cargo.lock index d5e2969e964..9bb9e480588 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -421,7 +421,7 @@ dependencies = [ "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pulldown-cmark 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2014,23 +2014,13 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pulldown-cmark" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3077,7 +3067,7 @@ version = "0.0.0" dependencies = [ "minifier 0.0.30 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pulldown-cmark 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3854,7 +3844,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicase" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4285,8 +4275,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" "checksum proptest 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24f5844db2f839e97e3021980975f6ebf8691d9b9b2ca67ed3feb38dc3edb52c" "checksum pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32" -"checksum pulldown-cmark 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d1b74cc784b038a9921fd1a48310cc2e238101aa8ae0b94201e2d85121dd68b5" -"checksum pulldown-cmark 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "157737d41407de9c5e0563a991d085117d60ae729af2cc1bf28d6dfbc97bcc1f" +"checksum pulldown-cmark 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "051e60ace841b3bfecd402fe5051c06cb3bec4a6e6fdd060a37aa8eb829a1db3" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" @@ -4400,7 +4389,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41d17211f887da8e4a70a45b9536f26fc5de166b81e2d5d80de4a17fd22553bd" +"checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25" "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 6cedab412df..b75212d606f 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -9,7 +9,7 @@ name = "rustdoc" path = "lib.rs" [dependencies] -pulldown-cmark = { version = "0.4.1", default-features = false } +pulldown-cmark = { version = "0.5.2", default-features = false } minifier = "0.0.30" tempfile = "3" parking_lot = "0.7" diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 12d10254c4d..334b8315650 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -351,9 +351,11 @@ impl<'a, 'b, 'ids, I: Iterator>> Iterator for HeadingLinks<'a, if let Some(Event::Start(Tag::Header(level))) = event { let mut id = String::new(); for event in &mut self.inner { - match event { + match &event { Event::End(Tag::Header(..)) => break, - Event::Text(ref text) => id.extend(text.chars().filter_map(slugify)), + Event::Text(text) | Event::Code(text) => { + id.extend(text.chars().filter_map(slugify)); + } _ => {}, } self.buf.push_back(event); @@ -402,7 +404,6 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool { | Tag::Item | Tag::Emphasis | Tag::Strong - | Tag::Code | Tag::Link(..) | Tag::BlockQuote => true, _ => false, @@ -790,9 +791,8 @@ pub fn plain_summary_line_full(md: &str, limit_length: bool) -> String { let next_event = next_event.unwrap(); let (ret, is_in) = match next_event { Event::Start(Tag::Paragraph) => (None, 1), - Event::Start(Tag::Code) => (Some("`".to_owned()), 1), - Event::End(Tag::Code) => (Some("`".to_owned()), -1), Event::Start(Tag::Header(_)) => (None, 1), + Event::Code(code) => (Some(format!("`{}`", code)), 0), Event::Text(ref s) if self.is_in > 0 => (Some(s.as_ref().to_owned()), 0), Event::End(Tag::Paragraph) | Event::End(Tag::Header(_)) => (None, -1), _ => (None, 0), diff --git a/src/test/rustdoc/issue-60482.rs b/src/test/rustdoc/issue-60482.rs new file mode 100644 index 00000000000..0fd1daa746d --- /dev/null +++ b/src/test/rustdoc/issue-60482.rs @@ -0,0 +1,9 @@ +// This code caused a panic in `pulldown-cmark` 0.4.1. + +pub const BASIC_UNICODE: bool = true; + + +/// # `BASIC_UNICODE`: `A` `|` +/// ```text +/// ``` +pub const BASIC_FONTS: bool = true; From 5f4f3684b93180097b8ed6a53b7090fc4e7d884c Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 29 May 2019 17:57:28 +0200 Subject: [PATCH 62/65] ci: display more debug information in the init_repo script --- src/ci/init_repo.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ci/init_repo.sh b/src/ci/init_repo.sh index 3dfd3381576..8b635810825 100755 --- a/src/ci/init_repo.sh +++ b/src/ci/init_repo.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +# FIXME(61301): we need to debug spurious failures with this on Windows on +# Azure, so let's print more information in the logs. +set -x + set -o errexit set -o pipefail set -o nounset From 5d72ac36393cace0ef7845c39cc46a9555dfdcb8 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 29 May 2019 17:58:44 +0200 Subject: [PATCH 63/65] libsyntax: introduce 'fn is_keyword_ahead(dist, keywords)'. --- src/libsyntax/parse/parser.rs | 73 ++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 07efeaa4cf2..746e9cad496 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1087,6 +1087,11 @@ impl<'a> Parser<'a> { } } + /// Returns whether any of the given keywords are `dist` tokens ahead of the current one. + fn is_keyword_ahead(&self, dist: usize, kws: &[Symbol]) -> bool { + self.look_ahead(dist, |t| kws.iter().any(|&kw| t.is_keyword(kw))) + } + /// Is the current token one of the keywords that signals a bare function type? fn token_is_bare_fn_keyword(&mut self) -> bool { self.check_keyword(kw::Fn) || @@ -4270,7 +4275,7 @@ impl<'a> Parser<'a> { self.token.is_keyword(kw::Async) && ( ( // `async move {` - self.look_ahead(1, |t| t.is_keyword(kw::Move)) && + self.is_keyword_ahead(1, &[kw::Move]) && self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace)) ) || ( // `async {` self.look_ahead(1, |t| *t == token::OpenDelim(token::Brace)) @@ -4280,12 +4285,12 @@ impl<'a> Parser<'a> { fn is_async_fn(&self) -> bool { self.token.is_keyword(kw::Async) && - self.look_ahead(1, |t| t.is_keyword(kw::Fn)) + self.is_keyword_ahead(1, &[kw::Fn]) } fn is_do_catch_block(&self) -> bool { self.token.is_keyword(kw::Do) && - self.look_ahead(1, |t| t.is_keyword(kw::Catch)) && + self.is_keyword_ahead(1, &[kw::Catch]) && self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace)) && !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL) } @@ -4309,17 +4314,17 @@ impl<'a> Parser<'a> { fn is_existential_type_decl(&self) -> bool { self.token.is_keyword(kw::Existential) && - self.look_ahead(1, |t| t.is_keyword(kw::Type)) + self.is_keyword_ahead(1, &[kw::Type]) } fn is_auto_trait_item(&self) -> bool { // auto trait - (self.token.is_keyword(kw::Auto) - && self.look_ahead(1, |t| t.is_keyword(kw::Trait))) + (self.token.is_keyword(kw::Auto) && + self.is_keyword_ahead(1, &[kw::Trait])) || // unsafe auto trait (self.token.is_keyword(kw::Unsafe) && - self.look_ahead(1, |t| t.is_keyword(kw::Auto)) && - self.look_ahead(2, |t| t.is_keyword(kw::Trait))) + self.is_keyword_ahead(1, &[kw::Auto]) && + self.is_keyword_ahead(2, &[kw::Trait])) } fn eat_macro_def(&mut self, attrs: &[Attribute], vis: &Visibility, lo: Span) @@ -5486,7 +5491,7 @@ impl<'a> Parser<'a> { (if isolated_self(self, 1) { self.bump(); SelfKind::Region(None, Mutability::Immutable) - } else if self.look_ahead(1, |t| t.is_keyword(kw::Mut)) && + } else if self.is_keyword_ahead(1, &[kw::Mut]) && isolated_self(self, 2) { self.bump(); self.bump(); @@ -5497,7 +5502,7 @@ impl<'a> Parser<'a> { let lt = self.expect_lifetime(); SelfKind::Region(Some(lt), Mutability::Immutable) } else if self.look_ahead(1, |t| t.is_lifetime()) && - self.look_ahead(2, |t| t.is_keyword(kw::Mut)) && + self.is_keyword_ahead(2, &[kw::Mut]) && isolated_self(self, 3) { self.bump(); let lt = self.expect_lifetime(); @@ -5676,8 +5681,7 @@ impl<'a> Parser<'a> { /// (returns `false` for things like `const fn`, etc.). fn is_const_item(&self) -> bool { self.token.is_keyword(kw::Const) && - !self.look_ahead(1, |t| t.is_keyword(kw::Fn)) && - !self.look_ahead(1, |t| t.is_keyword(kw::Unsafe)) + !self.is_keyword_ahead(1, &[kw::Fn, kw::Unsafe]) } /// Parses all the "front matter" for a `fn` declaration, up to @@ -5955,7 +5959,7 @@ impl<'a> Parser<'a> { self.look_ahead(1, |t| t.is_lifetime() || t.is_ident()) && self.look_ahead(2, |t| t == &token::Gt || t == &token::Comma || t == &token::Colon || t == &token::Eq) || - self.look_ahead(1, |t| t.is_keyword(kw::Const))) + self.is_keyword_ahead(1, &[kw::Const])) } fn parse_impl_body(&mut self) -> PResult<'a, (Vec, Vec)> { @@ -6316,7 +6320,7 @@ impl<'a> Parser<'a> { // `()` or a tuple might be allowed. For example, `struct Struct(pub (), pub (usize));`. // Because of this, we only `bump` the `(` if we're assured it is appropriate to do so // by the following tokens. - if self.look_ahead(1, |t| t.is_keyword(kw::Crate)) && + if self.is_keyword_ahead(1, &[kw::Crate]) && self.look_ahead(2, |t| t != &token::ModSep) // account for `pub(crate::foo)` { // `pub(crate)` @@ -6328,7 +6332,7 @@ impl<'a> Parser<'a> { VisibilityKind::Crate(CrateSugar::PubCrate), ); return Ok(vis) - } else if self.look_ahead(1, |t| t.is_keyword(kw::In)) { + } else if self.is_keyword_ahead(1, &[kw::In]) { // `pub(in path)` self.bump(); // `(` self.bump(); // `in` @@ -6340,8 +6344,7 @@ impl<'a> Parser<'a> { }); return Ok(vis) } else if self.look_ahead(2, |t| t == &token::CloseDelim(token::Paren)) && - self.look_ahead(1, |t| t.is_keyword(kw::Super) || - t.is_keyword(kw::SelfLower)) + self.is_keyword_ahead(1, &[kw::Super, kw::SelfLower]) { // `pub(self)` or `pub(super)` self.bump(); // `(` @@ -6380,13 +6383,16 @@ impl<'a> Parser<'a> { fn parse_defaultness(&mut self) -> Defaultness { // `pub` is included for better error messages if self.check_keyword(kw::Default) && - self.look_ahead(1, |t| t.is_keyword(kw::Impl) || - t.is_keyword(kw::Const) || - t.is_keyword(kw::Fn) || - t.is_keyword(kw::Unsafe) || - t.is_keyword(kw::Extern) || - t.is_keyword(kw::Type) || - t.is_keyword(kw::Pub)) { + self.is_keyword_ahead(1, &[ + kw::Impl, + kw::Const, + kw::Fn, + kw::Unsafe, + kw::Extern, + kw::Type, + kw::Pub, + ]) + { self.bump(); // `default` Defaultness::Default } else { @@ -6880,7 +6886,7 @@ impl<'a> Parser<'a> { // Ident ["<"...">"] ["where" ...] ("=" | ":") Ty ";" if self.check_keyword(kw::Type) || self.check_keyword(kw::Existential) && - self.look_ahead(1, |t| t.is_keyword(kw::Type)) { + self.is_keyword_ahead(1, &[kw::Type]) { let existential = self.eat_keyword(kw::Existential); assert!(self.eat_keyword(kw::Type)); Some(self.parse_existential_or_alias(existential)) @@ -7157,7 +7163,7 @@ impl<'a> Parser<'a> { let const_span = self.prev_span; if self.check_keyword(kw::Fn) || (self.check_keyword(kw::Unsafe) - && self.look_ahead(1, |t| t.is_keyword(kw::Fn))) { + && self.is_keyword_ahead(1, &[kw::Fn])) { // CONST FUNCTION ITEM let unsafety = self.parse_unsafety(); self.bump(); @@ -7202,10 +7208,10 @@ impl<'a> Parser<'a> { // `unsafe async fn` or `async fn` if ( self.check_keyword(kw::Unsafe) && - self.look_ahead(1, |t| t.is_keyword(kw::Async)) + self.is_keyword_ahead(1, &[kw::Async]) ) || ( self.check_keyword(kw::Async) && - self.look_ahead(1, |t| t.is_keyword(kw::Fn)) + self.is_keyword_ahead(1, &[kw::Fn]) ) { // ASYNC FUNCTION ITEM @@ -7239,8 +7245,7 @@ impl<'a> Parser<'a> { return Ok(Some(item)); } if self.check_keyword(kw::Unsafe) && - (self.look_ahead(1, |t| t.is_keyword(kw::Trait)) || - self.look_ahead(1, |t| t.is_keyword(kw::Auto))) + self.is_keyword_ahead(1, &[kw::Trait, kw::Auto]) { // UNSAFE TRAIT ITEM self.bump(); // `unsafe` @@ -7263,11 +7268,9 @@ impl<'a> Parser<'a> { } if self.check_keyword(kw::Impl) || self.check_keyword(kw::Unsafe) && - self.look_ahead(1, |t| t.is_keyword(kw::Impl)) || + self.is_keyword_ahead(1, &[kw::Impl]) || self.check_keyword(kw::Default) && - self.look_ahead(1, |t| t.is_keyword(kw::Impl)) || - self.check_keyword(kw::Default) && - self.look_ahead(1, |t| t.is_keyword(kw::Unsafe)) { + self.is_keyword_ahead(1, &[kw::Impl, kw::Unsafe]) { // IMPL ITEM let defaultness = self.parse_defaultness(); let unsafety = self.parse_unsafety(); @@ -7360,7 +7363,7 @@ impl<'a> Parser<'a> { } if self.check_keyword(kw::Trait) || (self.check_keyword(kw::Auto) - && self.look_ahead(1, |t| t.is_keyword(kw::Trait))) + && self.is_keyword_ahead(1, &[kw::Trait])) { let is_auto = if self.eat_keyword(kw::Trait) { IsAuto::No From eafa3a888f1aac52a7499fb464414519c434a7ce Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 30 May 2019 00:20:52 +0100 Subject: [PATCH 64/65] Sort in-band generic parameter definitions from APIT --- src/librustc/hir/lowering.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index c5bcddcb266..08fbd0d20d7 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1083,6 +1083,18 @@ impl<'a> LoweringContext<'a> { .chain(in_band_defs) .collect(); + // FIXME(const_generics): the compiler doesn't always cope with + // unsorted generic parameters at the moment, so we make sure + // that they're ordered correctly here for now. (When we chain + // the `in_band_defs`, we might make the order unsorted.) + lowered_generics.params.sort_by_key(|param| { + match param.kind { + hir::GenericParamKind::Lifetime { .. } => ParamKindOrd::Lifetime, + hir::GenericParamKind::Type { .. } => ParamKindOrd::Type, + hir::GenericParamKind::Const { .. } => ParamKindOrd::Const, + } + }); + (lowered_generics, res) } From 998ef688a39a1b842b5d0a71ea92a8f825650975 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 30 May 2019 00:21:04 +0100 Subject: [PATCH 65/65] Add a regression test for const parameters with impl Trait --- src/test/ui/const-generics/apit-with-const-param.rs | 10 ++++++++++ .../ui/const-generics/apit-with-const-param.stderr | 6 ++++++ 2 files changed, 16 insertions(+) create mode 100644 src/test/ui/const-generics/apit-with-const-param.rs create mode 100644 src/test/ui/const-generics/apit-with-const-param.stderr diff --git a/src/test/ui/const-generics/apit-with-const-param.rs b/src/test/ui/const-generics/apit-with-const-param.rs new file mode 100644 index 00000000000..70e718d8890 --- /dev/null +++ b/src/test/ui/const-generics/apit-with-const-param.rs @@ -0,0 +1,10 @@ +// run-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +trait Trait {} + +fn f(_: impl Trait) {} + +fn main() {} diff --git a/src/test/ui/const-generics/apit-with-const-param.stderr b/src/test/ui/const-generics/apit-with-const-param.stderr new file mode 100644 index 00000000000..b3038ee6488 --- /dev/null +++ b/src/test/ui/const-generics/apit-with-const-param.stderr @@ -0,0 +1,6 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/apit-with-const-param.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ +