-
Notifications
You must be signed in to change notification settings - Fork 13.4k
WIP: Lots of fixes from clippy #46960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
doc-valid-idents = ["TimSort"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above, can this be omitted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
//! We can explicitly specify `hello_world`'s lifetime as well: | ||
//! | ||
//! ``` | ||
//! let hello_world: &'static str = "Hello, world!"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is in documentation showing how to explicitly specify a lifetime, so it shouldn't be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, can this be reverted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
//! let hello_world: &str = "Hello, world!"; | ||
//! ``` | ||
//! | ||
//! *[See also the `str` primitive type](../../std/primitive.str.html).* | ||
|
@@ -1995,7 +1995,7 @@ impl str { | |
pub fn to_uppercase(&self) -> String { | ||
let mut s = String::with_capacity(self.len()); | ||
s.extend(self.chars().flat_map(|c| c.to_uppercase())); | ||
return s; | ||
s | ||
} | ||
|
||
/// Escapes each char in `s` with [`char::escape_debug`]. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2061,6 +2061,7 @@ macro_rules! __impl_slice_eq1 { | |
}; | ||
($Lhs: ty, $Rhs: ty, $Bound: ident) => { | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[cfg_attr(feature = "cargo-clippy", allow(partialeq_ne_impl))] | ||
impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> { | ||
#[inline] | ||
fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] } | ||
|
@@ -2337,8 +2338,7 @@ impl<T> Iterator for IntoIter<T> { | |
unsafe { | ||
if self.ptr as *const _ == self.end { | ||
None | ||
} else { | ||
if mem::size_of::<T>() == 0 { | ||
} else if mem::size_of::<T>() == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be left as it was, it's a bit clearer in terms of control flow previously There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can revert it but I'm a little confused how |
||
// purposefully don't use 'ptr.offset' because for | ||
// vectors with 0-size elements this would return the | ||
// same pointer. | ||
|
@@ -2355,7 +2355,6 @@ impl<T> Iterator for IntoIter<T> { | |
} | ||
} | ||
} | ||
} | ||
|
||
#[inline] | ||
fn size_hint(&self) -> (usize, Option<usize>) { | ||
|
@@ -2379,8 +2378,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> { | |
unsafe { | ||
if self.end == self.ptr { | ||
None | ||
} else { | ||
if mem::size_of::<T>() == 0 { | ||
} else if mem::size_of::<T>() == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above, can this be left as it was? |
||
// See above for why 'ptr.offset' isn't used | ||
self.end = arith_offset(self.end as *const i8, -1) as *mut T; | ||
|
||
|
@@ -2395,7 +2393,6 @@ impl<T> DoubleEndedIterator for IntoIter<T> { | |
} | ||
} | ||
} | ||
} | ||
|
||
#[stable(feature = "rust1", since = "1.0.0")] | ||
impl<T> ExactSizeIterator for IntoIter<T> { | ||
|
@@ -2485,7 +2482,7 @@ impl<'a, T> DoubleEndedIterator for Drain<'a, T> { | |
impl<'a, T> Drop for Drain<'a, T> { | ||
fn drop(&mut self) { | ||
// exhaust self first | ||
while let Some(_) = self.next() {} | ||
for _ in self.by_ref() {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be left as it was? This is a pretty unsafe implementation so having it be as clear/simple as possible (less layers of abstraction) makes it easier to audit and see what's going on. |
||
|
||
if self.tail_len > 0 { | ||
unsafe { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1621,7 +1621,7 @@ impl<T> VecDeque<T> { | |
} | ||
} | ||
|
||
return elem; | ||
elem | ||
} | ||
|
||
/// Splits the collection into two at the given index. | ||
|
@@ -2479,8 +2479,7 @@ impl<T> From<VecDeque<T>> for Vec<T> { | |
// Need to move the ring to the front of the buffer, as vec will expect this. | ||
if other.is_contiguous() { | ||
ptr::copy(buf.offset(tail as isize), buf, len); | ||
} else { | ||
if (tail - head) >= cmp::min((cap - tail), head) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to aove, can this be left as it was? |
||
} else if (tail - head) >= cmp::min((cap - tail), head) { | ||
// There is enough free space in the centre for the shortest block so we can | ||
// do this in at most three copy moves. | ||
if (cap - tail) > head { | ||
|
@@ -2527,7 +2526,6 @@ impl<T> From<VecDeque<T>> for Vec<T> { | |
right_edge += right_offset + 1; | ||
|
||
} | ||
} | ||
|
||
} | ||
let out = Vec::from_raw_parts(buf, len, cap); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can annotations like this be omitted? We don't run clippy in the main repository regularly so I'd prefer to not land annotations like this which are basically unused by all our infrastructure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!