diff options
| author | bors <bors@rust-lang.org> | 2020-01-24 08:32:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-24 08:32:10 +0000 |
| commit | dee12bb2b7d75cce8fc8f21b5d7ea0da920df5e5 (patch) | |
| tree | 3f0255955f4d43f524452b720ab33e6e64825836 /src/libcore | |
| parent | 62f227b3f822a27bd603acede9137bfb49ca8b68 (diff) | |
| parent | 7f8a61d96c5a628ffb88304eb84a85140479ecad (diff) | |
| download | rust-dee12bb2b7d75cce8fc8f21b5d7ea0da920df5e5.tar.gz rust-dee12bb2b7d75cce8fc8f21b5d7ea0da920df5e5.zip | |
Auto merge of #68506 - tmandry:rollup-kz9d33v, r=tmandry
Rollup of 7 pull requests Successful merges: - #68424 (Suggest borrowing `Vec<NonCopy>` in for loop) - #68438 (Account for non-types in substs for opaque type error messages) - #68469 (Avoid overflow in `std::iter::Skip::count`) - #68473 (Enable ASan on Fuchsia) - #68479 (Implement `unused_parens` for block return values) - #68483 (Add my (@flip1995) name to .mailmap) - #68500 (Clear out std, not std tools) Failed merges: r? @ghost
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/iter/adapters/mod.rs | 10 | ||||
| -rw-r--r-- | src/libcore/option.rs | 1 | ||||
| -rw-r--r-- | src/libcore/result.rs | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs index 6eb837ed0fe..5787b9174ed 100644 --- a/src/libcore/iter/adapters/mod.rs +++ b/src/libcore/iter/adapters/mod.rs @@ -1815,8 +1815,14 @@ where } #[inline] - fn count(self) -> usize { - self.iter.count().saturating_sub(self.n) + fn count(mut self) -> usize { + if self.n > 0 { + // nth(n) skips n+1 + if self.iter.nth(self.n - 1).is_none() { + return 0; + } + } + self.iter.count() } #[inline] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index a471b174534..cb4247d9874 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -151,6 +151,7 @@ use crate::{ /// The `Option` type. See [the module level documentation](index.html) for more. #[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] +#[rustc_diagnostic_item = "option_type"] #[stable(feature = "rust1", since = "1.0.0")] pub enum Option<T> { /// No value diff --git a/src/libcore/result.rs b/src/libcore/result.rs index c657ce33f60..bc70dbd62eb 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -242,6 +242,7 @@ use crate::ops::{self, Deref, DerefMut}; /// [`Err`]: enum.Result.html#variant.Err #[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] #[must_use = "this `Result` may be an `Err` variant, which should be handled"] +#[rustc_diagnostic_item = "result_type"] #[stable(feature = "rust1", since = "1.0.0")] pub enum Result<T, E> { /// Contains the success value |
