1
Fork 0

Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514

Remove useless borrows and derefs

They are nothing more than noise.
<sub>These are not all of them, but my clippy started crashing (stack overflow), so rip :(</sub>
This commit is contained in:
Matthias Krüger 2022-12-03 17:37:42 +01:00 committed by GitHub
commit 1a2f79b82c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 157 additions and 158 deletions

View file

@ -72,7 +72,7 @@ impl<'a, T: PartialOrd> PartialOrd for Interned<'a, T> {
if ptr::eq(self.0, other.0) {
Some(Ordering::Equal)
} else {
let res = self.0.partial_cmp(&other.0);
let res = self.0.partial_cmp(other.0);
debug_assert_ne!(res, Some(Ordering::Equal));
res
}
@ -86,7 +86,7 @@ impl<'a, T: Ord> Ord for Interned<'a, T> {
if ptr::eq(self.0, other.0) {
Ordering::Equal
} else {
let res = self.0.cmp(&other.0);
let res = self.0.cmp(other.0);
debug_assert_ne!(res, Ordering::Equal);
res
}

View file

@ -36,7 +36,7 @@ impl Deref for Mmap {
#[inline]
fn deref(&self) -> &[u8] {
&*self.0
&self.0
}
}
@ -96,13 +96,13 @@ impl Deref for MmapMut {
#[inline]
fn deref(&self) -> &[u8] {
&*self.0
&self.0
}
}
impl DerefMut for MmapMut {
#[inline]
fn deref_mut(&mut self) -> &mut [u8] {
&mut *self.0
&mut self.0
}
}

View file

@ -899,25 +899,25 @@ unsafe impl<O, T: ?Sized> StableAddress for OwningRef<O, T> {}
impl<O, T: ?Sized> AsRef<T> for OwningRef<O, T> {
fn as_ref(&self) -> &T {
&*self
self
}
}
impl<O, T: ?Sized> AsRef<T> for OwningRefMut<O, T> {
fn as_ref(&self) -> &T {
&*self
self
}
}
impl<O, T: ?Sized> AsMut<T> for OwningRefMut<O, T> {
fn as_mut(&mut self) -> &mut T {
&mut *self
self
}
}
impl<O, T: ?Sized> Borrow<T> for OwningRef<O, T> {
fn borrow(&self) -> &T {
&*self
self
}
}
@ -1021,7 +1021,7 @@ where
T: PartialEq,
{
fn eq(&self, other: &Self) -> bool {
(&*self as &T).eq(&*other as &T)
self.deref().eq(other.deref())
}
}
@ -1032,7 +1032,7 @@ where
T: PartialOrd,
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
(&*self as &T).partial_cmp(&*other as &T)
self.deref().partial_cmp(other.deref())
}
}
@ -1041,7 +1041,7 @@ where
T: Ord,
{
fn cmp(&self, other: &Self) -> Ordering {
(&*self as &T).cmp(&*other as &T)
self.deref().cmp(other.deref())
}
}
@ -1050,7 +1050,7 @@ where
T: Hash,
{
fn hash<H: Hasher>(&self, state: &mut H) {
(&*self as &T).hash(state);
self.deref().hash(state);
}
}
@ -1059,7 +1059,7 @@ where
T: PartialEq,
{
fn eq(&self, other: &Self) -> bool {
(&*self as &T).eq(&*other as &T)
self.deref().eq(other.deref())
}
}
@ -1070,7 +1070,7 @@ where
T: PartialOrd,
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
(&*self as &T).partial_cmp(&*other as &T)
self.deref().partial_cmp(other.deref())
}
}
@ -1079,7 +1079,7 @@ where
T: Ord,
{
fn cmp(&self, other: &Self) -> Ordering {
(&*self as &T).cmp(&*other as &T)
self.deref().cmp(other.deref())
}
}
@ -1088,7 +1088,7 @@ where
T: Hash,
{
fn hash<H: Hasher>(&self, state: &mut H) {
(&*self as &T).hash(state);
self.deref().hash(state);
}
}

View file

@ -192,7 +192,7 @@ impl SelfProfilerRef {
F: for<'a> FnOnce(&'a SelfProfiler) -> TimingGuard<'a>,
{
let profiler = profiler_ref.profiler.as_ref().unwrap();
f(&**profiler)
f(profiler)
}
if self.event_filter_mask.contains(event_filter) {
@ -466,7 +466,7 @@ impl SelfProfilerRef {
pub fn with_profiler(&self, f: impl FnOnce(&SelfProfiler)) {
if let Some(profiler) = &self.profiler {
f(&profiler)
f(profiler)
}
}
@ -733,7 +733,7 @@ impl Drop for VerboseTimingGuard<'_> {
if let Some((start_time, start_rss, ref message)) = self.start_and_message {
let end_rss = get_resident_set_size();
let dur = start_time.elapsed();
print_time_passes_entry(&message, dur, start_rss, end_rss);
print_time_passes_entry(message, dur, start_rss, end_rss);
}
}
}

View file

@ -366,7 +366,7 @@ impl<CTX> HashStable<CTX> for [u8] {
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for Vec<T> {
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
(&self[..]).hash_stable(ctx, hasher);
self[..].hash_stable(ctx, hasher);
}
}
@ -405,7 +405,7 @@ where
{
#[inline]
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
(&self[..]).hash_stable(ctx, hasher);
self[..].hash_stable(ctx, hasher);
}
}
@ -440,7 +440,7 @@ impl<CTX> HashStable<CTX> for str {
impl<CTX> HashStable<CTX> for String {
#[inline]
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
(&self[..]).hash_stable(hcx, hasher);
self[..].hash_stable(hcx, hasher);
}
}

View file

@ -201,7 +201,7 @@ cfg_if! {
#[inline(always)]
fn deref(&self) -> &T {
&*self.0
&self.0
}
}